What is IMAP? How email syncs across devices
The protocol that keeps your mail on the server and in sync across every device you use.
What IMAP does
IMAP stands for Internet Message Access Protocol. It is the standard way for a mail app to read and organize email that lives on a mail server. Your messages stay on the server, and the app works on them remotely: it downloads what it needs to show you, and it tells the server about every change you make.
That is why IMAP feels like sync. Read a message on your phone and it shows as read on your laptop. Move a message to a folder on your laptop and the phone sees it in that folder too. Every device is a window onto the same mailbox.
The current version is IMAP4rev2, published as RFC 9051 in 2021. Most servers still speak IMAP4rev1 (RFC 3501, from 2003), and the two are close enough that clients handle both.
How a client talks to an IMAP server
IMAP is a text protocol. The client sends commands, each starting with a short tag, and the server answers with lines that carry the same tag when the command is done. A shortened session looks like this:
C: a1 LOGIN alice@example.com ********
S: a1 OK LOGIN completed
C: a2 SELECT INBOX
S: * 172 EXISTS
S: * OK [UIDVALIDITY 3857529045] UIDs valid
S: a2 OK [READ-WRITE] SELECT completed
C: a3 FETCH 172 (FLAGS BODY.PEEK[HEADER.FIELDS (FROM SUBJECT DATE)])
S: * 172 FETCH (FLAGS (\Seen) BODY[...] {98}
S: a3 OK FETCH completedFolders, flags and push
In IMAP terms, folders are called mailboxes. Each message has a unique ID (UID) inside its mailbox, and a set of flags such as \Seen (read), \Answered, \Flagged (starred), \Draft and \Deleted. Changing a flag on one device changes it on the server, so every other device picks it up.
Clients can fetch just the headers of a message, or one attachment, without downloading the whole thing. Servers can also run searches, so a client can ask for every message from a given sender without scanning the mailbox itself.
For new mail, most clients use the IDLE command (RFC 2177). The client keeps the connection open and the server pushes a notice the moment a message arrives, instead of the client checking every few minutes.
Ports and what IMAP does not do
IMAP servers listen on port 993 for connections that are encrypted with TLS from the first byte, and on port 143 for connections that start in plain text and may upgrade with STARTTLS. Nearly every major provider uses 993, for example imap.gmail.com on port 993.
IMAP only reads and manages mail. Sending is a separate job handled by SMTP, which is why mail apps ask for both an incoming (IMAP) and an outgoing (SMTP) server when you set up an account by hand.
Questions
- If I delete a message in my mail app, is it deleted on the server?
- Yes. With IMAP the app marks the message deleted on the server (or moves it to Trash), so it disappears on every device. That is the main difference from POP3, which usually removes mail from the server after download.
- Is IMAP secure?
- IMAP over port 993 encrypts the whole connection with TLS, including your password. Plain IMAP on port 143 without STARTTLS sends everything in readable text, so avoid it on any network you do not control.
- Does IMAP use storage on the server?
- Yes. Because mail stays on the server, it counts against your provider's storage quota. Many clients also keep a local copy so you can read mail offline.
In Bloop.email
Bloop.email connects straight from your Mac to your provider over IMAP for reading and SMTP for sending (or Microsoft's sign-in for Outlook), with no Bloop server in between. It works with Gmail, Outlook, iCloud, Yahoo, AOL, Fastmail, Zoho and any other IMAP account.
See the features