How would postfix be configured so that a test e-mail as below would be sent through Gmail?
nicholas@mordor:~$
nicholas@mordor:~$ swaks --to nick@mordor.saundersconsulting.tech --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:<nicholas@mordor.saundersconsulting.tech>
<- 250 2.1.0 Ok
-> RCPT TO:<nick@mordor.saundersconsulting.tech>
<- 250 2.1.5 Ok
-> DATA
<- 354 End data with <CR><LF>.<CR><LF>
-> Date: Sat, 16 Dec 2023 13:52:09 -0800
-> To: nick@mordor.saundersconsulting.tech
-> From: nicholas@mordor.saundersconsulting.tech
-> Subject: test Sat, 16 Dec 2023 13:52:09 -0800
-> Message-Id: <20231216135209.1582531@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 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=<saunders.nicholas@gmail.com>, 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=<saunders.nicholas@gmail.com>, 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=<saunders.nicholas@gmail.com>, 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=<saunders.nicholas@gmail.com>, 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=<saunders.nicholas@gmail.com>, 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=<saunders.nicholas@gmail.com>, 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=<saunders.nicholas@gmail.com>, 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=<saunders.nicholas@gmail.com>, 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=<20231216135209.1582531@mordor.saundersconsulting.tech>
20 Dec 16 13:52:09 mordor postfix/qmgr[1530878]: E5A2E2ADC: from=<nicholas@mordor.saundersconsulting.tech>, 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=<nick@mordor.saundersconsulting.tech>, 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:~$
I've seen some tutorials for configuring a full-blown mail server with Dovecot and Postfix, but I'm just looking to relay through Gmail.
The caveat being that "localhost" or the FQDN should still be kept local, of course.
See also:
I have setup Postfix to send mail with SMTP.Gmail.com server, mail only gets send at server reboot? How can I configure Postfix to send all email through my Gmail account? Send email to gmail using postfix Why doesn't postfix/dovecot receive mails from Gmail? https://stackoverflow.com/a/67132304/4531180 https://askubuntu.com/a/1497265/847449