Configure Postfix to use external MX servers for delivery of local mail if user is unknown

Posted by mr.b on Server Fault See other posts from Server Fault or by mr.b
Published on 2011-03-20T17:04:25Z Indexed on 2011/03/20 19:23 UTC
Read the original article Hit count: 285

Filed under:
|

I have a following setup:

  • linux box with postfix configured to be responsible for example.com domain
  • domain's MX servers are configured so that mail sent to example.com is sent to google mail servers
  • several user accounts on linux machine exist (same machine also hosts example.com site)

When someone from the outside attempts to send mail to address ending with @example.com, it gets routed to google mail (and there handled appropriately).

When linux machine tries to send mail to outside world, mail is delivered correctly, as reverse dns and spf records are configured correctly, so linux machine is valid mail sender for example.com domain (along with google mail servers).

However, here's the problem. When php application (hosted at linux box) tries to send mail to [email protected] (and someuser doesn't exist on linux box), it fails, since it doesn't even consult google mail servers, but postfix smtp locally concludes that "someuser" is unknown.

So, the question is: how do I tell postfix to relay mails sent to @example.com domain to google mail servers (so, to servers specified in MX records), IF and only if a mailbox is not found locally.

© Server Fault or respective owner

Related posts about postfix

Related posts about mail