SPF, DKIM, and DMARC Explained: Complete Email Authentication Guide
Direct Answer: SPF (Sender Policy Framework), DKIM (DomainKeys Identified Mail), and DMARC (Domain-based Message Authentication, Reporting, and Conformance) form the three-pillar technical foundation of modern email authentication. SPF specifies which servers can send from your domain, DKIM proves message integrity using public-key cryptography, and DMARC connects them by verifying that the visible sender matches the authenticated domain while specifying what receiving servers should do if checks fail.
What Email Authentication Is and Why It Matters
When the original Simple Mail Transfer Protocol (SMTP, RFC 821) was designed in 1982, it lacked any identity verification mechanism. Any computer connected to the ARPANET could connect to port 25 and declare MAIL FROM: <[email protected]> without challenge. As commercial internet adoption exploded, this vulnerability led to widespread phishing, domain impersonation, and fraudulent wire scams.
Email authentication protocols add cryptographic proof and DNS-based authorization to SMTP transactions. Today, mailbox providers like Google, Yahoo, and Microsoft reject or quarantine incoming emails that lack valid authentication records.
SPF (Sender Policy Framework): How IP Authorization Works
SPF (defined in RFC 7208) allows a domain owner to publish a public DNS TXT record declaring which IP addresses and third-party mail relays are authorized to send mail using their domain in the envelope sender (the Return-Path or HELO/EHLO identity).
Example SPF Record Syntax
v=spf1 include:_spf.google.com include:sendgrid.net ip4:192.0.2.1/24 ~all
v=spf1: The mandatory SPF version identifier.include:: Recursively includes the SPF policy of an authorized ESP or SaaS partner.ip4:: Authorizes a specific dedicated IPv4 address or CIDR range.~all(SoftFail): Informs receiving servers that unlisted IPs should be marked with a soft failure header, but not dropped immediately. (Strict-allHardFail is also supported).
RFC 7208 mandates that evaluating an SPF record must not exceed 10 DNS queries. Each include, a, mx, or redirect statement consumes at least one lookup. Exceeding 10 results in an immediate PermError.
DKIM (DomainKeys Identified Mail): Cryptographic Signatures
While SPF authenticates the sending server's IP address, it provides zero protection if an intermediary mail server modifies the message content during transit. DKIM (defined in RFC 6376) provides cryptographic non-repudiation and body tamper-proofing.
How DKIM works:
- The domain owner generates a public/private cryptographic key pair (modern standard is 2048-bit RSA or Ed25519).
- The public key is published in DNS under a specific selector at
[selector]._domainkey.domain.com. - When an email is dispatched, the sending MTA calculates a hash of the headers and body, encrypts the hash with the private key, and embeds it into the
DKIM-Signatureheader:
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=company.com; s=s1; t=1707038400;
h=from:to:subject:date:message-id;
bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=;
b=dB...gQ==
The receiving mail server retrieves the public key from DNS, decrypts the signature, recalculates the message hash, and confirms that the message was not modified in transit.
DMARC: Policy Enforcement & Alignment
Before DMARC (RFC 7489), an attacker could authenticate an email using their own domain via SPF or DKIM, while setting the visible human-facing From: header to paypal.com. SPF and DKIM alone could not stop this spoofing.
DMARC solves this by requiring Identifier Alignment: the domain shown in the visible From: header must match (or align with) the domain verified by SPF and/or DKIM.
Example DMARC Record Syntax
v=DMARC1; p=quarantine; rua=mailto:[email protected]; pct=100; aspf=r; adkim=r
p=none: Monitoring mode. Receivers take no action on failed messages but send diagnostic reports.p=quarantine: Receivers route unauthenticated messages directly to the Spam/Junk folder.p=reject: Receivers reject unauthenticated messages outright at the SMTP boundary.rua=: Specifies the email address that receives daily aggregate XML diagnostic reports.
Strict vs. Relaxed Alignment Explained
DMARC supports two alignment modes:
- Relaxed Alignment (
r, default): The organizational domain must match. For example, mail sent fromnews.company.comaligns with aFrom:address ofcompany.com. - Strict Alignment (
s): Requires an exact Fully Qualified Domain Name (FQDN) match between theFrom:header and the authenticated identity.
Common DNS Configuration Mistakes to Avoid
- Publishing Multiple SPF Records: Having two separate
v=spf1records invalidates both. - Typing Errors in DKIM Public Keys: Truncating the base64 string when copying into DNS management consoles.
- Failing to Set Up DMARC Aggregate Mailboxes: Leaving out
rua=means you receive zero visibility into deliverability failures or spoofing attacks. - Prematurely Setting
p=reject: Jumping straight to reject before auditing all legitimate third-party sending services (CRMs, ticketing systems, ESPs).
How to Check Your Live Authentication Results
Send a test email to a personal Gmail account, click the three-dots menu in the web interface, and select "Show original". Review the top diagnostic summary:
SPF: PASS with IP 192.0.2.1DKIM: 'PASS' with domain company.comDMARC: 'PASS'
Ensure Sender Compliance and List Health
Authenticating your domain is step one. Step two is ensuring you only send to deliverable, high-reputation inboxes. Use Emails Verification to validate syntax, MX records, and mailboxes before sending.
Check Developer API Documentation ➔Frequently Asked Questions
Can I have multiple SPF TXT records on a single domain?
No. RFC 7208 explicitly forbids having more than one SPF TXT record on a single domain name or hostname. If you publish multiple SPF records, destination mail servers will treat your SPF configuration as PermError (permanent failure), causing authentication to fail. You must combine all authorized includes into a single record.
What is the 10 DNS lookup limit in SPF?
RFC 7208 limits SPF evaluations to a maximum of 10 nested DNS lookup mechanisms (such as include, a, mx, ptr, and exists) to prevent denial-of-service amplification attacks. Exceeding 10 lookups causes an automatic SPF PermError. Always audit your SPF includes to stay within the limit.
Does having a DMARC policy of p=none protect my domain from spoofing?
No. A policy of p=none (monitoring mode) only instructs receivers to send you aggregate diagnostic reports; it tells them to deliver unauthorized emails anyway. To actively protect your brand and domain from phishing and spoofing, you must advance your policy to p=quarantine or p=reject once your legitimate sending sources are aligned.