Postfix Relay through Gmail on CentOS 7

[1] Install Packages

sudo yum install cyrus-sasl-sql cyrus-sasl-plain cyrus-sasl-lib
sudo systemctl restart postfix

[2] Configure Postfix

sudo vi /etc/postfix/main.cf
# :::
#--- RELAY to GMAIL ---#
relayhost = [smtp.gmail.com]:587

#--- SMTP SASL Authentication parameters ---#
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
smtp_sasl_mechanism_filter = plain
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_tls_policy_maps = hash:/etc/postfix/tls_policy

[3] Configure Postfix SASL Credentials

sudo vi /etc/postfix/sasl_passwd

[smtp.gmail.com]:587 <username>@gmail.com:<password>

postmap /etc/postfix/sasl_passwd

chown root:postfix /etc/postfix/sasl_passwd*
chmod 640 /etc/postfix/sasl_passwd*
sudo vi /etc/postfix/tls_policy

[smtp.gmail.com]:587 encrypt

postmap /etc/postfix/tls_policy

sudo systemctl restart postfix

[4] Test the Relay

echo "This is a test." | mail -s "test message" [email protected]


Posted

in

Tags: