IMAP (Internet Message Access Protocol) is an application-layer protocol used by email clients to retrieve and manage messages on a remote mail server while keeping them synchronized across devices. Unlike POP3, which typically downloads messages to a single device and removes them from the server, IMAP treats the server as the primary source of truth. Any state change—such as marking an email as read, moving it to a folder, or deleting it—propagates across every connected desktop, mobile, and web client.
How it works
When an email client connects to a mail server—standardly over port 993 using implicit TLS (IMAPS)—it authenticates and synchronizes the folder hierarchy alongside message headers and metadata flags (such as \Seen, \Answered, or \Draft). The client downloads full message bodies and attachments only on demand when a user opens a specific email, conserving local storage and bandwidth.
Modern implementations rely on IMAP4rev1 (RFC 3501) and IMAP4rev2 (RFC 9051) alongside performance extensions:
- Real-time push via
IDLE: Instead of polling the server at fixed intervals, the client holds an open TCP connection so the server can immediately notify it of new arrivals. - Server-side search: The server indexes and searches mailstores directly, returning matching message IDs without forcing the client to download the entire archive.
- Concurrent sessions: Multiple devices can maintain simultaneous connections to the same mailbox without locking conflicts.
- Efficient resync (
CONDSTORE/QRESYNC): Extensions allow reconnecting clients to fetch only flag changes and expunged messages since their last session.
Example
In a typical Linux mail stack using Dovecot as the IMAP server, administrators enforce encrypted connections and configure Maildir storage so concurrent IMAP sessions do not corrupt mailbox files:
# /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:~/Maildir
# /etc/dovecot/conf.d/10-ssl.conf
ssl = required
ssl_cert = </etc/letsencrypt/live/https://mail.example.com/fullchain.pem
ssl_key = </etc/letsencrypt/live/https://mail.example.com/privkey.pem
# /etc/dovecot/conf.d/10-master.conf
service imap-login {
inet_listener imap {
port = 0
}
inet_listener imaps {
port = 993
ssl = yes
}
}
Setting port = 0 on the unencrypted listener disables plaintext port 143, forcing all mail clients onto TLS-encrypted port 993.
What matters when choosing a server or hosting
- Storage capacity and IOPS: Because the server retains all mail indefinitely, disk space scales directly with user retention habits. High-IOPS SSD or NVMe storage is critical when indexing large Maildir directories with tens of thousands of small files.
- Concurrent connection limits: Each mobile app or desktop client often opens multiple background connections (one per monitored folder). Ensure your hosting plan or Dovecot configuration sets appropriate
mail_max_userip_connectionslimits to avoid blocking legitimate users behind a shared office NAT IP. - Full-text search indexing: On large mailboxes, unindexed IMAP searches cause high CPU and disk spikes. Look for servers supporting dedicated search backends like Solr, Xapian, or Flatcurve.
- Automated backups: Since IMAP synchronizes deletions immediately, an accidental purge on one device wipes the server copy. Server-level snapshots or incremental backups are essential for recovery.
Common mistakes
- Confusing IMAP with SMTP: IMAP only retrieves and organizes existing mail. Outgoing messages still require SMTP (typically over port
465or587) for submission and relay. - Leaving plaintext port 143 exposed without STARTTLS enforcement: Allowing unencrypted authentication exposes user credentials on public networks. Always enforce TLS via port
993or requireSTARTTLSbefore authentication. - Using mbox format for busy IMAP accounts: Storing an entire folder in a single
mboxfile causes severe file-locking contention when multiple devices access the mailbox concurrently. UseMaildirormdboxinstead.
FAQ
What is the difference between port 143 and port 993?
Port 143 is the standard port for unencrypted IMAP, which relies on the STARTTLS command to upgrade to an encrypted session. Port 993 (IMAPS) initiates TLS encryption immediately upon connection and is the recommended default for modern clients.
Does IMAP send emails?
No. IMAP strictly handles reading, organizing, and synchronizing messages stored on the server. When you click send, your email client hands the message off to an SMTP server for delivery.
Why does IMAP use more server storage than POP3?
POP3 is designed to download messages to a local client and delete them from the server, freeing up host disk space. IMAP keeps the complete archive on the server permanently so every connected device sees the exact same mailbox state.