使用 Postfix 作为 MTA 从 Linux 邮件命令向 GMAIL 地址发送电子邮件

使用 Postfix 作为 MTA 从 Linux 邮件命令向 GMAIL 地址发送电子邮件

我是配置邮件传递系统的新手。最近,管理层下达命令,要求我们在客户完成申请后向其发送确认电子邮件(我在当地一所大学工作)。

在谷歌上搜索答案后,我在 DigitalOcean 上找到了这篇关于如何配置“仅发送” Postfix 的文章(https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-as-a-send-only-smtp-server-on-ubuntu-22-04),这正是我所需要的,因为管理层的命令参数是电子邮件不应回复。

按照上述链接中的说明进行操作后,我发现没有任何问题,除了:

Apr 16 08:53:03 application postfix/pickup[360142]: DA25140A2775: uid=0 from=<[email protected]>
Apr 16 08:53:03 application postfix/cleanup[360716]: DA25140A2775: message-id=<[email protected]>
Apr 16 08:53:03 application postfix/qmgr[360143]: DA25140A2775: from=<[email protected]>, size=415, nrcpt=1 (queue active)
Apr 16 08:53:34 application postfix/smtp[360718]: connect to gmail-smtp-in.l.google.com[74.125.204.27]:25: Connection timed out
Apr 16 08:53:49 application postfix/smtp[360718]: connect to alt1.gmail-smtp-in.l.google.com[142.250.141.26]:25: No route to host
Apr 16 08:54:04 application postfix/smtp[360718]: connect to alt2.gmail-smtp-in.l.google.com[142.250.115.27]:25: No route to host
Apr 16 08:54:34 application postfix/smtp[360718]: connect to alt3.gmail-smtp-in.l.google.com[64.233.171.27]:25: Connection timed out
Apr 16 08:55:04 application postfix/smtp[360718]: connect to alt4.gmail-smtp-in.l.google.com[142.250.152.26]:25: Connection timed out
Apr 16 08:55:04 application postfix/smtp[360718]: DA25140A2775: to=<[email protected]>, relay=none, delay=121, delays=0.46/0.01/121/0, dsn=4.4.1, status=deferred (connect to alt4.gmail-smtp-in.l.google.com[142.250.152.26]:25: Connection timed out)

...我在运行说明中指示的测试命令后在系统日志中发现了它。(出于隐私目的,我更改了域名和电子邮件地址。)

我的 Postfix 配置是:

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
append_dot_mydomain = no
readme_directory = no
compatibility_level = 3.6
smtpd_tls_cert_file=/etc/letsencrypt/live/college.ph/cert.pem
smtpd_tls_key_file=/etc/letsencrypt/live/college.ph/privkey.pem
smtpd_tls_security_level=may
smtp_tls_CApath=/etc/ssl/certs
smtp_tls_security_level=may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = college.ph
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = college.ph
relayhost =
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
inet_protocols = ipv4
mynetworks = 127.0.0.1/32

顺便说一下,我将 Postfix 配置为监听端口 3000/TCP,因为我们的 ISP 屏蔽了端口 25。端口转发以及 SPF 和 DMARC 都已到位。

我做错了什么?提前谢谢您。

答案1

无论您将 Postfix 配置为监听什么,Gmail 和其他邮件服务都会监听端口 25。如果您的 ISP 阻止它,您就无法发送邮件。

您可以尝试通过设置smtp_tls_security_level为 来规避此问题yes,但向未配置加密的邮件服务发送邮件将会失败。

基本上,您有两个选择:要求您的主机托管商打开端口 25 或切换到其他主机托管商。

相关内容