0

Does anyone know of a way to dynamically set the relay host when sending mail through Postfix? At what point does Postfix set the relay host? Is there some way that I can tell Postfix to use a relay host for a particular email (that is outside of global settings)?

Basically, when an email is to be sent to an outbound email address (Gmail, Outlook.com, etc.) I want to be able to choose which relay host to use based on which one has the best deliverability rating. And this could possibly change within seconds so it can't be a "global" postfix setting.

I've thought about creating a content filter which would lookup the "To", find the right relay host and then send the email using another application. However, that seems very awkward to do since we are already in Postfix.

Any help would be greatly appreciated!

Thanks.

thiesdiggity
  • 439
  • 1
  • 9
  • 22
  • 1
    [Use different relay in postfix](https://serverfault.com/questions/386757/use-different-relay-in-postfix). You can replace the hash with any backend you want. – sebix Jul 01 '15 at 20:27
  • @sebix - your link pointed me in the right direction! If you want to add an answer, I'll give you the credit. – thiesdiggity Jul 02 '15 at 18:49
  • I can't add an answer, however we decided to use Postfix header_checks outlined [here](http://serverfault.com/a/386848/88248) – thiesdiggity Jul 09 '15 at 04:11

1 Answers1

0

Your question is already answered in a more general way: Use different relay in postfix

It is possible to set transport_maps which matches recipients domains to relayhosts:

transport_maps = hash:/etc/postfix/transport

Instead of hashfiles, you can use all backends supported, see Postfix lookup table types for example: LDAP, memcache, mysql, pgsql, sqlite and many others.

See the documentation on transport (especially TABLE SEARCH ORDER) to see how postfix finds the values in databases and what keys are used for the search.

sebix
  • 4,175
  • 2
  • 25
  • 45
  • I accepted this answer as it gave direction to resolving the issue, however in our case we ended up using header_checks described [here](http://serverfault.com/a/386848/88248) – thiesdiggity Jul 09 '15 at 04:12