Using gmail as a Postfix Smarthost
Here’s are consolidated set of instructions for setting up a postfix gmail smarthost on Ubuntu 8.04. In “smarthost” configuration, the local mail transport agent (MTA) routes all mail to another server for delivery. This is useful since frequently you won’t want to try to deliver mail yourself (SPF and/or blacklisting would likely squash your message as spam).
- Install postfix.
sudo apt-get install postfix
- The deb-installer will prompt you to answer a series of questions
- Type of mail server : Satellite System
- Mail Name : example.org (the name you want on your outbound mail)
- SMTP relay host : smtp.gmail.com
- Postmaster : I left this blank
- Other destinations : I left this blank
- Synchronous Queues : your choice, won’t impact the relaying
- Network blocks to allow relay : default (unless you know what your doing)
- Mailbox size : your choice, won’t impact relaying
- Local address : i left this as ‘+’
- Listen Address : all, your choice
- We’re almost done, but need some tweaks in postfix config /etc/postfix/main.cf. Add the following lines to enable TLS and passwords on outbound connections.
smtp_use_tls=yes smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous smtp_sasl_tls_security_options = noanonymous
- And create the /etc/postfix/sasl_passwd with one line (replace the user and password with your own)
- Rebuild the hash:
- Restart postfix:
- You can optionally lock down your password file
chmod 640 /etc/postfix/sasl_passwd* chown postfix.postfix /etc/postfix/sasl_passwd*
Thats all there is to it. Here’s my main.cf for reference.