如何配置 postfix 以便通过 Gmail 发送如下的测试电子邮件?
nicholas@mordor:~$
nicholas@mordor:~$ swaks --to [email protected] --server mordor.saundersconsulting.tech
=== Trying mordor.saundersconsulting.tech:25...
=== Connected to mordor.saundersconsulting.tech.
<- 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: Sat, 16 Dec 2023 13:52:09 -0800
-> To: [email protected]
-> From: [email protected]
-> Subject: test Sat, 16 Dec 2023 13:52:09 -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 E5A2E2ADC
-> QUIT
<- 221 2.0.0 Bye
=== Connection closed with remote host.
nicholas@mordor:~$
nicholas@mordor:~$ nl /var/log/postfix.log
1 Dec 16 13:52:02 mordor postfix/qmgr[1530878]: 9671C2C56: from=<>, size=2244, nrcpt=1 (queue active)
2 Dec 16 13:52:02 mordor postfix/qmgr[1530878]: 3074D2D02: from=<>, size=2244, nrcpt=1 (queue active)
3 Dec 16 13:52:02 mordor postfix/qmgr[1530878]: 325DB2BDE: from=<>, size=2244, nrcpt=1 (queue active)
4 Dec 16 13:52:02 mordor postfix/qmgr[1530878]: ED36B20AE: from=<>, size=2244, nrcpt=1 (queue active)
5 Dec 16 13:52:02 mordor postfix/qmgr[1530878]: 07A052AAA: from=<>, size=2244, nrcpt=1 (queue active)
6 Dec 16 13:52:02 mordor postfix/qmgr[1530878]: B8E1F2D00: from=<>, size=2244, nrcpt=1 (queue active)
7 Dec 16 13:52:02 mordor postfix/qmgr[1530878]: 55FA320B0: from=<>, size=2244, nrcpt=1 (queue active)
8 Dec 16 13:52:02 mordor postfix/qmgr[1530878]: C70992ACE: from=<>, size=2244, nrcpt=1 (queue active)
9 Dec 16 13:52:02 mordor postfix/error[1582404]: 325DB2BDE: to=<[email protected]>, relay=none, delay=368, delays=368/0.02/0/0.04, dsn=4.4.3, status=deferred (delivery temporarily suspended: Host or domain name not found. Name service error for name=saundersconsulting.tech type=MX: Host not found, try again)
10 Dec 16 13:52:02 mordor postfix/error[1582402]: 3074D2D02: to=<[email protected]>, relay=none, delay=969, delays=969/0.01/0/0.05, dsn=4.4.3, status=deferred (delivery temporarily suspended: Host or domain name not found. Name service error for name=saundersconsulting.tech type=MX: Host not found, try again)
11 Dec 16 13:52:02 mordor postfix/error[1582401]: 9671C2C56: to=<[email protected]>, relay=none, delay=2172, delays=2172/0.01/0/0.05, dsn=4.4.3, status=deferred (delivery temporarily suspended: Host or domain name not found. Name service error for name=saundersconsulting.tech type=MX: Host not found, try again)
12 Dec 16 13:52:02 mordor postfix/error[1582406]: ED36B20AE: to=<[email protected]>, relay=none, delay=3975, delays=3975/0.02/0/0.03, dsn=4.4.3, status=deferred (delivery temporarily suspended: Host or domain name not found. Name service error for name=saundersconsulting.tech type=MX: Host not found, try again)
13 Dec 16 13:52:02 mordor postfix/error[1582408]: 07A052AAA: to=<[email protected]>, relay=none, delay=2172, delays=2172/0.03/0/0.04, dsn=4.4.3, status=deferred (delivery temporarily suspended: Host or domain name not found. Name service error for name=saundersconsulting.tech type=MX: Host not found, try again)
14 Dec 16 13:52:02 mordor postfix/error[1582406]: C70992ACE: to=<[email protected]>, relay=none, delay=369, delays=369/0.06/0/0.02, dsn=4.4.3, status=deferred (delivery temporarily suspended: Host or domain name not found. Name service error for name=saundersconsulting.tech type=MX: Host not found, try again)
15 Dec 16 13:52:02 mordor postfix/error[1582401]: 55FA320B0: to=<[email protected]>, relay=none, delay=3974, delays=3974/0.06/0/0.02, dsn=4.4.3, status=deferred (delivery temporarily suspended: Host or domain name not found. Name service error for name=saundersconsulting.tech type=MX: Host not found, try again)
16 Dec 16 13:52:02 mordor postfix/error[1582404]: B8E1F2D00: to=<[email protected]>, relay=none, delay=970, delays=970/0.06/0/0.02, dsn=4.4.3, status=deferred (delivery temporarily suspended: Host or domain name not found. Name service error for name=saundersconsulting.tech type=MX: Host not found, try again)
17 Dec 16 13:52:09 mordor postfix/smtpd[1582532]: connect from localhost[127.0.0.1]
18 Dec 16 13:52:09 mordor postfix/smtpd[1582532]: E5A2E2ADC: client=localhost[127.0.0.1]
19 Dec 16 13:52:09 mordor postfix/cleanup[1582540]: E5A2E2ADC: message-id=<[email protected]>
20 Dec 16 13:52:09 mordor postfix/qmgr[1530878]: E5A2E2ADC: from=<[email protected]>, size=555, nrcpt=1 (queue active)
21 Dec 16 13:52:09 mordor postfix/smtpd[1582532]: disconnect from localhost[127.0.0.1] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
22 Dec 16 13:52:09 mordor postfix/local[1582552]: E5A2E2ADC: to=<[email protected]>, relay=local, delay=0.04, delays=0.03/0.01/0/0.01, dsn=2.0.0, status=sent (delivered to mailbox)
23 Dec 16 13:52:09 mordor postfix/qmgr[1530878]: E5A2E2ADC: removed
nicholas@mordor:~$
nicholas@mordor:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04 LTS
Release: 22.04
Codename: jammy
nicholas@mordor:~$
我见过一些使用 Dovecot 和 Postfix 配置功能齐全的邮件服务器的教程,但我只是想通过 Gmail 进行中继。
当然,需要注意的是,“localhost”或 FQDN 仍应保持在本地。
也可以看看:
我已经设置 Postfix 使用 SMTP.Gmail.com 服务器发送邮件,邮件仅在服务器重启时发送? 如何配置 Postfix 以通过我的 Gmail 帐户发送所有电子邮件? 使用 postfix 发送电子邮件到 gmail 为什么 postfix/dovecot 无法接收来自 Gmail 的邮件? https://stackoverflow.com/a/67132304/4531180 https://askubuntu.com/a/1497265/847449