views:

477

answers:

3

I have google apps for receiving email. I get inquiries from people on info@[my-domain.com], which email is hosted on google.

Sometimes, I want my rails set-up to send emails from my own server, and that works fine. But when I want to send to an email address on my own domain, such as [email protected], postfix sees the my-domain.com and tries to deliver locally.

I understand that's normal, but I'd like to have those emails go to google apps rather than try to be delivered locally.

I know there's a postfix config file for aliases, but here, the email addresses are the same, just need to tell postfix not to try to deliver locally.

Any way to do this?

A: 

I get around it by doing this http://souptonuts.sourceforge.net/postfix_tutorial.html. Basically have that mail sent through one of your google domain accounts instead of locally.

trent
+2  A: 

It sounds like you have two mail servers set up to act as the primary destination for email to your domain: Google Apps and your postfix server. You can't do that because, as you've found, mail sometimes gets delivered to one server and sometimes the other.

Presumably you want Google Apps to be the primary destination. That is, mail for your domain should go to the Google servers, not yours. You will need to re-configure postfix so that it is not the mail server for your domain.

Edit the /etc/postfix/main.cf file and look for the mydestination line. Remove your domain from that line.

I don't normally use postfix, but I think if the line looks like this, you'll be good:

mydestination = $myhostname localhost.$mydomain localhost

Let's say your server name is "test1" and your domain is "example.com." The following addresses would be delivered locally:

info@test1
[email protected]
info@localhost

But mail to [email protected] would go to Google Apps because postfix is not configured to accept mail for simply "example.com."

Barry Brown
Thank you, was looking for the exact same thing and your solution hit the spot.
Artem Russakovskii
A: 

Either, as Barry Brown suggested, tell postfix that my-domain.com is not local by removing it from $mydestination on the postfix box, or if that's not practical, use virtual aliases in Postfix to rewrite that specific address ([email protected]) to the google-hosted address you want to deliver it to.

Virtual aliases in Postfix are not just for the virtual alias address class; they are a general-purpose pre-queue address rewriting mechanism. Sendmail-style aliases (depending on your distribution, either /etc/aliases or /etc/postfix/aliases) are used by the local delivery agent and only apply to the local address class. You could, of course, use sendmail-style aliases to forward mail for "info" to some-address@your-google-hosted-domain.

The documentation at postfix.org is pretty good. Try

http://www.postfix.org/STANDARD_CONFIGURATION_README.html

http://www.postfix.org/ADDRESS_CLASS_README.html

http://www.postfix.org/ADDRESS_REWRITING_README.html

http://www.postfix.org/VIRTUAL_README.html

robc