Dev.to Security πŸ” Cybersecurity πŸ‘ 0 πŸ“– 2 min read

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:

  1. Before switching nameservers: Export a JSON snapshot of all live NS, A, AAAA, MX, SPF, DMARC, DKIM, CAA, and verification TXT records.
  2. Immediately after cutover: Diff live DNS against before.json and 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: NS provider detection, MX resolution & RFC-invalid MX -> CNAME detection, recursive SPF 10-lookup counter, DMARC, concurrent 13-selector DKIM probe (flags revoked p= keys), CAA, and MTA-STS.
  • DNS Cutover Diff (--compare before.json): Instantly flags any dropped MX, SPF, DMARC, DKIM, A/AAAA, or TXT record 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?

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.