mercredi 16 mars 2011

Configuration relayhost use a Google Apps (gmail) smtp with postfix

All the commands are done under the root user (or you could use sudo)
as root apt-get install postfix libsasl2 ca-certificate libsasl2-modules
Configure Postfix
This tutorial will not outline how to configure your postfix server, but we’ll jump directly to the relayhost section.  You’ll want to add the following lines to your /etc/postfix/main.cf


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
The above lines are telling Postfix that you want to relay mail through gmail on a specific port, telling it to authenticate, and where to find the username and password.  The last three lines specify the authentication types supported, where the certificate authority file is and that it should use tls.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.

Define Username and Password
Next we’ll need to populate the sasl_passwd file.  Create the file /etc/postfix/sasl_passwd with the following contents:

[smtp.gmail.com]:587 user.name@domainGoogleApps:password
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
Then reload postfix (/etc/init.d/postfix reload) and you should be set.

Using & validating CA certificate
touch /etc/postfix/cacert.pem
cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem >> /etc/postfix/cacert.pem
 
cat /etc/ssl/certs/Equifax_Secure_CA.pem >> /etc/postfix/cacert.pem 

Aucun commentaire:

Enregistrer un commentaire

EurabiaHosting