Slicehost : Setting up outgoing mail and Google Apps (postfix)

We just moved to SliceHost recently and have been trying to get the server up and running. Every thing was super cool, but getting outgoing email to start working was a bitch.

What happens is that our poor little sendmail tries to be smart and deliver as much mail internally as possible. So even though the email address is set up to be used via Google Apps, sendmail tries to relay it internally and gets a ‘User unknown’.

This was confirmed by peeping into /var/log/mail.log and setting up a simple script in php which called the mail function. The user was never found, because we were looking at the wrong place.

Since I wasn’t prepared to spend a good part of the day on this thing, I decided to look out for options. After looking at a number of options, I decided to go ahead with ‘postfix’.

Let me take you step by step through the procedure :

1. As always, aptitude is there to help us out, so first we install postfix

sudo aptitude install postfix

2. During the installation, remember to choose the ‘Internet site’ option (because that is what you are doing. Right?)

3. Now that installation is done, it’s time to tell postfix that the domain is set up on Google Apps and not on the server (Actually we only tell postfix that the domain is not on the server). In the file /etc/postfix/mail.cnf we change the following

mydestination = mydomain.com, localhost.mydomain.com, localhost
to
mydestination = localhost.mydomain.com, localhost

4. Once that is done, just quit and restart (using sudo reboot) and you’re done.

In case you run into issues with the above, or find out a way to run this with sendmail, do let me know.

This entry was tagged , , , , . Bookmark the permalink.

5 Responses to Slicehost : Setting up outgoing mail and Google Apps (postfix)

  1. Thanks for the information dude. My friends were speaking about slicehost. Will make them see this post ASAP.

  2. Sudhanshu says:

    Glad to have helped Narendara. By the way, Slicehost is quite awesome, you should try it out.
    Cheers!

  3. Really good one. Thanks

  4. Collin says:

    Er, why would you reboot to finish installation?

    sudo /etc/init.d/postfix restart

    :)

  5. Jesse says:

    Finally!

    I just spent the past two hours looking this up. Though I’m on Linode (rather than Slicehost), this worked like a charm. I was getting so frustrated. I was ready to just give up on the whole Google Apps + Postfix setup. Thanks for the help!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>