服务器发送邮件出现Could not connect to SMTP host错误 解决办法

服务器发送邮件出现Could not connect to SMTP host错误 解决办法

功夫不负有心人,最后了解到,除了google的smtp服务器收到请求“smtp”会接受,其他服务器比如qq 163什么的必须要收到“smtp”请求(大写),郁闷呀!

解决办法:

在 class.phpmailer.php 中,将

function IsSMTP() {

$this->Mailer = 'smtp';

}

改成:

function IsSMTP() {

$this->Mailer = 'SMTP';

}

再次测试,终于看到了熟悉的面孔,  QQ右下角提示 收到新邮件!问题解决!舒心呀!

后来我发现并不是因为修改了smtp为SMTP之后却能够发送邮件,这个并不是因为有些邮件服务器不能接受smtp的原因,而是并不是使用了smtp来发送邮件,PHPmailer里有一个判断的函数,
public function IsSMTP() {
$this->Mailer = 'SMTP';
}

switch($this->Mailer) {
case 'sendmail':
return $this->SendmailSend($header, $body);
case 'smtp'://由于SMTP和smtp不相等 所以选择的是下面MailSend发送邮件 并不是使用smtp发送邮件
return $this->SmtpSend($header, $body);
default:
return $this->MailSend($header, $body);

原文地址:https://www.cnblogs.com/crystaltu/p/5755808.html