【发布时间】:2019-06-30 01:35:45
【问题描述】:
我在 Windows 上的 XAMPP 上使用 OpenSSL 运行 PHPMailer。
我在与我们的邮件网关建立 TLS 加密的 SMTP 连接时遇到问题。
我已开启SMTP transcript debugging for PHPMailer。成绩单不是超级信息 IMO:
[06-Feb-2019 13:48:08 timezone/redacted] SERVER -> CLIENT: 220 redactedmailserver.example.com ESMTP Postfix
[06-Feb-2019 13:48:08 timezone/redacted] CLIENT -> SERVER: EHLO redactedclientname
[06-Feb-2019 13:48:08 timezone/redacted] SERVER -> CLIENT: 250-redactedmailserver.example.com
250-SIZE 52428800
250-ETRN
250-STARTTLS
250-AUTH CRAM-MD5 PLAIN LOGIN DIGEST-MD5
250-AUTH=CRAM-MD5 PLAIN LOGIN DIGEST-MD5
250-ENHANCEDSTATUSCODES
250 8BITMIME
[06-Feb-2019 13:48:08 timezone/redacted] CLIENT -> SERVER: STARTTLS
[06-Feb-2019 13:48:08 timezone/redacted] SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
[06-Feb-2019 13:48:08 timezone/redacted] SMTP Error: Could not connect to SMTP host.
[06-Feb-2019 13:48:08 timezone/redacted] CLIENT -> SERVER: QUIT
[06-Feb-2019 13:48:08 timezone/redacted] SERVER -> CLIENT:
[06-Feb-2019 13:48:08 timezone/redacted] SMTP ERROR: QUIT command failed:
[06-Feb-2019 13:48:08 timezone/redacted] SMTP Error: Could not connect to SMTP host.
[06-Feb-2019 13:48:08 timezone/redacted] SMTP Error: Could not connect to SMTP host.
文字记录至少证明了错误信息具有误导性; PHPMailer is 成功连接到 SMTP 服务器,但 STARTTLS 出现问题。不过,错误消息和脚本没有提示具体的 TLS 问题可能是什么。
a closed issue on the PHPMailer Github 中描述了类似的症状,但那里的问题解决涉及使用 OpenSSL 命令行客户端对连接进行故障排除,如PHPMailer troubleshooting page 中所述。此页面提供了有关how to test the underlying OpenSSL connection outside of the PHP context 的一些说明,其中应详细说明连接可能失败的原因。它说运行以下命令:
echo QUIT | openssl s_client -starttls smtp -crlf -connect redactedemailserver.example.com:587
我想这适用于 Linux 上的 bash,但我在 Windows 上运行 XAMPP。我尝试运行一个希望等效的 PowerShell 命令:
echo QUIT | C:\xampp\php\extras\openssl\openssl.exe s_client -starttls smtp -crlf -connect redactedemailserver.example.com:587
但似乎什么也没发生。重新出现一个新的 PowerShell 提示符,并且 openssl 没有明显的输出。
我还尝试在没有echo QUIT | 的情况下运行该命令。不过,什么也没发生。
在 Windows 上,我可以使用哪些 PowerShell/openssl.exe 命令来确定 STARTTLS 失败的原因?
版本号:
- XAMPP 7.1.7
- PHP 7.1.7
- PHPMailer 6.0.6
- OpenSSL 1.0.2l
【问题讨论】:
-
我用 PHPMailer (php.net/manual/en/context.ssl.php) 的 SMTPOptions 属性做了一些蛮力实验。如果我设置
verify_peer_name => false,则 STARTTLS 有效。我仍然想知道如何在 Windows 上获得详细的 OpenSSL 证书诊断信息,这样我就可以确切地弄清楚为什么证书对等名称没有成功验证。 -
一个写得很好的问题,谢谢!不幸的是,关于在 Windows 上诊断 OpenSSL,我没有什么要补充的。
标签: windows openssl xampp phpmailer starttls