Zimbra邮件服务器Postfix连接Gmail SMTP超时问题求助
Postfix组件尝试连接alt4.gmail-smtp-in.l.google.com[64.233.171.26]:25时出现Connection timed out错误,导致邮件状态为deferred,相关日志如下:
Jun 21 04:40:28 instance-1 postfix/smtp[9475]: connect to alt4.gmail-smtp-in.l.google.com[64.233.171.26]:25: Connection timed out
Jun 21 04:40:28 instance-1 postfix/smtp[9474]: connect to alt4.gmail-smtp-in.l.google.com[64.233.171.26]:25: Connection timed out
Jun 21 04:40:28 instance-1 postfix/smtp[9475]: 7CAF670750EC: to=@gmail.com, relay=none, delay=50762, delays=50612/0.02/150/0, dsn=4.4.1, status=deferred (connect to alt4.gmail-smtp-in.l.google.com[64.233.171.26]:25: Connection timed out)
Jun 21 04:40:28 instance-1 postfix/smtp[9474]: 50D2C7074D97: to=@gmail.com, relay=none, delay=84589, delays=84439/0.04/150/0, dsn=4.4.1, status=deferred (connect to alt4.gmail-smtp-in.l.google.com[64.233.171.26]:25: Connection timed out)
排查与解决步骤
基础网络连通性检测
在Zimbra服务器上执行以下命令测试端口25的连通性:telnet alt4.gmail-smtp-in.l.google.com 25 # 或使用nc命令 nc -zv alt4.gmail-smtp-in.l.google.com 25如果同样超时,说明问题出在网络层面,而非Postfix配置。
检查防火墙/安全组规则
确认Zimbra服务器的出站规则允许访问25端口:- 若用
ufw,执行ufw status查看规则,确保存在allow out 25 - 若用
iptables,执行iptables -L OUTPUT -n检查是否放行25端口 - 云服务器需检查对应厂商的安全组配置,确保出站25端口未被限制
- 若用
切换SMTP端口或Gmail中继地址
Gmail支持587(STARTTLS)和465(SSL)端口,可修改Postfix配置改用这些端口:- 编辑Postfix主配置文件
/etc/postfix/main.cf,添加或修改:relayhost = [alt4.gmail-smtp-in.l.google.com]:587 smtp_tls_security_level = may - 重启Postfix服务:
systemctl restart postfix # 或Zimbra专用命令 zmcontrol restart postfix
也可尝试切换到其他Gmail SMTP入站地址,如
gmail-smtp-in.l.google.com、alt1.gmail-smtp-in.l.google.com等。- 编辑Postfix主配置文件
确认ISP端口限制
部分ISP会封禁出站25端口,需联系服务商确认;若被封禁,必须使用587/465端口或通过ISP提供的中继服务器发送邮件。调整Postfix超时参数
若偶尔出现超时,可修改Postfix连接超时参数,编辑/etc/postfix/main.cf:smtp_connect_timeout = 30s smtp_timeout = 60s重启Postfix生效。
内容的提问来源于stack exchange,提问作者babymoony team

