Postfix Relay Based on Recepient

0

1

What is the best practice when one has to implement this sort of ruleset in postfix:

  • Email sent to a@example.com, b@example.com, etc ought to be relayed to smtp.a.example.com.
  • Email sent to everyone else @example.com ought to be relayed to smtp.b.example.com.

Ideally this shouldn't depend on the content of the message - just the RCPT TO SMTP command.

Chris Smith

Posted 2014-05-05T01:50:41.880

Reputation: 118

Answers

0

You have to use transport_maps in your main.cf

#/etc/postfix/main.cf
#...
transport_maps = hash:/etc/postfix/transport
#...

#/etc/postfix/transport
a@example.com    smtp:smtp.a.example.com:25
b@example.com    smtp:smtp.a.example.com:25
example.com      smtp:smtp.b.example.com:25

transport_maps (default: empty)

Optional lookup tables with mappings from recipient address to (message delivery 
transport, next-hop destination). See transport(5) for details.

Specify zero or more "type:table" lookup tables. If you use this feature with 
local files, run "postmap /etc/postfix/transport" after making a change.

Ref: Postfix Docs

clement

Posted 2014-05-05T01:50:41.880

Reputation: 591