Guide

Email Authentication: SPF, DKIM & DMARC Explained

SPF, DKIM and DMARC are three DNS records that together stop your domain being spoofed: SPF and DKIM prove a message is authentic, and DMARC ties that proof to the visible From address and tells receivers to reject forgeries.

By Paul Rudenko, Security ResearcherUpdated Jun 26, 202611 min read

Anyone on the internet can send an email that claims to be from your domain. The visible From: address is just text — nothing in the core email protocol forces it to be true.

SPF, DKIM and DMARC are the three DNS-published standards that let receiving servers verify that a message really came from infrastructure you authorised, and that let you tell those servers what to do with the messages that fail. Configured together, they are what stop attackers from spoofing your domain in phishing and business-email-compromise attacks.

The guides in this cluster, at a glance

This pillar explains the concepts. The guides below are the practical, task-focused companions — provider walk-throughs and fixes for the specific findings a checker reports. Start here if you already know what you need to do.

GuideUse it when
SPF, DKIM & DMARC on GoDaddyYour DNS is hosted at GoDaddy and you want the exact host fields.
Setup for Google WorkspaceYou send mail through Google Workspace / Gmail.
Setup for Microsoft 365You send mail through Microsoft 365 / Office 365.
How to prevent email spoofingYou want the overall plan to stop your domain being forged.
“DMARC policy not enabled”A checker says you have no DMARC record or one stuck at p=none.
Why your DMARC is failingLegitimate mail shows dmarc=fail and you need the cause.
SPF too many DNS lookupsSPF returns permerror because the record exceeds 10 lookups.
Multiple SPF recordsYour domain has more than one v=spf1 record and SPF broke.

Why does email need authentication at all?

SMTP, the protocol that moves mail between servers, was designed in an era of mutual trust. It distinguishes between the envelope sender (the MAIL FROM address used during the SMTP transaction, also called the Return-Path) and the header From (the address your recipient actually sees in their mail client). Neither is verified by the protocol itself. A spammer can connect to a mail server, announce that the message is from billing@yourbank.example, and the message will be delivered with that header intact.

This gap is the root cause of most phishing and business email compromise. Because the From header is the field humans trust, an unauthenticated domain can be impersonated by anyone, and your customers, staff and suppliers have no reliable way to tell a real message from a forgery. Email authentication closes the gap with three complementary mechanisms, all published as DNS records:

  • SPF (Sender Policy Framework, RFC 7208) authorises which servers may send mail using your envelope sender domain.
  • DKIM (DomainKeys Identified Mail, RFC 6376) cryptographically signs messages so a receiver can verify they were not altered and came from your domain.
  • DMARC (Domain-based Message Authentication, Reporting and Conformance, RFC 7489) ties SPF and DKIM to the visible From domain, tells receivers what to do on failure, and provides reporting.

None of the three is sufficient on its own. SPF and DKIM each authenticate a domain that the recipient may never see; only DMARC binds authentication to the From header that matters. The rest of this guide explains each layer and the order in which to deploy them.

What does SPF do?

SPF lets you publish, in DNS, the list of hosts permitted to send mail for your domain. A receiving server looks at the envelope sender domain, fetches that domain's SPF record, and checks whether the connecting IP address is authorised. SPF is published as a single TXT record at the root of the domain, beginning with v=spf1:

example.com.  IN  TXT  "v=spf1 include:_spf.google.com include:sendgrid.net ip4:198.51.100.10 -all"

Each term is a mechanism. include: pulls in another domain's authorised hosts (how you authorise providers like Google Workspace or SendGrid), ip4: and ip6: authorise specific addresses or ranges, and a / mx authorise the hosts named in your A or MX records. The mechanisms are evaluated left to right; the first match wins.

The all mechanism: -all vs ~all

The final mechanism is the catch-all that decides the verdict for any sender that did not match. The qualifier in front of it matters:

  • -all (hard fail) — anything not explicitly listed fails SPF. This is the goal state and what you want once you are confident your record is complete.
  • ~all (soft fail) — non-listed senders are marked as suspicious but not outright rejected. Useful as a transitional setting while you confirm you have not missed a legitimate sender.
  • +all — authorises the entire internet. Never use this; it neutralises SPF completely.
SPF alone does not protect the visible From address. SPF checks the envelope sender (Return-Path), which a recipient never sees and which an attacker is free to set to a domain they control. SPF only becomes spoofing protection when DMARC requires it to align with the From header.

The 10-DNS-lookup limit

RFC 7208 caps the number of DNS-querying mechanisms an SPF record may trigger at ten. Every include, a, mx, ptr and exists term counts toward this limit, including lookups nested inside the records you include.

Exceed it and the receiver must return a permerror, which under DMARC counts as an SPF failure. Because each third-party provider you add typically consumes one or more lookups, busy domains hit the ceiling quickly.

