Skip to content
SpoofKiller
Provider setup guides

DMARC on Cloudflare DNS: Adding SPF, DKIM, and DMARC Records

How to add and verify email authentication records in Cloudflare DNS, including the proxy and CNAME pitfalls.

Reading time
6 min read
Last updated
Updated
An analyst's desk seen from above, with printed charts, a magnifying glass, and a stack of envelopes.
The dashboard shows what you typed. Only a lookup shows what you published. Check the second one.
In this guideShow 7 sections

There is a small orange cloud in the Cloudflare dashboard, and it has ended more email setups than any hacker. It sits beside your DNS records looking friendly. Click it on the wrong row and your DKIM key vanishes from the internet, replaced by the address of a web proxy that has never signed an email in its life.

Cloudflare is a fine place to keep DNS. It is fast, it is free for most domains, and changes show up quickly. It also has three or four habits that differ from other DNS hosts, and every one of them touches email authentication. This guide covers what to type, what to leave alone, and how to check that what you published is what the world sees.

How Cloudflare DNS differs from other hosts

Four behaviors account for nearly every email problem on Cloudflare:

  • It appends your domain. The Name field is relative to your zone. You type the label, and Cloudflare adds the rest.
  • It can proxy records. A proxied record answers with Cloudflare’s own addresses. That is the point for a website and a disaster for email records.
  • It splits long TXT values. You paste one long string; Cloudflare stores it as the multiple 255-character strings that DNS requires.
  • It will let you add duplicates. Nothing stops you from creating a second SPF record. Receivers will stop you later.

Cloudflare hosts your records. It does not send your mail. The record values come from whoever does: see the guides for Google Workspace, Microsoft 365, Postmark, and SendGrid. What follows is how to enter them correctly.

Step 1: Add or fix the SPF record

Open your domain in Cloudflare and go to DNS → Records. Before adding anything, search the list for v=spf1. If a record exists, edit it. If not, add one:

Type:     TXT
Name:     @
Content:  v=spf1 include:_spf.google.com ~all
TTL:      Auto

The @ means the root of your domain. The include shown is Google’s; substitute your own providers.

There must be exactly one SPF record at the root. Two records, even two correct ones, give receivers a permanent error and your domain no usable SPF. This happens on Cloudflare more than elsewhere for a simple reason: its Email Routing feature adds an SPF record of its own, and so do various setup wizards. If you find two, merge their mechanisms into one record and delete the other. The SPF record generator does the merging, and the SPF checker confirms the result stays within ten DNS lookups.

Step 2: Add DKIM records, with the cloud turned grey

DKIM records come in two forms, depending on your mail provider.

DKIM as a TXT record

Google Workspace, Postmark, and Rackspace Email give you a TXT record containing the public key:

Type:     TXT
Name:     google._domainkey
Content:  v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA...

Paste the whole value as a single line. A 2048-bit key runs past 255 characters, the limit for one string inside a TXT record. On many DNS hosts that means splitting the key by hand. Cloudflare handles the splitting for you. Your only job is to paste all of it: a key missing its last dozen characters publishes without complaint and verifies nothing.

DKIM as a CNAME record

Microsoft 365, SendGrid, and many marketing platforms give you CNAMEs that point at keys they host:

Type:     CNAME
Name:     s1._domainkey
Target:   s1.domainkey.u1234567.wl123.sendgrid.net
Proxy:    DNS only

This is where the cloud matters. Every DKIM, return-path, and mail-related CNAME must be set to “DNS only,” shown as a grey cloud. A proxied CNAME does not return the target name. It returns Cloudflare proxy addresses. The receiver looking for a TXT record containing a key finds nothing, and DKIM fails for every message you send.

Orange is for websites. Grey is for mail. Almost every Cloudflare email mystery ends with someone changing a color.

Do not assume the dashboard will choose correctly for you, least of all for bounce and return-path subdomains such as pm-bounces or em1234, which look to Cloudflare like any other hostname. Check each row. After saving, look the selector up in the DKIM checker.

Step 3: Add the DMARC record at _dmarc

Build your record with the DMARC record generator, then add it:

Type:     TXT
Name:     _dmarc
Content:  v=DMARC1; p=none; rua=mailto:dmarc-reports@example.com
TTL:      Auto

Type _dmarc in the Name field and nothing else. Cloudflare appends your zone name. If you enter the full _dmarc.example.com into a field that is already appending, you risk publishing this:

_dmarc.example.com.example.com   ← nobody will ever query this

The dashboard shows the full name it will create beneath the field as you type. Read it before you save. The same rule applies to every record in this guide: google._domainkey, not google._domainkey.example.com.

As with SPF, a domain gets one DMARC record. If one exists, edit it. For what the tags mean and which policy to begin with, see How to Configure DMARC.

Five Cloudflare mistakes and their symptoms

MistakeWhat you seeFix
DKIM CNAME proxiedProvider says “not verified”; dkim=fail or no key foundToggle the record to DNS only
Full hostname typed in NameRecord exists in dashboard, lookup returns nothingRe-create using only the label
Two SPF records at rootspf=permerror in headersMerge into one record
Truncated DKIM keyKey found, signatures fail to verifyPaste the complete value again
Editing a zone that is not liveNo change visible anywhereConfirm the registrar’s nameservers point to Cloudflare

The last row is more common than it should be. A domain can be added to a Cloudflare account while its nameservers still point elsewhere. Every record you add is then a note to yourself. The DNS security checker shows which nameservers are actually authoritative.

Step 4: Verify what the world can see

Cloudflare changes are usually visible within minutes. The delay you may notice comes from resolvers that cached the old answer and will keep it until its TTL expires. Cloudflare’s Auto TTL is short, so the wait is rarely long. If you are replacing a record that had a long TTL at a previous host, be patient with it.

Check in this order:

  1. Use the DNS propagation checker to confirm several public resolvers return your new record.
  2. Run the DMARC checker to validate the syntax and see the policy receivers will apply.
  3. Send yourself a message and confirm dmarc=pass in the headers.

If you prefer a command line, dig or nslookup gives the same answer:

dig +short TXT _dmarc.example.com
nslookup -type=TXT _dmarc.example.com

Cloudflare’s own email features

Cloudflare offers a DMARC Management feature in its dashboard. It can receive your aggregate reports and summarize the sources sending as your domain. It is a reasonable option, and worth knowing about. If you enable it, Cloudflare adds its own address to your rua tag. You can list more than one address there, separated by commas, so using it does not prevent you from sending reports elsewhere too.

Email Routing is a different feature: it forwards incoming mail and adds its own MX and SPF records. If you turn it on for a domain that already has a mail provider, review the records it created before something breaks.

Where a dedicated service earns its keep is in what happens after setup. SpoofKiller’s domain security monitoring re-checks your email DNS records on a schedule and keeps a history of changes, so when a teammate flips a cloud to orange next spring, you learn about it from an alert and not from a customer. Pair that with DMARC report monitoring and the reporting setup guide, and the records you entered today stay correct.

FAQ

Questions about DMARC for Cloudflare DNS

Short answers to what readers ask next. If yours is missing, write to us and a person will reply.

Ask a question

Free, no obligation

Want a second pair of eyes on your records?

Send us your domain. We will look at its DMARC, SPF, and DKIM setup and write back, in plain English, with what we found and what to fix first.

  • A person reads your records, not a script
  • Specific fixes, in order of importance
  • No sales sequence afterward

We use your details to reply. Nothing else.

Reading about it is the slow way.

Run the free check and see your own domain's DMARC, SPF, and DKIM in the time it took to read this paragraph. No account, no card.