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 info@my-domain.com, 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.

3 Answers
3

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
info@localhost.example.com
info@localhost

But mail to info@example.com would go to Google Apps because postfix is not configured to accept mail for simply "example.com."

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 (info@my-domain.com) 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.