Postfix Relay Based on Sender Recepient

Discussion in 'Server Operation' started by Contertulio, Jan 5, 2017.

  1. Contertulio

    Contertulio New Member

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

    • Email sent from local, to, ought to be relayed to
    • Email sent to everyone else and ought to be relayed locally

    I know there is a way to do a relay filtering recipient address using transport_maps, but I do not know how to filter depending on the sender address too.

    Can you help me please?? Thanks in advance
  2. florian030

    florian030 Well-Known Member HowtoForge Supporter

    Add sender_dependent_relayhost_maps = hash:/etc/postfix/relayhost_map to postfix, create /etc/postfix/relayhost_map: []
    [email protected] []

    and postmap this file. Afterwards reload postfix.
    Every mail sent from will be relayed to
    Contertulio likes this.
  3. Contertulio

    Contertulio New Member

    Thank you very much for your answer. But this only filters out sender emails.
    In my case I want to relay from to only. All other conditions are filtered locally.
  4. florian030

    florian030 Well-Known Member HowtoForge Supporter

    transport_maps = hash:/etc/postfix/transport

    recipient-domain smtp:[]

    postmap /etc/postfix/transport

    postfix reload
    Contertulio likes this.
  5. Contertulio

    Contertulio New Member

    So the following would work as I comment?
    - Messages from [email protected] to [email protected] => Using
    - Rest of messages from [email protected] to other domains => Using localhost
    - Messages from [email protected] => Using localhost

    /etc/postfix/relayhost_map []

    /etc/postfix/transport: smtp:[]

    postmap /etc/postfix/relayhost_map
    postmap /etc/postfix/transport
    postfix reload

Share This Page