首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PHPMailer SMTP错误:无法连接到SMTP主机

PHPMailer SMTP错误:无法连接到SMTP主机
EN

Stack Overflow用户
提问于 2016-05-06 06:05:21
回答 1查看 969关注 0票数 0

PHPMailer出现了一个奇怪的问题,它显示了一个SMTP连接错误,如下所示。是什么导致了这种情况?当我使用Gmail SMTP服务器时,它可以工作,也可以使用本地邮件功能。服务器上的Roundcube发送正常。看起来就像是PHPMailer。据我所知,所有设置都是正确的。它使用的是TLS,我尝试过不同的端口。正确的端口显示以下错误:

代码语言:javascript
复制
2016-05-05 21:58:47 Connection: opening to mail.myserver.com:587, timeout=300, options=array (
                                      )
2016-05-05 21:58:47 Connection: opened
2016-05-05 21:58:52 SMTP -> get_lines(): $data is ""
2016-05-05 21:58:52 SMTP -> get_lines(): $str is  "220 sys.myserver.com ESMTP Exim 4.72 Thu, 05 May 2016 17:58:50 -0400
                                      "
2016-05-05 21:58:52 SERVER -> CLIENT: 220 sys.myserver.com ESMTP Exim 4.72 Thu, 05 May 2016 17:58:50 -0400
2016-05-05 21:58:52 CLIENT -> SERVER: EHLO localhost
2016-05-05 21:58:52 SMTP -> get_lines(): $data is ""
2016-05-05 21:58:52 SMTP -> get_lines(): $str is  "250-sys.myserver.com Hello ***********]
                                      "
2016-05-05 21:58:52 SMTP -> get_lines(): $data is "250-sys.myserver.com Hello cpc68331-cdif16-2-0-cust906.5-1.cable.virginm.net [86.3.207.139]
                                      "
2016-05-05 21:58:52 SMTP -> get_lines(): $str is  "250-SIZE 52428800
                                      "
2016-05-05 21:58:52 SMTP -> get_lines(): $data is "250-sys.myserver.com Hello cpc68331-cdif16-2-0-cust906.5-1.cable.virginm.net [86.3.207.139]
                                      250-SIZE 52428800
                                      "
2016-05-05 21:58:52 SMTP -> get_lines(): $str is  "250-PIPELINING
                                      "
2016-05-05 21:58:52 SMTP -> get_lines(): $data is "250-sys.myserver.com Hello ***************************]
                                      250-SIZE 52428800
                                      250-PIPELINING
                                      "
2016-05-05 21:58:52 SMTP -> get_lines(): $str is  "250-AUTH PLAIN LOGIN
                                      "
2016-05-05 21:58:52 SMTP -> get_lines(): $data is "250-sys.myserver.com Hello ****************************]
                                      250-SIZE 52428800
                                      250-PIPELINING
                                      250-AUTH PLAIN LOGIN
                                      "
2016-05-05 21:58:52 SMTP -> get_lines(): $str is  "250-STARTTLS
                                      "
2016-05-05 21:58:52 SMTP -> get_lines(): $data is "250-sys.myserver.com Hello ******************]
                                      250-SIZE 52428800
                                      250-PIPELINING
                                      250-AUTH PLAIN LOGIN
                                      250-STARTTLS
                                      "
2016-05-05 21:58:52 SMTP -> get_lines(): $str is  "250 HELP
                                      "
2016-05-05 21:58:52 SERVER -> CLIENT: 250-sys.myserver.com Hello ***************]
                                      250-SIZE 52428800
                                      250-PIPELINING
                                      250-AUTH PLAIN LOGIN
                                      250-STARTTLS
                                      250 HELP
2016-05-05 21:58:52 CLIENT -> SERVER: STARTTLS
2016-05-05 21:58:52 SMTP -> get_lines(): $data is ""
2016-05-05 21:58:52 SMTP -> get_lines(): $str is  "220 TLS go ahead
                                      "
2016-05-05 21:58:52 SERVER -> CLIENT: 220 TLS go ahead
2016-05-05 21:58:52 SMTP Error: Could not connect to SMTP host.
2016-05-05 21:58:52 CLIENT -> SERVER: QUIT
2016-05-05 21:58:53 SMTP -> get_lines(): $data is ""
2016-05-05 21:58:53 SMTP -> get_lines(): $str is  "����221 sys.myserver.com closing connection
                                      "
2016-05-05 21:58:53 SMTP -> get_lines(): $data is "����221 sys.myserver.com closing connection
                                      "
2016-05-05 21:58:53 SMTP -> get_lines(): $str is  ""
2016-05-05 21:58:53 SERVER -> CLIENT: ����221 sys.myserver.com closing connection
2016-05-05 21:58:53 SMTP ERROR: QUIT command failed: ����221 sys.myserver.com closing connection


----------


2016-05-05 21:58:53 Connection: closed
2016-05-05 21:58:53 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
{"success":1,"id":"3391"}
EN

回答 1

Stack Overflow用户

发布于 2016-05-06 07:21:58

这在the troubleshooting guide中有介绍。它在STARTTLS之后立即失败,这通常表明您的邮件服务器正在发布无效的SSL证书,该证书要么已过期,要么是自签名的,要么与主机名不匹配。真正的解决方案是修复证书,但指南会告诉您如何禁用验证。

想必gmail能正常工作是因为它没有破坏SSL配置,而且roundcube可能是在没有TLS的情况下(通过mail())提交给本地主机,所以它不会遇到这个问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37061056

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档