
SPF, DKIM and DMARC Explained: How Email Authentication Works
by Leo Almeida · Published · 4 minute read
How SPF, DKIM and DMARC work together, what alignment means, example records for each, and the mistakes that leave a domain open to spoofing.
SMTP was designed without sender authentication. Any server on the internet can send a message with From: ceo@yourcompany.com, and without extra checks the receiving server has no way to tell it apart from the real thing. SPF, DKIM and DMARC are the three DNS-published standards that close that gap. Each one answers a different question, and only together do they stop someone spoofing your domain.
SPF: Which Servers May Send for This Domain?
Sender Policy Framework (RFC 7208) is a TXT record on your domain that lists the servers allowed to send mail for it:
example.com. TXT "v=spf1 include:_spf.google.com include:sendgrid.net -all"The receiving server takes the domain from the SMTP envelope sender (the MAIL FROM, which ends up in the Return-Path header, not the From your users see) and checks whether the connecting IP is allowed.
What to know:
-allvs~all.-allsays everything not listed fails;~allis a soft fail. With DMARC enforcing, either works, but never use+all, which authorises every server on the internet.- The 10-lookup limit. Evaluating SPF may trigger at most 10 DNS lookups (
include,a,mx,exists,redirect). Each SaaS sender you add usually costs one or more. Above 10, the result is a permanent error and many receivers treat SPF as failed. - One record only. Two
v=spf1records on the same name is also a permanent error. - SPF breaks on forwarding. A forwarded message arrives from the forwarder's IP, which isn't in your record.
DKIM: Was This Message Signed by the Domain, Unchanged?
DomainKeys Identified Mail (RFC 6376) adds a cryptographic signature to each message. The sending server signs selected headers and the body with a private key and adds a DKIM-Signature header naming the signing domain (d=) and a selector (s=). The receiver fetches the public key from DNS:
google._domainkey.example.com. TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkq..."What to know:
- Selectors can't be listed. Each sending service uses its own selector, such as
google,selector1andselector2for Microsoft 365, ors1for SendGrid. A DNS scan can only probe common names, so a key under a custom selector stays invisible until a real message shows it. - Use 2048-bit RSA keys where the provider allows it, and rotate them.
- DKIM survives forwarding as long as the message isn't modified, which makes it the more reliable half for DMARC.
DMARC: What Should Receivers Do When Both Fail?
SPF and DKIM each authenticate a domain, but not necessarily the one in the From header. A phishing message can pass SPF for attacker.example while showing From: billing@yourcompany.com. DMARC (RFC 7489) closes that gap with alignment: a message passes DMARC only if SPF or DKIM passes for a domain that matches the From domain.
- SPF is aligned when the envelope sender domain matches the From domain.
- DKIM is aligned when the signature's
d=domain matches the From domain. - By default alignment is relaxed, so
mail.example.comaligns withexample.com.aspf=sandadkim=srequire an exact match.
The DMARC record lives at _dmarc. under the domain and tells receivers what to do with mail that fails, and where to send reports:
_dmarc.example.com. TXT "v=DMARC1; p=reject; rua=mailto:dmarc@example.com"p=noneonly reports; failing mail is delivered as usual.p=quarantineasks receivers to treat failing mail as suspicious, usually the spam folder.p=rejectasks receivers to refuse it during the SMTP transaction.rua=is where receivers send daily aggregate reports: every IP that sent mail as your domain, with volumes and pass or fail results. Those reports are how you find legitimate senders before enforcing. (See the DMARC monitoring guide.)sp=sets the policy for subdomains if it should differ fromp=.
Why You Need All Three
| Checks | Stops spoofed From alone? | |
|---|---|---|
| SPF | The sending IP is allowed for the envelope domain | No: the envelope domain can differ from From |
| DKIM | The message was signed by a domain and not altered | No: the signing domain can differ from From |
| DMARC | SPF or DKIM passed and aligned with From, plus a policy | Yes, once the policy is quarantine or reject |
DMARC at p=none is monitoring, not protection. Spoofed messages still reach inboxes. Getting to p=reject safely is a process; this step-by-step guide walks through it.
Domains That Don't Send Mail
Parked domains and domains used only for web are popular for spoofing because nobody watches them. Publish records that say "nothing sends as me":
example.net. TXT "v=spf1 -all"
_dmarc.example.net. TXT "v=DMARC1; p=reject"Check Your Own Domain
Two free checks, no sign-up.
Send one real email to the SPF, DKIM and DMARC test to see how receivers evaluate your mail: SPF, DKIM, alignment and the policy they would apply.
Look up the DNS records for any domain right here: the SPF record and its lookup count, the DMARC policy, and DKIM keys at the common selectors.
Reads public DNS only: SPF, DMARC and DKIM keys at common selectors.
Records drift as teams add services and change providers. DMARC monitoring checks them daily and alerts when one breaks or changes.


