You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Postfix使用本机FQDN替代localhost发送测试邮件失败问题咨询

Postfix使用本机FQDN替代localhost发送测试邮件失败问题咨询

我遇到了一个Postfix的问题,想请教大家。我用localhost作为服务器发送测试邮件一切正常,但换成本机的FQDN(mordor.bounceme.net)就连接失败了。另外还有个小细节,发送邮件时用的MAIL FROM:<nicholas@mordor.saundersconsulting.tech>,不确定这会不会和问题有关,不过可能只是次要甚至无关的点。

发送测试的成功与失败情况

成功测试(指定server为localhost)

nicholas@mordor:~$ swaks --to nick@saundersconsulting.tech --server localhost

=== Trying localhost:25...

=== Connected to localhost.

<-  220 mordor.saundersconsulting.tech ESMTP Postfix (Ubuntu)

-> EHLO mordor.saundersconsulting.tech

<-  250-mordor.saundersconsulting.tech
<-  250-PIPELINING
<-  250-SIZE 10240000
<-  250-VRFY
<-  250-ETRN
<-  250-STARTTLS
<-  250-ENHANCEDSTATUSCODES
<-  250-8BITMIME
<-  250-DSN
<-  250-SMTPUTF8
<-  250 CHUNKING

-> MAIL FROM:<nicholas@mordor.saundersconsulting.tech>
<-  250 2.1.0 Ok

-> RCPT TO:<nick@saundersconsulting.tech>
<-  250 2.1.5 Ok

-> DATA
<-  354 End data with <CR><LF>.<CR><LF>

-> Date: Sun, 17 Dec 2023 06:01:02 -0800
-> To: nick@saundersconsulting.tech
-> From: nicholas@mordor.saundersconsulting.tech
-> Subject: test Sun, 17 Dec 2023 06:01:02 -0800
-> Message-Id: <20231217060102.2075937@mordor.saundersconsulting.tech>
-> X-Mailer: swaks v20201014.0 jetmore.org/john/code/swaks/

-> This is a test mailing

-> .
<-  250 2.0.0 Ok: queued as A563F44DE

-> QUIT
<-  221 2.0.0 Bye

=== Connection closed with remote host.

失败测试(指定server为mordor.bounceme.net)

nicholas@mordor:~$ swaks --to nick@saundersconsulting.tech --server mordor.bounceme.net

=== Trying mordor.bounceme.net:25...
*** Error connecting to mordor.bounceme.net:25:
***     IO::Socket::INET6: getaddrinfo: Name or service not known
nicholas@mordor:~$

Postfix日志信息

