Skip to content

Email migration when the MX cannot change for hours

When the MX record is owned by a third party that responds in days, mail migration becomes a relay-and-collect exercise — not a flip.

The mailbox migration is ready. The IMAP sync is staged. And the MX record belongs to a third-party DNS team that responds within “five business days”. Cancelling the cutover is not an option. The fix is to keep the old MX accepting mail and relay it to the new system in near-real-time, then catch up on whatever was in flight when the MX finally moves.

What’s happening

Mail flow during a cutover has three phases: while the old MX is still authoritative, you collect mail on the old server and forward it to the new one; during the DNS propagation window, mail arrives at both servers in random proportion; after propagation, only the new server receives. The risk is a message that arrives on the old server at minute 59, gets forwarded after the user has already read mail on the new server, and shows as unread again — or, worse, a message that gets lost.

How to verify

On the cPanel source, confirm Exim is set to forward not deliver locally:

exim -bt postmaster@example.com
grep "^example.com$" /etc/localdomains /etc/remotedomains
tail -f /var/log/exim_mainlog | grep example.com

On the destination, confirm it is accepting from the source’s IP:

# from the cPanel host
swaks --to test@example.com --server <dest-ip>
# on the destination
tail -f /var/log/mail.log | grep <src-ip>

The fix

  1. Sync existing mailboxes — imapsync from cPanel mailboxes to the destination, with --maxage 30 to limit to recent mail. Run twice: once a day before, once an hour before cutover.
  2. Switch cPanel to relay — for each domain, in WHM > Mail Routing, change from Local Mail Exchanger to Remote Mail Exchanger pointing at the new mail server. Test with exim -bt.
  3. Add a forwarder per user — in cPanel, add a forwarder for each mailbox to the same address on the new server (so user@example.com forwards to user@example.com after MX flips). Use whmapi1 add_forwarder.
  4. Open the SMTP path — allow the cPanel IP on the destination’s connection-rate limits; cPanel’s pidgin_send and bulk forwarder bursts can trigger throttling.
  5. After MX flips — run imapsync one last time to catch anything that arrived on cPanel post-flip but pre-propagation. Disable the forwarders 7 days later.

The longest tail is users who hardcoded the cPanel mail server’s hostname (e.g., mail.example.com) in their IMAP client. Stack Harbor handles these mail-flow cutovers under migration solutions — book a migration review when MX timing is constrained.