SPF, DKIM, and DMARC: The Complete Email Authentication Guide
Master email authentication with this comprehensive guide to SPF, DKIM, and DMARC. Learn how these protocols work together to secure your email delivery.

Introduction
Email authentication isn't a single technology—it's a three-layer security system. SPF, DKIM, and DMARC work together like locks on a door, each adding a different type of protection.
This comprehensive guide explains all three protocols, how they complement each other, and how to implement them correctly. By the end, you'll understand the complete email authentication stack and why each piece matters.
The Email Trust Problem
Email was designed in the 1970s without built-in security. The original protocol (SMTP) has no way to verify that an email actually came from the domain it claims to be from.
This creates serious problems:
- Phishing: Scammers impersonate banks, colleagues, or trusted brands
- Spoofing: Anyone can send emails claiming to be from your domain
- Spam: Mass mailers forge sender addresses to evade filters
- Fraud: Business Email Compromise (BEC) attacks cost companies billions annually
SPF, DKIM, and DMARC were developed to solve these problems. Each addresses a different aspect of email authentication.
SPF: Sender Policy Framework
What SPF Does
SPF answers the question: "Is this server authorized to send email from this domain?"
Think of SPF as a guest list for a private event. You publish a list of IP addresses and servers allowed to send email from your domain. When an email arrives, the receiving server checks if the sender's IP is on your list.
How SPF Works
You publish an SPF record in your domain's DNS:
v=spf1 ip4:192.0.2.1 include:_spf.google.com ~allAn email is sent from your domain
Receiving server checks if the sender's IP matches your SPF record
Result: Pass, Fail, or SoftFail
SPF Record Breakdown
Let's decode a typical SPF record:
v=spf1 ip4:192.0.2.1 include:_spf.google.com include:mailgun.org ~allv=spf1: This is an SPF version 1 recordip4:192.0.2.1: Allow this specific IP addressinclude:_spf.google.com: Include Google Workspace's authorized serversinclude:mailgun.org: Include Mailgun's authorized servers~all: SoftFail anything else (treat as suspicious but don't reject)
SPF Mechanisms Explained
Direct IP authorization:
ip4:192.0.2.1- Specific IPv4 addressip6:2001:db8::1- Specific IPv6 addressip4:192.0.2.0/24- IP range
Domain-based authorization:
a- Servers listed in the domain's A recordmx- Servers listed in the domain's MX recordinclude:domain.com- Use another domain's SPF record
Final qualifier (all):
+all- Allow everything (dangerous, don't use)~all- SoftFail (recommended for most)-all- HardFail (strict, reject unauthorized)?all- Neutral (don't care)
Common SPF Mistakes
1. Too Many DNS Lookups
SPF has a limit of 10 DNS lookups. Each include, a, or mx mechanism counts as a lookup.
❌ Wrong (15 lookups, will fail):
v=spf1 include:spf1.com include:spf2.com include:spf3.com
include:spf4.com include:spf5.com include:spf6.com
include:spf7.com include:spf8.com include:spf9.com
include:spf10.com include:spf11.com -all✅ Better (use SPF flattening or remove unused services):
v=spf1 include:_spf.google.com include:spf.protection.outlook.com
ip4:192.0.2.0/24 -all2. Multiple SPF Records
You can only have ONE SPF record per domain. Multiple records will cause all of them to fail — including the one that was working before you added the second. See Multiple SPF Records: Why Two Break Your Email for how to merge them into one.
3. Forgetting Third-Party Senders
If you use services like Mailchimp, SendGrid, or support systems that send email from your domain, you must include them in your SPF record. The reverse also matters: services that only receive or forward mail to you do not belong in SPF at all.
Testing Your SPF Record
Check your SPF configuration:
- Use our SPF Checker tool
- Command line:
dig yourdomain.com TXT - Send a test email and check headers
DKIM: DomainKeys Identified Mail
What DKIM Does
DKIM answers the question: "Has this email been tampered with since it was sent?"
Think of DKIM as a wax seal on a letter. It proves the message came from you and hasn't been altered in transit.
How DKIM Works
Your email server adds a digital signature to every outgoing email using a private key
You publish the public key in your DNS records
Receiving servers verify the signature using your public key
If the signature is valid, the email hasn't been tampered with
DKIM Technical Flow
Sending:
Email created → DKIM signature added → Email sent
(using private key)Receiving:
Email arrives → Extract DKIM signature → Look up public key in DNS
→ Verify signature → Pass or FailDKIM Record Example
DNS Record (at selector._domainkey.yourdomain.com):
v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC...v=DKIM1: DKIM version 1k=rsa: Uses RSA encryptionp=...: The public key (truncated here)
DKIM Selectors
The "selector" is a name you choose to identify different DKIM keys. This allows key rotation and multiple keys for different purposes.
Common selectors:
google(Google Workspace)selector1,selector2(Microsoft 365)default(many providers)- Custom:
mail,k1,dkim
To check a DKIM record:
dig selector._domainkey.yourdomain.com TXTDKIM Best Practices
1. Use 2048-bit Keys
Longer keys are more secure. Many providers now recommend 2048-bit over 1024-bit keys.
2. Rotate Keys Regularly
Change your DKIM keys every 6-12 months. Use selectors to manage rotation:
- Publish new key with new selector
- Update email server to sign with new key
- Remove old key after propagation
3. Sign All Outgoing Email
Configure your email server to sign all messages, not just some.
4. Monitor DKIM Failures
Use DMARC reports to identify when DKIM signatures are failing.
Common DKIM Issues
Problem: DKIM signature invalid
- Cause: Email was modified in transit (often by mailing lists)
- Solution: Check with email provider, verify DNS record is correct
Problem: DKIM record not found
- Cause: Wrong selector, DNS not propagated, or not configured
- Solution: Verify selector name and DNS record
Problem: Key length too short
- Cause: Using 1024-bit keys
- Solution: Upgrade to 2048-bit keys
DMARC: Domain-based Message Authentication
What DMARC Does
DMARC answers the question: "What should I do if SPF or DKIM fails?"
DMARC ties SPF and DKIM together and tells receiving servers what to do with emails that fail authentication.
Think of DMARC as the supervisor who enforces your security policies and sends you daily reports.
How DMARC Works
- You publish a DMARC policy in DNS
- Email is sent from your domain
- Receiving server checks SPF and DKIM
- DMARC verifies alignment (does the "From" domain match?)
- Server applies your policy (none, quarantine, or reject)
- Reports are sent to you daily
DMARC Record Example
v=DMARC1; p=reject; rua=mailto:dmarc@yourdomain.com;
ruf=mailto:forensic@yourdomain.com; fo=1; adkim=r; aspf=rLet's decode each tag:
v=DMARC1: DMARC version 1p=reject: Policy—reject emails that failrua=mailto:...: Send aggregate reports to this addressruf=mailto:...: Send forensic (failure) reports herefo=1: Forensic reporting optionsadkim=r: DKIM alignment mode (relaxed)aspf=r: SPF alignment mode (relaxed)
DMARC Policies Explained
p=none (Monitor Mode)
v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com- Effect: No enforcement, just send reports
- Use case: Initial setup, monitoring
- Duration: 2-4 weeks minimum
p=quarantine (Soft Enforcement)
v=DMARC1; p=quarantine; rua=mailto:dmarc@yourdomain.com- Effect: Send failing emails to spam/junk
- Use case: Gradual rollout
- Duration: 2-4 weeks before moving to reject
p=reject (Full Enforcement)
v=DMARC1; p=reject; rua=mailto:dmarc@yourdomain.com- Effect: Block failing emails completely
- Use case: Maximum protection
- Requirement: All legitimate senders must be authenticated
DMARC Alignment: The Critical Piece
DMARC doesn't just check if SPF/DKIM pass—it checks alignment.
Alignment means the domain in the "From" header matches the domain that passed SPF or DKIM.
Example of misalignment:
- Email "From" header:
user@yourdomain.com - SPF passes for:
mailserver.vendordomain.com - Result: SPF passes but DMARC fails (no alignment)
Two alignment modes:
Relaxed (r): Only the Organizational Domains must match
mail.yourdomain.comaligns withyourdomain.com✓
Strict (s): Domains must match exactly
mail.yourdomain.comdoes NOT align withyourdomain.com✗
Most organizations use relaxed alignment (adkim=r; aspf=r).
DMARC Reports: Your Intelligence System
DMARC provides two types of reports:
Aggregate Reports (RUA)
- Sent daily by email providers
- XML format (difficult to read manually)
- Shows all email activity from your domain
- Includes pass/fail statistics
Forensic Reports (RUF)
- Sent immediately when email fails DMARC
- Contains samples of failed emails
- Privacy concerns—not widely adopted
- Most providers don't send them
What reports tell you:
- All services sending email from your domain
- Which emails are failing authentication
- Source IPs of unauthorized senders
- Your authentication success rate
How SPF, DKIM, and DMARC Work Together
The Authentication Flow
Email sent from yourdomain.com
↓
[SPF Check]
Is sender IP authorized?
↓
[DKIM Check]
Is signature valid?
↓
[DMARC Alignment]
Does "From" domain match?
↓
[DMARC Policy]
What to do if failed?
↓
Deliver / Quarantine / RejectThe Three Layers of Protection
Layer 1: SPF (Server Authorization)
- Verifies the sending server is authorized
- Prevents basic IP spoofing
- Limitations: Only checks envelope sender, not "From" header
Layer 2: DKIM (Content Integrity)
- Verifies email hasn't been modified
- Survives email forwarding (usually)
- Limitations: Doesn't verify sender authorization
Layer 3: DMARC (Policy Enforcement)
- Requires SPF or DKIM alignment
- Enforces what to do with failures
- Provides visibility through reports
Why You Need All Three
SPF alone:
- Protects against basic spoofing
- Easily broken by forwarding
- No visibility into failures
SPF + DKIM:
- Stronger authentication
- Better deliverability
- Still no enforcement or reporting
SPF + DKIM + DMARC:
- Complete protection
- Enforcement of your policy
- Daily reports on email activity
- Industry standard compliance
Implementation Roadmap
Phase 1: SPF (Week 1)
- Audit all services sending email from your domain
- Create SPF record with all authorized senders
- Start with
~all(soft fail) - Test with email headers
- Monitor for issues
- Move to
-allwhen confident
Phase 2: DKIM (Week 2)
- Enable DKIM in your email provider
- Publish DKIM public key in DNS
- Verify signatures on outgoing email
- Add DKIM for all third-party senders
- Test with multiple recipients
Phase 3: DMARC Monitoring (Weeks 3-6)
- Create DMARC record with
p=none - Set up report collection email
- Monitor reports for 2-4 weeks
- Identify all legitimate senders
- Fix any authentication issues
Phase 4: DMARC Enforcement (Weeks 7-10)
- Move to
p=quarantine - Monitor for 2-4 weeks
- Address any legitimate email issues
- Move to
p=reject - Maintain ongoing monitoring
Tools and Testing
Checking Your Records
DMARC:
dig _dmarc.yourdomain.com TXTOr use: DMARC Checker Tool
SPF:
dig yourdomain.com TXTOr use: SPF Checker Tool
DKIM:
dig selector._domainkey.yourdomain.com TXTOr use: DKIM Checker Tool
Complete Domain Analysis
Get a comprehensive security score: Domain Score Tool
Reading Email Headers
Send yourself a test email and check the headers for authentication results:
Authentication-Results: mx.google.com;
dkim=pass header.i=@yourdomain.com;
spf=pass smtp.mailfrom=yourdomain.com;
dmarc=pass (p=REJECT)Troubleshooting Common Issues
Problem: SPF lookup limit exceeded
Symptoms: SPF fails with "too many DNS lookups" Solution: Use SPF flattening or remove unused includes Read more: SPF Too Many DNS Lookups Guide
Problem: DKIM signature invalid
Symptoms: DKIM fails validation Solution: Check key length, selector, and DNS propagation Read more: DKIM Signature Invalid Troubleshooting
Problem: DMARC alignment failed
Symptoms: SPF/DKIM pass but DMARC fails Solution: Verify "From" domain matches authenticated domain Read more: DMARC Alignment Failed Solutions
Problem: Legitimate emails going to spam
Symptoms: After enabling DMARC, some real emails are blocked
Solution: Review DMARC reports, fix authentication for affected services
Temporary fix: Lower policy to p=none while investigating
Industry Requirements
Gmail and Yahoo (2024 Requirements)
As of February 2024, Gmail and Yahoo require:
- SPF and DKIM authentication
- DMARC policy (at minimum
p=none) - One-click unsubscribe for bulk senders
- Spam rate below 0.3%
Read full details: Gmail & Yahoo 2024 Requirements
Compliance Standards
Many compliance frameworks require or recommend email authentication:
- PCI-DSS: Email security controls
- HIPAA: Protection of electronic communications
- CMMC: Email authentication required
- GDPR: Security of personal data in emails
Advanced Topics
Subdomain Policies
You can set different DMARC policies for subdomains:
v=DMARC1; p=reject; sp=quarantine; rua=mailto:dmarc@yourdomain.comp=reject: Main domain policysp=quarantine: Subdomain policy
RFC 9989 adds np, the policy for subdomains that do not exist in DNS (for example np=reject).
Testing Mode (t=y)
RFC 9989 (May 2026) removes the old pct tag and adds t=y for cautious rollouts:
v=DMARC1; p=reject; t=y; rua=mailto:dmarc@yourdomain.comReceivers that implement RFC 9989 apply the policy one level below the published one: here, p=quarantine. Receivers that do not know t ignore it and apply p=reject.
BIMI: Brand Indicators for Message Identification
Once you have DMARC at p=quarantine or p=reject, you can implement BIMI to display your logo in email clients:
- Requires DMARC enforcement
- Needs verified mark certificate (VMC)
- Supported by Gmail, Yahoo, others
The Bottom Line
Email authentication isn't optional anymore—it's a fundamental requirement for email deliverability and security in 2025.
Key takeaways:
- SPF authorizes servers to send from your domain
- DKIM verifies email integrity with cryptographic signatures
- DMARC enforces policies and provides reporting
- All three work together to create a complete authentication system
- Start with monitoring (
p=none) before enforcing - DMARC reports are essential for visibility
- Gmail and Yahoo now require authentication for bulk senders
The implementation process takes 6-10 weeks but protects your domain, improves deliverability, and builds trust with your recipients.
Next Steps
Ready to implement complete email authentication?
- Check your current configuration: Domain Score Tool
- Verify each protocol:
- Get automated monitoring: Start free trial for DMARC report analysis and alerts
Need expert guidance? Our platform provides step-by-step implementation guides and automated DMARC report parsing.
Related Articles:
- SPF Record Syntax Explained, With Examples
- What Is a DKIM Record? Format, Examples and Lookup
- DMARC Record Examples: 10 Ready-to-Use TXT Records
- What is DMARC? A Simple Guide for Non-Technical People
- DMARC Implementation Timeline: From p=none to p=reject
- Why Your Emails Are Going to Spam (And How to Fix It)
- An affordable dmarcian alternative for ongoing monitoring (DMARC Examiner vs dmarcian).
- An affordable EasyDMARC alternative — same comparison, applied to EasyDMARC.
- A PowerDMARC alternative — hosted services compared against price per domain.
Ready to improve your email deliverability?
Start monitoring your DMARC reports and get insights into your email authentication setup.
Start Free TrialRelated Articles
getting startedSPF Record Syntax Explained, With Examples
A complete reference to Sender Policy Framework syntax: every mechanism, qualifier and modifier, how receivers evaluate an SPF record, and copy-ready SPF record examples for common setups.
getting startedWhat Is a DKIM Record? Format, Examples and How to Check It
A DKIM record is a DNS TXT record that publishes the public key receivers use to verify your email signatures. Learn the record format, every tag, real DKIM record examples and how to do a DKIM lookup.
getting startedDMARC Record Examples: 10 Ready-to-Use TXT Records
Copy-ready DMARC TXT record examples for monitoring, quarantine, reject, subdomains, parked domains and external reporting, with every tag explained under RFC 9989 and how to do a DMARC lookup.