Keep the record lean: remove providers you no longer use, prefer ip4/ip6 over include where a provider publishes stable addresses, and consider SPF flattening only with a service that keeps the flattened record updated.

What does DKIM do?

DKIM (RFC 6376) attaches a digital signature to every outgoing message. Your sending server signs selected headers and the body with a private key; the matching public key is published in DNS. A receiving server reads the DKIM-Signature header, fetches the public key, and verifies that the signed content has not been altered in transit and that it was signed by a key belonging to your domain.

DKIM uses selectors so a single domain can publish several keys — one per provider, or rotated over time. The selector is named in the signature header and tells the receiver which key to fetch. The public key lives at <selector>._domainkey.<domain> as a TXT record:

s1._domainkey.example.com.  IN  TXT  "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQ..."

The p= tag holds the base64-encoded public key. A corresponding DKIM-Signature header on the message names the selector and the signing domain:

DKIM-Signature: v=1; a=rsa-sha256; d=example.com; s=s1;
  h=from:to:subject:date; bh=...; b=...

Here d= is the signing domain and s= is the selector. Because DKIM signs the message itself rather than the connecting IP, a valid DKIM signature survives legitimate forwarding that would otherwise break SPF — one reason DMARC accepts either SPF or DKIM as a pass.

Use at least 2048-bit RSA keys where your provider supports them, and rotate keys periodically by publishing a new selector before retiring the old one.

What does DMARC do?

DMARC (RFC 7489) is the layer that turns SPF and DKIM into real spoofing protection. It does three things: it requires that an authenticated domain align with the visible From domain, it tells receivers what policy to apply when a message fails, and it asks receivers to send you reports. The policy is a TXT record at the _dmarc subdomain:

_dmarc.example.com.  IN  TXT  "v=DMARC1; p=none; rua=mailto:dmarc@example.com; ruf=mailto:dmarc@example.com; fo=1; adkim=s; aspf=s"

The key tags:

  • p= — the policy applied to mail that fails DMARC: none (take no action, just monitor), quarantine (treat as suspicious, typically deliver to spam) or reject (block outright). reject is the only policy that actually stops spoofed mail reaching inboxes.
  • rua= — address for aggregate reports: daily XML summaries from receivers showing which IPs sent mail under your domain and whether they passed SPF, DKIM and alignment. This is the data you use to find your legitimate senders before enforcing.
  • ruf= — address for forensic/failure reports (per-message redacted samples). Support is patchy and they can contain personal data, so many operators omit them.
  • sp= — a separate policy for subdomains; pct= — apply the policy to a percentage of failing mail (useful for staged rollout); adkim / aspf — alignment strictness (r relaxed, the default, or s strict).

Alignment is the whole point

DMARC passes only if at least one of SPF or DKIM both passes and is aligned with the From domain. Alignment means the domain that SPF or DKIM authenticated matches the domain in the visible From header. Under relaxed alignment (the default) the organisational domains must match — mail.example.com aligns with example.com. Under strict alignment the domains must be identical. This alignment check is exactly what plugs the hole SPF and DKIM leave open: an attacker can pass SPF for a domain they own, but they cannot make that domain align with your From header.

Not sure whether your SPF, DKIM and DMARC records line up — and whether your From domain can be spoofed right now?

Run the free Email/DMARC checker

A safe rollout order

DMARC enforcement can silently block your own legitimate mail if you jump straight to p=reject before you know every system that sends as your domain. The standards-aligned approach, echoed in M3AAWG deployment guidance, is to monitor first and enforce gradually:

  • 1. Publish SPF and DKIM. Get a correct SPF record (with ~all to start) and DKIM signing enabled on every legitimate sending service.
  • 2. Deploy DMARC at p=none with rua. This changes nothing about delivery but starts the flow of aggregate reports.
  • 3. Read the reports. Use the aggregate data to find every system sending as your domain and fix their SPF/DKIM and alignment until all legitimate mail passes. This is the step that takes real calendar time.
  • 4. Move to p=quarantine. Optionally ramp with pct= (e.g. 25, then 50, then 100). Watch reports for collateral damage.
  • 5. Move to p=reject. Once quarantine is clean, enforce. Tighten SPF to -all and consider strict alignment.
p=none provides visibility but zero protection — a domain stuck at p=none can still be spoofed freely. It is a diagnostic phase, not a destination. Plan to reach quarantine or reject.

