Skip to content

Email stopped working after moving DNS to Cloudflare: the migration-day triage runbook

You pointed nameservers at Cloudflare and mail went quiet. Almost always the zone scan missed a record or the mail host got proxied. Here is the triage order that finds the break fast.

When email dies the same day you move a domain’s DNS to Cloudflare, the domain itself is fine — the zone Cloudflare now serves is not. Two causes cover almost every case: the onboarding scan missed records the old zone had (MX, DKIM selectors, autodiscover), or a mail hostname was imported with the proxy on, so senders now connect to a Cloudflare edge IP that does not accept SMTP. Deferred mail is not lost yet — most senders retry for three to five days — so the job is to find the broken record before those retry queues expire.

What’s happening

When you add a zone, Cloudflare builds the initial record set by scanning a list of common hostnames and copying whatever answers. That scan is best-effort by design: it cannot guess DKIM selector names (selector1._domainkey.example.com), rarely finds autodiscover, autoconfig, or SRV records, and misses secondary MX hosts and TXT verification strings. The moment your registrar change propagates, Cloudflare’s incomplete copy becomes the truth, and every record it does not have stops resolving.

The second failure mode is the proxy. A, AAAA, and CNAME records can be imported or created with the orange cloud on, and a proxied hostname resolves to Cloudflare’s anycast IPs instead of your server. HTTP keeps working — that is the point — but SMTP, IMAP, and POP3 on that hostname now hit an edge that speaks none of them. If your MX target or your users’ IMAP/SMTP hostname went orange, mail stops even though every record technically exists.

A third, smaller window: split-brain during propagation. If the old provider’s zone was deleted the same day, resolvers that still hold the old NS records get failures instead of stale-but-working answers, and delivery turns intermittent for hours.

What to check first

  • MX records exist. Cloudflare dashboard, DNS, filter by type MX. No MX means senders fall back to the apex A record — which is probably proxied.
  • Every mail hostname is DNS-only. The MX target, the imap. / smtp. / mail. names clients connect to, autodiscover. Grey cloud, not orange.
  • The TXT trio survived. Exactly one SPF record, the DKIM selector(s) your provider uses, _dmarc.
  • You have the old zone to diff against. The previous provider’s panel, a zone file export, or the old nameservers if they still answer.

How to verify

Query what the world sees, then what Cloudflare serves, then the old zone:

# What resolves right now
dig +short MX example.com
dig +short TXT example.com
dig +short A mail.example.com

# Ask Cloudflare's resolver directly, skipping local caches
dig @1.1.1.1 +short MX example.com
dig @1.1.1.1 +short TXT selector1._domainkey.example.com

# Compare with the old provider's nameserver while it still answers
dig @ns1.previous-dns-host.com +short MX example.com

If mail.example.com returns IPs in Cloudflare ranges (104.16.x.x, 172.67.x.x) instead of your server, it is proxied. Then prove SMTP reachability from outside:

# Banner and STARTTLS on the MX target
openssl s_client -connect mail.example.com:25 -starttls smtp -brief

# Full test delivery
swaks --to user@example.com --server mail.example.com

On the mail server, confirm whether anything arrives at all:

tail -f /var/log/exim_mainlog        # Exim / cPanel
tail -f /var/log/maillog             # Postfix / RHEL family

Silence in the log while outside senders time out means connections never reach the box — a DNS or proxy problem, not a mailbox problem.

The fix

  1. Re-import the full old zone. Export a BIND zone file from the previous provider and use Cloudflare’s DNS import. Leave the option to proxy imported records off — you can orange-cloud the web hostnames deliberately afterwards.
  2. Grey-cloud the mail path. Set the MX target’s A record and every client-facing mail hostname to DNS-only. Cloudflare flags an MX that points at a proxied name — treat that warning as an outage, not a suggestion. Changes propagate in seconds on Cloudflare’s side; the old proxied answer only lives as long as its 300-second TTL.
  3. Recreate missing MX records with the same targets and priorities the old zone had.
  4. Restore the TXT records — SPF (one record only), DKIM selectors copied exactly from the mail provider, _dmarc.
  5. Leave the old provider’s zone alive for a week. Resolvers migrate at their own pace; a live old zone with correct records turns propagation into a non-event.
  6. Re-test from outside with dig @1.1.1.1 and a swaks delivery, and watch the mail log for the accept line. Deferred mail from the outage window drains in over the next hours as senders retry.

When this fix is wrong

If dig shows correct records, grey clouds across the whole mail path, and port 25 answers with a banner, the migration is not your problem — look for a coincidence: a firewall change, an expired certificate, a full disk, or a blocklist entry. And if mail is hosted at Microsoft 365 or Google Workspace, the MX should point offsite; the fix there is restoring their records (MX, SPF include, autodiscover CNAME), not pointing anything at your web server.

Common mistakes

  • Deleting the old DNS zone the same day the nameservers change.
  • Trusting the scan — assuming Cloudflare imported everything without a record-by-record diff.
  • Fixing the MX but leaving the hostname it points at proxied.
  • Re-typing DKIM values by hand instead of pasting, truncating the key.
  • Testing from a machine that still caches the old answers, then declaring the problem fixed or not fixed.

Prevention

Export the zone file before touching nameservers, diff it against Cloudflare’s imported set, and drop TTLs to 300 the week before. Keep a checklist of mail names — MX targets, selectors under _domainkey, autodiscover, _dmarc — and confirm each with dig @1.1.1.1 before and after the switch. The DNS-only vs proxied distinction and the Cloudflare DNS record cookbook cover the rules the scan will not apply for you; Cloudflare’s own DNS documentation lives at developers.cloudflare.com/dns.

Mail that breaks after a DNS move is one of the most common incidents we untangle — Stack Harbor manages the full DNS and mail path under Managed Cloud Ops; book an infrastructure review before the next migration.