Email Protocols
SMTP, IMAP, POP3, SPF, DKIM, DMARC — the aging but critical infrastructure that delivers 300 billion emails daily, and the security stack bolted on to stop most of it from being spam.
// Chapter 1
The Oldest Living Protocol
Story
1971. Ray Tomlinson sends the first network email between two machines on ARPANET. He picks the @ symbol to separate user from host — a completely arbitrary choice that became one of the most recognizable symbols in human history. The message content is lost to time; Tomlinson recalled it as "something like QWERTYUIOP." SMTP as we know it wasn't standardized until 1982 (RFC 821). Forty-three years later, the same EHLO, MAIL FROM, RCPT TO, DATA commands that Jon Postel specified are still being executed billions of times per day.
Email is the most universal digital communication system in existence. Every internet user has an email address. It requires no central authority — any two SMTP servers can exchange mail directly. It is the only major internet protocol that is genuinely decentralized and federated. And it is deeply broken from a security perspective — because in 1982, nobody anticipated that 85% of all emails would one day be spam.
Email delivery involves three protocols working together: SMTP for sending and relaying, IMAP for synchronized multi-device access, and POP3 for legacy download-and-delete access. The security stack — SPF, DKIM, and DMARC — was retrofitted decades later to address the authentication problems SMTP's designers never anticipated.
Wow
Over 300 billion emails are sent daily. Approximately 85% are spam or malicious. The global email filtering industry represents over $3 billion annually. Without spam filtering, email would be essentially unusable. Business Email Compromise (BEC) — attackers spoofing executive email to authorize fraudulent transfers — generated $2.9 billion in losses in 2023 alone, according to the FBI. Email remains the number one initial attack vector for ransomware and data breaches.
// Chapter 2
SMTP: The Sending Protocol
SMTP (Simple Mail Transfer Protocol) is a text-based, session-oriented protocol for sending and relaying email. Client and server exchange commands and multi-digit response codes in a defined dialogue. Every SMTP response code has three digits: first digit indicates class (2xx success, 3xx intermediate, 4xx transient failure, 5xx permanent failure).
Port Architecture
• Port 25: MTA-to-MTA server relay. No authentication required. Blocked by residential ISPs and most cloud providers to prevent botnet spam. Direct submission to port 25 is not permitted from most IP ranges.
• Port 587: Mail submission with required AUTH. This is the correct port for all application email sending. Always uses STARTTLS for TLS negotiation.
• Port 465: Legacy implicit TLS (SMTPS). The original SSL port, briefly deprecated then restored by RFC 8314. Some providers use this instead of 587 for implicit TLS.
SMTP Session Walkthrough — click any step
220 mail.example.com ESMTP PostfixEHLO client.sender.com250-SIZE 52428800 / 250-STARTTLS / 250-AUTH LOGIN PLAIN / 250 OKSTARTTLS220 Go aheadAUTH PLAIN AHVzZXIAcGFzcw==235 2.7.0 Authentication successfulMAIL FROM:<sender@example.com>250 2.1.0 OKRCPT TO:<recipient@otherdomain.com>250 2.1.5 OKDATA354 Start mail input; end with <CRLF>.<CRLF>From: sender@example.com250 2.0.0 OK: queued as ABC123QUIT221 2.0.0 Bye4xx vs 5xx: Retry vs Bounce
The 4xx / 5xx distinction is operationally critical. A 4xx response (transient failure) means: "I can't accept this right now — try again later." The sending MTA queues the message and retries with exponential backoff, typically for 4–5 days before generating a bounce notification (NDR). A 5xx response (permanent failure) means: "this will never succeed." The message is immediately bounced back to the sender. Sending to a non-existent address returns 5xx; a temporarily overloaded server returns 4xx.
// Chapter 3
Email Delivery Architecture
Story
When you click Send on an email to bob@other.com, a chain of events unfolds: your client connects to your outbound server via SMTP/587, submits the message, and disconnects. Your server's MTA queries DNS for the MX records of other.com. It opens an SMTP connection to port 25 of other.com's mail server and delivers the message. Other.com's server stores it in Bob's mailbox. When Bob opens his email client, the client connects to other.com's IMAP server and retrieves the message. Six separate TCP connections, three protocols, potentially dozens of servers for spam filtering, virus scanning, and policy enforcement — all invisible to the users.
Mail Agent Roles
• MUA (Mail User Agent): Client — Outlook, Thunderbird, Apple Mail, Gmail. Submits via SMTP/587, retrieves via IMAP/993.
• MSA (Mail Submission Agent): Receives from MUAs (port 587), enforces policies, signs DKIM, forwards to MTA.
• MTA (Mail Transfer Agent): Routes between servers (port 25). Examples: Postfix, Exim, Sendmail, Exchange.
• MDA (Mail Delivery Agent): Delivers to local mailboxes. Examples: Dovecot, procmail.
• MRA (Mail Retrieval Agent): IMAP/POP3 server serving client requests. Often same as MDA.
MX Record Routing
When delivering to user@other.com, the sending MTA queries DNS for MX records at other.com. MX records have priority values — lower number is preferred. If the primary MX is unavailable, the MTA tries lower-priority alternatives. If all are unreachable, the message is queued and retried. After the queue lifetime (typically 4–5 days), an NDR (Non-Delivery Receipt) is sent to the original sender with the failure reason. Never return a 5xx to a message you intend to deliver later — use 4xx for transient issues.
Email Protocol Comparator
Note
IMAP supports server-side search, message flags, partial fetch, IDLE push notifications, and folder management. The right choice for all modern multi-device email.
// Chapter 4
IMAP: Synchronized Multi-Device Access
IMAP (Internet Message Access Protocol, RFC 3501) keeps messages on the server. Clients synchronize state — read/unread flags, folder structure, deleted messages — rather than downloading and removing from the server. Every client (phone, laptop, web UI) always sees the same mailbox state because the server is the single source of truth.
IMAP Commands and State Machine
IMAP connections progress through states: Not Authenticated → Authenticated (after LOGIN or AUTHENTICATE) → Selected (after SELECT mailboxname). Commands are tagged with client-assigned identifiers (A001, A002...) — the server's response references each tag, enabling pipelining. A client can send multiple commands without waiting for each response.
Critical commands: SELECT INBOX (open folder, returns message count and recent flags), SEARCH UNSEEN (server-side search returning message IDs), FETCH 1:* ENVELOPE (bulk fetch headers without body), STORE +FLAGS (\Seen) (mark as read), EXPUNGE (actually delete \Deleted messages).
IMAP IDLE: Push Notifications
The IDLE command keeps the IMAP connection open in a waiting state. When new mail arrives, the server sends an unsolicited EXISTS response — the client immediately receives the notification without polling. This is the mechanism behind "push email" on mobile devices. The client sends IDLE\r\n, server responds + idling, and both sides wait. Client terminates with DONE\r\n. Apple's iOS and Android both use IMAP IDLE for email push notification.
# IMAP session (manual telnet example) openssl s_client -connect imap.gmail.com:993 # After TLS handshake: A001 LOGIN user@gmail.com apppassword A002 LIST "" "*" # list all folders A003 SELECT INBOX # open inbox A004 SEARCH UNSEEN # find unread messages A005 FETCH 1 BODY[HEADER.FIELDS (FROM SUBJECT DATE)] A006 FETCH 1 BODY[TEXT] # fetch body A007 STORE 1 +FLAGS (Seen) # mark as read A008 LOGOUT # Check SMTP queue and delivery (Postfix) mailq # show queued messages postqueue -f # flush queue postcat -q <QUEUEID> # inspect message
// Chapter 5
Email Security: SPF, DKIM, DMARC
Story
2004. A phishing email arrives in millions of inboxes claiming to be from paypal@paypal.com. The From: header looks authentic. It asks users to verify their accounts. Tens of thousands enter credentials on a fake PayPal site. The attack works because SMTP has no authentication — anyone can put any From: address in an email. Nothing in the protocol prevented a server in Eastern Europe from claiming to be PayPal. The authentication stack took 12 more years to become widely deployed: SPF (2006 RFC), DKIM (2011 RFC), DMARC (2015 RFC).
Email Authentication Stack
SPF
DMARC Alignment: The Critical Concept
DMARC alignment is what ties the three mechanisms together. For a DMARC check to pass, at least one of SPF or DKIM must (1) pass the authentication check AND (2) align — the verified domain must match the visible From: header domain. An attacker could set up evil.com with valid SPF and DKIM, then put From: ceo@legitimate.com in the message header. SPF passes for evil.com; DKIM passes for evil.com — but DMARC alignment fails because evil.com does not match legitimate.com. The DMARC policy (none/quarantine/reject) then determines what the receiving server does.
Two alignment modes: relaxed (default) — subdomain OK (mail.example.com aligns with example.com). strict — exact domain match required. Strict alignment breaks mailing lists and legitimate subdomains, so relaxed is almost always appropriate.
Caution
Deploying DMARC p=reject before auditing all email sending sources is a career-limiting mistake. Any third-party service sending email on behalf of your domain — marketing tools, CRM systems, ticketing systems, old notification servers — must be either authorized in SPF or signing with DKIM, or their mail will be rejected. Always start with p=none, analyze rua= aggregate reports for 2–4 weeks, fix all sources, move to p=quarantine with pct=5, gradually increase to 100%, then switch to p=reject. Rushing causes legitimate email to disappear silently.
// Chapter 6
DKIM Deep Dive
DKIM (DomainKeys Identified Mail, RFC 6376) adds a cryptographic signature to every outbound message. The signature is stored in a DKIM-Signature: header. The receiving server verifies it using a public key from DNS. The signature covers specified headers plus a hash of the body.
Reading a DKIM-Signature Header
A typical DKIM-Signature: v=1; a=rsa-sha256; d=example.com; s=google2024; h=from:to:subject:date; bh=ABC...==; b=XYZ...==
• a=: signing algorithm (rsa-sha256 or ed25519-sha256)
• d=: signing domain (must align with From: for DMARC)
• s=: selector (key identifier — fetch public key from google2024._domainkey.example.com)
• h=: signed headers list (changing any of these invalidates the signature)
• bh=: SHA-256 hash of the canonicalized body
• b=: the actual RSA/Ed25519 signature
Key Rotation with Selectors
The selector enables zero-downtime key rotation: generate new key pair → publish public key at new selector in DNS → configure signing server to use new private key → wait for old key TTL to expire → remove old DNS record → optionally revoke old key by setting p= empty in the old selector's DNS TXT record (signals "revoked" to receivers). Ed25519 DKIM is preferred for new deployments: 68-character vs 392-character public key, faster verification, no known quantum vulnerability.
// Chapter 7
SMTP TLS: STARTTLS, MTA-STS, DANE
SMTP port 25 between servers can use STARTTLS to upgrade to TLS — but it is opportunistic. If the receiving server doesn't advertise STARTTLS in its EHLO capabilities, the sending server falls back to plaintext. A MITM attacker can trivially strip the STARTTLS capability from the greeting, forcing plaintext delivery. This downgrade attack was widely used by nation-state actors for years.
MTA-STS: Mandatory TLS for Inbound Delivery
MTA-STS (RFC 8461) publishes a policy specifying that TLS is mandatory for delivering to a domain. Setup requires two components: (1) a policy file at https://mta-sts.yourdomain.com/.well-known/mta-sts.txt listing required MX hostnames and mode (enforce/testing/none), and (2) a DNS TXT record at _mta-sts.yourdomain.com with a policy ID. Sending MTAs fetch the policy and refuse to deliver in plaintext or with invalid TLS certificates — they queue instead.
DANE: Certificate Pinning via DNSSEC
DANE (RFC 7672) uses DNSSEC-signed TLSA records to pin TLS certificates for mail servers. Instead of trusting public CAs, the domain owner publishes the certificate (or CA) hash directly in DNS. A DANE-supporting sending MTA fetches the TLSA record and verifies the server's certificate against it — preventing MITM even with a rogue CA certificate. Requires DNSSEC on the target domain; without DNSSEC, the TLSA records themselves could be spoofed.
# MTA-STS policy file # Host at: https://mta-sts.yourdomain.com/.well-known/mta-sts.txt version: STSv1 mode: enforce mx: mail.yourdomain.com max_age: 86400 # MTA-STS DNS TXT record # _mta-sts.yourdomain.com TXT "v=STSv1; id=20241201" # DANE TLSA record format: usage selector matching-type hash # _25._tcp.mail.yourdomain.com TLSA 3 1 1 <SHA256-of-SPKI> # Generate hash: openssl x509 -in cert.pem -pubkey -noout | openssl pkey -pubin -outform DER | openssl dgst -sha256 -binary | xxd -p -c 256 # Test SMTP TLS openssl s_client -connect mail.yourdomain.com:25 -starttls smtp # Check for: Verify return code: 0 (ok)
// Chapter 8
Email Headers: The Audit Trail
Email headers record a complete delivery history. Every SMTP server that handles a message prepends a Received: header. Reading headers bottom-up traces the path from sender to recipient. Each Received header includes the sending server's claimed identity, the receiving server's identity, the protocol used, a message queue ID, and a timestamp.
RFC 5321 Envelope vs RFC 5322 Message Headers
This distinction is the root cause of most email spoofing. RFC 5321 envelope headers: MAIL FROM and RCPT TO — used by SMTP servers for routing, never displayed to users. SPF checks the MAIL FROM domain against the sending IP. RFC 5322 message headers: From:, To:, Subject:, Date:, CC: — what the user sees in their email client. DMARC checks whether the authenticated RFC 5321 domain aligns with the RFC 5322 From: domain.
An attacker sends MAIL FROM: attacker@evil.com (authorized by SPF for evil.com) but writes From: ceo@legitimate.com in the message. The user sees the CEO's address. SPF passes for evil.com. DKIM passes for evil.com. DMARC alignment fails — evil.com does not match legitimate.com. Only DMARC catches this attack. This is why DMARC p=reject is the goal.
Authentication-Results Header
The final receiving server adds Authentication-Results: recording SPF, DKIM, and DMARC pass/fail. In Gmail: open the email → three-dot menu → "Show original" — the full headers are displayed. The Authentication-Results header at the top (prepended last) is the authoritative result from Gmail's infrastructure.
// Chapter 9
Deliverability: Getting Legitimate Email Delivered
High-volume senders (transactional email, marketing) must actively manage deliverability — the probability that a legitimate email reaches the inbox rather than spam folder or being blocked entirely.
IP Warm-Up
New IP addresses have no sending reputation. Major ISPs (Gmail, Outlook) rate-limit mail from unknown IPs. A new server going from 0 to 1 million emails per day will immediately trigger rate limits and spam filtering. Warm-up process: start with 1,000 emails/day to the most engaged users, double every 2–3 days, monitor bounce rates and complaint rates, reach full volume after 4–8 weeks. Services like SendGrid and Mailgun manage warm-up automatically for dedicated IPs.
Bounce and Complaint Management
Hard bounces (5xx — address doesn't exist) must be immediately removed from your list. Sending to known-bad addresses signals poor list hygiene and damages reputation. Soft bounces (4xx — temporary failure) should be retried a few times then removed. Spam complaints from recipients must be processed via Feedback Loop (FBL) subscriptions — most major ISPs provide FBL lists that notify senders when recipients mark their mail as spam. High complaint rates (above 0.1%) trigger filtering.
Caution
Never use shared IP addresses for business-critical transactional email. Shared IPs are used by many senders — if another sender on the same IP spams, your deliverability suffers from IP reputation damage you didn't cause. Always use dedicated IPs for important transactional mail, or use a managed transactional email service (SendGrid, Postmark, Amazon SES) that provides dedicated IPs and actively manages reputation on your behalf.
// Chapter 10
MIME: Multipart Messages and Attachments
MIME (Multipurpose Internet Mail Extensions, RFC 2045–2049) extends SMTP to support non-ASCII content, HTML email, attachments, and multipart messages. The base SMTP protocol supports only 7-bit ASCII text.
A typical HTML email has a multipart/alternative body: two parts — text/plain (plain text fallback) and text/html (HTML version). Email clients display whichever part they prefer. An email with an attachment is multipart/mixed: HTML body + one attachment. Attachments are base64-encoded within the MIME structure.
Key MIME headers: Content-Type: multipart/mixed; boundary="abc123" defines the container and the separator string. Each part begins with --abc123 and ends with --abc123-- for the final part. Content-Transfer-Encoding: base64 signals the content is base64 encoded. Content-Disposition: attachment; filename="file.pdf" signals this part is an attachment with the given filename.
# Send multipart HTML + plain text email (Python)
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
msg = MIMEMultipart('alternative')
msg['From'] = 'sender@example.com'
msg['To'] = 'recipient@example.com'
msg['Subject'] = 'Hello'
plain = MIMEText('Hello, this is plain text.', 'plain', 'utf-8')
html = MIMEText('<h1>Hello</h1><p>This is HTML.</p>', 'html', 'utf-8')
msg.attach(plain)
msg.attach(html)
with smtplib.SMTP('smtp.example.com', 587) as s:
s.starttls()
s.login('user', 'password')
s.sendmail(msg['From'], msg['To'], msg.as_string())// Chapter 11
Email Attack Patterns
Business Email Compromise (BEC)
The attacker spoofs or compromises a CEO/CFO/vendor email address and sends a request to an employee to transfer funds, purchase gift cards, or share credentials. BEC generated $2.9B in losses in 2023 (FBI IC3 report). Defenses: DMARC p=reject prevents external spoofing of your domain. MFA prevents account compromise. Financial approval workflows requiring out-of-band verification for large transfers prevent social engineering. Employee training to recognize urgency + financial request patterns is also essential.
Phishing and Spear-Phishing
Mass phishing: bulk campaigns impersonating banks, package carriers, Netflix. Spear-phishing: targeted attacks using personal details (name, company, role) to increase credibility. Email-based malware: malicious attachments (PDF with embedded JavaScript, Office macros, ISO files containing executables). URL-based: links to credential-harvesting sites. Defenses: email gateway scanning, URL rewriting/click tracking, attachment sandboxing, and user training.
SMTP Smuggling
A 2023-discovered attack where different SMTP servers interpret end-of-DATA sequences differently. An attacker embeds a second SMTP transaction within the first message's DATA section using carefully crafted line endings. The receiving server processes two separate messages where the outer server saw only one — the inner message bypasses SPF/DKIM/DMARC checks and potentially bypasses spam filtering. Postfix, Exim, and Sendmail all issued patches to normalize SMTP line ending handling. Ensure your MTA is patched and configured to reject non-standard DATA terminators.
// Chapter 12
Email Forensics: Header Analysis
# Phishing email headers — analyze delivery path
# Read Received: headers BOTTOM-UP for delivery path
Received: from mail.attacker.net (attacker.net [198.51.100.42])
by mx.victim.com with ESMTP id abc123 ← final hop (top)
for <ceo@victim.com>; Mon 10:00:00 +0000
Received: from localhost ([127.0.0.1])
by mail.attacker.net with SMTP id def456 ← attacker's server
Mon 09:59:55 +0000
From: cfo@trusted-bank.com ← spoofed From:
Reply-To: attacker@evil.com ← real reply address
To: ceo@victim.com
Subject: Wire Transfer Request
Authentication-Results: mx.victim.com;
spf=fail smtp.mailfrom=attacker.net ← SPF FAIL
dkim=none ← no DKIM
dmarc=fail action=none header.from=trusted-bank.com
# Key indicators:
# 1. Received: from attacker.net — bad IP
# 2. SPF fail for attacker.net
# 3. No DKIM signature
# 4. DMARC fail — From: domain doesn't align
# 5. Reply-To differs from From: — very suspicious// Chapter 13
Common Misconceptions
Misconception — The From: header proves who sent the email
The From: header (RFC 5322) is set by the sending software and has historically had zero authentication. Anyone can write any address. Phishing emails claiming to be from your bank, PayPal, or the CEO all work exactly because From: can be freely set. DMARC alignment is the only mechanism that verifies the From: header domain against an authenticated identity (SPF-verified sending IP or DKIM signature). Without DMARC p=reject on the target domain, From: is a suggestion, not a proof.
Misconception — SPF passing means the email is legitimate
SPF verifies only that the sending IP is authorized for the MAIL FROM domain — the envelope sender, not the From: header the user sees. An attacker sets MAIL FROM: spammer@evil.com (authorized by their SPF) and From: trusted@bank.com (what the user sees). SPF passes for evil.com. DMARC alignment fails because evil.com does not match bank.com. SPF alone does not prevent from-header spoofing — DMARC alignment is required.
Misconception — STARTTLS makes email as secure as HTTPS
SMTP STARTTLS is opportunistic — the connection falls back to plaintext if the server doesn't advertise TLS or if the capability is stripped by a MITM. This is trivially exploitable. HTTPS with HSTS enforces TLS from the start with no fallback. MTA-STS closes this gap for SMTP by making TLS mandatory for specific domains, failing delivery rather than downgrading. DANE adds certificate pinning via DNSSEC. Without MTA-STS or DANE, SMTP STARTTLS provides encryption against passive observers but not active downgrade attackers.
Misconception — Email is delivered instantly like a chat message
Email is a store-and-forward system. The sending server accepts the message, queues it, then delivers asynchronously — typically within seconds for good mail, but potentially hours or days if the recipient's server is temporarily unavailable. The sending server retries with exponential backoff for 4–5 days before bouncing. Email has no real-time delivery guarantee by design. This is fundamentally different from messaging apps, which are designed for low-latency delivery with strong ordering guarantees.
Misconception — DMARC p=reject blocks all spoofing of your domain immediately
DMARC p=reject asks receiving servers to reject non-aligned messages. But (1) not all receiving servers implement DMARC checks, (2) p=reject also rejects legitimate email from your domain that lacks proper SPF/DKIM — third-party tools, old servers, newsletters. You must identify and fix all sending sources before enforcing reject. The rua= aggregate reports tell you exactly what's failing. Skipping the monitoring phase causes real legitimate email to bounce silently with no user-visible error.
// Chapter 14
IQ Depth Check
IQ — Beginner
Email uses three main protocols: SMTP for sending (like a postal carrier), IMAP for reading on multiple devices (mail stays on the server), and POP3 (older — downloads mail to one device and deletes from server). When you send an email, your app sends it to your mail server via SMTP, your server routes it to the recipient's server via SMTP, and the recipient's app retrieves it via IMAP. The From: address in an email can be faked — spam and phishing emails do this. SPF, DKIM, and DMARC are security mechanisms to detect faked senders.
IQ — Intermediate
SMTP ports: 25 (server-to-server relay), 587 (authenticated submission), 465 (implicit TLS). SMTP response codes: 2xx success, 4xx transient (retry), 5xx permanent (bounce). IMAP keeps mail server-side for multi-device sync; POP3 downloads and deletes. Email auth: SPF checks sending IP against MAIL FROM domain in DNS TXT. DKIM cryptographically signs messages; public key in DNS at selector._domainkey.domain. DMARC ties them together with a policy and alignment requirement — at least SPF or DKIM must pass AND align with the visible From: header. STARTTLS on port 25 is opportunistic; MTA-STS/DANE enforce TLS. Read Received: headers bottom-up to trace delivery path.
IQ — Senior
SMTP envelope (RFC 5321: MAIL FROM, RCPT TO) vs message headers (RFC 5322: From:, To:, Subject:) — completely separate. DMARC alignment catches the MAIL FROM = legitimate/From: = spoofed attack by requiring the SPF or DKIM verified domain to match the From: header domain. DMARC alignment modes: relaxed (eTLD+1 match, subdomain OK) vs strict (exact match). DKIM selector enables key rotation; Ed25519 preferred for new deployments (68-char key vs RSA's 392-char). DMARC rua= aggregate XML reports (daily per-domain) enable monitoring all sending sources before enforcing reject. MTA-STS: policy served via HTTPS, DNS TXT with policy ID for cache invalidation, max_age controls how long the policy is cached. DANE/TLSA: DNSSEC required; usage 3 (DANE-EE) = pin exact leaf cert; usage 2 (DANE-TA) = pin CA. SMTP smuggling: inconsistent DATA terminator handling allows injecting a second transaction inside the first message body.
IQ — PhD
DMARC alignment uses "organizational domain" (eTLD+1) as the alignment boundary in relaxed mode — RFC 7489 appendix A defines this as the registered domain per the Public Suffix List. DKIM oversigning: h= list should include an empty slot for each header that must not be injected above the signed one — prevents header injection attacks where an attacker prepends a second From: header to bypass alignment. ARC (Authenticated Received Chain, RFC 8617) preserves original authentication results across mailing list forwarding: the forwarder appends ARC-Seal and ARC-Message-Signature headers chaining the original authentication; the final receiver can evaluate the original chain using the ARC-Authentication-Results of the first signer. Gmail uses ARC to rescue DMARC-failing legitimate email from known trusted mailing lists. BIMI VMC (Verified Mark Certificate) is an Extended Validation-like certificate from DigiCert or Entrust asserting trademark ownership — prevents brand impersonation in the BIMI display. SMTP smuggling fix requires MTAs to normalize received data: strip bare CR, refuse LF-only line endings, and reject messages where the DATA payload contains the sequence CRLF.CRLF mid-message followed by additional SMTP commands. Post-quantum DKIM: current RSA-2048 and Ed25519 signatures face long-term threats from quantum computing; CRYSTALS-Dilithium signatures (NIST PQC standard) would increase DKIM-Signature size from ~250 bytes to ~2420 bytes — potentially causing delivery failures on servers with header size limits or DKIM parser buffer limits. Open research: DMARC enforcement interaction with ARC chain manipulation; formal verification of DMARC policy inheritance across subdomain hierarchies; email metadata leakage in encrypted-at-rest email storage systems.
🎯 Key Takeaways
- ✓Email uses three protocols: SMTP for sending/relaying (ports 25/587/465), IMAP for server-side synchronized access (port 993), POP3 for legacy download-delete (port 995).
- ✓SMTP is a session-based text protocol — EHLO/MAIL FROM/RCPT TO/DATA — with 4xx (transient: retry) and 5xx (permanent: bounce) response codes.
- ✓The From: header in an email has no inherent authentication — phishing and spoofing attacks exploit this. SPF, DKIM, and DMARC exist to verify sender identity via DNS.
- ✓SPF verifies the sending IP against the MAIL FROM domain. DKIM cryptographically signs the message. DMARC ties both to the visible From: header via alignment enforcement.
- ✓DMARC alignment is the key concept: at least SPF or DKIM must pass AND the verified domain must match the From: header domain — catching the spoofed-From: attack.
- ✓Deploy DMARC in stages: p=none (monitor) → p=quarantine (with small pct=) → p=reject. Rushing causes legitimate email to disappear.
- ✓SMTP STARTTLS is opportunistic and susceptible to downgrade attacks. MTA-STS enforces TLS for inbound delivery; DANE pins certificates via DNSSEC.
- ✓Reading Received: headers bottom-up traces the delivery path; Authentication-Results records SPF/DKIM/DMARC pass/fail at the receiving server.
- ✓IP warm-up, bounce management, and spam complaint rate monitoring are required for high-volume senders to maintain inbox delivery.
- ✓Business Email Compromise causes $2.9B+ in annual losses — DMARC p=reject on your domain plus MFA on email accounts are the primary defenses.
Discussion
0Have a better approach? Found something outdated? Share it — your knowledge helps everyone learning here.