Gmail as relayhost for Postfix

      No Comments on Gmail as relayhost for Postfix
Reading Time: 2 minutes
Gmail as relayhost for Postfix
5 (100%) 1 vote

I just installed a new Ubuntu 13.04 server and thought I’d look into using gmail as relayhost for Postfix instead of Exim for a change. Postfix is the default MTA (mail transfer agent) on Ubuntu, so let’s set it up already…

Installing packages:

If you have not installed postfix before, you’ll be asked some questions during installation. Select ‘Internet Site’ for the first question, and as FQDN you can just enter the name of your server or whatever you like.

Configure postfix by editing /etc/postfix/main.cf

add the following lines at the end of the file:

Create /etc/postfix/sas_passwd file, which contains your gmail user and password:

Add the following line, replacing johndoe and mypassword with your gmail user name & password:

(note: in some cases you can not use the brackets which will make postfix do an mxlookup. If it works with them, just leave it like that)

Generate /etc/postfix/sasl_passwd.db file using postmap:

Set up CA certificate for postfix:

Secure the files by setting file permissions:

Reload postfix to effectuate configuration changes:


Futher:

Testing the configuration:

Replacing the target with the email address you’d like to send mail to. This should send a message to you (might take a min), and it should also show up in your sent mail box if your sending from the same account as you’re receiving on.

Making sure mail sent to root goes to your email:

To make sure mail to ‘root’ is actually forwarded to your mail address, edit the /etc/aliases file:

modify the email again, and add the following line:

Enjoy your new postfix installation!

update: minor fixes done

Source: old site

Share