Back to blog
Infrastructure

Add SPF, DKIM, DMARC in Cloudflare DNS

Cloudflare's proxy orange cloud does not apply to TXT. The mistake is still editing SPF on the wrong subdomain or duplicating records during a migration.

ZeroHook
ZeroHook Team
Security Analysts
Nov 7, 2026~3 min read
Add SPF, DKIM, DMARC in Cloudflare DNS
A startup proxied their marketing site through Cloudflare but published DMARC on `www` while mail sent from the apex, and every aggregate report showed failures until someone moved `_dmarc` to the name receivers actually queried.

Cloudflare DNS vs Cloudflare Proxy

Right, email authentication records are plain DNS TXT (and sometimes CNAME for certain DKIM setups). The orange-cloud proxy toggle on A records does not publish or hide TXT. You edit TXT in the DNS tab for the zone, whether the website is proxied or not.

Names that matter

RecordTypical name in Cloudflare
SPF`@` (apex) TXT
DKIM`selector._domainkey` TXT (example: `google._domainkey`)
DMARC`_dmarc` TXT

Warning

Cloudflare allows multiple TXT on one name. SPF allows only one logical `v=spf1` string merged into a single row. Two separate TXT rows both starting with `v=spf1` cause permerror.
“Orange cloud on your website does not publish SPF. TXT in the DNS tab does.”

Publish SPF in Cloudflare

1

One merged `v=spf1` row on `@` is the whole game here. If you already have SPF, edit that row instead of adding another TXT on `@`.

1

Open Cloudflare Dashboard > your zone > DNS > Records.

2

If no SPF exists, Add record > Type TXT > Name `@` > Content starting with `v=spf1`. Google Workspace example: v=spf1 include:_spf.google.com ~all

3

If SPF already exists, Edit that row instead of adding a second TXT on `@`.

4

Add vendor `include:` tokens on the same line, separated by spaces. Save once.

5

Use dig or zerohook.org/spf-checker after TTL to confirm one record and lookup count.

Publish DKIM and DMARC

DKIM

Your mail provider gives a hostname like `google._domainkey` and a long public key string. Wrong selector name means pass in the UI and fail in Gmail. In Cloudflare, Add record > TXT > Name `google._domainkey` (Cloudflare appends your zone automatically). Paste the full key as Content. Cloudflare stores long TXT without manual splitting in most cases.

DMARC

Add TXT > Name `_dmarc` > Content: v=DMARC1; p=none; rua=mailto:[email protected]; adkim=r; aspf=r; Replace the rua address with a mailbox you read. Start at `p=none` until reports stay clean.

Pro tip

Use Cloudflare's DNS only mode if a third-party email DNS sync tool also writes records; two writers cause drift.

Warning

Subdomains need their own `_dmarc` if you send bulk from `news.yourdomain.com` with a different From: domain alignment story.

Frequently Asked Questions

Key takeaways

1

Edit SPF plus DKIM plus DMARC in Cloudflare DNS as TXT on the correct hostnames.

2

Merge to one `v=spf1` on `@`; duplicate TXT rows break SPF evaluation.

3

Long DKIM keys usually fit in one Cloudflare TXT content field.

4

Start DMARC at `p=none` with a working `rua` before enforcement.

5

Verify all three layers together after TTL, not just the record Cloudflare's UI turns green.

Plot SPF plus DKIM plus DMARC together after Cloudflare edits at zerohook.org/dns-health-check before you move DMARC past monitor mode.

Share this analysis

Help others discover this content

Fix DNS before the next audit
Provider-specific copy-paste fixes for Cloudflare, Route53, GoDaddy, and more.
Start free scan

More from our blog