Configure Postfix to use external MX servers for delivery of local mail if user is unknown
- by mr.b
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 someuser@example.com (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.