3

How do I configure Postfix to send email through a different relayhost based the system user?

The current setup has relayhost= set so all mail goes through that smtp server but I would like Postfix to send directly based on system user.

I'm open to other options that would allow a script to in some way have Postfix override the relayhost.

transport_maps based on recipient domain unfortunately won't work in this case as it's not the recipient domain that determines what relayhost is chosen.

Thanks,

Shovas
  • 153
  • 1
  • 11
  • Perhaps this is what you are looking for? http://serverfault.com/questions/400549/conditionnal-relay-in-postfix –  Nov 24 '14 at 22:22
  • Thanks I saw similar solutions but I couldn't use that as it's based on recipient domain. – Shovas Nov 24 '14 at 22:58
  • Ah, I misunderstood the problem. –  Nov 25 '14 at 00:13
  • What do you mean by system user? The sender will be user@domain in that case or for a single system user you could have different senders? Could different system users share a sender? – Migtor Nov 25 '14 at 11:25

1 Answers1

1

I took a hint from the post Use different relay in postfix and used header_checks to assign the proper transport for emails that I had inserted an X-Foo header into:

# cat /etc/postfix/main.cf
...
header_checks = regexp:/etc/postfix/header_checks

# cat /etc/postfix/header_checks
...
/^X-Foo: 1/ FILTER relay:otherhost.com:25

relayhost was commented out (default) in /etc/postfix/main.cf but it could've been anything and you'd use the header_checks to override it

Shovas
  • 153
  • 1
  • 11