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.

Requirement

This can only be set up on Postfix version >=2.7.x, because the parameter we need sender_dependent_default_transport_maps is available in Postfix-2.7 and later releases.

To check your Postfix version run:

# postconf mail_version

Which would return something like: mail_version = 2.10.3

Steps

sender_dependent_default_transport_maps = pcre:/etc/postfix/sdd_transport.pcre
/@example\.com$/   sample-smtp:
sample-smtp     unix -       -       n       -       -       smtp
    -o smtp_bind_address=172.16.244.159
#    -o smtp_helo_name=example.com
#    -o syslog_name=postfix-example-com

Option smtp_helo_name and syslog_name are optional.

After this restart the Postfix service to apply your changes:

# /etc/init.d/postfix restart

Note: any unmatched domains will continue using the server's primary IP address just as before.