Howto change the email sending IP to an IP other than the main shared IP in exim on a cPanel server

Often it happens that a mail server’s main IP gets black listed by Yahoo, Gmail, Hotmail etc, there by causing issues to the web hosting customers in the server yelling and raising lots of support tickets.

When yahoo generates a permanently deferred message, it will take approximately 4 days or 96 hours – sometimes even a week to get it start accepting the mails from the servers. Gmail and Hotmail, simply accept the mails, but it blackholes the email , means mails will simply be deleted, without any error message from the servers.

So the solution would be to identify the spam sources and remove them. However even after we remove the spam sources, customers wont start getting emails immediately. So a temporary work around is to change the IPs from which the emails are sent out.

By default emails are sent out from a mail server using it’s main shared IP. Here we are changing it. You can change it on per-account basis or for a entire server

The easiest method to see a full version of the files with proper syntax is to temporarily enable the following “automatic” option under WHM >> Main >> Service Configuration >> Exim Configuration Editor >> Standard Options >> Domains and IPs
“Automatically send outgoing mail from the account’s IP address instead of the main IP address.”

/etc/mailips will have the following format to be followed. xx.xx.xx.1 xx.xx.xx.2 xx.xx.xx.2
*: xx.xx.xx.xx

If you want the entire server to use an alternate IP, use the last line alone which is the wild card entry.

*: new.ip.for.smtp

Sometimes you would want to set chattr +i /etc/mailips since, a cPanel update can clear the lines in it. And once you believe the main server is unblocked, remove the chattr. Please restart the exim server as well, after you made the changes in /etc/mailips

You would need to search for

driver = smtp

and make sure that a line similar to below exists, which does literal search for the IPs in /etc/mailips. If /etc/mailips lines are not there, you can simply add interface=xx.xx.xx.xx entries.

interface = ${if exists {/etc/mailips}{${lookup{$sender_address_domain}lsearch*{/etc/mailips}{$value}{$
helo_data = ${if exists {/etc/mailhelo}{${lookup{$sender_address_domain}lsearch*{/etc/mailhelo}{$value$

Ref : for more details and few more formats.

Post to Twitter Tweet This Post

Comment Form

About this blog

This blog, acts as a knowledge repository for the world and is unofficial! Anything we find interesting in the cyber world will go here. Most cases, this blog will reflect the happiness of our staff in reaching successful solution to an issue (s)he worked on. A reference for other fellow SAGEs who come across similar issues later