Skip to content

SPF, DKIM and DMARC explained, with real records

Short answer

SPF lists the servers allowed to send mail for a domain, DKIM signs each message with a key published in DNS, and DMARC tells receivers what to do when neither passes in alignment with the From address. Publish SPF and DKIM for every sending service first, then DMARC at p=none, read the reports, and tighten the policy.

Steps at a glance

  1. List every service that sends mail. Inventory the mailbox provider, website forms, CRM, newsletter and invoicing tools that send as the domain.
  2. Publish one SPF record. Combine all senders into a single TXT record starting with v=spf1 and stay within 10 DNS lookups.
  3. Enable DKIM for each sender. Publish each provider's public key at selector._domainkey and turn on signing in the provider.
  4. Publish DMARC at p=none with rua. Add a TXT record at _dmarc with p=none and an aggregate report address.
  5. Review reports, then tighten. Once legitimate mail passes, move to p=quarantine and then p=reject.

Why these three records exist

Email was designed without any way to prove who sent a message. Anyone can put any address in the From line, which is why phishing works. SPF, DKIM and DMARC are three DNS-published standards that receivers such as Gmail and Microsoft use to decide whether a message claiming to be from a domain really came from someone the domain owner authorised.

None of them is a deliverability guarantee. Receivers also weigh sender reputation, content, engagement and complaint rates. What these records do is remove the most common technical reason legitimate mail is rejected or filtered: the receiver cannot confirm it is genuine. For an agency, they are also a frequent source of breakage, because every new tool a client signs up for wants to send email as their domain.

SPF: which servers may send

SPF (Sender Policy Framework, RFC 7208) is a TXT record on the domain itself. It lists the IP addresses and services permitted to send mail whose envelope sender (the Return-Path, not necessarily the visible From) uses that domain. A typical record for a business on Google Workspace that also sends invoices through a separate service looks like this:

example.com.  3600  IN  TXT  "v=spf1 include:_spf.google.com include:servers.mcsv.net ip4:203.0.113.25 ~all"

Reading left to right: v=spf1 identifies the record. include: pulls in another domain's SPF record, which is how providers publish their ever-changing IP ranges. ip4: authorises a single address, here a web server that sends form notifications. The final ~all is the default for anything not listed: a soft fail, meaning 'treat as suspicious'. -all is a hard fail; +all authorises the entire internet and should never be used.

  • Only one SPF record per domain. Two TXT records both starting with v=spf1 produce a permanent error, and SPF fails for everything. This is the most common mistake we see when a new tool's setup guide says 'add this SPF record' rather than 'add this include to your existing record'.
  • Ten DNS lookups maximum. Each include, a, mx, ptr, exists and redirect counts, including the ones nested inside included records. Exceed ten and receivers return permerror. ip4 and ip6 don't count.
  • SPF breaks on forwarding. When a message is forwarded, the forwarding server's IP isn't in your record. That's one reason DKIM matters.

Our SPF checker follows include and redirect chains to a safe bound to estimate the lookup count, and flags duplicate and +all records.

DKIM: a signature on every message

DKIM (DomainKeys Identified Mail, RFC 6376) has the sending server add a cryptographic signature header to each message. The receiver fetches the matching public key from DNS and verifies that the signed headers and body weren't altered. The key lives at a name built from a selector the provider chooses:

google._domainkey.example.com.  3600  IN  TXT  "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."

The selector (google in this example) is visible in the DKIM-Signature header of a sent message as s=google, alongside d=example.com, the signing domain. Many providers publish their key as a CNAME pointing to their own DNS so they can rotate keys, for example selector1._domainkey CNAME selector1-example-com._domainkey.example.onmicrosoft.com for Microsoft 365.

Because selectors are arbitrary, there is no way to list every DKIM key a domain has. A checker that guesses common selectors and reports 'DKIM missing' when none match is wrong more often than it is right. Our tools check DKIM only for a selector you give us, and a missing guessed selector is never treated as a failure.

DMARC: policy and alignment

DMARC (RFC 7489) ties the other two to the address people actually see. A message passes DMARC if SPF or DKIM passes and the domain that passed is aligned with the From header domain. Alignment is what stops an attacker from passing SPF with their own domain while showing yours in From. The record lives at _dmarc:

_dmarc.example.com.  3600  IN  TXT  "v=DMARC1; p=none; rua=mailto:[email protected]; pct=100"
  • p= is the policy for failing mail: none (deliver normally, just report), quarantine (usually spam folder) or reject.
  • rua= is where receivers send daily aggregate XML reports listing which IPs sent as your domain and whether they passed. This is the most useful part of DMARC during rollout.
  • pct= applies the policy to a percentage of failing mail, for gradual enforcement. Default 100.
  • sp= sets a separate policy for subdomains; adkim= and aspf= choose relaxed (default) or strict alignment.

p=none is not an error. It is the correct starting point and a legitimate long-term choice for a domain that wants visibility without risking legitimate mail. Some large mailbox providers now expect bulk senders to publish at least a p=none DMARC record. Our DMARC checker reports p=none as monitoring mode and explains when to move on.

A safe rollout order for a client domain

Rushing to p=reject before every sender is authenticated is how agencies accidentally block their client's invoices. This order avoids that:

  • Inventory senders: the mailbox provider, the website's contact form, newsletter platform, CRM, helpdesk, invoicing and booking tools. Ask the client; check old invoices for SaaS subscriptions.
  • Merge everything into one SPF record and confirm it stays within ten lookups. If it doesn't, remove unused includes before reaching for SPF flattening services.
  • Turn on DKIM in every provider that supports it, publishing the record or CNAME they give you.
  • Publish DMARC with p=none and an rua address. Leave it for at least two to four weeks, through a full billing cycle.
  • Read the aggregate reports. Any legitimate source failing alignment needs fixing at the source.
  • Move to p=quarantine, optionally with pct=25 and then 100, and finally p=reject when reports are clean.

Monitoring after rollout

These records rarely break on their own; people break them. A new marketing tool adds a second SPF record, a DNS migration drops _dmarc, or a switch of email provider replaces MX but leaves the old include behind. Taking a snapshot of SPF, DMARC, MX and NS on a schedule and comparing it with the previous one turns those silent changes into an issue someone sees the same day, with the exact before and after values to show the client.

Troubleshooting quick reference

  • SPF permerror: look for two v=spf1 records or more than ten lookups. Remove includes for services the client no longer uses.
  • DMARC fails but SPF passes: the envelope sender belongs to the provider's domain, so SPF isn't aligned. Enable DKIM signing with the client's domain in that provider.
  • No DMARC record found: it must be a TXT record at exactly _dmarc.domain and start with v=DMARC1. A record at the root domain is ignored.
  • DKIM fails after a provider change: the old selector's key may have been deleted while mail still flows through the old service, or the new provider's CNAME wasn't added.

Frequently asked questions

Try it on a real domain — free, no account needed.