Table of Contents
Concepts
Summery
IMAP (Internet Message Access Protocol) lets you access and manage emails stored on a mail server. It handles receiving, organizing, and syncing emails between devices. Sending emails is normally handled by SMTP, not IMAP. IMAP commands use tags like A1 or 1 so the server can match responses to requests. In simple words, it’s a more advanced POP3.
Ports
Plain IMAP uses port 143.
IMAPS uses port 993.
Access
telnet or netcat for normal IMAP
openssl s_client -connect mail.example.com:993 for IMAPS
Tools
Scripts
Commands
LOGIN - authenticates to the IMAP server using a username and password. Example - A1 LOGIN john dqsTwTpZPn#nL.
LIST - displays available mailboxes, such as INBOX, Sent, and Trash. Example - A1 LIST "" "*".
CREATE - creates a new mailbox/folder.
DELETE - permanently removes a mailbox/folder.
RENAME - changes a mailbox’s name.
LSUB - lists mailboxes the user is subscribed to.
SELECT - opens a mailbox so messages can be read or manipulated. Example - A1 SELECT INBOX.
UNSELECT - leaves the currently selected mailbox without closing it.
FETCH - retrieves message information, such as headers, body, or flags. Example - A1 FETCH 0 BODY[].
CLOSE - closes the selected mailbox, expunging messages marked deleted.
LOGOUT - terminates the IMAP session.
CHILDREN - requests information about child mailboxes in a hierarchy.
IDLE - keeps the connection open for real-time mailbox updates.
QUOTA - retrieves mailbox storage/usage limits.
SORT - sorts messages according to criteria such as date or sender.
ACL - manages access-control permissions on mailboxes.
NAMESPACE - shows the server’s mailbox namespace structure.
RIGHTS - displays the permissions assigned to a user for a mailbox.
Typical usage:
A1 LOGIN john dqsTwTpZPn#nL
A1 LIST "" "*"
A1 SELECT INBOX`
A1 FETCH 0 BODY[]