2017-06-19 147 views
0

我在想,如果它能夠定義一個CI電子郵件的fromreply_to在電子郵件的配置如下所示:笨設置電子郵件從配置

$mail_config = Array(
    'protocol' => 'smtp', 
    'smtp_host' => $school_custom['smtp_host'], 
    'smtp_port' => $school_custom['smtp_port'], 
    'smtp_user' => $school_custom['smtp_user'], 
    'smtp_pass' => $school_custom['smtp_password'], 
    'mailtype' => 'html', 
    'from' => 'from_email', 
    'reply_to' => 'reply_to_email' 
); 

$this -> load -> library('email', $mail_config); 

我找原因這是因爲加載我的庫的地方位於我的函數的頂部,並且在哪裏設置from和reply_to位於底部,所以我想將它們與配置一起分組,因爲它們對於所有電子郵件都是相同的將被髮送。

我找不到任何關於此事的信息,而且我對上述測試所做的測試似乎無效,所以我不完全確定它是可行的。

提前

回答

0

創建文件APPPATH.'config/custom_email.php'感謝名單:

<?php 
$config = [ 
    'from_mail' => '[email protected]', 
    'reply_to_email' => '[email protected]', 
]; 

自動加載文件中APPPATH.'config/custom_mail.php'

$autoload['config'] = array('custom_email');// line 106 

使用這種方式:

$mail_config = Array(
    'protocol' => 'smtp', 
    'smtp_host' => $school_custom['smtp_host'], 
    'smtp_port' => $school_custom['smtp_port'], 
    'smtp_user' => $school_custom['smtp_user'], 
    'smtp_pass' => $school_custom['smtp_password'], 
    'mailtype' => 'html', 
    'from' => $this->config->item('from_mail'), 
    'reply_to' => $this->config->item('reply_to_email') 
); 

$this -> load -> library('email', $mail_config); 

你也可以根據你的需要設置其他值或其他配置文件。 如果該配置全部是靜態配置,那麼您可以將配置文件中的所有值傳遞並直接使用manual loading之後的一行代碼加載,如文檔中所述。