Skip to content
DMARC Pulse
Guides

Cloudflare (DNS)

How to set up SPF, DKIM and DMARC in Cloudflare DNS

Add SPF, DKIM and DMARC records in Cloudflare DNS, and avoid the proxy and CNAME flattening settings that can break email authentication.

Before you start

'This guide shows where to add SPF, DKIM and DMARC records when your DNS is hosted on Cloudflare.' Cloudflare-assigned nameservers look like name.ns.cloudflare.com, and some plans allow custom nameservers instead.

The values come from your email providers, such as Google Workspace or Microsoft 365. Here you learn where to enter them and which Cloudflare settings can get in the way.

SPF and DMARC are TXT records, which Cloudflare never proxies. DKIM can be a TXT record or a CNAME, and the CNAME is the one the proxy can break.

Add every record in the dashboard under DNS > Records > Add record. In Name, use @ for the root domain and only the short label for anything else. In the example.com zone, the name _dmarc becomes _dmarc.example.com.

Step 1: SPF

  1. Look for a TXT record on the root domain that starts with v=spf1. A domain must have only one.
  2. If there is none, create one with Type TXT, Name @ and the value from your provider in Content. For Google Workspace:
TXT
v=spf1 include:_spf.google.com ~all
  1. If one exists, edit it and add the new include: before ~all or -all.

Leave ~all in place while you test. A change to -all tells receivers to treat unlisted servers as a hard failure, so make it only after your reports show every sender. TXT records are always DNS only on Cloudflare.

Step 2: DKIM

Your provider gives you a TXT record or one or more CNAME records.

  • TXT, as with Google Workspace: the name is the selector plus ._domainkey, typically google._domainkey. Paste the value that starts with v=DKIM1; into Content.
  • CNAME, as with Microsoft 365: create selector1._domainkey and selector2._domainkey with the targets Microsoft shows you. Set Proxy status to DNS only on each one.

A long DKIM key can use several quoted strings of up to 255 octets inside one TXT record; receivers concatenate them to verify the signature.

The proxy matters because a proxied CNAME is answered with Cloudflare’s own IP addresses and the CNAME itself is not returned. Receivers then cannot follow it to your provider’s key. Cloudflare may warn you or refuse to proxy a DKIM record, but check the status yourself.

Step 3: DMARC

Look for a TXT record named _dmarc. If one exists, preserve its policy, alignment and report destinations while adding your monitored rua address. Never create a second record. Only when none exists, use Type TXT, Name _dmarc and this Content:

Use this starter value only if no DMARC policy exists at this name. Otherwise edit the existing record, preserving its p=, alignment settings and report addresses; add your monitored rua destination there. Never create a second policy record.

TXT
v=DMARC1; p=none; rua=mailto:dmarc@example.com

Replace the rua address, where receivers send aggregate reports, with the reporting address DMARC Pulse gives you for this domain. An address on another domain only receives reports if that domain publishes an authorization record.

The policy p=none only monitors. See how the three policies differ before you change it.

Cloudflare also offers DMARC Management under Email > DMARC Management, for apex domains only. When a DMARC record exists, enabling it adds another rua entry to that record. A DMARC record can list several rua addresses separated by commas. Keep a single _dmarc record.

Step 4: Check

Cloudflare says zone changes take effect globally within 5 minutes, usually much less. A resolver that cached the old answer can keep it until the TTL expires.

Run the SPF checker, the DKIM checker and the DMARC checker on your domain. Preserve existing policy, alignment and report destinations. For a first deployment, monitor at p=none; after all legitimate senders align, assess p=quarantine. p=reject is optional and needs a separate mailing-list/forwarding risk assessment. Receivers decide individual delivery.

Cloudflare Email Routing and Email Sending

Cloudflare’s Email Service has two parts, and each publishes different records.

Email Routing receives and forwards mail through root MX hosts route1.mx.cloudflare.net, route2.mx.cloudflare.net and route3.mx.cloudflare.net, with DKIM selector cf2024-1. If no root SPF exists, Cloudflare publishes this value. Otherwise merge include:_spf.mx.cloudflare.net into the existing SPF record:

TXT
v=spf1 include:_spf.mx.cloudflare.net ~all

