← RFC Reference

The Lifecycle of an Email

Email Concepts Encyclopedia
ELI5: Sending an email is like sending a physical letter through a chain of post offices. You write it (MUA), hand it to your local post office (MSA), they route it through the mail system (MTA to MTA), it arrives at the recipient’s post office (MX), gets sorted into their mailbox (MDA), and they pick it up when they check their mail (IMAP/POP3). At every stop along the way, someone checks the envelope, verifies the stamps, and decides whether to pass it along or flag it.

From the moment you click "Send" to the moment a message appears in someone's inbox — every hop, every protocol, every decision along the way.

The Actors

The Internet Mail Architecture (RFC 5598) defines the roles that participate in email delivery. Understanding these roles is essential because the same piece of software often plays multiple roles, and the boundaries between them matter for understanding how mail flows.

Role Name Function
MUA Mail User Agent The application you compose and read email in. Outlook, Thunderbird, Gmail's web interface, Apple Mail, your phone's mail app.
MSA Mail Submission Agent The server that accepts outgoing email from your MUA. Listens on port 587 (STARTTLS) or 465 (implicit TLS). Requires authentication.
MTA Mail Transfer Agent The server that routes email between organizations. Speaks SMTP on port 25. Handles queuing, retries, and relay decisions.
MX Mail Exchanger The receiving MTA, identified by MX DNS records. Accepts incoming mail for a domain.
MDA Mail Delivery Agent Deposits the message into the recipient's mailbox. Applies filters, sorting rules, and spam classification.
MRA Mail Retrieval Agent Serves the mailbox to the MUA via IMAP or POP3.

In practice, these roles are often collapsed. Gmail's infrastructure is simultaneously MSA, MTA, MX, MDA, and MRA. Postfix can act as both MSA and MTA. But the logical roles remain distinct, and understanding them helps you debug delivery problems.

Stage 1: Composition (MUA)

The lifecycle begins when a user composes a message in their mail client, or when an application generates a message programmatically (via an API or SMTP library).

The MUA constructs the message according to RFC 5322 (Internet Message Format):

From: Alice <alice@example.com>
To: Bob <bob@example.net>
Subject: Project update
Date: Tue, 11 Mar 2026 09:15:00 -0400
Message-ID: <a1b2c3@example.com>
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="boundary42"

--boundary42
Content-Type: text/plain; charset=utf-8

Hi Bob, here is the latest on the project...
--boundary42
Content-Type: text/html; charset=utf-8

<p>Hi Bob, here is the latest on the project...</p>
--boundary42--

Key decisions at this stage:

Stage 2: Submission (MUA → MSA)

The MUA connects to the MSA (RFC 6409) to hand off the message. This is the submission step.

# MUA connects to MSA on port 587
220 smtp.example.com ESMTP ready
EHLO alices-laptop.local
250-smtp.example.com
250-STARTTLS
250-AUTH PLAIN LOGIN
250 SIZE 52428800
STARTTLS
220 Ready to start TLS
# TLS handshake completes
EHLO alices-laptop.local
250-smtp.example.com
250-AUTH PLAIN LOGIN
250 SIZE 52428800
AUTH PLAIN AGFsaWNlAHMzY3IzdA==
235 Authentication successful
MAIL FROM:<alice@example.com>
250 OK
RCPT TO:<bob@example.net>
250 OK
DATA
354 Start mail input
[message content]
.
250 OK: queued as ABC123

What the MSA does upon receiving the message:

The API submission path

When using a transactional email service like Mailer To Go, your application typically submits via an HTTP API rather than SMTP. The API server accepts the message, constructs the SMTP envelope and headers, applies DKIM signing, and injects the message into the MTA queue. The API call replaces both the MUA and the MUA-to-MSA SMTP transaction, but everything downstream remains the same.

Stage 3: Routing and Transfer (MTA → MTA)

The sending MTA must now deliver the message to the recipient's domain. This is the relay phase, governed by RFC 5321 (SMTP).

DNS resolution

The MTA looks up the MX records for the recipient's domain:

$ dig +short MX example.net
10 mx1.example.net.
20 mx2.example.net.

It tries the lowest-priority MX first. If that server is unreachable, it falls back to the next. See DNS and Mail Routing for the full algorithm, including fallback to A/AAAA records and Null MX handling.

The transfer

# Sending MTA connects to mx1.example.net:25
220 mx1.example.net ESMTP
EHLO sender.mailertogo.com
250-mx1.example.net
250-STARTTLS
250-SIZE 26214400
250 ENHANCEDSTATUSCODES
STARTTLS
220 Ready to start TLS
# TLS handshake — connection now encrypted
EHLO sender.mailertogo.com
250-mx1.example.net
250 ENHANCEDSTATUSCODES
MAIL FROM:<alice@example.com>
250 OK
RCPT TO:<bob@example.net>
250 OK
DATA
354 End data with <CR><LF>.<CR><LF>
[message with additional Received: header]
.
250 OK: queued as DEF456

At this stage:

