Postfix Configuration – Different Outgoing Hosts Based on Sender

gmailpostfix

I've seen a few answers to this on the web, but nothing definitive nor any good examples.

I relay all my mail out through Postfix, currently everything sent to my ISP's mail server.

However, there are a few users with gmail accounts or gmail-hosted accounts; I'd like to route their outgoing mail through Google's servers (since it will then appear in their Gmail sent folder). All email NOT from one of these senders should go out through the default relayhost.

I believe I need to use the "sender_dependent_default_transport_maps" configuration within Postfix, but can't find a good example on what this setup looks like. Can anyone point me at a specific setup?

Best Answer

Are you sure you're after sender_dependent_default_transport_maps, and not sender_dependent_relayhost_maps? In either case, I'm pretty sure the format is like any of the other _maps tables:

theirmail@senderdomain.com      smtp.gmail.com
@someothersenderdmn.com         smtp.gmail.com

The first being an exact sender match, the second being a domain level match.

That being said, I'm pretty sure Google isn't going to allow you to relay through them without authenticating, and as you're handling relaying for multiple users, I'm sure you don't want to setup that kind of relaying setup, nor will they likely want to disclose their passwords to you.