【问题标题】:codeigniter email function smtp errorcodeigniter 电子邮件功能 smtp 错误
【发布时间】:2014-02-15 01:08:59
【问题描述】:

我一直在使用 codeigniter 电子邮件功能发送我的电子邮件,但收到警告

邮箱配置文件为:

$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['newline'] = '\r\n';
$config['smtp_host']='ssl:server address';
$config['smtp_user']='noreply@some.com';
$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

我的电子邮件文件配置可能有什么问题。

提前致谢 阿米特

【问题讨论】:

    标签: php codeigniter email


    【解决方案1】:

    尝试在配置中添加它。

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

    【讨论】:

    • 我尝试了默认端口 25 但同样的警告,还有其他的吗?如果 ssl://server.com 被删除,警告不是他们的,但我没有收到任何邮件,如果这可能是我们的服务器警告或者我真的很困惑>请告诉我?
    【解决方案2】:

    尝试使用PHPMailer,它是如此简单而强大的工具。

    在这里,解释如何使用它: http://phpsblog.agustinvillalba.com/phpmailer-codeigniter/

    【讨论】:

    • 如果您找到了报告问题的解决方案,请发布。如果您只是想推荐另一个具有相同功能的库,请至少解释为什么您不应该使用另一个库。
    【解决方案3】:

    我使用过这样的功能来发送电子邮件。

    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' => 'sender@gmail.com',
                'smtp_pass' => 'sender',
                'mailtype' => 'html'
            );
    
            // recipient, sender, subject, and you message
    
            $to = $email;
            $from = "sender@gmail.com";
            $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";
            }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-07
      • 2014-10-26
      • 1970-01-01
      • 1970-01-01
      • 2012-10-27
      • 1970-01-01
      • 2011-06-12
      • 1970-01-01
      相关资源
      最近更新 更多