PDA

View Full Version : Postfix Using Gmail as Host How To



carlostico
02-29-12, 01:50 PM
Found this Instructions , I'm not sure if this is the right procedure but it's working for me:

1) You’ll want to add the following lines to your /etc/postfix/main.cf file:

relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_loglevel = 1
smtp_tls_per_site = hash:/etc/postfix/tls_per_site
smtp_tls_CAfile = /etc/ssl/certs/Equifax_Secure_CA.pem
smtp_tls_session_cache_database = btree:/var/lib/postfix/smtp_tls_session_cache

2) Next we need to create and populate the sasl_passwd file.

Create the file /etc/postfix/sasl_passwd with the following contents:[smtp.gmail.com]:587 user.name@gmail.com:password


3) This file should have restrictive permissions and then needs to be translated into a .db that Postfix will read.

sudo chmod 400 /etc/postfix/sasl_passwd
sudo postmap /etc/postfix/sasl_passwd

4) At this point you can restart Postfix and it should work, however it will complain about not being able to authenticate the certificate. To take care of this issue we’ll use the ca-certificate package we installed and tell it where it can validate the certificate. Certificate package we installed and tell it where it can validate the certificate.

cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | sudo tee -a /etc/postfix/cacert.pem

5) Go ahead and reload postfix (sudo /etc/init.d/postfix reload) and you should be set.

6) Gmail now uses certificate from Equifax Use this instead of the Thawte certs

cat /etc/ssl/certs/Equifax_Secure_CA.pem >> /etc/postfix/cacert.pem

7)

% cat sasl_passwd
[smtp.gmail.com]:587 user@gmail.com:pass

and

% cat tls_per_site
smtp.gmail.com MUST

sudo postmap sasl_passwd
sudo postmap tls_per_site

8) If after all of this you get
warning: SASL authentication failure
no mechanism found

run

apt-get install libsasl2-modules

Let me know if any correction, tried to setup with Webmin but it was a little confusing.