如何使用 FQDN 而不是本地主机通过 postfix 发送测试电子邮件?

如何使用 FQDN 而不是本地主机通过 postfix 发送测试电子邮件?

有问题的线路:

MAIL FROM:<[email protected]>

尽管这可能是一个次要问题,甚至不是一个问题。


发送成功与失败:

nicholas@mordor:~$ 
nicholas@mordor:~$ swaks --to [email protected] --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:<[email protected]>
<-  250 2.1.0 Ok
 -> RCPT TO:<[email protected]>
<-  250 2.1.5 Ok
 -> DATA
<-  354 End data with <CR><LF>.<CR><LF>
 -> Date: Sun, 17 Dec 2023 06:01:02 -0800
 -> To: [email protected]
 -> From: [email protected]
 -> Subject: test Sun, 17 Dec 2023 06:01:02 -0800
 -> Message-Id: <[email protected]>
 -> 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.
nicholas@mordor:~$ 
nicholas@mordor:~$ swaks --to [email protected] --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:~$ 

日志:

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=<[email protected]>, 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=<[email protected]>
Dec 17 06:00:39 mordor postfix/qmgr[2062128]: 579F943A0: from=<[email protected]>, 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=<[email protected]>, 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=<[email protected]>
Dec 17 06:01:02 mordor postfix/qmgr[2062128]: A563F44DE: from=<[email protected]>, 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=<[email protected]>, 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: [email protected]

无论如何,通过 localhost 发送都是可以的。为什么不能为 localhost 指定 FQDN,因为它是同一台机器。

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

所以我希望 postfix 解析 FQDN 的方式与在服务器中输入“localhost”的方式相同。

--

顺便说一下,我看到了:

请小心此消息

这可能是一封伪造的邮件。该邮件声称是从您的帐户发送的,但 Gmail 无法验证其实际来源。除非您确定您确实发送了此邮件,否则请避免点击链接或回复敏感信息。(无需重置密码,真正的发件人实际上无权访问您的帐户!)

来自我自己的消息。

相关内容