Loading learning content...
When you click "Send" on an email, you initiate a remarkable journey through the global Internet infrastructure. Within seconds—or sometimes milliseconds—your message traverses networks, passes through multiple servers, undergoes security checks, and arrives in your recipient's inbox. This apparent simplicity masks a sophisticated multi-stage process involving numerous protocols, components, and decisions.
Understanding mail flow is essential for anyone operating email infrastructure, troubleshooting delivery issues, or designing systems that integrate with email. Each stage presents opportunities for filtering, logging, security enforcement, and potential failure. Knowing where to look when mail doesn't arrive, understanding why legitimate mail ends up in spam folders, and designing reliable email-based workflows all require mastery of the complete message journey.
This page traces an email's complete path from the moment a user composes it until the recipient reads it, examining every component interaction, protocol exchange, and potential failure point.
By completing this page, you will be able to trace any email's journey through the delivery infrastructure, identify where failures occur, understand how spam filtering decisions are made, and optimize delivery for legitimate email. You'll master the complete mail flow from composition to reading.
Email flow follows the store-and-forward model—messages are stored at each hop before being forwarded to the next. This fundamental architecture choice ensures reliability: even if the next server is temporarily unavailable, the message is safely queued for later delivery.
The complete mail flow consists of these major stages:
Timing Characteristics:
Mail flow timing varies dramatically based on conditions:
| Scenario | Typical Timing | Determining Factors |
|---|---|---|
| Local delivery (same server) | < 1 second | No network transit, no MX lookup |
| Standard internet delivery | 2-30 seconds | DNS lookup, connection setup, filtering |
| Greylist delayed | 5-15 minutes | Initial rejection, retry on schedule |
| Deferred delivery | Minutes to hours | Temporary rejection, retry backoff |
| Queued delivery | Up to 5 days | Recipient server unreachable |
The mail flow begins when a user composes a message in their Mail User Agent (MUA). While seemingly straightforward, the composition stage involves significant processing as the MUA constructs a properly formatted message.
User Actions During Composition:
MUA Responsibilities During Composition:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
From: Alice Smith <alice@sender.com>To: Bob Jones <bob@recipient.com>Cc: Carol White <carol@recipient.com>Bcc: Dave Black <dave@hidden.com>Subject: Quarterly ReportDate: Mon, 17 Jan 2026 12:30:00 +0530Message-ID: <550e8400-e29b-41d4-a716-446655440000@sender.com>User-Agent: Mozilla Thunderbird 115.0MIME-Version: 1.0Content-Type: multipart/mixed; boundary="----=_Part_001" ------=_Part_001Content-Type: multipart/alternative; boundary="----=_Part_002" ------=_Part_002Content-Type: text/plain; charset=UTF-8Content-Transfer-Encoding: 7bit Hi Bob, Please find the quarterly report attached. Best regards,Alice ------=_Part_002Content-Type: text/html; charset=UTF-8Content-Transfer-Encoding: 7bit <!DOCTYPE html><html><body><p>Hi Bob,</p><p>Please find the quarterly report attached.</p><p>Best regards,<br>Alice</p></body></html> ------=_Part_002-- ------=_Part_001Content-Type: application/pdf; name="Q4-Report.pdf"Content-Disposition: attachment; filename="Q4-Report.pdf"Content-Transfer-Encoding: base64 JVBERi0xLjQKJeLjz9MKMSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZwov... (base64 encoded PDF content) ... ------=_Part_001--The MUA constructs the message with Bcc recipients in the header, but the MSA/MTA is responsible for removing the Bcc header before transmission to visible recipients. Mail is delivered to Bcc addresses, but they are stripped from the message those recipients receive.
When the user clicks "Send," the MUA initiates an SMTP connection to the configured Mail Submission Agent (MSA) on port 587. This submission stage authenticates the sender and validates the message before it enters the mail transfer system.
Submission Flow Steps:
MSA Processing:
The MSA performs critical validation before accepting the message:
Authentication Verification:
Message Validation:
Header Processing:
Signing:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
# Submission session from alice@sender.com to MSA >> [TCP Connect to mail.sender.com:587] << 220 mail.sender.com ESMTP Ready >> EHLO [192.168.1.100] << 250-mail.sender.com Hello<< 250-PIPELINING<< 250-SIZE 52428800<< 250-STARTTLS<< 250-AUTH PLAIN LOGIN XOAUTH2<< 250-ENHANCEDSTATUSCODES<< 250 DSN >> STARTTLS << 220 2.0.0 Ready to start TLS >> [TLS 1.3 Handshake - Certificate: *.sender.com] >> EHLO [192.168.1.100] << 250-mail.sender.com Hello<< 250-AUTH PLAIN LOGIN XOAUTH2<< 250 OK >> AUTH PLAIN AGFsaWNlQHNlbmRlci5jb20AcGFzc3dvcmQxMjM= << 235 2.7.0 Authentication successful >> MAIL FROM:<alice@sender.com> SIZE=15234 << 250 2.1.0 OK >> RCPT TO:<bob@recipient.com> << 250 2.1.5 OK >> RCPT TO:<carol@recipient.com> << 250 2.1.5 OK >> RCPT TO:<dave@hidden.com> << 250 2.1.5 OK >> DATA << 354 Start mail input; end with <CRLF>.<CRLF> >> From: Alice Smith <alice@sender.com>>> To: Bob Jones <bob@recipient.com>>> Cc: Carol White <carol@recipient.com>>> Subject: Quarterly Report>> Date: Mon, 17 Jan 2026 12:30:00 +0530>> Message-ID: <550e8400-e29b-41d4-a716-446655440000@sender.com>>> MIME-Version: 1.0>> Content-Type: text/plain; charset=UTF-8>>>> Hi Bob,>>>> Please find the quarterly report attached.>>>> Best regards,>> Alice>> . << 250 2.0.0 OK: queued as 4F7B892C1A >> QUIT << 221 2.0.0 ByeAfter the MSA accepts the message, it enters the Mail Transfer Agent's queue. The MTA must now determine where to send the message—a process dependent on DNS MX (Mail Exchanger) record lookups.
Routing Algorithm:
For each recipient domain, the sending MTA follows this logic:
123456789101112131415161718192021222324252627282930313233343536373839
# MTA routing query for bob@recipient.com # Step 1: Query MX records$ dig MX recipient.com ;; ANSWER SECTION:recipient.com. 3600 IN MX 10 mx1.recipient.com.recipient.com. 3600 IN MX 10 mx2.recipient.com.recipient.com. 3600 IN MX 20 mx-backup.recipient.com. # MTA interpretation:# Priority 10: mx1.recipient.com (primary)# Priority 10: mx2.recipient.com (primary, load balanced)# Priority 20: mx-backup.recipient.com (backup) # Step 2: Resolve primary MX$ dig A mx1.recipient.com ;; ANSWER SECTION:mx1.recipient.com. 300 IN A 203.0.113.10 $ dig A mx2.recipient.com ;; ANSWER SECTION:mx2.recipient.com. 300 IN A 203.0.113.11 # Step 3: MTA attempts connection in order:# 1. Try mx1.recipient.com:25 (203.0.113.10)# If successful -> deliver# If connection refused/timeout -> try mx2# 2. Try mx2.recipient.com:25 (203.0.113.11)# If successful -> deliver # If connection refused/timeout -> try backup# 3. Try mx-backup.recipient.com:25# If successful -> deliver# If all fail -> queue for retry # Note: Same-priority MX records (10 and 10) are typically# load-balanced by random selection or round-robinRouting Edge Cases:
Multiple Recipient Domains: When a message has recipients in multiple domains, the MTA must route separately to each domain. The message is duplicated and delivered to each domain's MX independently.
Sender Domain Considerations:
MX Record Edge Cases:
| Scenario | Behavior |
|---|---|
| No MX records exist | Fall back to A/AAAA record of domain |
| MX points to CNAME | Technically invalid (but often works) |
| MX priority 0 | Valid but unusual (null MX means no mail accepted) |
| All MX unreachable | Queue and retry per RFC 5321 guidelines |
| MX points to IP | Invalid (must be hostname) |
Null MX (RFC 7505):
Domains that never receive email can advertise this fact:
example.com. IN MX 0 .
The single dot (.) as the MX target with priority 0 explicitly indicates "this domain does not accept mail." Compliant senders immediately generate bounces rather than attempting delivery.
MX records are cached according to their TTL (Time To Live). When migrating mail servers, set low TTLs in advance to ensure changes propagate quickly. Standard TTLs of 1-24 hours can cause prolonged delivery issues during transitions.
With the destination MX resolved, the sending MTA initiates an SMTP connection to the receiving MTA on port 25. This server-to-server transfer differs from submission in authentication expectations and represents the core internet mail relay function.
SMTP Transfer Characteristics:
No Authentication (Typically): Unlike submission on port 587, MTA-to-MTA transfer on port 25 traditionally does not require SMTP AUTH. Any server may attempt to deliver mail to an MX. This openness is fundamental to email's distributed architecture but creates spam challenges.
TLS Opportunistic (STARTTLS): Modern MTAs negotiate TLS when available:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
# Transfer from sender MTA to recipient MTA (port 25) >> [TCP Connect to mx1.recipient.com:25] << 220 mx1.recipient.com ESMTP Ready >> EHLO mail.sender.com << 250-mx1.recipient.com Hello mail.sender.com [198.51.100.10]<< 250-STARTTLS<< 250-SIZE 104857600<< 250-8BITMIME<< 250-ENHANCEDSTATUSCODES<< 250-PIPELINING<< 250 DSN >> STARTTLS << 220 2.0.0 Ready to start TLS >> [TLS handshake completes] >> EHLO mail.sender.com << 250-mx1.recipient.com Hello mail.sender.com [198.51.100.10]<< 250-SIZE 104857600<< 250-8BITMIME<< 250 OK >> MAIL FROM:<alice@sender.com> << 250 2.1.0 OK >> RCPT TO:<bob@recipient.com> << 250 2.1.5 OK >> DATA << 354 Start mail input >> Received: from [192.168.1.100] (unknown [198.51.100.5])>> by mail.sender.com (Postfix) with ESMTPSA id 4F7B892C1A>> for <bob@recipient.com>; Mon, 17 Jan 2026 12:30:00 +0530>> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sender.com;>> s=default; h=from:to:subject:date:message-id;>> bh=lK7kgXBJl+8k7hjd...; b=pXjmxY...>> From: Alice Smith <alice@sender.com>>> To: Bob Jones <bob@recipient.com>>> Subject: Quarterly Report>> Date: Mon, 17 Jan 2026 12:30:00 +0530>> Message-ID: <550e8400-e29b-41d4-a716-446655440000@sender.com>>> [... message body ...]>> . << 250 2.0.0 OK: queued as 8A3C4D5E6F >> QUIT << 221 2.0.0 ByeReceived Headers:
Each MTA adds a "Received" header documenting the hop. These headers create an audit trail:
Received: from mail.sender.com (mail.sender.com [198.51.100.10])
by mx1.recipient.com (Postfix) with ESMTPS id 8A3C4D5E6F
for <bob@recipient.com>; Mon, 17 Jan 2026 12:30:05 +0530
Multi-Hop Scenarios:
Messages may traverse multiple MTAs:
Each hop adds latency and a Received header, creating traceable delivery paths.
Response Codes:
| Code | Meaning | Action |
|---|---|---|
| 250 | Message accepted | Delivery complete |
| 421 | Service unavailable | Temporary, retry |
| 450 | Mailbox unavailable | Temporary, retry |
| 451 | Local processing error | Temporary, retry |
| 452 | Insufficient storage | Temporary, retry |
| 500-504 | Syntax/command errors | Permanent failure |
| 550 | Mailbox unavailable | Permanent, bounce |
| 551 | User not local | Permanent, forward info |
| 552 | Exceeded storage | Permanent, bounce |
| 553 | Mailbox name invalid | Permanent, bounce |
| 554 | Transaction failed | Permanent, bounce |
Before accepting a message, the receiving MTA performs extensive security and policy checks. This filtering stage determines whether mail reaches the inbox, spam folder, quarantine, or is rejected outright.
Filtering Occurs at Multiple Points:
SPF, DKIM, DMARC Verification Flow:
Received message: From: alice@sender.com
1. SPF Check:
Query: sender.com TXT record
Result: v=spf1 mx ip4:198.51.100.0/24 -all
Connecting IP: 198.51.100.10
Verdict: PASS (IP in authorized range)
2. DKIM Check:
Signature selector: "default"
Query: default._domainkey.sender.com TXT
Result: v=DKIM1; k=rsa; p=MIGfMA0...
Signature verification: VALID
Verdict: PASS
3. DMARC Check:
Query: _dmarc.sender.com TXT
Result: v=DMARC1; p=reject; adkim=s; aspf=s
SPF alignment: PASS (From domain matches envelope)
DKIM alignment: PASS (From domain matches signed domain)
Verdict: PASS
Final authorization: ACCEPT (all checks passed)
Filtering Outcomes:
| Outcome | When Applied | User Experience |
|---|---|---|
| Accept to Inbox | All checks pass, low spam score | Normal delivery |
| Accept to Spam | Moderate spam signals, policy | Spam folder |
| Quarantine | High spam score, admin review | Delayed, reviewed |
| Reject (SMTP) | Security policy violation | Sender gets bounce |
| Drop (Silently) | Known spam, virus | No notification |
SMTP rejection (5xx response) notifies senders of delivery failure. Silent dropping prevents backscatter but may lose legitimate mail without notification. Organizations must balance spam prevention against the risk of silently losing mail.
After passing all filters, the message reaches the Mail Delivery Agent (MDA) for final delivery to the recipient's mailbox. This local delivery stage performs final processing and persistent storage.
MDA Invocation Methods:
The MTA hands off messages to the MDA through several possible mechanisms:
deliver, maildrop). Message passed via stdin. Exit code indicates success/failure.MDA Processing Steps:
User Resolution:
Quota Checking:
Sieve Filtering:
Final Delivery:
1234567891011121314151617181920212223
# Dovecot LMTP delivery log entry Jan 17 12:30:10 mail dovecot[12345]: lmtp(12346): Connect from localJan 17 12:30:10 mail dovecot[12345]: lmtp(12346, bob@recipient.com): 8A3C4D5E6F: msgid=<550e8400-e29b-41d4-a716-446655440000@sender.com>: saved mail to INBOX # Breakdown:# - Accepted from local MTA via LMTP# - Recipient: bob@recipient.com# - Queue ID: 8A3C4D5E6F (correlates with MTA logs)# - Message-ID: from sender# - Destination: INBOX (default folder) # With Sieve filtering:Jan 17 12:30:10 mail dovecot[12345]: lmtp(12346, bob@recipient.com): sieve: msgid=<550e8400...@sender.com>: stored mail into mailbox 'Projects/Quarterly-Reports' # Quota warning example:Jan 17 12:30:10 mail dovecot[12345]: lmtp(12346, bob@recipient.com): Warning: user is over quota (quota: 1024 MB, used 1020 MB)Mailbox Storage Formats:
Maildir Format:
/var/mail/vhosts/recipient.com/bob/
├── cur/ # Read messages
│ └── 1737105010.V802I....:2,S
├── new/ # Unread messages (just delivered)
│ └── 1737105610.V802I...
├── tmp/ # Temporary during delivery
├── dovecot.index
├── dovecot.index.cache
└── dovecot.index.log
dbox/mdbox (Dovecot optimized):
Database Storage:
The final stage occurs when the recipient checks their email. The Mail User Agent connects to the Mail Access Agent (IMAP/POP3 server) to retrieve and display the delivered message.
Retrieval Initiation:
Retrieval may be triggered by:
IMAP Retrieval Pattern:
POP3 Retrieval Pattern:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
# Bob's MUA retrieves Alice's message via IMAP >> [Connect to imap.recipient.com:993 with TLS] S: * OK [CAPABILITY IMAP4rev1 LITERAL+ IDLE] IMAP readyC: A001 LOGIN "bob@recipient.com" "password"S: A001 OK LOGIN completed C: A002 SELECT INBOXS: * 147 EXISTSS: * 1 RECENTS: * OK [UNSEEN 147]S: * OK [UIDVALIDITY 1234567890]S: * OK [UIDNEXT 2048]S: A002 OK [READ-WRITE] SELECT completed # MUA sees 1 new message (RECENT), message 147 is unread C: A003 FETCH 147 (UID FLAGS ENVELOPE BODYSTRUCTURE)S: * 147 FETCH ( UID 2047 FLAGS () ENVELOPE ( "Mon, 17 Jan 2026 12:30:00 +0530" "Quarterly Report" (("Alice Smith" NIL "alice" "sender.com")) (("Bob Jones" NIL "bob" "recipient.com")) NIL NIL NIL "<550e8400-e29b-41d4-a716-446655440000@sender.com>" ) BODYSTRUCTURE (...) )S: A003 OK FETCH completed # User clicks to read message body C: A004 FETCH 147 (BODY[TEXT])S: * 147 FETCH (BODY[TEXT] {256} Hi Bob, Please find the quarterly report attached. Best regards, Alice )S: A004 OK FETCH completed # Mark as readC: A005 STORE 147 +FLAGS (\Seen)S: * 147 FETCH (FLAGS (\Seen))S: A005 OK STORE completed # Return to IDLE for pushC: A006 IDLES: + idlingPush Notification Flow:
Modern mobile email delivery often involves push notifications:
Complete Message Journey Summary:
Alice's message to Bob traversed:
When mail doesn't arrive as expected, understanding how to trace its path through logs is an essential skill for email administrators and developers.
Key Log Locations:
| Component | Typical Log Location | What It Shows |
|---|---|---|
| Postfix | /var/log/mail.log | Submission, transfer, local delivery |
| Dovecot | /var/log/mail.log | IMAP/POP3 access, LDA delivery |
| Exchange | Event Viewer / Message Tracking | End-to-end flow |
| Rspamd | /var/log/rspamd/rspamd.log | Spam filtering decisions |
| ClamAV | /var/log/clamav/clamav.log | Virus detection |
Tracing by Message-ID:
Every message has a unique Message-ID header. Searching logs for this ID reveals the complete path:
# Find all log entries for a specific message
grep "550e8400-e29b-41d4-a716" /var/log/mail.log
# Postfix queue ID correlation
grep "4F7B892C1A" /var/log/mail.log
mailq in Postfix). Examine deferred queue reasons. Test connectivity to recipient MX. Verify DNS resolution.123456789101112131415161718192021222324252627282930
# Key headers to examine for troubleshooting # 1. Received headers (read bottom-to-top for chronological order)Received: from mx1.recipient.com (mx1.recipient.com [203.0.113.10]) by imap.recipient.com (Dovecot) with LMTP id XYZ789 for <bob@recipient.com>; Mon, 17 Jan 2026 12:30:08 +0530Received: from mail.sender.com (mail.sender.com [198.51.100.10]) by mx1.recipient.com (Postfix) with ESMTPS id 8A3C4D5E6F for <bob@recipient.com>; Mon, 17 Jan 2026 12:30:05 +0530Received: from [192.168.1.100] (unknown [198.51.100.5]) by mail.sender.com (Postfix) with ESMTPSA id 4F7B892C1A for <bob@recipient.com>; Mon, 17 Jan 2026 12:30:00 +0530 # 2. Authentication results (added by receiving server)Authentication-Results: mx1.recipient.com; dkim=pass header.d=sender.com header.s=default; spf=pass (sender IP is 198.51.100.10) smtp.mailfrom=sender.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sender.com # 3. Spam/filter results (if present)X-Spam-Status: No, score=-2.1 required=5.0 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_PASS=-0.5, RCVD_IN_DNSWL_MED=-1.4]X-Spam-Score: -2.1 # 4. DKIM signature (for verification)DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sender.com; s=default; h=from:to:subject:date:message-id; bh=lK7kgXBJl+8k7hjd...; b=pXjmxY...We have traced an email's complete journey from sender to recipient, examining every component, protocol, and potential failure point. Let's consolidate this knowledge:
What's Next:
With mail flow mastered, we'll examine Email Addressing—understanding address formats, domain handling, aliases, forwarding, catch-all configurations, and the addressing schemes that route billions of messages daily.
You now possess complete understanding of email message flow—from the moment a user clicks 'Send' through every hop, filter, and storage operation until the recipient reads the message. This knowledge enables you to troubleshoot delivery issues, optimize mail infrastructure, and understand why mail behaves as it does.