SPF, DKIM and DMARC are three DNS records that let a receiving mail server check whether an email claiming to be from your domain really is. SPF lists the servers allowed to send for the domain, DKIM adds a cryptographic signature to each message, and DMARC requires one of those checks to pass for the domain in the visible From address and tells receivers what to do when they don't.
All three are TXT records you can look up yourself. The examples below are live records of public domains, fetched with nslookup in October 2026; they may have changed since.
SPF, DKIM and DMARC at a glance
| SPF | DKIM | DMARC | |
|---|---|---|---|
| Specification | RFC 7208 | RFC 6376 | RFC 7489, updated by RFC 9989 (May 2026) |
| DNS name | example.com | selector._domainkey.example.com | _dmarc.example.com |
| Question it answers | Is this IP address allowed to send for this domain? | Was this message signed by this domain, and unchanged since? | Does a passing check match the From domain, and what if not? |
| Domain it checks | The envelope sender (MAIL FROM), not the From header | The d= domain in the signature | The From header the reader sees |
| Survives forwarding? | Usually not | Usually, unless the content is modified | If either aligned check survives |
SPF: which servers may send for the domain
An SPF record is a TXT record on the domain itself, starting with v=spf1. Look one up:
nslookup -type=TXT google.com
The SPF line in the output (other TXT records trimmed):
"v=spf1 include:_spf.google.com ~all"
Read it left to right. include:_spf.google.com means "also accept whatever that record allows", and that record, looked up the same way, lists IP ranges such as ip4:74.125.0.0/16 and ip4:209.85.128.0/17. ~all covers every other server.
The symbol in front of a mechanism is its qualifier. RFC 7208 defines four, and a mechanism without one defaults to +:
| Qualifier | Result | Typical use |
|---|---|---|
+ (default) | pass | include:, ip4:, mx entries |
- | fail | -all: everything else is unauthorised |
~ | softfail | ~all: probably unauthorised |
? | neutral | No statement either way |
A domain that never sends mail can say so explicitly. example.com publishes "v=spf1 -all": no server is authorised.
Three rules from RFC 7208 cause most SPF problems:
- One record only. If a receiver finds more than one
v=spf1record, the result ispermerror. Adding a second record for a new email service, instead of adding aninclude:to the existing one, breaks SPF for everything. - Ten DNS lookups maximum. Terms that need a DNS query (
include,a,mx,ptr,exists,redirect) are capped at 10 per check, counting nested includes. Exceed it and the result ispermerror. Domains that use many sending services hit this limit. - SPF checks the envelope sender, not the From line. It validates the MAIL FROM address used in the SMTP conversation (often a bounce address at the email provider) and the HELO name. The From address the reader sees is not checked by SPF at all, which is the gap DMARC closes.
DKIM: a signature on every message
With DKIM, the sending server signs selected headers and the body of each message with a private key and adds the signature as a DKIM-Signature header. The receiver fetches the matching public key from DNS and verifies it. If the signature checks out, the message really passed through a server holding that domain's key, and the signed parts have not changed. How digital signatures work covers the underlying mechanism.
The important tags in a DKIM-Signature header, per RFC 6376:
d=the signing domain, which takes responsibility for the message.s=the selector, which picks one key among several the domain may publish.h=the list of header fields that were signed (From is always among them).bh=the hash of the body;b=the signature itself.
The receiver combines the selector and domain into a DNS name, <s>._domainkey.<d>. For a signature with d=github.com and s=google:
nslookup -type=TXT google._domainkey.github.com
Example output (key shortened):
"v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAj6T5sl/RwdSq..."
p= is the base64 public key. You need the selector to look a key up; there is no way to list all of a domain's selectors from DNS, so read it from the s= tag of a message's headers. Some records come back with an empty key, for example "v=DKIM1; k=rsa; p=", which is what 20230601._domainkey.gmail.com returned when we checked. RFC 6376 says "An empty value means that this public key has been revoked": the selector is retired, and signatures made with it no longer verify.
DKIM on its own does not decide anything. The RFC states that signature verification failure "does not force rejection of the message"; what happens next is local policy, or DMARC.
DMARC: alignment plus a policy
SPF and DKIM each authenticate some domain, but neither has to be the domain in the From line. A phishing message can pass SPF for the attacker's own bounce domain and carry a valid DKIM signature from the attacker's domain while displaying From: [email protected]. DMARC closes that gap with one rule: a message passes DMARC only if SPF or DKIM passes for a domain that is aligned with the From domain.
Alignment comes in two modes. Relaxed (the default) accepts the same organisational domain, so a DKIM signature from mail.example.com aligns with From: [email protected]. Strict requires an exact match. The adkim= and aspf= tags choose the mode, with s for strict and r for relaxed.
The record lives at _dmarc. plus the domain:
nslookup -type=TXT _dmarc.github.com
"v=DMARC1; p=quarantine; sp=reject; pct=100; rua=mailto:[email protected]; ruf=mailto:[email protected]; fo=1"
| Tag | Meaning |
|---|---|
p= | Policy for failing mail: none (just report), quarantine (treat as suspicious, for example spam folder), reject (refuse it) |
sp= | Policy for subdomains, if different |
rua= | Where to send daily aggregate reports |
ruf=, fo= | Failure reports and when to send them |
adkim=, aspf= | Alignment mode, relaxed (default) or strict |
pct= | Share of mail the policy applies to (default 100); removed in RFC 9989 |
Other live examples show the range: _dmarc.google.com returned p=reject, _dmarc.gmail.com returned p=none; sp=quarantine, and example.com, which sends no mail, publishes p=reject;sp=reject;adkim=s;aspf=s.
A note on versions: DMARC was first published in 2015 as RFC 7489, an Informational document. In May 2026 it was replaced by RFC 9989, now on the Standards Track. The record format is the same (v=DMARC1 at _dmarc, with none, quarantine and reject), but the update removes the pct tag and adds a t= test-mode tag and an np= policy for non-existent subdomains. Existing records keep working; new ones can skip pct.
How the three work together on one message
- Your provider's server connects to the recipient's server and sends
MAIL FROM:<[email protected]>. The receiver checks the SPF record ofmail.example.comagainst the connecting IP address. - The receiver verifies the
DKIM-Signatureheader, sayd=example.com, using the key ats1._domainkey.example.com. - The receiver reads the From header (
[email protected]) and fetches_dmarc.example.com. - DMARC passes if SPF passed for an aligned domain (
mail.example.comaligns in relaxed mode) or DKIM passed for an aligned domain. If neither did, the receiver appliesp=. - Later, the receiver sends an aggregate report to the
rua=address listing which sources passed and failed.
How to check your own domain
On Windows, macOS or Linux:
nslookup -type=TXT yourdomain.com
nslookup -type=TXT _dmarc.yourdomain.com
nslookup -type=TXT <selector>._domainkey.yourdomain.com
On macOS and Linux, dig TXT _dmarc.yourdomain.com +short prints just the record. Check for exactly one v=spf1 line, an SPF record that covers every service that sends as you (mail provider, newsletter tool, help desk, invoicing), a DKIM key for each of those services' selectors, and a DMARC record. If DNS lookups themselves are unfamiliar, how DNS works explains what a TXT query does.
Gmail's sender guidelines make this concrete: since February 2024, all senders to Gmail accounts need SPF or DKIM, and bulk senders (more than 5,000 messages a day) need SPF, DKIM and a DMARC record, which "can be set to none", with the From domain aligned with the SPF or DKIM domain.
Rolling out DMARC without losing mail
- Publish SPF and turn on DKIM signing in every service that sends as your domain.
- Publish
v=DMARC1; p=none; rua=mailto:[email protected]and read the aggregate reports for a few weeks. They show every source sending as your domain, including ones you forgot. - Fix the sources that fail alignment, usually by enabling DKIM with your own domain in that service.
- Move to
p=quarantine, thenp=reject.
Authentication tells you who sent a message, not whether it is safe: a scammer's own domain can pass all three checks. For the checks that still need a human, see how to spot phishing.
Frequently asked questions
- Do I need all three of SPF, DKIM and DMARC?
- For reliable delivery, yes. Gmail's sender guidelines require SPF or DKIM from every sender, and SPF, DKIM and a DMARC record from bulk senders (more than 5,000 messages a day to Gmail accounts), with the From domain aligned to the SPF or DKIM domain. DMARC is also the only one of the three that tells receivers what to do with mail that fails.
- Can a domain have two SPF records?
- No. RFC 7208 says a domain must not publish more than one SPF record, and if a receiver finds more than one, the result is permerror, which receivers treat as a failure to authenticate. Merge all senders into a single v=spf1 record with multiple include: terms.
- What does ~all versus -all mean in SPF?
- Both describe what to do with servers not listed. -all produces a fail result, ~all a softfail, which means 'probably not authorised, but don't reject outright'. Under DMARC, a softfail is simply not an SPF pass, so the stricter choice matters less once DMARC is in place.
- Does SPF break when email is forwarded?
- Often, yes. The forwarding server sends the message from its own IP address, which is not in the original domain's SPF record. DKIM usually survives forwarding because the signature travels inside the message, which is one reason DMARC accepts either an aligned SPF pass or an aligned DKIM pass.
- What is the safest DMARC policy to start with?
- Start with p=none and an rua= address so you receive aggregate reports without affecting delivery. Once the reports show that all of your legitimate mail passes SPF or DKIM with alignment, move to p=quarantine and then p=reject.