What do SPF, DKIM and DMARC each do?
All three are published as TXT records in your DNS zone. Receiving servers look them up on every message. The example values below use example.com and the record names Cloudflare Email Sending uses.
| Record | DNS type | Name | Example value | What it proves |
|---|---|---|---|---|
| SPF | TXT | cf-bounce.example.com | v=spf1 include:_spf.mx.cloudflare.net ~all | The server that connected is allowed to send for the envelope sender's domain |
| DKIM | TXT | cf-bounce._domainkey.example.com | v=DKIM1; h=sha256; k=rsa; p=MIIB... | The message carries a valid signature from a key the domain published, and the signed parts were not changed |
| DMARC | TXT | _dmarc.example.com | v=DMARC1; p=none; rua=mailto:dmarc@example.com | SPF or DKIM passed for a domain that matches the From address, plus your policy and where reports go |
SPF is defined in RFC 7208, DKIM in RFC 6376 and DMARC in RFC 7489. SPF records must be TXT records. The dedicated SPF record type was discontinued.
The SPF qualifier on all sets how strict the record is. -all means fail, ~all means softfail, a weak statement that the host is probably not authorized. RFC 7208 advises receivers not to reject on softfail alone.
Each DKIM signature names a signing domain in d= and a selector in s=. The selector lets one domain publish several keys. The public key lives in a TXT record at selector._domainkey.domain. Only one TXT record may exist per selector. DKIM requires the From header to be signed.
What is alignment, and why does DMARC need it?
SPF and DKIM on their own prove a domain, but not necessarily the one the reader sees. A spammer can pass SPF for their own domain and still put your domain in the From address. DMARC closes that gap. It passes a message only when SPF or DKIM passes and the authenticated domain is aligned with the From domain.
| Mode | Tag | Rule | Example that passes |
|---|---|---|---|
| Relaxed (default) | adkim=r, aspf=r | Both domains share the same organizational domain | From example.com, SPF checked on cf-bounce.example.com |
| Strict | adkim=s, aspf=s | The domains match exactly | From example.com, DKIM d=example.com |
One aligned pass is enough. DMARC does not need both SPF and DKIM to align. That is why a sending service can authenticate with its own bounce subdomain and still pass your DMARC check under relaxed alignment. The organizational domain is found with the public suffix list, so it is a heuristic (RFC 7489, section 3.2).
How do I roll out DMARC without losing mail?
The p tag sets the policy. Move up one step at a time, and read the aggregate reports between steps.
| Step | Record | What receivers do | Move on when |
|---|---|---|---|
| 1. Monitor | v=DMARC1; p=none; rua=mailto:dmarc@example.com | Nothing to failing mail. You get reports | Reports show every real sender passing with an aligned SPF or DKIM |
| 2. Quarantine | v=DMARC1; p=quarantine; pct=10; rua=mailto:dmarc@example.com | Send failing mail to spam, for pct percent of messages | No legitimate mail lands in spam. Raise pct to 100 |
| 3. Reject | v=DMARC1; p=reject; rua=mailto:dmarc@example.com | Refuse failing mail | Stay here, and keep reading reports |
Details that matter:
pctis a number from 0 to 100 and defaults to 100. Reports are never sampled. Google recommends starting with a small percentage and raising it to 100.- Google recommends enabling SPF or DKIM first and waiting 48 hours before you add DMARC.
ruareports can be high volume. Send them to a dedicated mailbox, a group or a reporting service, not to your own inbox.- If the
ruaaddress is on a different domain, that domain must publish a TXT record containingv=DMARC1at<your-domain>._report._dmarc.<report-host>. Without it, receivers ignore the address (RFC 7489, section 7.1). spsets a separate policy for subdomains. Without it,papplies to them too.
Check what is already in your zone before you start. Cloudflare adds v=DMARC1; p=reject; when you onboard a sending domain, but only if no DMARC record exists. If other systems send mail as your domain, switch that record to p=none first. Gmail and Yahoo require a DMARC record from bulk senders, and p=none satisfies them: see the sender requirements checklist.
What mistakes break the records?
| Mistake | What happens | Fix |
|---|---|---|
| Two SPF records on one name | SPF returns permerror and fails for every message (RFC 7208, section 4.5) | Merge them into one record with several include: terms |
| More than 10 DNS lookups in SPF | SPF returns permerror. Terms that count: include, a, mx, ptr, exists and redirect. ip4, ip6 and all do not count | Drop services you no longer use, or replace include: terms with ip4: ranges. More than 2 lookups that return nothing also trigger permerror |
| Wrong DKIM selector | Receivers query s= and d= from the signature. A key published under a different name is never found | Copy the name the sender shows. Read s= and d= from a real message header and query that exact name |
| Two DMARC records | Receivers drop DMARC for the message (RFC 7489, section 6.6.3) | Keep one TXT record on _dmarc |
Jumping straight to p=reject | Legitimate mail from a forgotten system is refused | Run p=none with rua first |
| Pasting a long DKIM key as one string | A TXT string is limited to 255 octets | Split it into several quoted strings. Receivers join them with no spaces |
If a domain already has an SPF record, merge the new entries into it. Cloudflare says the same in its domain setup page.
How do I check the records with dig?
Query each name and read the TXT answer. Add +short for the value only.
# SPF: the envelope sender domain
dig TXT cf-bounce.example.com +short
"v=spf1 include:_spf.mx.cloudflare.net ~all"
# DKIM: selector + _domainkey + signing domain
dig TXT cf-bounce._domainkey.example.com +short
"v=DKIM1; h=sha256; k=rsa; p=MIIB..."
# DMARC
dig TXT _dmarc.example.com +short
"v=DMARC1; p=none; rua=mailto:dmarc@example.com"
Count the answers. Two lines starting with v=spf1 or v=DMARC1 are a bug. To find the right DKIM name, open a delivered message and look at its DKIM-Signature header:
DKIM-Signature: v=1; a=rsa-sha256; d=example.com; s=selector1; ...
# the key is at s + ._domainkey. + d
dig TXT selector1._domainkey.example.com +short
To ask a specific resolver, put it after an at sign: dig @1.1.1.1 TXT _dmarc.example.com +short. Cloudflare says a new record that shows "Not Found" usually needs 5 to 15 minutes, and propagation can take up to 24 hours.
How do I set this up on Cloudflare?
Cloudflare Email Sending, a public beta, manages the sending records for each domain you onboard. If you work through an agent, sendmcp is a free, MIT-licensed Worker on your own Cloudflare account whose MCP tools write the records (domains_add) and read back the DMARC policy (deliverability_check). It follows the rule above: it leaves an existing DMARC record alone, writes p=none with reports when other services send as the domain, and keeps Cloudflare's p=reject when nothing else does. The steps are on the SPF, DKIM and DMARC setup page.
Sources
- RFC 7208: Sender Policy Framework (SPF) checked
- RFC 6376: DomainKeys Identified Mail (DKIM) Signatures checked
- RFC 7489: DMARC checked
- Cloudflare: Email Service, domain configuration checked
- Cloudflare: DNS record types checked
- Google: Set up DMARC checked