当前位置: 首页 > 后端技术 > PHP

phpmailer无法接收

时间:2023-03-29 22:28:17 PHP

phpmailer发送的邮件无法接收phpmailer发送的邮件。本地测试邮件发送,收邮件没有问题,但是阿里云服务器上有问题,邮件服务报错。仔细排查,最终发现不是别的,而是阿里云邮件发送的25端口被禁用了,导致无法使用smtp协议。需要去阿里云申请解锁这个25,或者改端口为465补充网上大量资料说把phpmailer中的IsSMTP的smtp改成smtp其实是误导/***SetsMailerto使用SMTP发送消息。*@returnvoid*/publicfunctionIsSMTP(){$this->Mailer='SMTP';}//选择邮件程序并通过它发送switch($this->Mailer){case'sendmail':return$this->SendmailSend($this->MIMEHeader,$this->MIMEBody);case'smtp':return$this->SmtpSend($this->MIMEHeader,$this->MIMEBody);默认值:返回$this->MailSend($this->MIMEHeader,$this->MIMEBody);}上面的改动后,会走php默认的mail方式,不会使用smtp协议发送。这突出了查看源代码的重要性