Different postfix relayhost based on system user?

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,


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