This document describes how to configure postfix to use gmail as relay server on debian squeeze.
1. Install the required package. On the dialog window please select No configuration.
apt-get install postfix libsasl2-2 ca-certificates libsasl2-modules
2. Configure postfix
vim /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
alias_maps = hash:/etc/aliases
inet_interfaces = 127.0.0.1
:wq
3. Define an username and a password
vim /etc/postfix/sasl_passwd
[smtp.gmail.com]:587 email@gmail.com:password
:wq
4. Fix file permissions
chmod 400 /etc/postfix/sasl_passwd
5. Generate Postix lookup table
postmap /etc/postfix/sasl_passwd
6. Use the ca-certificate package we installed and tell it where it can validate the certificate
cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | tee -a /etc/postfix/cacert.pem
7. Restart postfix
/etc/init.d/postfix restart
8. Test installation
echo "Test from a postfix configured to use gmail as a relay server" | mail -s "Test from postfix" "email@example.com"