Using Postfix to relay via multiple Google Apps accounts

g-suitepostfix

I'm in the process of setting up a web app that needs to send emails via two different email addresses on a domain that uses Google Apps. I'm using Postfix as a relay as I'm reasonably familiar with it.

However, I'm struggling to puzzle out how to get this working with two different email addresses on the same domain. The impression I've gotten is that you need to set up two different password files in /etc/postfix/sasl, which I've done, and then set smtp_sasl_password_maps to hash:/etc/postfix/sasl/passwd, but I'm not too sure on the syntax required for two different file. I've tried setting it as follows:

smtp_sasl_password_maps = hash:/etc/postfix/sasl/passwd, hash:/etc/postfix/sasl/passwd2

But that doesn't seem to do the trick. I also tried having both in one file, but that didn't work either. Whichever method I try, it only ever seems to pick up on one address. Google doesn't seem to be very helpful with this issue either?

Can anyone see where I've gone astray here?

EDIT: Perhaps I wasn't too clear about what I'm trying to do.

The web server for example.com has Postfix installed, but the MX records are pointed at Google Apps. There are two email addresses, noreply@example.com and support@example.com, and both of them are on Google Apps. What I want to do is configure Postfix to use Google Apps as a relay for both of these email addresses.

The problem is that I can't figure out how to set up password maps for these two accounts and I can therefore only set it up for one, not both.

Best Answer

You need to enable sender dependent authentication so that Postfix will choose the appropriate credentials based on the sender of the message being delivered. The password map should be keyed by the sender address instead of the relay host.

main.cf:

smtp_sender_dependent_authentication = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_password_maps

sasl_password_maps:

noreply@example.com noreply@example.com:password123
support@example.com support@example.com:password456