Yet another reminder to myself how to use Gmail as SMTP-service.
Start with installing postfix. Just do the usual:
sudo aptitude install postfix
Select the following settings to start with during installation. Adjust according to your needs.
General type of mail configuration: SatelliteSystem System mail name: yourhostname SMTP relay host (blank for none): smtp.gmail.com:587 Root and postmaster mail recipient: sysadmins Other destinations to accept mail for (blank for none): yourhostname, localhost, localhost.localdomain Force synchronous updates on mail queue? No Local networks: 127.0.0.0/8 Mailbox size limit (bytes): 0 Local address extension character: + Internet protocols to use: ipv4 eller ipv6 beroende på vad som används
If you ever need to redo the configuration run:
sudo dpkg-reconfigure postfix
Edit /etc/postfix/main.cf by adding the following rows:
smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous smtp_use_tls = yes
Create the file /etc/postfix/sasl_passwd with the following content:
smtp.gmail.com:587 your_account@gmail.com:password
When done run and restart postfix afterwards:
sudo postmap /etc/postfix/sasl_passwd sudo service postfix restart
Now check you mail configuration by sending a mail to your own mailbox:
mail -s "Test" your_email@domain.com