IMAP

Tagged commands and selected mailboxes

Read tagged client commands, untagged server data, completion responses, and mailbox selection.

8 minute lesson

~~~

Every IMAP client command begins with a tag chosen by the client, such as A001. The final server response repeats that tag so several outstanding commands can be matched.

Untagged responses begin with * and carry data or state changes. A continuation request begins with +.

After authentication, LIST discovers mailboxes and SELECT INBOX opens one for read-write access. EXAMINE opens a mailbox read-only.

Tags make concurrency readable:

C: A001 LIST "" "*"
S: * LIST (\HasNoChildren) "/" "INBOX"
S: A001 OK LIST completed
C: A002 SELECT INBOX
S: * 42 EXISTS
S: * OK [UIDVALIDITY 93842] UIDs valid
S: A002 OK [READ-WRITE] SELECT completed

The untagged lines are data. A001 OK and A002 OK complete their matching commands. NO means a valid command could not be performed; BAD means a protocol or syntax problem.

Mailbox names and hierarchy delimiters come from the server. Do not split every mailbox name on /; the LIST response states the delimiter, and a NIL delimiter means no hierarchy is available.

SELECT returns synchronization evidence such as message count, UIDVALIDITY, and often UIDNEXT. Cache those values with the mailbox. A successful selection of the same display name does not prove its UID generation stayed the same.

Add a second command tag before A001 completes. Then match every final response to its command and separate untagged data from completion status.

Lesson completed

Take this course offline

Get every free book and course as PDF and EPUB files.

Get the download library →