port number: 143
Note: Each client command is prefixed with an identifier (typically a short alphanumeric string,
e.g. A0001, A0002, etc.) called a "tag". A different tag is generated by the client for each command.
Commands:
- NOOP
- LOGOUT
The LOGOUT command informs the server that the client is done with
the connection. The server MUST send a BYE untagged response
before the (tagged) OK response, and then close the network
connection.
- AUTHENTICATE
The AUTHENTICATE command indicates an authentication mechanism.
- LOGIN
Format: LOGIN uername password
The LOGIN command identifies the client to the server and carries the plaintext password authenticating this user.
Possible results are:
- OK - login completed, now in authenticated state
- NO - login failure: user name or password rejected
- BAD - command unknown or arguments invalid
- SELECT
Format: SELECT mailboxname
The SELECT command selects a mailbox so that messages in the mailbox can be accessed.
Possible results are:
- OK - select completed, now in selected state
- NO - select failure, now in authenticated state: no such mailbox, can't access mailbox
- BAD - command unknown or arguments invalid
Before returning an OK to the client, the server must send the following untagged data to the client:
- FLAGS Defined flags in the mailbox.
- <n> EXISTS The number of messages in the mailbox.
- <n>RECENT The number of messages with the \Recent flag set.
- OK [UIDVALIDITY <n>] The unique identifier validity value.
- EXAMINE
Format: EXAMINE mailboxname
The EXAMINE command is identical to SELECT and returns the same output; however, the selected
mailbox is identified as read-only. No changes to the permanent state of the mailbox, including per-user state, are
permitted.
- LIST
Format: LIST reference_name mailbox_name_with_possible_wildcards
The LIST command returns a subset of names from the complete set of all names available to the client.
Zero or more
untagged LIST replies are returned, containing the name attributes, hierarchy delimiter, and name.
An empty ("" string) reference name argument indicates that the mailbox name is interpreted as by SELECT.
The returned mailbox names must match the supplied mailbox name pattern. A non-empty reference name argument is the
name of a mailbox or a level of mailbox hierarchy, and indicates a context in which the mailbox name is interpreted in
an implementation-defined manner.
- CREATE
Format: CREATE mailboxname
The CREATE command creates a mailbox with the given name. An OK response is returned only if a
new mailbox with that name has been created. It is an error to attempt to create INBOX or a mailbox with a name that
refers to an extant mailbox. Any error in creation will return a tagged NO response.
- DELETE
Format: DELETE mailboxname
The DELETE command permanently removes the mailbox with the given name. A tagged OK response
is returned only if the mailbox has been deleted. It is an error to attempt to delete INBOX or a mailbox name that
does not exist.
- RENAME
Format: RENAME existing_mailbox new_mailbox
The RENAME command changes the name of a mailbox.
- STATUS
Format: STATUS mailboxname status_data_item_names
The STATUS command requests the status of the indicated mailbox. It does not change the currently selected mailbox,
nor does it affect the state of any messages in the queried mailbox. The currently defined status data items that can
be requested are:
- MESSAGES The number of messages in the mailbox.
- RECENT The number of messages with the \Recent flag set.
- UIDNEXT The next UID value that will be assigned to a new message in the mailbox. It is guaranteed
that this value will not change unless new messages are added to the mailbox; and that it will change when new
messages are added even if those new messages are subsequently expunged.
Example:
a012 STATUS inbox (MESSAGES RECENT)
* STATUS inbox (MESSAGES 22 RECENT 0)
a012 OK STATUS completed
- CLOSE
The CLOSE command permanently removes from the currently selected
mailbox all messages that have the \Deleted flag set, and returns
to authenticated state from selected state.
- EXPUNGE
The EXPUNGE command permanently removes from the currently selected mailbox all messages that have the
\Deleted flag set. Before returning an OK to the client, an untagged EXPUNGE response
is sent for each message that is removed.
- SEARCH
Format: SEARCH optional_charset_spec search_criteria (one or more)
The SEARCH command searches the mailbox for messages that match the given searching criteria. Searching
criteria consist of one or more search keys. In all search keys that use strings, a message matches the key if
the string is a substring of the field. The matching is case-insensitive.
The defined search keys are as follows:
- message set Messages with message sequence numbers corresponding to the specified message sequence
number set
- ALL All messages in the mailbox; the default initial
key for ANDing.
- ANSWERED Messages with the \Answered flag set.
- BCC string Messages that contain the specified string in the
envelope structure's BCC field.
- BEFORE date Messages whose internal date is earlier than the
specified date.
- BODY string Messages that contain the specified string in the
body of the message.
- CC string Messages that contain the specified string in the
envelope structure's CC field.
- DELETED Messages with the \Deleted flag set.
- DRAFT Messages with the \Draft flag set.
- FLAGGED Messages with the \Flagged flag set.
- FROM string Messages that contain the specified string in the
envelope structure's FROM field.
- HEADER field-name string
Messages that have a header with the specified
field-name (as defined in [RFC-822]) and that
contains the specified string in the [RFC-822]
field-body.
- KEYWORD flag Messages with the specified keyword set.
- LARGER n Messages with an [RFC-822] size larger than the
specified number of octets.
- NEW Messages that have the \Recent flag set but not the
\Seen flag. This is functionally equivalent to
"(RECENT UNSEEN)".
- NOT search-key Messages that do not match the specified search
key.
- OLD Messages that do not have the \Recent flag set.
This is functionally equivalent to "NOT RECENT" (as
opposed to "NOT NEW").
- ON date Messages whose internal date is within the
specified date.
- OR search-key1 search-key2 Messages that match either search key.
- RECENT Messages that have the \Recent flag set.
- SEEN Messages that have the \Seen flag set.
- SENTBEFORE date
Messages whose [RFC-822] Date: header is earlier
than the specified date.
- SENTON date Messages whose [RFC-822] Date: header is within the
specified date.
- SENTSINCE date
Messages whose [RFC-822] Date: header is within or
later than the specified date.
- SINCE date Messages whose internal date is within or later
than the specified date.
- SMALLER n Messages with an [RFC-822] size smaller than the
specified number of octets.
- SUBJECT string
Messages that contain the specified string in the
envelope structure's SUBJECT field.
- TEXT string Messages that contain the specified string in the
header or body of the message.
- TO string Messages that contain the specified string in the
envelope structure's TO field.
- UID message set
Messages with unique identifiers corresponding to
the specified unique identifier set.
- UNANSWERED Messages that do not have the \Answered flag set.
- UNDELETED Messages that do not have the \Deleted flag set.
- UNDRAFT Messages that do not have the \Draft flag set.
- UNFLAGGED Messages that do not have the \Flagged flag set.
- UNKEYWORD flag
Messages that do not have the specified keyword
set.
- UNSEEN Messages that do not have the \Seen flag set.
Example:
a023 SEARCH BODY ist362
- FETCH
Format: FETCH message_set message_data_item_names
The FETCH command retrieves data associated with a message in the mailbox. The data items to be fetched
can be either a single atom or a parenthesized list. Message set is either a UID of a specific message, or a sequence
of UIDs separated with commas, or a set of UIDs assigned by two boundaries (first:last).
The currently defined data items that can be fetched are:
- ALL Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE)
- BODY Non-extensible form of BODYSTRUCTURE.
- BODY[section]<<partial>>
The text of a particular body section. The section
specification is a set of zero or more part
specifiers delimited by periods. A part specifier
is either a part number or one of the following:
HEADER, HEADER.FIELDS, HEADER.FIELDS.NOT, MIME, and
TEXT. An empty section specification refers to the
entire message, including the header.
- BODY.PEEK[section]<<partial>>
An alternate form of BODY[section] that does not implicitly set the \Seen flag.
- BODYSTRUCTURE The [MIME-IMB] body structure of the message. This is computed by the server by
parsing the [MIME-IMB] header fields in the [RFC-822] header and [MIME-IMB] headers.
- ENVELOPE The envelope structure of the message. This is computed by the server by parsing the
[RFC-822] header into the component parts, defaulting
various fields as necessary.
- FAST Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE)
- FLAGS The flags that are set for this message.
- FULL Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE BODY)
- INTERNALDATE The internal date of the message.
- UID The unique identifier for the message.
a017 FETCH 1:22 (FLAGS BODY[HEADER.FIELDS (DATE FROM SUBJECT)])
a123 FETCH * (FLAGS)
- STORE
Format: STORE message_set message_data_item_name value_for_message_data_item
The STORE command alters data associated with a message in the mailbox.
The currently defined data items that can be stored are:
- FLAGS flag list
Replace the flags for the message with the
argument. The new value of the flags are returned
as if a FETCH of those flags was done.
- FLAGS.SILENT flag list
Equivalent to FLAGS, but without returning a new
value.
- +FLAGS flag list
Add the argument to the flags for the message. The
new value of the flags are returned as if a FETCH
of those flags was done.
- +FLAGS.SILENT flag list
Equivalent to +FLAGS, but without returning a new
value.
- -FLAGS flag list
Remove the argument from the flags for the message.
The new value of the flags are returned as if a
FETCH of those flags was done.
- -FLAGS.SILENT flag list
Equivalent to -FLAGS, but without returning a new
value.
Example: a023 STORE 2:4 +FLAGS (\Deleted)
The currently-defined system flags are:
- \Seen -- Message has been read
- \Answered -- Message has been answered
- \Flagged -- Message is "flagged" for urgent/special attention
- \Deleted -- Message is "deleted" for removal by later EXPUNGE
- \Draft -- Message has not completed composition (marked as a draft).
- \Recent -- Message is "recently" arrived in this mailbox. This session is the first session to
have been notified about this message; subsequent sessions will not see \Recent set for this
message. This flag can not be altered by the client.
- COPY
Format: COPY message_set mailboxname
The COPY command copies the specified message(s) to the end of the specified destination mailbox. The flags and
internal date of the message(s) SHOULD be preserved in the copy.
- UID
- APPEND
- SUBSCRIBE
- UNSUBSCRIBE
- LSUB
- CHECK
Typical scenario:
a001 LOGIN username password
a002 SELECT inbox
a003 FETCH 1:22 (FLAGS BODY[HEADER.FIELDS (DATE FROM SUBJECT)])
a004 FETCH 22 (FLAGS BODY[TEXT])
a005 FETCH 21 (FLAGS BODY[TEXT])
a006 FETCH 20 (FLAGS BODY[TEXT])
a007 COPY 22 test
a008 STORE 21:22 +FLAGS (\Deleted)
a009 SEARCH BODY test
a010 SEARCH BODY test NOT FROM someaddr@somewhere.edu
a011 FETCH 8,19 (BODY[HEADER.FIELDS (FROM SUBJECT)])
a012 CLOSE
a013 SELECT test
a014 STATUS test (MESSAGES)
a015 FETCH 1:2 (FLAGS BODY[HEADER.FIELDS (FROM SUBJECT)])
a016 STORE 1:2 FLAGS (\Answered)
a017 LOGOUT
Please use this command line IMAP client to manually work with the
IMAP protocol.
Official information: Internet Mail Access Protocol.