codeigniter电子邮件功能smtp错误

时间:2014-01-24 06:28:48

标签: php codeigniter email

我一直在使用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

我的电子邮件文件配置可能出错。

提前致谢 amith

3 个答案:

答案 0 :(得分:0)

尝试使用配置添加此内容。

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

答案 1 :(得分: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' => '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";
        }
    }

答案 2 :(得分:-1)

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

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