Send out email from specified IP address

If you have multiple IP addresses available on your iRedMail server, and would like to send from different IP Addresses for different domains, follow the steps below.

Requirements

Configuration

sample-smtp     unix -       -       n       -       -       smtp
    -o smtp_bind_address=172.16.244.159
#    -o smtp_helo_name=example.com
#    -o syslog_name=postfix/sample-smtp

Use case 1: Force all users under local domain to send out from specified IP address

You have email domain name example.com hosted on iRedMail server, and you want to force all emails sent by users under example.com to be sent from specified IP address.

sender_dependent_default_transport_maps = hash:/etc/postfix/sdd_transport
@example.com   sample-smtp:
postmap /etc/postfix/sdd_transport
postfix reload

Use case 2: Sent to certain recipient domains from specified IP address

You want to force all emails sent from iRedMail server to Gmail (gmail.com) to be sent from specified IP address.

gmail.com sample-smtp:

You may want to force for all sub-domain names (e.g. x.gmail.com, y.gmail.com) too:

.gmail.com sample-smtp:
postmap /etc/postfix/transport
postfix reload