2015-06-05 59 views
0

我收到此錯誤幫助!我試圖發送電子郵件,但在你的if語句再次使用前$this->email->send()其不工作無法發送沒有「發件人」標題的郵件

 $this->email->from('[email protected]', 'Your Name'); 
     $this->email->to($data['email']); 
     $this->email->subject('This the test'); 
     $this->email->message('this is the test message'); 

     $this->email->send(); 

     if(! $this->email->send()){ 

      echo $this->email->print_debugger(); 
     } 

     else 
     { 
      echo 'send'; 
     } 

我得到這個誤差

Cannot send mail with no "From" header. 

回答

5

在你的代碼已經使用$this->email->send()。圖書館在發送電子郵件後清除所有內容。所以,如果你想要做的事在發生錯誤的情況下,你不這樣做同樣的方法兩次:

$this->load->library('email'); 
     $this->email->from('[email protected]', 'Your Name'); 
     $this->email->to($data['email']); 
     $this->email->subject('This the test'); 
     $this->email->message('this is the test message'); 
// $this->email->send(); don't do this and then the same thing! 

if (!$this->email->send()) 
{  
echo $this->email->print_debugger(); 

} 
0

同時,確保任何初始化例如碼

$config['protocol'] = 'sendmail'; 
$config['mailpath'] = '/usr/sbin/sendmail'; 
$config['charset'] = 'iso-8859-1'; 
$config['wordwrap'] = TRUE; 

$this->email->initialize($config); 

是您設置,之前,主題等等