2014-01-24 105 views
3

我一直在使用笨電子郵件功能來發送我的電子郵件,我得到的電子郵件的警告笨電子郵件功能SMTP錯誤

配置文件是:

$config['mailtype'] = 'html'; 
$config['charset'] = 'utf-8'; 
$config['newline'] = '\r\n'; 
$config['smtp_host']='ssl:server address'; 
$config['smtp_user']='[email protected]'; 
$config['smtp_pass']='iamnotreplying'; 
$config['smtp_port']=465; 

我得到一個警告說

Warning: fwrite() [function.fwrite]: SSL: Connection reset by peer in /home/.../public_html/.../system/libraries/Email.php on line 1846 
Warning: fwrite() [function.fwrite]: SSL operation failed with code 1. OpenSSL Error messages: error:1409F07F:SSL routines:SSL3_WRITE_PENDING:bad write retry in /home/../public_html/.../system/libraries/Email.php on line 1846 

我的電子郵件文件配置有什麼問題。

在此先感謝 amith

回答

0

嘗試用配置添加此。

$config['smtp_crypto'] = 'ssl'; 
$config['protocol'] = 'smtp'; 
+0

添加到我的文件,但彈出上面的錯誤/警告 – user3230834

+0

你有沒有嘗試使用默認的'端口'? – tomexsans

+0

默認端口與25我試過但相同的警告,有其他?如果該ssl://server.com被刪除警告不是他們的,但我沒有收到任何郵件,如果這可能是我們的服務器警告或我真的感到困惑>請告訴我? – user3230834

-1

嘗試使用PHPMailer,是如此簡單而強大的工具。

這裏,解釋如何使用: http://phpsblog.agustinvillalba.com/phpmailer-codeigniter/

+1

如果您已經找到報告問題的解決方案,請發佈。如果你只是想推薦另一個庫來提供相同的功能,至少可以解釋爲什麼你不應該使用另一個庫。 – Logus

0

我用這樣的函數來發送電子郵件。

function sendEmail($email) { 

     // parameters of your mail server and how to send your email 
     $config = array(
      'protocol' => 'smtp', 
      'smtp_host' => 'ssl://smtp.googlemail.com', 
      'smtp_port' => 465, 
      'smtp_user' => '[email protected]', 
      'smtp_pass' => 'sender', 
      'mailtype' => 'html' 
     ); 

     // recipient, sender, subject, and you message 

     $to = $email; 
     $from = "[email protected]"; 
     $subject = "subject"; 
     $message = "message body"; 

     // load the email library that provided by CI 
     $this->ci->load->library('email', $config); 
     // this will bind your attributes to email library 
     $this->ci->email->set_newline("\r\n"); 
     $this->ci->email->from($from, 'sender'); 
     $this->ci->email->to($to); 
     $this->ci->email->subject($subject); 
     $this->ci->email->message($message); 

     // send your email. if it produce an error it will return 'Fail to send your email!' 
     if ($this->ci->email->send()) {     
      return "Email was sent successfully!"; 
     } else { 
      return "Fail to send your email"; 
     } 
    }