Skip to content

MX record strategy when cPanel handles mail (and when it doesn't)

cPanel can serve mail locally or route to an external provider. Your MX strategy depends on that choice — and getting it wrong means lost mail or duplicate delivery.

A common breakage: a domain on cPanel migrates mail to Microsoft 365, the MX gets repointed to *.mail.protection.outlook.com, but cPanel keeps trying to deliver mail locally. The result is split-brain — half the messages reach Microsoft, half land in /home/user/mail/ and never sync. The fix is two settings, not one: the MX record and cPanel’s local mail routing.

What’s happening

cPanel has a per-domain “mail routing” mode separate from the MX record. The choices are:

  • Local Mail Exchanger — cPanel always delivers to local mailboxes, ignoring the MX. Right when cPanel hosts the mail.
  • Backup Mail Exchanger — cPanel delivers locally only if the external MX is down. Rarely the right answer in 2026.
  • Remote Mail Exchanger — cPanel sends every message to wherever the MX points, even if the domain has accounts on the server. Right when an external provider handles mail.
  • Automatic Detect Configuration — cPanel guesses based on the MX. Often wrong on migration day because the MX is in transition.

The MX record and the routing mode must agree. If MX points to Microsoft 365 but the routing mode says Local, every message destined for the domain that hits the cPanel server stays on the cPanel server and the Microsoft mailbox never sees it. If the routing mode says Remote but the MX still points at the cPanel server, mail bounces in a loop.

How to verify

Check the MX and the routing mode together:

dig +short MX example.com
whmapi1 get_domain_info domain=example.com | grep -i mail_routing
cat /etc/localdomains | grep example.com
cat /etc/remotedomains | grep example.com

A domain in /etc/localdomains means cPanel will deliver locally; in /etc/remotedomains means it will route via MX. The two files are mutually exclusive — a domain in both is a bug; absent from both is also a bug.

Trace where a hypothetical message would go:

exim -bt test@example.com

The output tells you whether Exim plans to deliver to a local mailbox or hand off to a remote MX.

The fix

  1. Decide where mail lives: cPanel, an external provider (Google Workspace, Microsoft 365, Fastmail, Zoho), or one of the dedicated mail-only platforms.
  2. Set the MX record to match. In cPanel Zone Editor, edit the MX. Provider TTLs are usually 3600; lower to 300 if you’re cutting over within hours.
  3. Set cPanel mail routing to match the MX. WHM > DNS Functions > Modify a DNS Zone has it; or use the Email Routing Configuration in WHM. For external mail, pick “Remote Mail Exchanger”.
  4. Verify both ends. Send a test message from a third-party account. Check the provider’s inbox; check /home/user/mail/ on the cPanel server is empty for that user.
  5. For a migration, change the routing mode at the same time as the MX, not before. Otherwise mail bounces during the cutover window.

If the domain is on a cPanel DNS cluster and the routing change doesn’t replicate, force it: /scripts/updateuserdomains && /scripts/dnscluster synczone example.com.

For SaaS providers with deep MX setups (Microsoft 365 with their separate connector requirements, Google Workspace with multiple priority MX entries), publish the records exactly as the provider documents them — abbreviated copies leave fallback delivery broken. Stack Harbor handles the MX-plus-routing coordination during mail migrations as part of migration solutions.