2015-11-04 116 views
0

我在config文件夾中email.php:笨不是SMTP設置發送電子郵件

$config = Array(
    'protocol' => 'tls', 
    'smtp_host' => 'mail.lifepro.ro', 
    'smtp_port' => 465, 
    'smtp_user' => '[email protected]', 
    'smtp_pass' => 'xxxxxxxxxxxx', 
    'mailtype' => 'html', 
    'charset' => 'utf-8', 
    'wordwrap' => TRUE 
); 

這個功能幫手

function email_send($to, $subject, $body) { 

     $ci = get_instance(); 
     $ci->email->from('[email protected]', 'Office LifePro'); 
     $ci->email->to($to); 
     $ci->email->cc('[email protected]'); 

     $ci->email->subject($subject); 
     $ci->email->message($body); 

     if($ci->email->send()) 
      return true; 
    } 

的問題是,在CI甚至發送電子郵件如果我輸入錯誤的憑據。爲什麼發生這種情況?我知道配置文件夾中的email.php會自動加載。

回答

1

沒有什麼你在電子郵件庫做的,使用此

$this->load->library('email'); //load library 

$this->email->from('[email protected]', 'Your Name'); 
$this->email->to('[email protected]'); 

$this->email->subject('Email Test'); 
$this->email->message('Testing the email class.'); 

if(!$this->email->send()) 
{ 
    echo $this->email->print_debugger(); 
} 
else 
{ 
    echo "Sent" 
} 

Email Class

0

解決

'protocol' => 'smtp' 
0
$config = Array(
    'protocol' => 'smtp', 
    'smtp_crypto' => 'tls', //   <--- notice 
    'smtp_host' => 'mail.lifepro.ro', 
    'smtp_port' => 465, //    <--- or 587 
    'smtp_user' => '[email protected]', 
    'smtp_pass' => 'xxxxxxxxxxxx', 
    'mailtype' => 'html', 
    'charset' => 'utf-8', 
    'wordwrap' => TRUE 
);