17 January 2011

Use smtp.gmail.com as postfix relay

As some ISPs are blocking outgoing mail from home smtp server, we have to use a relay.
smtp.gmail.com is a good choice.

Here are the steps I've followed in order to configure postfix on ubuntu 10.10 to use gmail as a relay :

Install postfix
Choose Internet Site and keep the proposed next option
aptitude install postfix
configure postfix
cd /etc/postfix
nano main.cf
add the following lines at the end of the file :
relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl/passwd
smtp_sasl_security_options = noanonymous
(there is no need to comment out the same options that can be present before in the file as only the last ones are used)

create the file passwd
cd /etc/postfix/sasl/
nano /etc/postfix/sasl/passwd
insert this line, changing your own logon information
[smtp.gmail.com]:587 yourname@gmail.com:yourpassword
generate a db file that postfix can read
postmap passwd
give the right to postfix to read the two files
chmod +r /etc/postfix/passwd*
Generate the cacert.pem file
/usr/lib/ssl/misc/CA.pl -newca
I input the following information (but I don't think that any data input below are important):
Country Name (2 letter code) [AU]:BE
State or Province Name (full name) [Some-State]:Liege
Locality Name (eg, city) []:Liege
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Google
Organizational Unit Name (eg, section) []:Google
Common Name (eg, YOUR name) []:nicolas jolet
Email Address []:myaddress@gmail.com
Copy cacert.pem
cp demoCA/cacert.pem /etc/postfix/
EDIT 17/01/2011:
if you copy the content of the equifax certificate, this is also working and much more simple that the two previous steps
cat /etc/ssl/certs/Equifax_Secure_CA.pem > /etc/postfix/cacert.pem
Restart postfix deamon
/etc/init.d/postfix restart

I saw on some blogs/forums that you should add the ca cert of Equifax, but in my case, I didn't do it and this is working fine.



Credit : 1 2 3
Post a Comment