Protocol Security9 min read
Demystifying SPF, DKIM, and DMARC: How Email Authentication Works Under the Hood
A comprehensive technical breakdown of DNS email security protocols and why MX isolation is crucial for deliverability.
Marcus Vance, Systems Administrator
Published on 2026-10-21
The Legacy Architecture of SMTP
The Simple Mail Transfer Protocol (SMTP), designed in the 1980s under RFC 821, was built on an implicit assumption of network trust. In the original SMTP specification, any computer connected to the internet could connect to port 25 of another server and claim to be sending an email from[email protected] or [email protected].Because the raw protocol lacked native authentication, the internet suffered decades of rampant identity spoofing, phishing, and CEO wire-transfer fraud. To fix this fundamental architectural flaw without breaking backward compatibility, the cybersecurity community engineered a triumvirate of DNS-backed authentication standards: **SPF**, **DKIM**, and **DMARC**.1. SPF (Sender Policy Framework - RFC 7208)
SPF is a DNS TXT record published on the sender's domain that declares which IP addresses are authorized to dispatch outbound email on behalf of that domain.#How SPF Works:
# Example SPF record for example.com
example.com. IN TXT "v=spf1 ip4:198.51.100.24 ip4:203.0.113.0/24 include:_spf.google.com -all"
When a receiving mail exchanger (like SafePassMail's Postfix server) accepts an incoming connection from IP 198.51.100.24, it inspects the sender's Return-Path (envelope-from domain). It performs a DNS lookup on example.com. If the connecting IP matches the published SPF list, the message achieves **SPF PASS**. If an unauthorized IP attempts delivery, the policy flags a **SoftFail** (~all) or **HardFail** (-all).2. DKIM (DomainKeys Identified Mail - RFC 6376)
While SPF verifies the connecting IP address, it cannot verify whether the email's body was altered in transit by an intermediate proxy. DKIM solves this using **asymmetric cryptography**.#How DKIM Works:
1. **Key Generation:** The sending server generates a public-private RSA or Ed25519 key pair. The public key is published in DNS under a selector subdomain (e.g.selector1._domainkey.example.com).
2. **Cryptographic Signing:** When an email is dispatched, the sending MTA calculates a SHA-256 hash of the headers and body, signs it with the private key, and injects a DKIM-Signature header:
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=example.com;
s=selector1; t=1697829100;
h=from:to:subject:date:content-type;
bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=;
b=dB/0K5R...
3. **Verification:** The receiving server retrieves the public key from DNS and verifies the mathematical signature. If even a single byte of the body was altered, the signature fails.3. DMARC (Domain-based Message Authentication, Reporting, and Conformance - RFC 7489)
SPF and DKIM operate independently. However, attackers quickly discovered a loophole: an attacker could pass SPF on their own domain (evil.com), but forge the user-visible From: header to display paypal.com.**DMARC bridges this gap through Alignment:**
DMARC mandates that the domain visible to the human user in the From: header must strictly align with the domain verified by SPF or DKIM.
# Example DMARC policy
_dmarc.example.com. IN TXT "v=DMARC1; p=reject; rua=mailto:[email protected]; pct=100"
- p=none: Monitor and report only (no enforcement).
- p=quarantine: Direct unaligned messages into spam/junk folders.
- p=reject: Command receiving servers to reject unaligned emails during the SMTP handshake.Why MX Isolation Is Critical for Disposable Email Platforms
A major vulnerability of amateur temporary email services is mixing their public website domain with their mail receiving domains. If a temporary email provider hosts both their web application and incoming mail ontempmailservice.com, any spammer sending abusive traffic can pollute the domain's reputation with Spamhaus and Google Postmaster Tools.At SafePassMail, we implement strict **Domain & MX Isolation**:
- **Primary Domain (safepassmail.com):** Dedicated solely to the Next.js web application and static assets. Protected by strict DMARC p=reject policies. Zero incoming or outgoing MX records exist on the primary domain.
- **Secondary Receiving Domains (inbox.safepassmail.net, burnpass.io):** Managed on independent Postfix clusters configured strictly for Inbound-Only reception with strict DKIM and SPF verification.This guarantees that our public web reputation remains 100% compliant with Google AdSense and search engine trust guidelines while delivering sub-second email reception.
MV
Written by Marcus Vance, Systems Administrator
Verified AuthorMarcus has 12+ years of experience administering enterprise mail exchangers, hardening Postfix/Dovecot daemons, and designing anti-spam filtering heuristics.
RHCE Linux CertifiedPostmaster SpecialistSpamhaus Threat Intelligence Contributor