Tribut to Diogo Esteves http://yaui.me/postfix-gmail-smtp-server-relay-ubuntu/
Prerequisites
$ sudo apt-get install postfix libsasl2-2 libsasl2-modules ca-certificates
Edit /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
Create file /etc/postfix/sasl_passwd
[smtp.gmail.com]:587 user.name@gmail.com:password
$ sudo chmod 400 /etc/postfix/sasl_passwd $ sudo postmap /etc/postfix/sasl_passwd $ cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | sudo tee -a /etc/postfix/cacert.pem $ sudo /etc/init.d/postfix reload