美文网首页
linux PHPMailer 发送邮件sendmail 发邮件

linux PHPMailer 发送邮件sendmail 发邮件

作者: hello大象 | 来源:发表于2017-12-06 14:17 被阅读0次

1、用的腾讯云服务器,折腾了很多资料,发现改错了。谨记检查端口25开放
2、TP框架用PHPMailer 发送邮件,windows本地测试正常,上传到腾讯云linux服务器就发送不成功:
细节如下:[root@VM_82_192_centos ~]# tail -40 /var/log/maillog

Dec  6 11:39:38 localhost sendmail[2069]: alias database /etc/aliases rebuilt by root
Dec  6 11:39:38 localhost sendmail[2069]: /etc/aliases: 76 aliases, longest 10 bytes, 771 bytes total
Dec  6 11:40:07 localhost postfix/postfix-script[2162]: stopping the Postfix mail system
Dec  6 11:40:07 localhost sendmail[2161]: starting daemon (8.14.7): SMTP+queueing@01:00:00
Dec  6 11:40:07 localhost sendmail[2161]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA: cannot bind: Address already in use
Dec  6 11:40:07 localhost sendmail[2161]: daemon MTA: problem creating SMTP socket
Dec  6 11:40:07 localhost postfix/master[1192]: terminating on signal 15
Dec  6 11:40:12 localhost sm-msp-queue[2177]: starting daemon (8.14.7): queueing@01:00:00
Dec  6 11:41:03 localhost sendmail[2183]: vB63f3vj002183: from=root, size=1566, class=0, nrcpts=1, msgid=<201712060341.vB63f3vj002183@localhost.localdomain>, relay=root@localhost
Dec  6 11:41:03 localhost sendmail[2184]: vB63f34n002184: from=<root@localhost.localdomain>, size=1824, class=0, nrcpts=1, msgid=<201712060341.vB63f3vj002183@localhost.localdomain>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
Dec  6 11:41:03 localhost sendmail[2183]: vB63f3vj002183: to=2848278204@qq.com, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=31566, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (vB63f34n002184 Message accepted for delivery)

把class.phpmailer.php中的$this->mailer = smtp;中的smtp换成大写:SMTP。说是因为qq 163等邮箱需要接受发送过来的大写的SMTP;
发现还是不成功
反过头来检查25端口:

[root@VM_82_192_centos ~]# netstat -tunlp | grep 25

发现没反应:yum重装sendmail,还是同样。直接杀到云服务器哪儿,检查25端口是否开放;泪流满面:赶紧解封。


image.png

确认:


image.png
再次重装sendmail:并检查25端口:
[root@VM_82_192_centos ~]# systemctl start sendmail.service 
[root@VM_82_192_centos ~]# netstat -tunlp | grep 25

OK,测试发送mail -s '33333333555ksTest mail' 2848278204@qq.com < /etc/passwd

success
success

相关文章

网友评论

      本文标题:linux PHPMailer 发送邮件sendmail 发邮件

      本文链接:https://www.haomeiwen.com/subject/fxnkixtx.html