Back to Blog
    Email Deliverability

    SPF, DKIM, and DMARC Explained: Email Authentication for Beginners

    EmailTestLab Team
    December 26, 2024
    5 min read
    spfdkimdmarcemail authenticationdeliverabilitydns

    SPF, DKIM, and DMARC Explained: Email Authentication for Beginners

    Email authentication might sound technical, but it's essential for getting your emails delivered. Without proper authentication, your emails are more likely to land in spam—or be rejected entirely.

    This guide explains SPF, DKIM, and DMARC in plain English, with step-by-step instructions.

    Why Email Authentication Matters

    Email authentication helps receiving servers verify that:

    1. You are who you claim to be
    2. Your email hasn't been tampered with
    3. You've authorized the sending server

    Without authentication:

    • 📧 Higher spam folder rates
    • 🚫 Emails may be rejected
    • ⚠️ Vulnerable to spoofing attacks

    With authentication:

    • ✅ Better inbox placement
    • 🛡️ Protection against phishing
    • 📈 Improved sender reputation

    The Three Pillars of Email Authentication

    1. SPF (Sender Policy Framework)

    What it does: Specifies which mail servers are allowed to send email on behalf of your domain.

    How it works:

    1. You add a DNS TXT record listing authorized servers
    2. Receiving server checks if the sending IP is in your list
    3. If yes → Pass. If no → Fail.

    Example SPF Record:

    v=spf1 include:_spf.google.com include:sendgrid.net ~all
    

    Breakdown:

    • v=spf1 - SPF version
    • include:_spf.google.com - Allow Google's servers
    • include:sendgrid.net - Allow SendGrid
    • ~all - Soft fail for all other servers

    SPF Qualifiers:

    • +all - Allow all (never use this!)
    • -all - Hard fail unauthorized servers
    • ~all - Soft fail (recommended while testing)
    • ?all - Neutral (no assertion)

    2. DKIM (DomainKeys Identified Mail)

    What it does: Adds a digital signature to your emails that proves they haven't been modified.

    How it works:

    1. Your email server signs the email with a private key
    2. Public key is published in your DNS
    3. Receiving server uses the public key to verify the signature

    Example DKIM DNS Record:

    selector._domainkey.yourdomain.com TXT "v=DKIM1; k=rsa; p=MIGfMA0GCS..."
    

    Breakdown:

    • selector - Identifies which key to use (set by your email provider)
    • v=DKIM1 - DKIM version
    • k=rsa - Key type
    • p=... - Your public key

    Where to get your DKIM key:

    • Your email service provider (ESP) generates it
    • Add the provided DNS record to your domain

    3. DMARC (Domain-based Message Authentication, Reporting & Conformance)

    What it does: Tells receiving servers what to do when SPF or DKIM fails, and sends you reports.

    How it works:

    1. Email is checked against SPF and DKIM
    2. DMARC policy determines action on failure
    3. Reports are sent to your specified email

    Example DMARC Record:

    _dmarc.yourdomain.com TXT "v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com"
    

    Breakdown:

    • v=DMARC1 - DMARC version
    • p=none - Policy (none/quarantine/reject)
    • rua=mailto:... - Where to send aggregate reports

    DMARC Policies:

    • p=none - Monitor only, no action
    • p=quarantine - Send to spam
    • p=reject - Block the email

    Recommended progression:

    1. Start with p=none to collect data
    2. Move to p=quarantine after fixing issues
    3. Eventually use p=reject for full protection

    Step-by-Step Setup Guide

    Step 1: Check Current Authentication

    Before making changes, check your current status:

    1. Send a test email
    2. Check email headers for authentication results
    3. Use EmailTestLab to verify SPF, DKIM, and DMARC

    Step 2: Set Up SPF

    1. Identify all services that send email as your domain:

      • Email marketing platforms (Mailchimp, SendGrid, etc.)
      • CRM systems
      • Transactional email services
    2. Create your SPF record:

    v=spf1 include:[provider1] include:[provider2] ~all
    
    1. Add to DNS as a TXT record:
      • Host: @ (root domain)
      • Type: TXT
      • Value: Your SPF record

    Step 3: Set Up DKIM

    1. Get DKIM records from your ESP:

      • Most providers have a settings page for this
      • They'll give you DNS records to add
    2. Add DNS records:

      • Usually a CNAME or TXT record
      • Selector name varies by provider
    3. Enable DKIM signing:

      • Some providers do this automatically
      • Others require you to toggle it on

    Step 4: Set Up DMARC

    1. Start with monitoring:
    v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com
    
    1. Add DNS record:

      • Host: _dmarc
      • Type: TXT
      • Value: Your DMARC record
    2. Monitor reports for 2-4 weeks

    3. Gradually increase enforcement:

    v=DMARC1; p=quarantine; pct=25; rua=mailto:dmarc@yourdomain.com
    

    Common Authentication Problems

    Problem: SPF "Too Many DNS Lookups"

    SPF allows maximum 10 DNS lookups. If you exceed this:

    Solution:

    • Use ip4: and ip6: directly where possible
    • Flatten your SPF record using online tools
    • Consider SPF macro syntax for advanced setups

    Problem: DKIM Signature Invalid

    Common causes:

    • Email content was modified in transit
    • Wrong selector in DNS
    • Key mismatch

    Solution:

    • Verify DNS record matches ESP settings
    • Check for email forwarding services modifying content

    Problem: DMARC Reports Show Failures

    Solution:

    • Identify unauthorized senders in reports
    • Add legitimate senders to SPF
    • Set up DKIM for all sending services

    Testing Your Authentication

    Manual testing is time-consuming. EmailTestLab automatically checks your email authentication:

    • ✅ SPF record validation
    • ✅ DKIM signature verification
    • ✅ DMARC policy checking
    • ✅ Clear pass/fail indicators

    Check Your Email Authentication →


    Quick Reference

    Record Purpose Example Host
    SPF Authorize senders @
    DKIM Sign emails selector._domainkey
    DMARC Set policy _dmarc

    Conclusion

    Email authentication is crucial for deliverability. Here's your action plan:

    1. Set up SPF - List all authorized senders
    2. Configure DKIM - Add signatures to your emails
    3. Implement DMARC - Start with p=none and monitor
    4. Test regularly - Verify your setup works

    Verify your email authentication instantly with EmailTestLab - see your SPF, DKIM, and DMARC status in seconds.

    EmailTestLab Team

    Helping you send better emails with comprehensive testing and validation.

    Ready to Test Your Emails?

    Run 13+ quality checks, preview in 6 email clients, and catch issues before your subscribers do.

    Start Testing Free