msmtp TLS 超时

msmtp TLS timeout

我已经查看了可能的解决方案列表,但我没有看到这个问题,就在这里。

我的 crontab 条目多年来一直使用 smtp 通过电子邮件提供状态更新。然后这周它退出了,我无法修复它。然后我看到它变成了孤儿,建议移动到msmtp。所以我下载并安装在我的 Ubuntu 18.10 系统上。

我正在尝试向我的 myaccount@gmail.com 帐户发送电子邮件。 看起来我正在与 gmail smtp 服务器正常通信,如下面的调试所示。但它总是会出现 TLS 超时。

我也不明白为什么我有多个 EHLO 条目。我的系统没有 DNS 域名,所以我不知道该放什么;本地主机似乎工作正常。另外,我的 Thunderbird 电子邮件程序可以正常使用 gmail。

Here's the debug output:

echo "Hello there" | msmtp --debug myaccount@gmail.com >/tmp/msmtpOut.txt

ignoring system configuration file /etc/msmtprc: No such file or directory
loaded user configuration file /home/myhome/.msmtprc
falling back to default account
using account default from /home/myhome/.msmtprc
host = smtp.gmail.com
port = 587
proxy host = (not set)
proxy port = 0
timeout = off
protocol = smtp
domain = localhost
auth = choose
user = myaccount
password = *
passwordeval = (not set)
ntlmdomain = (not set)
tls = on
tls_starttls = on
tls_trust_file = /etc/ssl/certs/ca-certificates.crt
tls_crl_file = (not set)
tls_fingerprint = (not set)
tls_key_file = (not set)
tls_cert_file = (not set)
tls_certcheck = on
tls_min_dh_prime_bits = (not set)
tls_priorities = (not set)
auto_from = off
maildomain = (not set)
from = myaccount@gmail.com
add_missing_from_header = on
dsn_notify = (not set)
dsn_return = (not set)
logfile = (not set)
syslog = (not set)
aliases = (not set)
reading recipients from the command line
<-- 220 smtp.gmail.com ESMTP 4sm116524ywc.22 - gsmtp
--> EHLO localhost
<-- 250-smtp.gmail.com at your service, [71.56.87.81]
<-- 250-SIZE 35882577
<-- 250-8BITMIME
<-- 250-STARTTLS
<-- 250-ENHANCEDSTATUSCODES
<-- 250-PIPELINING
<-- 250-CHUNKING
<-- 250 SMTPUTF8
--> STARTTLS
<-- 220 2.0.0 Ready to start TLS
TLS certificate information:
    Owner:
        Common Name: smtp.gmail.com
        Organization: Google LLC
        Locality: Mountain View
        State or Province: California
        Country: US
    Issuer:
        Common Name: Google Internet Authority G3
        Organization: Google Trust Services
        Country: US
    Validity:
        Activation time: Tue 21 May 2019 04:48:45 PM EDT
        Expiration time: Tue 13 Aug 2019 04:32:00 PM EDT
    Fingerprints:
        SHA256: C7:78:B6:D6:4E:3E:2B:2F:08:6D:A4:84:E6:1D:87:8E:A1:DF:54:D2:AB:79:AC:A6:BB:50:E5:5D:EC:B4:20:4C
        SHA1 (deprecated): 39:C5:E5:40:64:37:17:25:17:7F:E8:BA:20:F4:70:F4:FE:22:70:22
--> EHLO localhost
msmtp: cannot read from TLS connection: the operation timed out
msmtp: could not send mail (account default from /home/myhome/.msmtprc)

使用 --with-tls=openssl 构建 msmtp 来解决问题。

关于 EHLO 命令发送两次 RFC3207 状态:

The server MUST discard any knowledge obtained from the client, such as the argument to the EHLO command, which was not obtained from the TLS negotiation itself. The client MUST discard any knowledge obtained from the server, such as the list of SMTP service extensions, which was not obtained from the TLS negotiation itself. The client SHOULD send an EHLO command as the first command after a successful TLS negotiation.

所以这是正常行为。