Postfix dynamic smtp_helo_name

postfixsmtp

I have a mail server that relays e-mails for two different domains. I want the smtp_helo_name to be different based on the domain. I'm assuming there is no way to do this via checking the mail headers, so I was wondering if there was a way to do it by sending mail for one domain to one IP address, and mail for the other to another.

I tried modified master.cf to do this:

localhost:smtp      inet n - n - - smtpd
ip1:smtp inet n - n - - smtpd
ip2:smtp  inet n - n - - smtpd -o myhostnamee=example2.com

And setting smtp_helo_name to $myhostname in main.cf.

I also tried doing -o smtp_helo_name instead, neither work. Any suggestions would be great.

Best Answer

This should work (not tried it, though):

Define a separate transport for the other domain and then route mail to this transport using sender_dependent_relayhost_maps option in main.cf.

Something like this:

In 'master.cf':

smtp-other      unix  -       -       n       -       -       smtp
     -o smtp_helo_name=my.other.helo.name

In 'main.cf':

sender_dependent_relayhost_maps = hash:/etc/postfix/relay_maps

In 'relay_maps':

my.other.domain    smtp-other:

And run 'postmap /etc/postfix/relay_maps'