phpemailer 提示Mailer Error: SMTP connect() failed

今天遇到一个很诡异的现象,之前好好的phpmailer今天突然出bug了,提示Mailer Error: SMTP connect() failed,比较诡异的是,我在本地,不管是前端请求,还是命令行直接执行,都是正常的,然而在服务器上面,命令行执行可以正常发送,然而在前端请求的时候就出了问题,一直提示如上错误
phpmailer配置:

try {
        $mail = new PHPMailer();
        $mail->IsSMTP();
        $mail->Host = 'smtp.163.com';
        $mail->Port = 25;
        $mail->SMTPAuth = true;
        $mail->Username = 'xxx';//这里的信息隐去了,不是账户密码问题
        $mail->Password = "xxx";
        $mail->From = 'xxx';
        $mail->FromName = 'xxx';
        $mail->AddAddress($address);
        $mail->CharSet = "utf-8";
        $mail->Encoding = "base64";
        $mail->IsHTML(true);
        $mail->Subject = $title;
        $mail->Body = $body;
        return $mail->Send();
    } catch (phpmailerException $e) {
//        echo "邮件发送失败:" . $e->errorMessage();
        return false;
    }

前端控制器是用的最简单的代码测试的,引入helper 执行函数(CI框架)

$this->load->helper('email');
$res = Send('xxx' , 'aa' , 'bb');//xxx是需要发送的邮箱
var_dump($res);

服务器php.ini 开启extension=php_openssl.dll

以下是具体的报错信息

2017-01-14 03:26:24    Connection: opening to smtp.163.com:25, timeout=300, options=array ( ) 2017-01-14 03:26:24    Connection: opened 2017-01-14 03:26:25    SMTP -> get_lines(): $data is "" 2017-01-14 03:26:25    SMTP -> get_lines(): $str is "220 163.com Anti-spam GT for Coremail System (163com[20141201]) " 2017-01-14 03:26:25    SERVER -> CLIENT: 220 163.com Anti-spam GT for Coremail System (163com[20141201]) 2017-01-14 03:26:25    CLIENT -> SERVER: EHLO www.iciyuan.com 2017-01-14 03:26:25    SMTP -> get_lines(): $data is "" 2017-01-14 03:26:25    SMTP -> get_lines(): $str is "250-mail " 2017-01-14 03:26:25    SMTP -> get_lines(): $data is "250-mail " 2017-01-14 03:26:25    SMTP -> get_lines(): $str is "250-PIPELINING " 2017-01-14 03:26:25    SMTP -> get_lines(): $data is "250-mail 250-PIPELINING " 2017-01-14 03:26:25    SMTP -> get_lines(): $str is "250-AUTH LOGIN PLAIN " 2017-01-14 03:26:25    SMTP -> get_lines(): $data is "250-mail 250-PIPELINING 250-AUTH LOGIN PLAIN " 2017-01-14 03:26:25    SMTP -> get_lines(): $str is "250-AUTH=LOGIN PLAIN " 2017-01-14 03:26:25    SMTP -> get_lines(): $data is "250-mail 250-PIPELINING 250-AUTH LOGIN PLAIN 250-AUTH=LOGIN PLAIN " 2017-01-14 03:26:25    SMTP -> get_lines(): $str is "250-coremail 1Uxr2xKj7kG0xkI17xGrU7I0s8FY2U3Uj8Cz28x1UUUUU7Ic2I0Y2UFvMPogUCa0xDrUUUUj " 2017-01-14 03:26:25    SMTP -> get_lines(): $data is "250-mail 250-PIPELINING 250-AUTH LOGIN PLAIN 250-AUTH=LOGIN PLAIN 250-coremail 1Uxr2xKj7kG0xkI17xGrU7I0s8FY2U3Uj8Cz28x1UUUUU7Ic2I0Y2UFvMPogUCa0xDrUUUUj " 2017-01-14 03:26:25    SMTP -> get_lines(): $str is "250-STARTTLS " 2017-01-14 03:26:25    SMTP -> get_lines(): $data is "250-mail 250-PIPELINING 250-AUTH LOGIN PLAIN 250-AUTH=LOGIN PLAIN 250-coremail 1Uxr2xKj7kG0xkI17xGrU7I0s8FY2U3Uj8Cz28x1UUUUU7Ic2I0Y2UFvMPogUCa0xDrUUUUj 250-STARTTLS " 2017-01-14 03:26:25    SMTP -> get_lines(): $str is "250 8BITMIME " 2017-01-14 03:26:25    SERVER -> CLIENT: 250-mail 250-PIPELINING 250-AUTH LOGIN PLAIN 250-AUTH=LOGIN PLAIN 250-coremail 1Uxr2xKj7kG0xkI17xGrU7I0s8FY2U3Uj8Cz28x1UUUUU7Ic2I0Y2UFvMPogUCa0xDrUUUUj 250-STARTTLS 250 8BITMIME 2017-01-14 03:26:25    CLIENT -> SERVER: STARTTLS 2017-01-14 03:26:25    SMTP -> get_lines(): $data is "" 2017-01-14 03:26:25    SMTP -> get_lines(): $str is "220 Ready to start TLS " 2017-01-14 03:26:25    SERVER -> CLIENT: 220 Ready to start TLS 2017-01-14 03:26:25    SMTP Error: Could not connect to SMTP host. 2017-01-14 03:26:25    CLIENT -> SERVER: QUIT 2017-01-14 03:26:25    SMTP -> get_lines(): $data is "" 2017-01-14 03:26:25    SMTP -> get_lines(): $str is "" 2017-01-14 03:26:25    SERVER -> CLIENT:  2017-01-14 03:26:25    SMTP ERROR: QUIT command failed:  2017-01-14 03:26:25    Connection: closed 2017-01-14 03:26:25    SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

PHPMailer 最近暴了一个漏洞

163邮箱现在用的密码,改为“客户端授权密码”。http://help.163.com/14/0923/2…

  • 比较大的项目 要不要把url都统一到一个表里面?大家都是怎么做的?
  • 如何面试PHP
  • apache配置了https,过一段时间后无法访问了,重启后又正常了
  • PHP正则替换问题?
  • YII2的依赖注入,如何传递参数呀?
  • Yii2 框架自带的ActiveRecord 事务嵌套分析
  • PHP模板引擎如何实现
  • 签到的需求,怎么做才好。
  • 关于php开发的一些疑问
  • laravel 数组转xml用composer的哪个package ?
  • PHP自定义函数前加&,为什么效果一样呢,上全部代码