IMAP & POP3 — Reading Your Email

IMAP-POP3

SMTP delivers mail to servers; IMAP and POP3 are how clients retrieve it. IMAP keeps mail on the server and synchronises state across devices — the modern standard. POP3 downloads and deletes — a relic of the single-device era that still sees use in specific scenarios.

applicationimappop3emailrfc9051rfc1939

Overview

When an email arrives at a mail server, SMTP’s job is done — the message is stored in a mailbox. The user needs a separate protocol to access that mailbox from their email client. Two protocols serve this purpose:

POP3 (Post Office Protocol version 3) — defined in RFC 1939 (1996). Designed for the era of single, always-connected desktop computers. Downloads messages to the local machine and (typically) deletes them from the server.

IMAP (Internet Message Access Protocol) — currently IMAPv4rev2, RFC 9051 (2021). Designed for a world where users access email from multiple devices. Mail stays on the server; clients synchronise folders and message state (read/unread, flagged, deleted).

In 2026, IMAP dominates. POP3 persists in automated processing pipelines, legacy systems, and niche use cases where local-only storage is desired.

FeatureIMAPPOP3
Mail storedOn serverDownloaded to client
Multi-device syncYesNo (unless configured)
Folder managementFullNone
Server-side searchYesNo
Partial message fetchYes (just headers, no body)No (full message)
Port (plaintext)143110
Port (TLS)993995

IMAP — Server-Side Mailbox Management

IMAP treats the mail server as the authoritative store. Clients download messages on demand and synchronise state changes back to the server. Reading a message on your phone marks it read on your laptop too.

Mail Client
IMAP Server
TCP Connect → port 993 (TLS)
* OK Dovecot ready
Server greeting
a1 LOGIN alice password
Authenticate (ideally SASL AUTH over TLS)
a1 OK LOGIN completed
a2 SELECT INBOX
Open a mailbox
* 42 EXISTS * 3 RECENT a2 OK [READ-WRITE] SELECT completed
42 messages total, 3 new
a3 FETCH 40:42 (FLAGS ENVELOPE)
Fetch headers for messages 40–42
* 40 FETCH (FLAGS (\Seen) ENVELOPE (...)) * 41 FETCH ... * 42 FETCH ...
Message metadata
a4 FETCH 42 BODY[]
Fetch full body of message 42
* 42 FETCH (BODY[] {2048} <message data>)
Full message content
a5 STORE 42 +FLAGS (\Seen)
Mark as read
* 42 FETCH (FLAGS (\Seen))
State updated on server
a6 LOGOUT

IMAP Protocol Structure

Every IMAP command is prefixed with a tag (like a1, a2) — a unique identifier that allows the client to match responses to commands. The server can send untagged responses (prefixed with *) asynchronously — for example, notifying the client that new mail arrived while it was idle.

Sequence numbers vs UIDs: IMAP can refer to messages by sequence number (position in the mailbox — changes when messages are deleted) or by UID (a permanent, monotonically increasing identifier that persists across sessions). UIDs are preferred for reliable synchronisation; sequence numbers are used for interactive commands.

IMAP Flags

Message state is stored as flags on the server, visible to all clients:

FlagMeaning
\SeenMessage has been read
\AnsweredMessage has been replied to
\FlaggedMarked important (starred)
\DeletedMarked for deletion — not yet removed
\DraftDraft message

\Deleted does not immediately remove the message — the client must issue EXPUNGE to permanently remove all messages flagged \Deleted. This allows clients to batch deletions.

IMAP IDLE — Push Notifications

Without IDLE, clients must poll for new mail (CHECK or NOOP on a timer). The IDLE command (RFC 2177) allows the client to tell the server “notify me when something changes.” The server keeps the connection open and sends untagged responses immediately when new mail arrives, a flag changes, or a message is deleted. IMAP IDLE is the backbone of near-instant email push on mobile devices.

IMAP includes a rich SEARCH command that runs on the server — the client does not need to download messages to search them:

SEARCH SINCE 1-Mar-2026 FROM "[email protected]" SUBJECT "invoice"

Returns the sequence numbers of matching messages. The client then fetches only those messages.


POP3 — Download and Delete

POP3 is a much simpler protocol. It was designed when a user had one computer that was occasionally dialed in to retrieve mail. The model: connect, download everything new, disconnect, read offline.

Mail Client
POP3 Server
TCP Connect → port 995 (TLS)
+OK POP3 server ready
USER alice
+OK
PASS password
+OK 5 messages (120480 octets)
5 messages waiting
LIST
List message sizes
+OK 5 messages 1 4512 2 8903 ...
Message number and size in bytes
RETR 1
Download message 1
+OK 4512 octets <message data>
Full message
DELE 1
Mark for deletion
QUIT
Session ends — deletions committed

POP3 has no folders, no server-side search, no synchronisation. The only state it tracks is which messages have been retrieved. DELE marks a message for deletion; deletions are committed when the session ends with QUIT.

POP3 with “leave on server”: Most clients can be configured to leave messages on the server after downloading. This enables multi-device access, but the server has no way to synchronise read state across clients — every client sees every message as unread.


Which Should You Use?

Use IMAP for any human mailbox accessed from more than one device (phone, laptop, webmail). IMAP is the correct choice for all modern email setups.

POP3 is appropriate for:

In practice: Consumer email providers (Gmail, Outlook, iCloud) support both. Corporate mail (Exchange, Dovecot) is almost always IMAP. If a user asks which to configure — IMAP.


TLS for IMAP and POP3

Both protocols have plaintext and TLS variants:

Never use plain IMAP or POP3 for real mailboxes — passwords are transmitted in cleartext.


References