2014-01-24 104 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"; 
     } 
    }