Facebook X (Twitter) Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook X (Twitter) Instagram
    TecAdmin
    You are at:Home»General Articles»Postfix: Relay Outgoing Emails Based On Sender Address

    Postfix: Relay Outgoing Emails Based On Sender Address

    By RahulDecember 9, 20222 Mins Read

    Have you ever wished you could relay outgoing emails based on the sender’s address? Well, now you can! With the help of sender_dependent_default_transport_maps, you can easily configure Postfix to route outgoing emails based on the email address of the sender. All you need to do is configure the ‘sender_dependent_default_transport_maps’ parameter in the main.cf file. This is an incredibly powerful tool that can be used to easily route emails sent from different domains through different mail servers. It can also be used to route emails from different parts of your organization to different mail servers.

    So if you’re looking for an easy way to relay outgoing emails based on sender address, give sender_dependent_default_transport_maps a try!

    1. First of all, create a mapping of the sender domain or email address with the corresponding SMTP server. To do this, create a configuration file as below:
      sudo nano /etc/postfix/relay_by_sender 
      

      Add the sender domain and SMTP servers one per line.

      [email protected]         	smtp:[ses.amazon.com]:587
      @example.net             	smtp:192.168.1.10:25
      no-relay@localhost		smtp
      
    2. Next use the postmap command to update the Postfix lookup table for the above-created configuration file.
      sudo postmap /etc/postfix/relay_by_sender 
      
    3. Now update the Postfix main configuration file:
      sudo postconf -e "sender_dependent_default_transport_maps = hash:/etc/postfix/relay_by_sender"
      
    4. Finally, restart the Postfix service
      sudo systemctl restart postfix
      

    To verify the above settings, I have sent an email from the terminal using [email protected] email address. As per the above configuration, the emails from @example.net should relay through 192.168.1.10:25 SMTP server. As per the logs, the email was relayed through the correct SMTP server.

    Postfix: Relay Emails Based On Sender Address
    Email log

    For those who need to relay outgoing emails based on the sender address, the sender_dependent_default_transport_maps parameter in Postfix can come in handy. This parameter enables you to specify which transport a message should be routed through based on its sender address.

    Postfix Relayhost smtp
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Difference Between Full Virtualization vs Paravirtualization

    Virtualization vs. Containerization: A Comparative Analysis

    Using .env File in FastAPI

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Difference Between Full Virtualization vs Paravirtualization
    • Virtualization vs. Containerization: A Comparative Analysis
    • Using .env Files in Django
    • Using .env File in FastAPI
    • Setting Up Email Notifications for Django Error Reporting
    Facebook X (Twitter) Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.