Email Sending sends outbound mail and needs Cloudflare DNS. It creates MX, SPF and DKIM records on the cf-bounce subdomain. The SPF value is the same as above, and the DKIM selector is cf-bounce, published at cf-bounce._domainkey under your domain. Cloudflare signs with your domain’s key and says Email Service handles SPF and DKIM alignment automatically. Alignment means the authenticated domain matches the domain in the visible From address.

Common problems

A DKIM CNAME or mail host is set to Proxied. Cloudflare says SMTP, IMAP and POP3 do not work through its standard HTTP proxy. Switch DKIM CNAMEs, mail.example.com and every MX target to DNS only. The MX record itself is always DNS only, but its target needs checking.

CNAME flattening changes the DKIM answer. Flattening returns an IP address in place of the CNAME, which can stop providers from reading the record. Paid zones can turn it on for all CNAMEs under DNS > Settings, or per record with the Flatten option. Records flattened with the per-record option carry the tag cf-flatten-cname. Turn off whichever one applies to your DKIM records.

Two SPF records. RFC 7208 forbids more than one on the same name. Merge them into one.

SPF is over 10 DNS lookups. Receivers return a permanent error beyond that limit. Each include: counts, and so do the lookups inside it. Remove senders you no longer use. Under Email > DMARC Management > View records, editing the SPF record shows a warning when you are over the limit.

Email Routing has locked your SPF record. After onboarding, the root MX, SPF and DKIM records cannot be edited until you select Unlock in the Email Routing settings. Disabling Email Routing deletes those records, even one you unlocked and edited. Note your full SPF value first and recreate it if it disappears.

Error 2008: Non-Cloudflare MX records exist. Email Routing needs exclusive control of the root MX records. Email Routing cannot run alongside a mailbox provider on the root domain. If you keep your mailboxes at Google Workspace, Microsoft 365 or similar, do not delete these MX records. If you are moving, add your destination addresses first, then delete the old MX records, onboard Email Routing and create your routing rules right away, because mail to an address with no rule is rejected. The old provider stops receiving your mail from that point.

Email Sending published p=reject. Preserve an intentional existing policy. If a newly auto-created default causes legitimate failures, diagnose alignment first. The owner may choose temporary monitoring at p=none, accepting reduced protection, only if the dashboard supports editing; otherwise contact Cloudflare support. Edit the same record and retain report addresses. For a first deployment, publish monitoring before enabling Email Sending.

The record is in the wrong place. If a subdomain is delegated with NS records, its mail records live with that external provider. Edit them there.

Frequently asked questions

Should mail hostnames be proxied on Cloudflare?
Keep them DNS only. Cloudflare says SMTP, IMAP and POP3 do not work through its standard HTTP proxy. A host such as mail.example.com, and any host an MX record points to, must be set to DNS only.
How long does a DNS change take on Cloudflare?
Cloudflare says changes to your zone take effect globally within 5 minutes, usually much less. Resolvers that cached the old answer can keep it until its TTL expires.
Can I use Cloudflare Email Routing with another sender?
Yes, for sending. Email Routing only handles incoming mail, 'so an outbound provider must still be listed in your single SPF record and needs its own DKIM records.' For receiving, Email Routing needs Cloudflare MX records and cannot share the root domain with external mail servers.
What is the SPF include for Cloudflare Email Service?
Both Email Routing and Email Sending use include:_spf.mx.cloudflare.net. Email Routing publishes it on the root domain. Email Sending publishes it on the cf-bounce subdomain.
Does Cloudflare create a DMARC record by itself?
When you enable Email Sending on a domain with no DMARC record, Cloudflare adds one with p=reject. If a DMARC record already exists, Cloudflare keeps it unchanged.
Can I use Cloudflare DMARC Management and DMARC Pulse together?
Yes. When you enable DMARC Management on a domain that already has a DMARC record, Cloudflare adds another rua entry to that record. Your existing address stays in the list and both receive reports.

Sources consulted

Cloudflare: Proxy status
checked 2026-11-09
Cloudflare: CNAME flattening
checked 2026-11-09
Cloudflare: Nameservers
checked 2026-11-09
RFC 9989 §4.7 (the rua tag)
checked 2026-11-09

Keep it healthy

Know the moment something breaks

Point your DMARC reports to DMARC Pulse and see who sends email as your domain, what fails and why — with a calm alert when anything changes.

Free plan: 1 domain, no credit card.