Common mistakes

  • More than one SPF record. A domain must publish exactly one v=spf1 TXT record. Two records are a permerrorand cause SPF to fail entirely. Merge them into a single record.
  • Too many DNS lookups. Crossing the ten-lookup limit gives a permerror and breaks SPF, often silently. Audit your include chains as you add and remove providers.
  • Ignoring alignment. A message can pass raw SPF or DKIM and still fail DMARC because the authenticated domain does not match the From domain. Many third-party senders need explicit configuration (a custom return-path or a CNAME for DKIM) to align.
  • Living at p=none forever. Monitoring without ever enforcing leaves your domain spoofable. Treat p=none as temporary.
  • Forgetting non-sending and parked domains. A domain that never sends mail can still be spoofed. Publish a hard-deny posture: an SPF record of v=spf1 -all, a DMARC record of v=DMARC1; p=reject;, and a null MX record (0 .) to signal it accepts no mail either.
  • One DKIM key forever. Keys should be rotatable. Use selectors so you can roll to a new key without an outage, and retire weak (short) keys.

How do I check my own domain?

You can inspect the raw records yourself with dig:

dig +short TXT example.com
dig +short TXT _dmarc.example.com
dig +short TXT s1._domainkey.example.com

But reading the records is only half the job — the real question is whether SPF, DKIM and DMARC align on the visible From domain, whether your SPF is inside the lookup limit, and whether your DMARC policy is actually enforcing. The SecScan Email/DMARC checker runs those checks for you and flags exactly where a spoofer could slip through. Once your email is locked down, close the rest of your external attack surface with our security headers guide and the broader website security guide.

Frequently asked questions

Is SPF enough to stop spoofing?

No. On its own, SPF cannot stop someone spoofing your domain. SPF authenticates the envelope sender (the Return-Path used during the SMTP transaction), not the From address your recipient actually sees. An attacker can set the envelope sender to a domain they own — passing SPF for that domain — while still forging your domain in the visible From header, which is the field humans trust. SPF only becomes anti-spoofing protection when DMARC is layered on top, because DMARC requires the SPF-authenticated domain to align with the From domain. You should still publish a correct SPF record, but treat it as one of three layers: SPF and DKIM provide the authentication signals, and DMARC binds them to the visible sender and enforces a policy. Deploy all three to actually block forgeries.

What DMARC policy should I use?

The end goal is p=reject, the only policy that actually stops spoofed mail from reaching inboxes. But you should not start there. Begin at p=none, which changes nothing about delivery but turns on aggregate (rua) reporting so you can discover every legitimate system sending as your domain. Read those reports until all your real mail passes SPF or DKIM with alignment, then move to p=quarantine — optionally ramping with the pct tag — so failures land in spam rather than being delivered. Once quarantine runs clean with no collateral damage to legitimate mail, advance to p=reject. The mistake to avoid is staying at p=none indefinitely: it gives you visibility but zero protection, so a domain stuck at p=none can still be spoofed freely. Treat p=none as a temporary diagnostic phase, never the destination.

What is DMARC alignment?

Alignment is the check that makes DMARC meaningful. SPF and DKIM each authenticate some domain, but that domain may not be the one your recipient sees in the From header. DMARC passes only if at least one of SPF or DKIM both passes and is aligned — meaning the authenticated domain matches the visible From domain. Under relaxed alignment (the default) the organisational domains must match, so mail.example.com aligns with example.com. Under strict alignment they must be identical. Alignment is precisely what closes the gap SPF and DKIM leave open: an attacker can pass SPF or DKIM for a domain they control, but they cannot make that domain align with your From header. Many third-party senders need explicit configuration — a custom return-path for SPF, or a CNAME for DKIM — before their mail aligns with your domain.

Why does my SPF record fail with too many lookups?

RFC 7208 limits an SPF record to ten DNS-querying mechanisms. Every include, a, mx, ptr and exists term counts toward that limit, including the lookups nested inside records you include. Each third-party provider you authorise typically consumes one or more lookups, so domains using several services hit the ceiling quickly. When you exceed ten, the receiver must return a permerror, which under DMARC counts as an SPF failure — and it often happens silently, so legitimate mail starts failing without any obvious cause. To fix it, remove providers you no longer use, replace include statements with explicit ip4 or ip6 entries where a provider publishes stable addresses, and avoid redundant a and mx mechanisms. If you genuinely need many senders, use an SPF flattening service that keeps the flattened record current, since hand-flattening breaks when a provider changes its IPs.

How do I check if my domain can be spoofed?

Start by reading the raw DNS records: query the TXT record at your domain for SPF, at _dmarc.yourdomain for DMARC, and at selector._domainkey.yourdomain for DKIM. The decisive questions are whether DMARC is published with an enforcing policy (quarantine or reject rather than none), whether SPF and DKIM actually align with your visible From domain, and whether your SPF stays within the ten-lookup limit. A domain with no DMARC record, or one stuck at p=none, can be spoofed today regardless of how good its SPF and DKIM look. Checking all of this by hand is error-prone, so the practical answer is to run an automated check. The SecScan Email/DMARC checker inspects all three records, tests alignment and your policy strength, and flags exactly where a spoofer could slip through.

Related guides

See your whole external attack surface

One page is a start. The full external scan covers TLS, headers, DNS, exposed files, open services and known-exploited CVEs across your whole domain.

See the full scan →