SMTP is stated against RFC 5321, the mail message format against RFC 5322, POP3 against RFC 1939 and IMAP against RFC 9051. Port numbers come from the IANA service-name registry.
Read the vocabulary, then trace the three-leg journey until you can draw it and label every arrow from memory. The exercises are all variations on that one diagram. Solutions are at the bottom.
Two places where the standard textbook picture and current practice differ, and both are worth knowing. Port 25 is for server-to-server transfer; a mail client submitting a new message uses port 587 (RFC 6409). And the 7-bit ASCII restriction is real in base SMTP, but attachments and non-English text travel by MIME encoding on top of it, or over the 8BITMIME extension. This page teaches the classic model, which is what is examined, and flags where a real capture will look different.
Three components, and one job each#
The mail system has three moving parts, and naming them correctly makes the rest of the topic straightforward:
| Component | What it is | What it does |
|---|---|---|
| User agent | The mail reader — Outlook, Thunderbird, a phone mail app, a webmail page | Lets a person compose, edit and read messages |
| Mail server | An always-on machine holding mailboxes | Stores incoming messages, queues outgoing ones |
| SMTP | The protocol between mail servers | Transfers a message from the sender’s server to the recipient’s |
Every mail server keeps two things for each user: a mailbox holding messages that have arrived, and a message queue holding messages waiting to go out. Both matter in an answer, because a message spends time sitting in each.
One protocol moves mail between servers. A different protocol lets a person get mail out of their own server. Mail transfer and mail access are separate jobs, and the mistake this topic punishes is using one protocol for both.
Vocabulary, before anything uses it#
| Term | What it means |
|---|---|
| User agent | The program a person uses to compose and read mail. |
| Mail server | An always-on host that stores mailboxes and relays messages. |
| Mailbox | The store on a server holding messages that have arrived for one user. |
| Message queue | The store on a server holding outgoing messages waiting to be transferred. |
| SMTP | Simple Mail Transfer Protocol: the protocol that pushes a message from one mail server to another. |
| Mail access protocol | A protocol that lets a user agent retrieve messages from the user’s own mail server. |
| POP3 | Post Office Protocol version 3: a simple access protocol that downloads messages, optionally deleting them. |
| IMAP | Internet Message Access Protocol: an access protocol that keeps messages on the server and manages them there. |
| Push protocol | A protocol in which the machine holding the data initiates the transfer. |
| Pull protocol | A protocol in which the machine that wants the data initiates the transfer. |
| Handshaking | The opening greeting phase of an SMTP conversation, before any message is transferred. |
| 7-bit ASCII | A character encoding using values 0 to 127, which base SMTP requires messages to be in. |
| CRLF.CRLF | A line containing a single dot, which is how SMTP marks the end of a message body. |
| Header lines | The To:, From: and Subject: lines at the top of the message itself. |
| Webmail | Mail accessed through a browser, where the user-agent leg runs over HTTP instead of a mail protocol. |
The journey, leg by leg#
Take a message from one person to another and count the arrows. There are three, and each one is a separate question about which protocol runs on it.
sender’s agent → sender’s server → recipient’s server → recipient’s agent
- Leg 1, agent to own server. The sender composes the message and hands it to their own mail server, which puts it in the outgoing message queue. This leg uses SMTP when the sender is running a mail client — and HTTP when the sender is using webmail in a browser, because then the composing happens on a web page.
- Leg 2, server to server. The sending server opens a TCP connection directly to the recipient’s mail server on port 25 and pushes the message across. This leg is always SMTP. There is no intermediate mail server and no store-and-forward chain in the normal case — it is a direct transfer.
- Leg 3, server to recipient’s agent. The recipient’s server puts the message in their mailbox, where it sits until the recipient asks for it. Retrieving it uses a mail access protocol — POP3 or IMAP — or HTTP if the recipient uses webmail.
SMTP never carries leg 3. SMTP delivers to the recipient’s server. Getting the message out of the mailbox afterwards is a different job with different protocols. Writing “POP3 carries the message between the two mail servers” reverses the architecture and is the single most penalised error on this topic.
The two ends can differ. A sender using webmail and a recipient using a mail client produce a journey of HTTP, then SMTP, then POP3 or IMAP — three different protocols on three legs. Read what each end is using before naming anything.
Where the message physically sits along the way is worth stating too: in the sender’s outgoing queue after leg 1, and in the recipient’s mailbox after leg 2, possibly for days. A good answer mentions both, because they are why the recipient does not have to be online when the message is sent.
SMTP itself#
SMTP uses TCP for reliable transfer, on port 25 for server-to-server. A transfer has three phases: handshaking, then transfer of messages, then closure. The interaction is command and response in ASCII text, with numeric status codes — structurally very like HTTP.
S: 220 mail.example.com ESMTP ready
C: HELO relay.example.org
S: 250 Hello relay.example.org
C: MAIL FROM: <alice@example.org>
S: 250 OK
C: RCPT TO: <bob@example.com>
S: 250 OK
C: DATA
S: 354 End data with .
C: From: alice@example.org
C: To: bob@example.com
C: Subject: Lunch
C:
C: Are you free Thursday?
C: .
S: 250 Message accepted
C: QUIT
S: 221 Closing connectionThree properties get examined, and all three are visible above:
- SMTP uses persistent connections. One TCP connection can carry several messages to the same server.
- Base SMTP requires 7-bit ASCII, header and body alike. Anything else — an image, an accented character — has to be encoded into ASCII first.
- The end of a message is marked by a line containing a single dot. There is no length field, so the dot on its own line is the terminator.
The comparison with HTTP is a standard exam question, and it has a clean answer:
| HTTP | SMTP | |
|---|---|---|
| Direction of initiative | Pull — the machine that wants the data asks for it | Push — the machine that has the data sends it |
| Interaction style | ASCII command and response with status codes | The same |
| Multiple objects | Each object gets its own response message | Multiple objects go in one multipart message |
| Connections | Persistent by default in HTTP/1.1 | Persistent |
SMTP commands are not message headers. MAIL FROM: and RCPT TO: are SMTP commands that tell the server where to deliver. From: and To: are lines inside the message itself, defined by RFC 5322, and the server does not route on them. They usually agree, and nothing forces them to — which is exactly why forged sender addresses are possible.
POP3 and IMAP, and why the difference matters#
Both let a user agent retrieve mail from the user’s own server. They differ in where the messages end up living, and that one difference produces every other difference.
POP3 runs in two phases. In authorization, the client sends user and pass, and the server answers +OK or -ERR. In the transaction phase the client issues list, retr, dele and finally quit.
S: +OK POP3 server ready
C: user bob
S: +OK
C: pass hungry
S: +OK user successfully logged on
C: list
S: 1 498
S: 2 912
S: .
C: retr 1
S: <message 1 contents>
S: .
C: dele 1
C: quit
S: +OK POP3 server signing offPOP3 can run in download-and-delete mode, which removes each message from the server, or download-and-keep, which leaves it. Download-and-delete has a consequence people meet in real life: read your mail on the desktop, and it is not on the phone. And POP3 is stateless across sessions — it remembers nothing once you disconnect, so folders you make in one client mean nothing to another.
IMAP takes the opposite position: messages stay on the server. The user organises them into folders that live on the server, and IMAP keeps user state across sessions — folder names, and which message is in which folder. Every device sees the same mailbox, because there is only one mailbox.
| POP3 | IMAP | |
|---|---|---|
| Where messages live | Downloaded to the client | Kept on the server |
| Folders | Local to each client | On the server, shared by all clients |
| State across sessions | None | Kept |
| Several devices | Awkward — each holds a different subset | Natural — all see the same mailbox |
| Complexity | Simple, few commands | Considerably richer |
| Default port | 110 | 143 |
POP3 moves mail to the client. IMAP manages mail on the server. Everything else on this table follows from that one sentence, so if you can say it you can rebuild the table.
Worked example#
A sender uses a browser-based mail service to send a message. The recipient reads their mail with a desktop client configured for POP3. List, in order, the application-layer protocols used to move the message from the sender’s host to the recipient’s host.
Step 1 — Draw four endpoints and three arrows before naming anything. Sender’s host, sender’s mail server, recipient’s mail server, recipient’s host. Do not start writing protocol names until the arrows are on the page; naming before drawing is how legs get merged.
Step 2 — Label each arrow from what that end is running. The sender is in a browser, so leg 1 is a web transaction. Leg 2 is server to server, which is always the transfer protocol. The recipient is running a client configured for POP3, so leg 3 is that.
HTTP → SMTP → POP3
Step 3 — Say what each protocol did, not just its name. HTTP carried the composed message from the browser to the sender’s mail server, which queued it. SMTP pushed it over a direct TCP connection to the recipient’s mail server, which placed it in the mailbox. POP3 let the recipient’s client download it from that mailbox when the recipient chose to look.
Step 4 — Mention where it waited. In the sender’s outgoing queue, and then in the recipient’s mailbox until retrieval. That is why the recipient need not be online when it is sent.
Three legs, in chronological order, each with its protocol and a clause saying what that protocol did on that leg — plus where the message was stored between legs. A bare list of three names is a partial answer.
Practice#
- Name the three components of the email system and give each one job.
- Which protocol runs between two mail servers, and what port does it use?
- A sender uses a desktop mail client and the recipient uses IMAP. Name the protocol on each of the three legs.
- Why is SMTP described as a push protocol and HTTP as a pull protocol?
- How does an SMTP server know a message body has ended?
- What is the difference between
MAIL FROM:and theFrom:line, and what does that difference make possible? - A user reads mail on a laptop and then opens their phone to find the message missing. Which access protocol and which mode explains that, and what would have prevented it?
- Give two things IMAP does that POP3 does not, and name the single underlying difference they come from.
- Someone writes “the message travels from Alice to Bob by POP3.” Correct it in one sentence.
Solutions#
Find the first sentence where your reasoning diverged and rework from there. On this topic, check first whether your answer kept mail transfer and mail access as separate jobs — almost every wrong answer merges them.
- User agents, mail servers, SMTP. The user agent lets a person compose, edit and read messages. The mail server holds each user’s mailbox for incoming mail and a message queue for outgoing mail. SMTP transfers messages from one mail server to another.
- SMTP on port 25. SMTP, over TCP on port 25 for server-to-server transfer. A mail client submitting a new message to its own server normally uses port 587 instead.
- SMTP, SMTP, IMAP. Leg 1, client to own server: SMTP, because the sender is using a mail client rather than a browser. Leg 2, server to server: SMTP. Leg 3, server to recipient: IMAP.
- Who initiates the transfer. SMTP pushes because the machine that has the message opens the connection and sends it to the machine that will store it. HTTP pulls because the machine that wants the object opens the connection and asks for it. The difference is which end takes the initiative, not the direction the bytes travel.
- A line containing a single dot. The client sends a line containing only a dot — the CRLF.CRLF sequence. SMTP has no length field, so that line is the terminator.
- Envelope versus message content, which enables forgery.
MAIL FROM:is an SMTP command that tells the receiving server where the message came from for delivery purposes — the envelope.From:is a line inside the message, which is what the recipient’s mail reader displays. Nothing forces them to match, which is what makes a forged sender address possible. - POP3 in download-and-delete mode. POP3 in download-and-delete mode: the laptop retrieved the message and removed it from the server, so the phone had nothing to fetch. Download-and-keep mode would have left a copy, and IMAP would have avoided the problem entirely by never moving the message off the server.
- Server-side folders and cross-session state, from keeping messages on the server. IMAP lets a user organise messages into folders that live on the server, and it keeps user state across sessions, including folder names and which message is in which folder. Both follow from the one underlying difference: IMAP keeps messages on the server, while POP3 downloads them to the client.
- POP3 does not move mail between hosts. The message travels from the sender’s mail server to the recipient’s mail server by SMTP; POP3 is only what the recipient’s client uses afterwards to retrieve it from their own mailbox.
Test-readiness checklist#
- ☐ I can draw the four endpoints and three arrows before naming a single protocol.
- ☐ I can name the protocol on each leg for any combination of client and webmail at either end.
- ☐ I can say why SMTP is push and HTTP is pull in terms of who initiates.
- ☐ I can name the three phases of an SMTP transfer.
- ☐ I can state the 7-bit ASCII rule and the dot-line terminator.
- ☐ I can tell an SMTP command apart from a message header line, and say why that gap matters.
- ☐ I can give the POP3 command sequence for both phases.
- ☐ I can rebuild the POP3-versus-IMAP table from the one sentence that generates it.
- ☐ I can say where the message is stored between legs, and why the recipient need not be online.
Answer email questions as a chronological sequence with a labelled arrow for every leg, never as a list of protocol names. The marks are in the legs, and a name with no leg attached to it cannot be given credit.
Frequently asked questions#
Which protocol carries email between two mail servers?
SMTP, over TCP on port 25. The transfer is direct from the sending server to the receiving server. POP3 and IMAP never carry a message between servers; they only let a recipient retrieve mail from their own server afterwards.
What protocols are used when a webmail user emails someone who uses a mail client?
Three, one per leg. HTTP carries the message from the browser to the sender mail server. SMTP pushes it from that server to the recipient mail server. Then POP3 or IMAP, depending on what the recipient client is configured for, retrieves it from the mailbox.
Why is SMTP called a push protocol and HTTP a pull protocol?
Because of which end initiates. In SMTP the machine holding the message opens the connection and sends it. In HTTP the machine that wants the object opens the connection and asks for it. Both are ASCII command and response with status codes; only the initiative differs.
What is the main difference between POP3 and IMAP?
POP3 downloads messages to the client, optionally deleting them from the server, and keeps no state between sessions. IMAP keeps messages on the server, supports server-side folders, and keeps user state across sessions, so every device sees the same mailbox.
How does SMTP know where a message ends?
A line containing a single dot marks the end of the message body. SMTP carries no length field, so that line is the only terminator.
Something here not clear? A topic you wish we covered? Tell us. We read every message, and a request is the fastest way to get a guide written.
Test yourself in the free Kestrel Exams app
Topic-selectable practice — offline, no ads, no account. A networking question bank is not built yet; every other subject is open.
Choose your subject →