How to configure the IP address for outgoing mail in Postfix

Created:

2016-11-16 13:10:48 UTC

Modified:

2017-06-22 15:33:04 UTC

2

Was this article helpful?


Have more questions?

Submit a request

How to configure the IP address for outgoing mail in Postfix

Question

How to change outbound mail IP address for Postfix, if the primary IP address is blacklisted and mail is not going out?

Answer

It is hardcoded in the Plesk backend that the IP address for outgoing mail in the Postfix configuration file ( /etc/postfix/master.cf ) will be the same as the interface IP to which Postfix is listening. For example:

203.0.113.2- unix - n n - - smtp -o smtp_bind_address=203.0.113.2 -o smtp_bind_address6= -o smtp_address_preference=ipv4
203.0.113.3- unix - n n - - smtp -o smtp_bind_address=203.0.113.3 -o smtp_bind_address6= -o smtp_address_preference=ipv4
 

Since Plesk 12.0, the ability to change the outbound mail IP address for Postfix was implemented . Please note, that several IP addresses should be added to the Plesk server .

For older Plesk versions, the following workaround is available:

  1. Edit the /etc/postfix/master.cf file and replace smtp_bind_address=203.0.113.2 with smtp_bind_address=203.0.113.3 .

  2. Restart Postfix:

     # service postfix restart

Note: the default settings in /etc/postfix/master.cf will be restored after mail reconfiguration on any domain. Consider creating a scheduled task to replace /etc/postfix/master.cf with a custom file. The script for the scheduled task would be:

#!/bin/bash

/bin/grep 'smtp_bind_address=203.0.113.2' /etc/postfix/master.cf
if [ $? -ne 1 ]; then
/bin/sed -i 's/smtp_bind_address=203.0.113.2/smtp_bind_address=203.0.113.3/g' /etc/postfix/master.cf
/etc/init.d/postfix reload
fi
exit 0

 

Have more questions? Submit a request
Please sign in to leave a comment.