Skip to main content
CybersecurityJuly 26, 202614 min read

Complete SPF, DKIM, and DMARC Email Security Setup Guide for 2026

Rudra Chauhan, Senior Systems Architect

Complete SPF, DKIM, and DMARC Email Security Setup Guide for 2026

Complete SPF, DKIM, and DMARC Email Security Setup Guide for 2026

Email spoofing and phishing remain the primary initial access vector for cyber attacks. In 2024–2026, major mailbox providers like Google, Yahoo, and Microsoft enforce strict DMARC authentication requirements for bulk and transactional email senders.

Without valid SPF, DKIM, and DMARC records, your domain's outgoing emails will be rejected or sent straight to the recipient's spam folder.

Email Authentication: A Primer

Email authentication protocols ensure the integrity and authenticity of email messages. The primary protocols are:

ProtocolFull NameFunctionDNS Record Type
SPFSender Policy FrameworkSpecifies which IP addresses & servers are authorized to send mail for your domainTXT
DKIMDomainKeys Identified MailAdds a cryptographic digital signature to email headers to verify message integrityTXT
DMARCDomain-based Message AuthenticationInstructs recipient servers how to handle emails failing SPF/DKIM alignmentTXT

The Email Authentication Triad Explained

Each protocol plays a crucial role in ensuring email security:

  • SPF verifies the sender's IP address and domain.
  • DKIM ensures the message's integrity and authenticity.
  • DMARC enforces alignment between SPF and DKIM records.

Step 1: Configuring Sender Policy Framework (SPF)

An SPF record is a DNS TXT record published at your apex domain (example.com):

dns
v=spf1 include:_spf.google.com include:sendgrid.net ip4:192.0.2.1 -all

Key Directives:

  • v=spf1: Identifies record version.
  • include:: Authorizes third-party senders (Google Workspace, SendGrid, Mailchimp).
  • ip4:: Explicitly authorizes specific server IPv4 addresses.
  • -all: Hard Fail — reject mail from unauthorized IPs.
  • ~all: Soft Fail — accept mail but mark as suspicious.

CRITICAL RULE: An SPF record must not cause more than 10 DNS lookups (RFC 7208). Exceeding 10 lookups results in a PermError.

Step 2: Setting Up DKIM (DomainKeys Identified Mail)

DKIM uses public-key cryptography. The sending mail server attaches a header signature (DKIM-Signature), and recipient servers retrieve your public key from DNS:

dns
# Selector record: google._domainkey.example.com
v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQ...

Step 3: Enforcing DMARC Policies

DMARC unites SPF and DKIM authentication results. Publish a TXT record at _dmarc.example.com:

dns
v=DMARC1; p=reject; rua=mailto:dmarc-reports@example.com; ruf=mailto:dmarc-forensics@example.com; pct=100

DMARC Policy Levels (p=):

  • p=none: Monitoring mode only. Collect aggregate reports without blocking mail.
  • p=quarantine: Direct failing emails to the Spam/Junk folder.
  • p=reject: Hard block — reject failing emails at the gateway level.

Troubleshooting Checklist

  • Verify SPF, DKIM, and DMARC records are correctly configured.
  • Ensure SPF records do not exceed 10 DNS lookups.
  • Validate DKIM key pairs and selector records.
  • Test DMARC policies with email authentication tools.

Frequently Asked Questions

  • Q: What is the purpose of SPF records?
  • A: SPF records specify authorized IP addresses and servers for sending mail from your domain.
  • Q: What is the difference between SPF and DKIM?
  • A: SPF verifies the sender's IP address and domain, while DKIM ensures message integrity and authenticity.
  • Q: What is the purpose of DMARC records?
  • A: DMARC records enforce alignment between SPF and DKIM records, ensuring email security.

Free Email Security Utilities on Teksolvr

Build and audit your email DNS records with Teksolvr tools:

References

Image Credits

  • Diagram Name

    Diagram Name

Additional Resources

Was this guide helpful?

Troubleshooting or testing this guide?

Teksolvr provides 97 free tools to help you inspect DNS configs, validate DKIM certificates, test port openings, check server blacklists, and run calculations.