Changing the Outgoing Mail IP in WHM/cPanel
This guide explains the full working process to force Exim to send all outgoing mail using a chosen IP address on servers where WHM locks the default Exim transports.
π§© Requirements
- WHM root access
- A server with multiple IPv4 addresses
- Domain DNS access (for SPF/DKIM)
- Ability to set PTR/rDNS (usually via your hosting provider)
π Part 1 β Configure Exim to Send From Your Custom IP
WHM no longer allows modifying the built-in remote_smtp transport.
So we create:
- A custom transport bound to your desired IP
- A custom router that forces outbound email to use that transport
Both are added using WHM β Exim Advanced Editor.
1οΈβ£ Open the Exim Advanced Editor
WHM β
Service Configuration β Exim Configuration Manager β Advanced Editor
2οΈβ£ Add the Custom Transport
Scroll to Section: TRANSPORTS CONFIGURATION.
Paste this:
remote_smtp_custom:
driver = smtp
interface = <YOUR-IP-HERE>
helo_data = $primary_hostname
π Replace <YOUR-IP-HERE> with the IP you want outgoing mail to use.
Example:
interface = 5.135.74.178
This defines a brand-new SMTP transport that always uses your selected IP.
3οΈβ£ Add the Router That Uses the Custom Transport
Scroll to Section: ROUTERSTART.
Paste this:
send_via_custom_ip:
driver = dnslookup
domains = !+local_domains
transport = remote_smtp_custom
ignore_target_hosts = 127.0.0.0/8
no_more
What this does:
- dnslookup β uses normal DNS for external destinations
domains = !+local_domainsβ only applies to external mail- Forces all external mail to use
remote_smtp_custom - Prevents Exim from falling through to other routers (
no_more)
4οΈβ£ Save & Restart Exim
Scroll to the bottom β Save.
WHM will restart Exim with the new configuration.
π§ͺ Part 2 β Verify the Routing
Test an external address:
exim -bt user@outlook.com
You should see:
router = send_via_custom_ip transport = remote_smtp_custom
This confirms Exim is using your custom routing and transport.
π§ͺ Part 3 β Confirm the IP in the Mainlog
Send a live test email:
echo "test" | mail -s "IP test" youraddress@gmail.com
Then check:
grep remote_smtp_custom /var/log/exim_mainlog | tail
You should see something like:
Connecting to gmail-smtp-in.l.google.com [...] from <YOUR-IP-HERE>
This confirms Exim is using your chosen IP for outbound mail.
π Part 4 β Fix Gmail/Outlook Blocking (SPF DKIM rDNS)
Your email routed fine but Gmail blocked it because the IP was not authenticated.
From Gmail error:
SPF β¦ did not pass
DKIM = did not pass
This is normal when moving email to a new IP.
To fix:
1οΈβ£ SPF: Authorise Your New IP
In DNS for your domain (e.g. portal.eclipse1.co.uk) add or update your SPF TXT record:
v=spf1 ip4:<YOUR-IP-HERE> a mx ~all
Example:
v=spf1 ip4:5.135.74.178 a mx ~all
2οΈβ£ DKIM: Enable It in cPanel/WHM
For each sending domain:
- cPanel β Email Deliverability
- Click Repair or Install Suggested Record next to DKIM
- Ensure DNS records propagate
This adds:
default._domainkey.domain.com TXT (DKIM public key)
3οΈβ£ rDNS / PTR Setup
Your sending IP must have PTR pointing to your mail hostname e.g.:
- Forward:
portal.eclipse1.co.ukβ 5.135.74.178 - Reverse: 5.135.74.178 β
portal.eclipse1.co.uk
Set the PTR record in your hosting providerβs control panel (OVH Hetzner etc.).
π§ͺ Part 5 β Final Deliverability Test
Send a real email to Gmail after SPF/DKIM/rDNS propagate:
echo "final test" | mail -s "IP final test" youraddress@gmail.com
Then in Gmail:
- Open the message β 3 dots β Show original
- You want to see:
SPF: PASS
DKIM: PASS
DMARC: PASS (optional)
If SPF & DKIM pass Gmail will stop blocking you.