phpmailer发送邮件 SMTP Error: Could not authenticate 错误

方法1:将fsockopen函数替换成pfsockopen函数

方法2:使用stream_socket_client函数

一般fsockopen()被禁,pfsockopen也有可能被禁,所以这里介绍另一个函数stream_socket_client()。

stream_socket_client的参数与fsockopen有所不同,所以代码要修改为:

$this->smtp_conn = stream_socket_client("tcp://".$host.":".$port, $errno,  $errstr,  $tval);

 

记得把phpmailer里面的IsSMTP中的小写换成大写,有两个地方,第一个地方:

 

                            第二个地方:

switch($this->Mailer) {
case 'sendmail':
return $this->SendmailSend($header, $body);
case 'SMTP':
return $this->SmtpSend($header, $body);
default:
return $this->MailSend($header, $body);
}

 

posted @ 2018-11-07 18:27  润土偷西瓜  阅读(1674)  评论(0编辑  收藏  举报