While you would want to set up a proper email relay on a full-fledged server, for a small home machine, nothing beats the simplicity of having Gmail as the relay.
Just add the following lines to
relayhost = [smtp.gmail.com]:587 smtp_sasl_auth_enable = yes smtp_tls_CAfile = /etc/postfix/cacert.pem smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous smtp_use_tls = yes
Copy Thawte Certificate Authority to Postfix's CA file:
# tee -a will append contents to file if file already exists cat /etc/ssl/certs/thawte_Premium_Server_CA.pem | tee -a /etc/postfix/cacert.pem
Then generate a Gmail App Password to create the
sasl_password file by going to App Passwords on your Google Security tab.
Once you have it add the following line to
[smtp.gmail.com]:587 [email protected]:APP_PASSWORD
You must then fix
chmod 400 /etc/postfix/sasl_passwd
And then use
postmap to generate
sasl_passwd.db file which postfix will need:
The only thing left to do is to restart the service:
You can then use this one-liner to send an email to yourself and check if Postfix is working as intended:
echo "Test mail from postfix" | mail -s "Test Postfix" [email protected]
The logs should show something like this (notice the relay server):
Jun 25 17:14:56 AEC1E9C0043: uid=0 from=<wasteofserver> Jun 25 17:14:58 AEC1E9C0043: to=<[email protected]>, relay=smtp.gmail.com[220.127.116.11]:587, delay=2.2, delays=0.06/0.01/1.4/0.73, dsn=2.0.0, status=sent (250 2.0.0 OK 1624637698 v5sm11709310wml.26 - gsmt Jun 25 17:14:58 AEC1E9C0043: removed
Alternatively, you can also check your Gmail "sent folder". As the email will be sent by Gmail using your account, the email will be there.
As an Amazon Associate I may earn from qualifying purchases on some links.
If you found this page helpful, please share.