First, set up a Gmail account, note the user name and password for later.
Install postfix
$ sudo apt-get install postfix
Add the following to /etc/postfix/main.cnf
# Forward mail through Gmail
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_CAfile = /etc/ssl/certs/Equifax_Secure_CA.pem
Create the file /etc/postfix/sasl_passwd
and add the following:
[smtp.gmail.com]:587 [username]@gmail.com:[password]
Be sure to replace [username]
and [password]
with your account user name and password.
Modify file permissions and generate sasl_passwd.db
$ cd /etc/postfix
$ postmap sasl_passwd
$ chmod 600 sasl_passwd sasl_passwd.db
Restart postfix service
$ sudo service postfix restart
Send a test email
$ sudo apt-get install mailutils $ echo 'Success!' | mailx -s 'Test Message' [email_address]
Replace [email_address]
with your email address to receive a test message.