Wednesday, April 24, 2013

Ubuntu Relaying Postfix SMTP (gmail)


The purpose is to sent mail through my Linux laptop with mailutils...

1. # apt-get install postfix

2. Edit /etc/postfix/main.cf by edit any exist entry as below values:

relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes

3. Saved your gmail authentication info to  /etc/postfix/sasl_passwd  as below:
[smtp.gmail.com]:587    user.name@gmail.com:password

4. Change permissions 
#sudo chmod 400 /etc/postfix/sasl_passwd
#sudo postmap /etc/postfix/sasl_passwd

5. Tell it where it can validate the certificate.
# cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | sudo tee -a /etc/postfix/cacert.pem

6. Restart & Test
#sudo service postfix restart
# echo 'test' | mail user.name@gmail.com

end.

[ref :https://help.ubuntu.com/community/Postfix]