Network Working Group M. Crispin
Request for Comments: 1064 SUMEX-AIM
July 1988
INTERACTIVE MAIL ACCESS PROTOCOL - VERSION 2
Crispin [Page 1]
RFC 1064 IMAP2 July 1988
(1) Workstations (especially Lisp workstations) have a software design that gives full control of all aspects of the system to the user at the console. As a result, background tasks, like receiving mail, could well be kept from running for long periods of time either because the user is asking to use all of the machine's resources, or because, in the course of working, the user has (perhaps accidentally) manipulated the environment in such a way as to prevent mail reception. This could lead to repeated failed delivery attempts by outside agents.
Crispin [Page 2]
RFC 1064 IMAP2 July 1988
The mail server acts an an interface among users, data storage, and other mailers. The mail access protocol is used to retrieve messages, access and change properties of messages, and manage mailboxes. This differs from some approaches (e.g., Unix mail via NFS) in that the mail access protocol is used for all message manipulations, isolating the user and the client from all knowledge of how the data storage is used. This means that the mail server can utilize the data storage in whatever way is most efficient to organize the mail in that particular environment, without having to worry about storage representation compatibility across different machines.
Crispin [Page 3]
RFC 1064 IMAP2 July 1988
In PCMAIL, there is a long-term client/server relationship in which some mailbox state is preserved on the client. There is a registration of clients used by a particular user, and the client keeps a set of "descriptors" for each message which summarize the message. The server and client synchronize their states when the DMSP connection starts up, and, if a client has not accessed the server for a while, the client does a complete reset (reload) of its state from the server.
Crispin [Page 4]
RFC 1064 IMAP2 July 1988
The Protocol
Crispin [Page 5]
RFC 1064 IMAP2 July 1988
The second category is that data which describes the composition and delivery information of a message; that is, information such as the message sender, recipient lists, message-ID, subject, etc. This is the information which is stored in the message header in RFC 822 format message and is traditionally called the "envelope". [Note: this should not be confused with the SMTP (RFC 821) envelope, which is strictly limited to delivery information.] IMAP2 defines a structured and unambiguous representation for the envelope which is particularly nice for Lisp-based parsers. A client can use the envelope for operations such as replying and not worry about RFC 822 at all. Envelopes are discussed in more detail below. The first and second category data can be fetched together by using the macro-fetch word "ALL"; that is, "ALL" expands to "(FLAGS INTERNALDATE RFC822.SIZE ENVELOPE)".
Crispin [Page 6]
RFC 1064 IMAP2 July 1988
Client Server
------ ------
{Wait for Connection}
{Open Connection} -->
Crispin [Page 7]
RFC 1064 IMAP2 July 1988
Conventions
Crispin [Page 8]
RFC 1064 IMAP2 July 1988
Definitions of Commands and Responses
Commands || Responses
-------- || -------
tag NOOP || tag OK text
tag LOGIN user password || tag NO text
tag LOGOUT || tag BAD text
tag SELECT mailbox || * message_number data
tag CHECK || * FLAGS flag_list
tag EXPUNGE || * SEARCH sequence
tag COPY sequence mailbox || * BYE text
tag FETCH sequence data || * OK text
tag STORE sequence data value || * NO text
tag SEARCH search_program || * BAD text
|| + text
Commands
Crispin [Page 9]
RFC 1064 IMAP2 July 1988
Multiple SELECT commands are permitted in a session, in which case the prior mailbox is deselected first.
Crispin [Page 10]
RFC 1064 IMAP2 July 1988
tag COPY sequence mailbox
Crispin [Page 11]
RFC 1064 IMAP2 July 1988
FLAGS The flags which are set for this message.
RFC822 The message in RFC 822 format.
RFC822.HEADER The RFC 822 format header of the message.
+FLAGS Add the flags in the argument to the
message's flag list.
Crispin [Page 12]
RFC 1064 IMAP2 July 1988
-FLAGS Remove the flags in the argument from the
message's flag list.
STORE is not allowed if the user does not have write access to this mailbox.
Crispin [Page 13]
RFC 1064 IMAP2 July 1988
ON date Messages whose internal date is the same as
RECENT Messages which have the \RECENT flag set.
SEEN Messages which have the \SEEN flag set.
UNSEEN Messages which do not have the \SEEN flag set.
EXAMPLE: A003 SEARCH DELETED FROM "SMITH" SINCE 1-OCT-87 returns the message numbers for all deleted messages from Smith that were placed in the mail file since October 1, 1987.
Crispin [Page 14]
RFC 1064 IMAP2 July 1988
Responses
Crispin [Page 15]
RFC 1064 IMAP2 July 1988
envelope of a message. The envelope is computed by the server by parsing the RFC 822 header into the component parts, defaulting various fields as necessary.
Crispin [Page 16]
RFC 1064 IMAP2 July 1988
characters in the message as expressed in RFC 822 format.
Crispin [Page 17]
RFC 1064 IMAP2 July 1988
+ text
Crispin [Page 18]
RFC 1064 IMAP2 July 1988
Sample IMAP2 session
S: Larry
S: -------
Crispin [Page 19]
RFC 1064 IMAP2 July 1988
S: ) S: pa004 OK Fetch completed U: a005 logout S: * BYE DEC-20 IMAP II server terminating connection S: a005 OK SUMEX-AIM.Stanford.EDU Interim Mail Access Protocol
Crispin [Page 20]
RFC 1064 IMAP2 July 1988
Implementation Discussion
Crispin [Page 21]
RFC 1064 IMAP2 July 1988
Another advantage is that a non-lockstep client implementation is possible. The client could send a command, and entrust the handling of the server responses to a different process which would signal the client when the tagged response comes in. Under certain circumstances, the client could even have more than one command outstanding.
Crispin [Page 22]
RFC 1064 IMAP2 July 1988
People familiar with demand-paged virtual memory operating system design will recognize this model as being very similar to page-fault handling on a demand-paged system.
Crispin [Page 23]
RFC 1064 IMAP2 July 1988
Formal Syntax
env_cc ::= nil / "(" 1*address ")"
env_date ::= string
Crispin [Page 24]
RFC 1064 IMAP2 July 1988
env_to ::= nil / "(" 1*address ")"
expunge ::= "EXPUNGE"logout ::= "LOGOUT"mailbox ::= "INBOX" / string
Crispin [Page 25]
RFC 1064 IMAP2 July 1988
ready ::= "+" SP text_line
search ::= "SEARCH" SP 1#("ALL" / "ANSWERED" /
"BCC" SP string / "BEFORE" SP string /
"BODY" SP string / "CC" SP string / "DELETED" / "FLAGGED" / "KEYWORD" SP atom / "NEW" / "OLD" / "ON" SP string / "RECENT" / "SEEN" / "SINCE" SP string / "TEXT" SP string / "TO" SP string / "UNANSWERED" / "UNDELETED" / "UNFLAGGED" / "UNKEYWORD" / "UNSEEN")select ::= "SELECT" SP mailboxsequence ::= NUMBER / (NUMBER "," sequence) / (NUMBER ":"
string ::= atom / """" 1*character """" / literalsystem_flags ::= "\ANSWERED" SP "\FLAGGED" SP "\DELETED" SP
userid ::= stringAcknowledgements