Dec 17 05:52:30 mordor postfix/smtp[2062947]: connect to smtp.gmail.com[2607:f8b0:400e:c0a::6d]:587: Network is unreachable
Dec 17 05:52:31 mordor postfix/smtp[2062947]: 989AC4464: to=<nick@saundersconsulting.tech>, relay=smtp.gmail.com[172.253.117.108]:587, delay=1, delays=0.05/0.04/0.25/0.68, dsn=2.0.0, status=sent (250 2.0.0 OK  1702821151 c2-20020a170902848200b001d09c539c96sm5759678plo.229 - gsmtp)
Dec 17 05:52:31 mordor postfix/qmgr[2062128]: 989AC4464: removed
Dec 17 06:00:39 mordor postfix/smtpd[2074921]: warning: /etc/postfix/main.cf, line 63: overriding earlier entry: smtp_tls_security_level=may
Dec 17 06:00:39 mordor postfix/postlogd[2074922]: warning: /etc/postfix/main.cf, line 63: overriding earlier entry: smtp_tls_security_level=may
Dec 17 06:00:39 mordor postfix/proxymap[2074923]: warning: /etc/postfix/main.cf, line 63: overriding earlier entry: smtp_tls_security_level=may
Dec 17 06:00:39 mordor postfix/smtpd[2074921]: connect from localhost[127.0.0.1]
Dec 17 06:00:39 mordor postfix/trivial-rewrite[2074924]: warning: /etc/postfix/main.cf, line 63: overriding earlier entry: smtp_tls_security_level=may
Dec 17 06:00:39 mordor postfix/cleanup[2074925]: warning: /etc/postfix/main.cf, line 63: overriding earlier entry: smtp_tls_security_level=may
Dec 17 06:00:39 mordor postfix/smtpd[2074921]: 579F943A0: client=localhost[127.0.0.1]
Dec 17 06:00:39 mordor postfix/cleanup[2074925]: 579F943A0: message-id=<20231217060039.2074920@mordor.saundersconsulting.tech>
Dec 17 06:00:39 mordor postfix/qmgr[2062128]: 579F943A0: from=<nicholas@mordor.saundersconsulting.tech>, size=541, nrcpt=1 (queue active)
Dec 17 06:00:39 mordor postfix/smtpd[2074921]: disconnect from localhost[127.0.0.1] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
Dec 17 06:00:39 mordor postfix/smtp[2074926]: warning: /etc/postfix/main.cf, line 63: overriding earlier entry: smtp_tls_security_level=may
Dec 17 06:00:39 mordor postfix/smtp[2074926]: connect to smtp.gmail.com[2607:f8b0:400e:c0a::6d]:587: Network is unreachable
Dec 17 06:00:41 mordor postfix/smtp[2074926]: 579F943A0: to=<nick@saundersconsulting.tech>, relay=smtp.gmail.com[172.253.117.109]:587, delay=1.9, delays=0.03/0.03/0.98/0.84, dsn=2.0.0, status=sent (250 2.0.0 OK  1702821641 oe16-20020a17090b395000b0028b21d24ba6sm5180708pjb.15 - gsmtp)
Dec 17 06:00:41 mordor postfix/qmgr[2062128]: 579F943A0: removed
Dec 17 06:01:02 mordor postfix/smtpd[2074921]: connect from localhost[127.0.0.1]
Dec 17 06:01:02 mordor postfix/smtpd[2074921]: A563F44DE: client=localhost[127.0.0.1]
Dec 17 06:01:02 mordor postfix/cleanup[2074925]: A563F44DE: message-id=<20231217060102.2075937@mordor.saundersconsulting.tech>
Dec 17 06:01:02 mordor postfix/qmgr[2062128]: A563F44DE: from=<nicholas@mordor.saundersconsulting.tech>, size=541, nrcpt=1 (queue active)
Dec 17 06:01:02 mordor postfix/smtp[2074926]: connect to smtp.gmail.com[2607:f8b0:400e:c0a::6d]:587: Network is unreachable
Dec 17 06:01:02 mordor postfix/smtpd[2074921]: disconnect from localhost[127.0.0.1] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
Dec 17 06:01:04 mordor postfix/smtp[2074926]: A563F44DE: to=<nick@saundersconsulting.tech>, relay=smtp.gmail.com[172.253.117.109]:587, delay=1.9, delays=0.03/0/0.72/1.1, dsn=2.0.0, status=sent (250 2.0.0 OK  1702821664 f11-20020a17090aec8b00b0028ae8284840sm8565076pjy.10 - gsmtp)
Dec 17 06:01:04 mordor postfix/qmgr[2062128]: A563F44DE: removed

其他观察到的细节

我注意到收到的邮件里有这个头信息:

X-Google-Original-From: nicholas@mordor.saundersconsulting.tech

另外,Gmail还会给我发送的邮件添加安全提示:

Be careful with this message
This may be a spoofed message. The message claims to have been sent
from your account, but Gmail couldn’t verify the actual source. Avoid
clicking links or replying with sensitive information, unless you are
sure you actually sent this message. (No need to reset your password,
the real sender does not actually have access to your account!)

我的核心疑问

用localhost发送完全没问题,但为什么不能用本机的FQDN来替代localhost呢?毕竟是同一台机器啊。我的Postfix配置里相关项是:

mydestination = $myhostname, mordor.saundersconsulting.tech, localhost
myhostname = mordor.saundersconsulting.tech
myorigin = mordor.saundersconsulting.tech

按照这个配置,我本来以为Postfix会把这个FQDN和localhost同等对待才对,实在搞不懂哪里出了问题。


备注:内容来源于stack exchange,提问作者Nicholas Saunders

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.20 12:54:38