SPF, DKIM, and DMARC Explained for Email Marketers
Why Authentication Is the Foundation of Deliverability
You can have the most beautifully designed HTML email in the world — perfectly rendered in every client, precisely targeted to your audience, with copy that converts at industry-best rates — and none of that matters if the email lands in spam. Email authentication is the infrastructure layer that tells mailbox providers your email is legitimate, not a phishing attempt or spam campaign hijacking your domain.
SPF, DKIM, and DMARC are the three authentication standards that comprise modern email authentication. Each addresses a different angle of the "is this email really from who it claims to be from?" question. Understanding all three is essential for anyone serious about email deliverability.
This guide explains each standard in plain language, walks you through configuration, and describes how to verify your setup is working correctly.
SPF: Sender Policy Framework
What Is SPF?
SPF allows you to specify which mail servers are authorized to send email on behalf of your domain. It works through a DNS TXT record that lists the IP addresses and hostnames permitted to send from your domain.
When a receiving mail server gets an email claiming to be from you, it looks up your SPF record and checks whether the sending server's IP address is on the authorized list. If it is, SPF passes. If it's not, SPF fails — which is a signal that the email may be spoofed or unauthorized.
How to Set Up SPF
An SPF record is a DNS TXT record published at your domain (or subdomain). Here's a typical SPF record:
v=spf1 include:_spf.google.com include:_spf.mailchimp.com ~all
Breaking this down:
v=spf1— identifies this as an SPF recordinclude:_spf.google.com— authorizes Google's mail servers (if you use Google Workspace)include:_spf.mailchimp.com— authorizes Mailchimp's servers (if you send via Mailchimp)~all— "soft fail" for anything not on the list (use-allfor a "hard fail")
Get the correct include value from each service you send email through. Every ESP provides documentation with their SPF include mechanism. Add an include for each ESP, transactional email service, or mail server that sends on behalf of your domain.
SPF Limitations
SPF has a lookup limit of 10 DNS queries. Include too many services and SPF lookups start failing. If you send through many services, consolidate where possible or use an SPF flattening service that resolves all includes to direct IP ranges.
SPF also only validates the sending server's IP against the "envelope from" domain — not the "From" address displayed to the user. This distinction matters for DMARC alignment, discussed below.
DKIM: DomainKeys Identified Mail
What Is DKIM?
DKIM adds a cryptographic signature to your emails that proves the email content hasn't been altered in transit and that it originated from a server authorized by your domain. It works using public key cryptography:
- You publish a public key as a DNS TXT record at a designated subdomain of your domain.
- Your mail server signs outgoing emails with the corresponding private key.
- Receiving servers verify the signature using your public key from DNS.
If the signature verifies correctly, DKIM passes. If the email has been tampered with in transit, or if it wasn't signed by an authorized server, DKIM fails.
How to Set Up DKIM
DKIM setup is done through your ESP or mail server — they generate the key pair and provide you the DNS record to publish. For example, in Google Workspace:
- Go to Admin console > Apps > Google Workspace > Gmail > Authenticate email
- Click "Generate new record" to create your DKIM key pair
- Google provides a DNS record like:
google._domainkey.yourdomain.com TXT "v=DKIM1; k=rsa; p=[public key]" - Add this TXT record to your domain's DNS
- Wait for DNS propagation (up to 48 hours), then click "Start Authentication"
Each service you use to send email should have its own DKIM signature. Follow the DKIM setup instructions for each ESP individually. Mailchimp, Klaviyo, HubSpot, and SendGrid all have straightforward DKIM configuration documentation.
DKIM Record Structure
A DKIM record is published at a "selector._domainkey.yourdomain.com" subdomain. The selector is usually provided by your ESP (e.g., "mandrill" for Mandrill, "k1" for Klaviyo). The record itself contains the version, key type, and the public key value.
DMARC: Domain-based Message Authentication Reporting and Conformance
What Is DMARC?
DMARC builds on top of SPF and DKIM to give you explicit control over what happens when authentication fails, and to send you reports about authentication activity for your domain.
A DMARC policy tells receiving mail servers: "If an email claiming to be from my domain fails authentication, here's what to do with it — nothing, quarantine it (spam folder), or reject it entirely." It also specifies where to send aggregate and forensic authentication reports.
DMARC Alignment
DMARC requires "alignment" — the domain in the visible From: header must match (or align with) the domain that passed SPF or DKIM. This closes the loophole where a spammer could use a legitimate mail server (passing SPF) but put a spoofed domain in the From: field.
DMARC Policy Options
p=none— Monitor mode. Receive reports but take no action on failures. Start here.p=quarantine— Failing emails go to the spam folder.p=reject— Failing emails are rejected and never delivered.
Setting Up DMARC
Publish a DNS TXT record at _dmarc.yourdomain.com:
v=DMARC1; p=none; rua=mailto:dmarc-reports@yourdomain.com; ruf=mailto:dmarc-forensics@yourdomain.com; sp=none; adkim=r; aspf=r;
Start with p=none and review the aggregate reports (rua) for 2-4 weeks. The reports show you who is sending email on behalf of your domain, whether their SPF and DKIM are passing, and from which IP addresses. Once you're confident all legitimate sending sources are properly authenticated, move to p=quarantine, then eventually to p=reject.
DMARC Reporting Services
DMARC aggregate reports come as XML files, which aren't human-readable. Free services like Postmark's DMARC tool, dmarcian, or Valimail parse these reports and present them in a usable dashboard. Sign up for one before enabling DMARC reporting to actually make use of the data.
Verifying Your Setup
After configuring SPF, DKIM, and DMARC, verify they're working:
- MXToolbox: Free tools at mxtoolbox.com to check SPF, DKIM, and DMARC records. Run "SuperTool" on your domain to see all email-related DNS records.
- Google Postmaster Tools: If you send to Gmail addresses, Google's Postmaster Tools shows your authentication pass rates, spam rates, and domain reputation. This is perhaps the most valuable tool for diagnosing deliverability issues.
- Send a test email and check headers: Send a test email to a Gmail or Yahoo address and view the raw headers. Look for "dkim=pass", "spf=pass", and "dmarc=pass" in the "Authentication-Results" header. If any show "fail", there's a misconfiguration to investigate.
Your email design and content matter — but if your authentication isn't properly configured, even the best HTML email won't reliably reach inboxes. Get these fundamentals right first, then focus on the experience you're delivering to subscribers who actually receive your messages.