phpmailer发送邮箱无法收到
在本地测试邮件发送,邮件接收都没有问题,但到阿里云服务器上就出问题了,邮件服务就报错了。经过仔细的排查,最后发现不是别的,而是阿里云邮件发送的25端口被禁用,导致不能使用smtp协议.
需要到阿里云去给这个25申请解禁,或者把端口换成465
补充
网上大量的信息说,将phpmailer中IsSMTP的smtp 改成SMTP,其实是有误导性的
/** * Sets Mailer to send message using SMTP. * @return void */ public function IsSMTP() { $this->Mailer = 'SMTP'; }
// Choose the mailer and send through it switch($this->Mailer) { case 'sendmail': return $this->SendmailSend($this->MIMEHeader, $this->MIMEBody); case 'smtp': return $this->SmtpSend($this->MIMEHeader, $this->MIMEBody); default: return $this->MailSend($this->MIMEHeader, $this->MIMEBody); }
上面改了以后,会走到php默认的mail方法,而不会使用smtp协议发送。这就突出了看源码的重要性了