Queuing and retries

If the receiving MX returns a 4xx temporary error (server busy, greylisting, rate limiting), the sending MTA queues the message and retries later. Retry schedules typically use exponential backoff: 15 minutes, 30 minutes, 1 hour, 2 hours, etc. If the message cannot be delivered after the retry period (usually 4–5 days), the MTA generates a bounce message (DSN) and sends it back to the envelope sender.

Stage 4: Reception (MX)

The receiving MX (the MTA that accepts incoming mail for the recipient's domain) is where most filtering happens. This is the gatekeeper.

At connection time, before any message content arrives:

During the envelope phase:

After DATA (the full message is received):

Stage 5: Delivery (MDA)

The Mail Delivery Agent takes the message that passed filtering and deposits it into the recipient's mailbox. In many systems, the MDA is integrated into the MX server rather than being a separate process.

The MDA's responsibilities:

At this point, the message is at rest in the recipient's mail store. The SMTP transaction is complete. The sending MTA's responsibility ended when it received the 250 OK from the receiving MX.

Stage 6: Retrieval (MRA → MUA)

The recipient's mail client retrieves the message from the mail store using one of three protocols:

IMAP (RFC 9051)

The dominant mail access protocol. IMAP keeps messages on the server and synchronizes state (read/unread, flags, folders) across multiple clients. The client downloads message headers first and fetches full bodies on demand. Changes made on one client (marking as read, moving to a folder) are reflected on all clients.

POP3 (RFC 1939)

The older, simpler protocol. POP3 downloads messages to the client and (by default) deletes them from the server. It does not synchronize state between clients. Largely superseded by IMAP, but still used in some scenarios.

Web and API access

Webmail interfaces (Gmail, Outlook.com) and mobile apps access the mail store through proprietary APIs or JMAP (RFC 8620), bypassing IMAP/POP3 entirely. The message never leaves the provider's servers — the client displays it via a web request.

Where Things Go Wrong: Failure Modes at Each Stage

Submission failures

Authentication fails (wrong password, expired token), the MSA rejects the message (over size limit, policy violation), or the connection times out. The user sees an error immediately.

Routing failures

DNS resolution fails (no MX records, DNS timeout), all MX hosts are unreachable, or every MX returns a permanent error. After retries are exhausted, the sender receives a bounce (DSN).

Reception-time rejection

The receiving MX rejects the message at SMTP time: blocklisted IP (550), failed authentication (550 5.7.1), unknown recipient (550 5.1.1), or content rejection (554). The sending MTA generates a bounce notification to the envelope sender.

Post-acceptance filtering

The MX accepted the message (250 OK) but the MDA routes it to the spam folder based on content analysis and reputation scoring. The sender does not receive a bounce — the message was technically "delivered" — but the recipient never sees it. This is the most common and most difficult deliverability problem to diagnose.

Mailbox full

The recipient's mailbox is over quota. Depending on implementation, this is either a rejection at RCPT TO time or a bounce generated after DATA acceptance.

The Headers Tell the Story

Every stage of the lifecycle adds headers to the message. Reading headers from bottom to top reconstructs the journey:

# Added by the receiving MX (last hop, top of headers)
Received: from sender.mailertogo.com (198.51.100.42)
by mx1.example.net with ESMTPS id DEF456
for <bob@example.net>;
Tue, 11 Mar 2026 13:15:02 +0000
Authentication-Results: mx1.example.net;
spf=pass smtp.mailfrom=example.com;
dkim=pass header.d=example.com;
dmarc=pass header.from=example.com

# Added by the sending MTA/MSA (first hop, bottom of headers)
Received: from alices-laptop.local (192.0.2.10)
by smtp.example.com with ESMTPSA id ABC123
for <bob@example.net>;
Tue, 11 Mar 2026 13:15:00 +0000
DKIM-Signature: v=1; a=rsa-sha256; d=example.com; s=mtg; ...

The Received: headers are the bread crumbs. Each one records the sending host, the receiving host, the protocol used (ESMTP, ESMTPS for TLS, ESMTPSA for authenticated+TLS), a queue ID, and a timestamp. See Anatomy of Email Headers for a full guide.

The Transactional Email Path

When an application sends email through a service like Mailer To Go, the lifecycle is slightly different:

  1. Application calls the API. Your app sends a POST request with the message content, recipients, and metadata.
  2. The service constructs the message. It builds the MIME structure, adds required headers (Date, Message-ID, List-Unsubscribe if applicable), and applies DKIM signing with your domain's key.
  3. The service's MTA sends the message. The message is sent from the service's IP to the recipient's MX via SMTP on port 25, with STARTTLS.
  4. The rest is identical. MX reception, authentication checks, content filtering, MDA delivery, and client retrieval all proceed as described above.

The key difference: your application never speaks SMTP directly. The API abstracts away the entire submission layer. But the message still traverses the same infrastructure, undergoes the same authentication checks, and is evaluated by the same spam filters.

Key Takeaways

Further Reading

Related RFCs