Networking / Email delivery (SMTP, IMAP, POP3)

Email delivery (SMTP, IMAP, POP3)

Trace one message from alice@example.com to bob@example.net: submitted and relayed with SMTP, routed by an MX record, queued, filtered, and finally read over IMAP or POP3.

Beginner7 steps~7 min
Alice — sends from alice@example.com
Mail server — accepts, queues and passes mail on
Message — the email being carried
Bob — reads at bob@example.net
// THE SHORT VERSION

In 30 seconds

An email travels in hops. Your mail app hands the message to your provider’s server, which looks up the recipient’s mail server in DNS (the MX record) and passes it on. Both handovers use SMTP.

Every server stores the message before forwarding it, so nothing is lost if the next machine is briefly offline. The receiving server also decides what is spam.

Reading is a separate job: IMAP keeps mail on the server and syncs every device, while POP3 downloads it to one.

Email delivery (SMTP, IMAP, POP3), step by step

STEPS01 / 07

Simplified: one sending and one receiving server. Large providers pass a message through several internal servers, and retry schedules vary from one to the next.

STEP 01 / 07 Four machines, three hops
THE MATH
alice@example.com → bob@example.net submit, relay, fetch
  1. Step 1: Four machines, three hops. Alice’s message does not go straight to Bob’s screen. Her mail app gives it to her provider’s server, that server passes it to the server for Bob’s domain, and Bob’s app collects it from there. The part of an address after the @ names the domain whose server takes the mail.
  2. Step 2: Submit with SMTP. Alice’s app logs in to her provider’s server and hands the message over using SMTP, the Simple Mail Transfer Protocol. The server does not deliver it at once. It accepts it, puts it in a queue of outgoing mail and tells the app it has it. From here on, Alice’s app is no longer involved.
  3. Step 3: Look up the MX record. To find where mail for example.net should go, Alice’s server asks DNS for the domain’s MX (mail exchanger) records. Each names a mail server and gives it a preference number; the lowest number is tried first, the others are backups. One more lookup turns that name into an address.
  4. Step 4: Relay, server to server. Alice’s server connects to mx1.example.net on port 25 and the two hold a short SMTP conversation: who is sending, who it is for, then the message itself. Each line gets a numbered reply; 250 means accepted. After the final 250 the message is the receiving server’s responsibility.
  5. Step 5: Store and forward. Email never needs every machine to be online at once. If Bob’s server does not answer, Alice’s server keeps the message in its queue and tries again later, typically for several days, before giving up and sending Alice a bounce notice. Each hop stores the message first and forwards it when it can.
  6. Step 6: Spam checks at the door. Most filtering happens at the receiving server, as the message arrives. It checks whether the sending server is allowed to send for example.com (SPF), whether the message carries a valid signature from that domain (DKIM), what the domain asks to be done on failure (DMARC), and how the content and sender look.
  7. Step 7: Read it: IMAP or POP3. SMTP only pushes mail towards a mailbox; reading uses a different protocol. With IMAP the messages stay on the server and every device shows the same synchronised mailbox. With POP3 one device downloads them and, in the usual setup, they are then deleted from the server.
VALUES SO FAR
tobob@example.netinput
submit····rule
MX····DNS
mx1····DNS
relay····rule
accepted····reply
if down····rule
checks····receiver
reading····rule

Spotted a mistake on this page?