Home Postfix Google as SMTP Relay

Postfix Google as SMTP Relay

as a fix solution you can use google, as smtp relay for e.g. notifications. In this example I am working on a Fedora 27 Host.

Install needed packages

dnf -y install postfix mailx cyrus-sasl-plain

Restart and enable services

systemctl restart postfix && systemctl enable postfix

Adjust /etc/postfix/main.cf depends your needs (marked in red)

myhostname = zuerich.tuxclouds.org

relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous

Setup the secret

vim /etc/postfix/sasl_passwd
[smtp.gmail.com]:587 username:password

Issue the command postmap to read the new secret

postmap /etc/postfix/sasl_passwd

Set correct owner and permissons

chown root:postfix /etc/postfix/sasl_passwd
chmod 640 /etc/postfix/sasl_passwd

Reload the service

systemctl reload postfix

Verify the setup, by sending you a Test Notification Mail

echo "Test Mail" | mail -s "Test Notification Mail" [email protected]


This post is licensed under CC BY 4.0 by the author.