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.

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

  1. Narendra.s.v says:

    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. Speakbnidas says:

    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!

  6. Pingback: I think installing PostFix solved my problem, but it seemed *too* easy Drija

  7. Pingback: postfix (for sending mail only) multiple domain setup Drija

  8. Michael Grech says:

    Sweet, works w/ slicehost and rackspace as well. Note if you recieve an error on using the mail command make sure you install mailutils under ubuntu 10.4.

  9. Ike says:

    Thanks.
    I have been trying to set something up easily, this should work – will give it a try.
    I am currently using ssmtp sendmail gmail on slicehost

  10. admin says:

    Great, I found this to be the simplest setup. Do let me know if you have any issues.

  11. vanita singh says:

    I am using slicehost for my website builder tool.Your post helped me in solving a problem that i was facing.Thanks a lot.

  12. Ben Barber says:

    Superb! just what I was looking for, works like a charm

  13. Pingback: Use Gmail for incoming mail, and own mail server for outgoing email - Admins Goodies