Skip to main content
< All Topics
Print

Changing the Outgoing Mail IP in WHM/cPanel

Table of Contents

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:

  1. A custom transport bound to your desired IP
  2. 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:

  1. cPanel β†’ Email Deliverability
  2. Click Repair or Install Suggested Record next to DKIM
  3. 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.


πŸŽ‰ Done β€” Your Server Now Correctly Sends Mail From the Custom IP

Table of Contents