First you have to enable the access for less secure apps option in gmail settings.
1. Update Ubuntu and install required packages.......
$ sudo apt-get update
$ sudo apt-get install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules
2. Now configure the postfix
$ vi /etc/postfix/main.cf
relayhost = [smtp.gmail.com]: 587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
3. Now specify the Gmail username and password
$ vi /etc/postfix/sasl/sasl_passwd
[smtp.gmail.com]: 587 username@gmail.com:password
4. Now give the permission to sasl_passwd file and update postfix to use sasl_passwd file:
$ sudo chmod 400 /etc/postfix/sasl/sasl_passwd
$ sudo postmap /etc/postfix/sasl/sasl_passwd
5. Now validate certificate
$ cat /etc/ssl/certs/thawte_Primary_Root_CA.pem | sudo tee -a /etc/postfix/sasl/ca-certificates.crt
$ sudo /etc/init.d/postfix reload
6. Now test the configurations by sending a mail
$ echo "Test mail" | mail -s "Test Mail" username@domain.com
Check the mail in receiver's inbox OR sender's sent box. For troubleshooting check the log:
$ sudo tail -f /var/log/mail.log //Try to find the cause of error.//
1. Update Ubuntu and install required packages.......
$ sudo apt-get update
$ sudo apt-get install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules
2. Now configure the postfix
$ vi /etc/postfix/main.cf
relayhost = [smtp.gmail.com]: 587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
3. Now specify the Gmail username and password
$ vi /etc/postfix/sasl/sasl_passwd
[smtp.gmail.com]: 587 username@gmail.com:password
4. Now give the permission to sasl_passwd file and update postfix to use sasl_passwd file:
$ sudo chmod 400 /etc/postfix/sasl/sasl_passwd
$ sudo postmap /etc/postfix/sasl/sasl_passwd
5. Now validate certificate
$ cat /etc/ssl/certs/thawte_Primary_Root_CA.pem | sudo tee -a /etc/postfix/sasl/ca-certificates.crt
$ sudo /etc/init.d/postfix reload
6. Now test the configurations by sending a mail
$ echo "Test mail" | mail -s "Test Mail" username@domain.com
Check the mail in receiver's inbox OR sender's sent box. For troubleshooting check the log:
$ sudo tail -f /var/log/mail.log //Try to find the cause of error.//
No comments:
Post a Comment