Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
configure gmail as relay smtp using postfix
Steps to configure this server to send mail via gmail relay
1. Download postfix and required packages
sudo apt-get install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules
2. Configure gmail as relay host : in /etc/postfix/main.cf
relayhost = [smtp.gmail.com]:587
smtpd_sasl_auth_enable = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes
4. Write in /etc/postfix/master.cf
10025 inet n -n - - smtpd
3. Stock gmail username and password in /etc/postfix/sasl_passwd,
give 400 access rights + add to postmap
write :
[smtp.gmail.com]:587 username@gmail.com:password
smtp.gmail.com username@gmail.com:password
gmail-smtp.l.google.com username@gmail.com:password
to /etc/postfix/sasl_passwd
sudo chmod 400 /etc/postfix/sasl_passwd
sudo postmap /etc/postfix/sasl_passwd
4. Create certificate file
cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | sudo tee -a /etc/postfix/cacert.pem
5. Finally, reload postfix :
service postfix restart
For testing :
echo "test email from postfix | mail -s "subject" destination@xyz.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.