Christopher Juckins

SysAdmin Tips, Tricks and other Software Tools

User Tools

Site Tools


GMail as a Relay on Linux Ubunutu 20.04 LTS and CENTOS8

Using Postfix for this solution.

Follow instructions at

Or see the same at Sending Emails Using Postfix From Your Linux Server

  • Will this also break with less sure apps?
    • The "Less Secure Apps" is not available in Gmail if your account is configured for 2-factor authentication
    • Everything should work OK.


dnf install postfix ca-certificates mutt
dnf install cyrus-sasl, cyrus-sasl-gssapi, cyrus-sasl-lib, cyrus-sasl-plain
systemctl start postfix
systemctl enable postfix

Next perform the following steps as root:

cd /etc/postfix
mkdir /etc/postfix/sasl
cd /etc/postfix/sasl
vi sasl_passwd

Add this line:

[]:587 [email protected]:password
postmap /etc/postfix/sasl/sasl_passwd
chown root:root /etc/postfix/sasl/sasl_passwd /etc/postfix/sasl/sasl_passwd.db
chmod 0600 /etc/postfix/sasl/sasl_passwd /etc/postfix/sasl/sasl_passwd.db
vi /etc/postfix/

Comment out this line:

#smtp_tls_security_level = may

Now wdd to the end of the file:

# Local Edits
relayhost = []:587
# Enable SASL authentication
smtp_sasl_auth_enable = yes
# Disallow methods that allow anonymous authentication
smtp_sasl_security_options = noanonymous
# Location of sasl_passwd
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
# Enable STARTTLS encryption
smtp_tls_security_level = encrypt
# Location of CA certificates
smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt

Restart postfix:

systemctl restart postfix

Send test message:

mutt -s "Test" [email protected] </dev/null
gmail_as_a_relay_on_linux_centos8.txt · Last modified: 2022/05/21 18:40 by juckins