Sendmail 连接超时

Erw*_*ald 4 email debian sendmail

我最近设置了一个新的 Debian 服务器,

第一次安装和设置 sendmail 后,我无法发送电子邮件。

Reason : Connection timeout.

/var/log/mail.log 的输出:

> May  6 02:42:53 k***** sm-mta[15070]: q465gjxF013677:
> to=<*****@gmail.com>, ctladdr=<*****@*****.ca> (1001/1001),
> delay=01:00:08, xdelay=00:00:00, mailer=esmtp, pri=300329,
> relay=alt4.gmail-smtp-in.l.google.com., dsn=4.0.0, stat=Deferred:
> Connection timed out with alt4.gmail-smtp-in.l.google.com.
Run Code Online (Sandbox Code Playgroud)

netstat 的输出:

tcp        0      0 0.0.0.0:587             0.0.0.0:*   LISTEN   15069/sendmail: MTA
tcp        0      0 0.0.0.0:25              0.0.0.0:*   LISTEN   15069/sendmail: MTA
Run Code Online (Sandbox Code Playgroud)

从另一台计算机 (telnet theserver.imworkingon.com 25) 运行时,25 上的 Telnet 也成功,但如果我尝试从我正在使用的服务器运行它,则不会成功。这告诉我出站端口 25 似乎以某种方式被阻止了......

谁有想法?

eww*_*ite 7

标准邮件故障排除步骤适用于此处...从日志中,我们看到您能够解析要发送到的 gmail.com 目标的 MX/DNS 记录。所以这不是 DNS 或路由问题。

由于这是基本的 SMTP 传送,请尝试使用 telnet 到端口 25 以确保您能够连接到目标主机...

我会按照这个顺序:

dig mx gmail.com
# Look for the mail destination IP in the output - "209.85.225.27" in this case

telnet 209.85.225.27 25
# This is an attempt to telnet to port 25 (smtp) on the recipient's server...
Run Code Online (Sandbox Code Playgroud)

您应该会看到类似于以下内容的内容:

Trying 209.85.225.27...
Connected to iy-in-f27.1e100.net (209.85.225.27).
Escape character is '^]'.
220 ***************************************
Run Code Online (Sandbox Code Playgroud)

如果您没有看到以上内容,则您的出站端口 25 smtp 流量在机器级别(检查 iptables 等)或网络级别(检查网络防火墙或 ISP 策略)被阻止。

如果您确实看到了类似的消息,那么您就可以传递邮件,并且不会收到超时错误。