I've successfully set Postfix to relay emails via Mandrill using SASL and sender_dependent_relayhost_maps
with a MySQL table so that different senders connect to Mandrill using their own Mandrill username and API key.
So far so good, but I've got three users that all use an Email Service Provider and the Sender in the message envelope is set to "mailer@infusionmail.com" for all three users, and the only place containing the actual user's email address is in the From: email header.
I'm happy with the security (or lack thereof) of using the From: email header as I'm only forwarding mails sent to specific email addresses that are tightly controlled, but I'd be really grateful for suggestions as to how I can best specify the relayhost based on the value of the From: header. Is there any way to set the envelope value to be the same as the From field? Or any other way to do this?
Best Answer
Based on this thread on postfix mailing-list: different transport for all mail introduced via sendmail(1), looks like your case was possible. Unfortunately you can't only rely on two tables
sender_dependent_relayhost_maps
andsmtp_sasl_password_maps
. You need modifymaster.cf
. The idea is usingheader_checks
to route email to different transport. Then in each transport, we define smtp client that use independent credential and relayhost.First define header_checks in main.cf and its pcre table
Good, now we setup
smtp1
,smtp2
,smtp3
transport in master.cfFile
smtpX.relay
has similar content e.g.Disclaimer:
smtp_sasl_password_maps
is only for example. You can replace it with mysql table.