Why Client Emails Land in Spam After DNS Migrations (SPF 10-Lookup Limit, Duplicate DMARC & Cutover Diffing)
Every freelance web developer has lived through this exact horror story: you migrate a client's domain to Cloudflare, the new website loads in 120ms, SSL is greenβand 3 hours later the client calls in a panic because the
Every freelance web developer has lived through this exact horror story: you migrate a client's domain to Cloudflare, the new website loads in 120ms, SSL is greenβand 3 hours later the client calls in a panic because their company emails are bouncing or landing straight in Gmail spam.
Almost every time, it comes down to one of three silent DNS mistakes that standard HTTP checks never catch.
1. Duplicate _dmarc or v=spf1 Records (Instant RFC Failure)
This happens constantly when you enable a provider's "1-click DMARC" (like Cloudflare DMARC Management) on a domain that already had a _dmarc TXT record from Zoho, Google Workspace, or Microsoft 365:
# BROKEN: Two separate _dmarc TXT records!
_dmarc TXT "v=DMARC1; p=none; rua=mailto:[email protected];"
_dmarc TXT "v=DMARC1; p=none; rua=mailto:[email protected]"
Both RFC 7208 (SPF) and RFC 7489 (DMARC) strictly allow only one record per domain. Two v=spf1 records trigger an immediate PermError; two _dmarc records cause receivers to ignore DMARC completely.
Fix: Merge both reporting addresses into one record using a comma:
_dmarc TXT "v=DMARC1; p=quarantine; pct=100; rua=mailto:[email protected],mailto:[email protected]; adkim=r; aspf=r"
2. Exceeding the Recursive SPF 10-Lookup Limit
Your SPF record might look tiny (v=spf1 include:_spf.google.com include:sendgrid.net include:servers.mcsv.net ~all), only 3 includesβright?
Wrong. RFC 7208 counts recursive DNS lookups (include:, a, mx, ptr, exists:, redirect=) across every nested vendor record. A single marketing or CRM include: can expand into 4β5 nested lookups on its own. The moment the total hits 11, receiving mail servers throw PermError and fail SPF.
Always count lookups recursively before adding a new SaaS sender, and keep total lookups <= 8 for safety margin.
3. Never Migrate DNS Without a Before/After Cutover Snapshot
Manual visual comparison between GoDaddy and Cloudflare DNS tables is how MX records, DKIM keys, and domain verification TXT records silently vanish during a cutover.
A 2-step habit eliminates migration anxiety:
-
Before switching nameservers: Export a JSON snapshot of all live
NS,A,AAAA,MX,SPF,DMARC,DKIM,CAA, and verificationTXTrecords. -
Immediately after cutover: Diff live DNS against
before.jsonand fail loudly if a single critical record was dropped.
Automating All of This With Zero Dependencies
You don't even need dnspython or paid SaaS checkersβPython's standard library can query Cloudflare & Google DNS-over-HTTPS (DoH) directly in < 3 seconds.
I packaged the full workflow into DNSGuard v1.0.0 ($12 one-time, zero pip install dependencies):
-
7 DNS & Email Audits:
NSprovider detection,MXresolution & RFC-invalidMX -> CNAMEdetection, recursive SPF 10-lookup counter,DMARC, concurrent 13-selectorDKIMprobe (flags revokedp=keys),CAA, andMTA-STS. -
DNS Cutover Diff (
--compare before.json): Instantly flags any droppedMX,SPF,DMARC,DKIM,A/AAAA, orTXTrecord after switching nameservers. -
White-Label Bilingual HTML/PDF Reports (
EN / ηΉι«δΈζ) + auto-generated Copy-Paste DNS Fix Records (Cloudflare/Namecheap/GoDaddy & BIND Zone formats) + GitHub Actions workflow.
Check it out here: https://taijibala.gumroad.com/l/sqfww
(And if you need free pre-launch Security Headers, robots.txt/sitemap.xml, or a 25-point launch checklist, those are free with zero login at https://webpulse.taijibala.com/)
What's the nastiest DNS or email deliverability bug you've ever had to untangle after a launch?
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.