idnits 2.17.1 draft-melnikov-rfc3501bis-05.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The document seems to lack an Introduction section. ** There is 1 instance of too long lines in the document, the longest one being 3 characters in excess of 72. -- The draft header indicates that this document obsoletes RFC3501, but the abstract doesn't seem to mention this, which it should. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == The document seems to contain a disclaimer for pre-RFC5378 work, but was first submitted on or after 10 November 2008. The disclaimer is usually necessary only for documents that revise or obsolete older RFCs, and that take significant amounts of text from those RFCs. If you can contact all authors of the source material and they are willing to grant the BCP78 rights to the IETF Trust, you can and should remove the disclaimer. Otherwise, the disclaimer is needed and you can ignore this comment. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (October 18, 2015) is 3110 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Missing Reference: 'IMAP2' is mentioned on line 4184, but not defined == Missing Reference: 'IMAP-OBSOLETE' is mentioned on line 4179, but not defined == Missing Reference: 'IMAP-COMPAT' is mentioned on line 4169, but not defined == Missing Reference: 'IMAP-HISTORICAL' is mentioned on line 4174, but not defined == Missing Reference: 'RFC-822' is mentioned on line 4188, but not defined ** Obsolete undefined reference: RFC 822 (Obsoleted by RFC 2822) == Missing Reference: 'HEADER' is mentioned on line 3415, but not defined == Missing Reference: 'IMAP-DISC' is mentioned on line 4149, but not defined == Missing Reference: 'SMTP' is mentioned on line 4163, but not defined == Missing Reference: 'UNSEEN 12' is mentioned on line 1457, but not defined == Missing Reference: 'UIDVALIDITY 3857529045' is mentioned on line 3398, but not defined == Missing Reference: 'UIDNEXT 4392' is mentioned on line 1491, but not defined == Missing Reference: 'UNSEEN 8' is mentioned on line 1489, but not defined == Missing Reference: 'TEXT' is mentioned on line 3351, but not defined == Missing Reference: 'UNSEEN 17' is mentioned on line 3397, but not defined == Missing Reference: 'READ-WRITE' is mentioned on line 3399, but not defined == Missing Reference: 'IMAP-TLS' is mentioned on line 4196, but not defined == Missing Reference: 'IMAP-MODEL' is mentioned on line 4154, but not defined == Missing Reference: 'ACAP' is mentioned on line 4159, but not defined == Missing Reference: 'RFC-821' is mentioned on line 4192, but not defined ** Obsolete undefined reference: RFC 821 (Obsoleted by RFC 2821) == Unused Reference: 'IMAP-MULTIACCESS' is defined on line 4142, but no explicit reference was found in the text ** Obsolete normative reference: RFC 2831 (ref. 'DIGEST-MD5') (Obsoleted by RFC 6331) ** Obsolete normative reference: RFC 5246 (ref. 'TLS') (Obsoleted by RFC 8446) ** Downref: Normative reference to an Informational RFC: RFC 2152 (ref. 'UTF-7') ** Downref: Normative reference to an Informational RFC: RFC 2683 (ref. 'IMAP-IMPLEMENTATION') ** Downref: Normative reference to an Informational RFC: RFC 2180 (ref. 'IMAP-MULTIACCESS') Summary: 9 errors (**), 0 flaws (~~), 22 warnings (==), 3 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group A. Melnikov, Ed. 3 Internet-Draft Isode Ltd 4 Obsoletes: 3501 (if approved) October 18, 2015 5 Intended status: Standards Track 6 Expires: April 20, 2016 8 INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1 9 draft-melnikov-rfc3501bis-05.txt 11 Abstract 13 The Internet Message Access Protocol, Version 4rev1 (IMAP4rev1) 14 allows a client to access and manipulate electronic mail messages on 15 a server. IMAP4rev1 permits manipulation of mailboxes (remote 16 message folders) in a way that is functionally equivalent to local 17 folders. IMAP4rev1 also provides the capability for an offline 18 client to resynchronize with the server. 20 IMAP4rev1 includes operations for creating, deleting, and renaming 21 mailboxes, checking for new messages, permanently removing messages, 22 setting and clearing flags, RFC 5322 and RFC 2045 parsing, searching, 23 and selective fetching of message attributes, texts, and portions 24 thereof. Messages in IMAP4rev1 are accessed by the use of numbers. 25 These numbers are either message sequence numbers or unique 26 identifiers. 28 IMAP4rev1 supports a single server. A mechanism for accessing 29 configuration information to support multiple IMAP4rev1 servers is 30 discussed in RFC 2244. 32 IMAP4rev1 does not specify a means of posting mail; this function is 33 handled by a mail transfer protocol such as RFC 5321. 35 Status of This Memo 37 This Internet-Draft is submitted in full conformance with the 38 provisions of BCP 78 and BCP 79. 40 Internet-Drafts are working documents of the Internet Engineering 41 Task Force (IETF). Note that other groups may also distribute 42 working documents as Internet-Drafts. The list of current Internet- 43 Drafts is at http://datatracker.ietf.org/drafts/current/. 45 Internet-Drafts are draft documents valid for a maximum of six months 46 and may be updated, replaced, or obsoleted by other documents at any 47 time. It is inappropriate to use Internet-Drafts as reference 48 material or to cite them other than as "work in progress." 49 This Internet-Draft will expire on April 20, 2016. 51 Copyright Notice 53 Copyright (c) 2015 IETF Trust and the persons identified as the 54 document authors. All rights reserved. 56 This document is subject to BCP 78 and the IETF Trust's Legal 57 Provisions Relating to IETF Documents 58 (http://trustee.ietf.org/license-info) in effect on the date of 59 publication of this document. Please review these documents 60 carefully, as they describe your rights and restrictions with respect 61 to this document. Code Components extracted from this document must 62 include Simplified BSD License text as described in Section 4.e of 63 the Trust Legal Provisions and are provided without warranty as 64 described in the Simplified BSD License. 66 This document may contain material from IETF Documents or IETF 67 Contributions published or made publicly available before November 68 10, 2008. The person(s) controlling the copyright in some of this 69 material may not have granted the IETF Trust the right to allow 70 modifications of such material outside the IETF Standards Process. 71 Without obtaining an adequate license from the person(s) controlling 72 the copyright in such materials, this document may not be modified 73 outside the IETF Standards Process, and derivative works of it may 74 not be created outside the IETF Standards Process, except to format 75 it for publication as an RFC or to translate it into languages other 76 than English. 78 Table of Contents 80 1. How to Read This Document . . . . . . . . . . . . . . . . . . 4 81 1.1. Organization of This Document . . . . . . . . . . . . . . 5 82 1.2. Conventions Used in This Document . . . . . . . . . . . . 5 83 1.3. Special Notes to Implementors . . . . . . . . . . . . . . 6 84 2. Protocol Overview . . . . . . . . . . . . . . . . . . . . . . 6 85 2.1. Link Level . . . . . . . . . . . . . . . . . . . . . . . 6 86 2.2. Commands and Responses . . . . . . . . . . . . . . . . . 7 87 2.2.1. Client Protocol Sender and Server Protocol Receiver . 7 88 2.2.2. Server Protocol Sender and Client Protocol Receiver . 8 89 2.3. Message Attributes . . . . . . . . . . . . . . . . . . . 8 90 2.3.1. Message Numbers . . . . . . . . . . . . . . . . . . . 9 91 2.3.2. Flags Message Attribute . . . . . . . . . . . . . . . 11 92 2.3.3. Internal Date Message Attribute . . . . . . . . . . . 12 93 2.3.4. [RFC-5322] Size Message Attribute . . . . . . . . . . 12 94 2.3.5. Envelope Structure Message Attribute . . . . . . . . 12 95 2.3.6. Body Structure Message Attribute . . . . . . . . . . 13 96 2.4. Message Texts . . . . . . . . . . . . . . . . . . . . . . 13 98 3. State and Flow Diagram . . . . . . . . . . . . . . . . . . . 13 99 3.1. Not Authenticated State . . . . . . . . . . . . . . . . . 13 100 3.2. Authenticated State . . . . . . . . . . . . . . . . . . . 13 101 3.3. Selected State . . . . . . . . . . . . . . . . . . . . . 13 102 3.4. Logout State . . . . . . . . . . . . . . . . . . . . . . 14 103 4. Data Formats . . . . . . . . . . . . . . . . . . . . . . . . 15 104 4.1. Atom . . . . . . . . . . . . . . . . . . . . . . . . . . 16 105 4.2. Number . . . . . . . . . . . . . . . . . . . . . . . . . 16 106 4.3. String . . . . . . . . . . . . . . . . . . . . . . . . . 16 107 4.3.1. 8-bit and Binary Strings . . . . . . . . . . . . . . 16 108 4.4. Parenthesized List . . . . . . . . . . . . . . . . . . . 17 109 4.5. NIL . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 110 5. Operational Considerations . . . . . . . . . . . . . . . . . 17 111 5.1. Mailbox Naming . . . . . . . . . . . . . . . . . . . . . 17 112 5.1.1. Mailbox Hierarchy Naming . . . . . . . . . . . . . . 18 113 5.1.2. Mailbox Namespace Naming Convention . . . . . . . . . 18 114 5.1.3. Mailbox International Naming Convention . . . . . . . 19 115 5.2. Mailbox Size and Message Status Updates . . . . . . . . . 20 116 5.3. Response when no Command in Progress . . . . . . . . . . 21 117 5.4. Autologout Timer . . . . . . . . . . . . . . . . . . . . 21 118 5.5. Multiple Commands in Progress . . . . . . . . . . . . . . 21 119 6. Client Commands . . . . . . . . . . . . . . . . . . . . . . . 22 120 6.1. Client Commands - Any State . . . . . . . . . . . . . . . 23 121 6.1.1. CAPABILITY Command . . . . . . . . . . . . . . . . . 23 122 6.1.2. NOOP Command . . . . . . . . . . . . . . . . . . . . 24 123 6.1.3. LOGOUT Command . . . . . . . . . . . . . . . . . . . 25 124 6.2. Client Commands - Not Authenticated State . . . . . . . . 25 125 6.2.1. STARTTLS Command . . . . . . . . . . . . . . . . . . 26 126 6.2.2. AUTHENTICATE Command . . . . . . . . . . . . . . . . 27 127 6.2.3. LOGIN Command . . . . . . . . . . . . . . . . . . . . 29 128 6.3. Client Commands - Authenticated State . . . . . . . . . . 30 129 6.3.1. SELECT Command . . . . . . . . . . . . . . . . . . . 30 130 6.3.2. EXAMINE Command . . . . . . . . . . . . . . . . . . . 32 131 6.3.3. CREATE Command . . . . . . . . . . . . . . . . . . . 33 132 6.3.4. DELETE Command . . . . . . . . . . . . . . . . . . . 34 133 6.3.5. RENAME Command . . . . . . . . . . . . . . . . . . . 35 134 6.3.6. SUBSCRIBE Command . . . . . . . . . . . . . . . . . . 37 135 6.3.7. UNSUBSCRIBE Command . . . . . . . . . . . . . . . . . 38 136 6.3.8. LIST Command . . . . . . . . . . . . . . . . . . . . 38 137 6.3.9. LSUB Command . . . . . . . . . . . . . . . . . . . . 41 138 6.3.10. STATUS Command . . . . . . . . . . . . . . . . . . . 42 139 6.3.11. APPEND Command . . . . . . . . . . . . . . . . . . . 43 140 6.4. Client Commands - Selected State . . . . . . . . . . . . 45 141 6.4.1. CHECK Command . . . . . . . . . . . . . . . . . . . . 45 142 6.4.2. CLOSE Command . . . . . . . . . . . . . . . . . . . . 45 143 6.4.3. EXPUNGE Command . . . . . . . . . . . . . . . . . . . 46 144 6.4.4. SEARCH Command . . . . . . . . . . . . . . . . . . . 47 145 6.4.5. FETCH Command . . . . . . . . . . . . . . . . . . . . 50 146 6.4.6. STORE Command . . . . . . . . . . . . . . . . . . . . 54 147 6.4.7. COPY Command . . . . . . . . . . . . . . . . . . . . 55 148 6.4.8. UID Command . . . . . . . . . . . . . . . . . . . . . 56 149 6.5. Client Commands - Experimental/Expansion . . . . . . . . 57 150 6.5.1. X Command . . . . . . . . . . . . . . . . . . . 57 151 7. Server Responses . . . . . . . . . . . . . . . . . . . . . . 58 152 7.1. Server Responses - Status Responses . . . . . . . . . . . 59 153 7.1.1. OK Response . . . . . . . . . . . . . . . . . . . . . 60 154 7.1.2. NO Response . . . . . . . . . . . . . . . . . . . . . 61 155 7.1.3. BAD Response . . . . . . . . . . . . . . . . . . . . 61 156 7.1.4. PREAUTH Response . . . . . . . . . . . . . . . . . . 61 157 7.1.5. BYE Response . . . . . . . . . . . . . . . . . . . . 62 158 7.2. Server Responses - Server and Mailbox Status . . . . . . 62 159 7.2.1. CAPABILITY Response . . . . . . . . . . . . . . . . . 63 160 7.2.2. LIST Response . . . . . . . . . . . . . . . . . . . . 64 161 7.2.3. LSUB Response . . . . . . . . . . . . . . . . . . . . 65 162 7.2.4. STATUS Response . . . . . . . . . . . . . . . . . . . 65 163 7.2.5. SEARCH Response . . . . . . . . . . . . . . . . . . . 65 164 7.2.6. FLAGS Response . . . . . . . . . . . . . . . . . . . 65 165 7.3. Server Responses - Mailbox Size . . . . . . . . . . . . . 66 166 7.3.1. EXISTS Response . . . . . . . . . . . . . . . . . . . 66 167 7.3.2. RECENT Response . . . . . . . . . . . . . . . . . . . 66 168 7.4. Server Responses - Message Status . . . . . . . . . . . . 67 169 7.4.1. EXPUNGE Response . . . . . . . . . . . . . . . . . . 67 170 7.4.2. FETCH Response . . . . . . . . . . . . . . . . . . . 68 171 7.5. Server Responses - Command Continuation Request . . . . . 73 172 8. Sample IMAP4rev1 connection . . . . . . . . . . . . . . . . . 73 173 9. Formal Syntax . . . . . . . . . . . . . . . . . . . . . . . . 75 174 10. Author's Note . . . . . . . . . . . . . . . . . . . . . . . . 85 175 11. Security Considerations . . . . . . . . . . . . . . . . . . . 85 176 11.1. STARTTLS Security Considerations . . . . . . . . . . . . 86 177 11.2. Other Security Considerations . . . . . . . . . . . . . 86 178 12. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 87 179 13. References . . . . . . . . . . . . . . . . . . . . . . . . . 87 180 13.1. Normative References . . . . . . . . . . . . . . . . . . 88 181 13.2. Informative References (related protocols) . . . . . . . 89 182 13.3. Informative References (historical aspects of IMAP and 183 related protocols) . . . . . . . . . . . . . . . . . . . 90 184 Appendix A. Changes from RFC 3501 . . . . . . . . . . . . . . . 91 185 Appendix B. Acknowledgement . . . . . . . . . . . . . . . . . . 91 186 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 187 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 95 189 1. How to Read This Document 190 1.1. Organization of This Document 192 This document is written from the point of view of the implementor of 193 an IMAP4rev1 client or server. Beyond the protocol overview in 194 section 2, it is not optimized for someone trying to understand the 195 operation of the protocol. The material in sections 3 through 5 196 provides the general context and definitions with which IMAP4rev1 197 operates. 199 Sections 6, 7, and 9 describe the IMAP commands, responses, and 200 syntax, respectively. The relationships among these are such that it 201 is almost impossible to understand any of them separately. In 202 particular, do not attempt to deduce command syntax from the command 203 section alone; instead refer to the Formal Syntax section. 205 1.2. Conventions Used in This Document 207 "Conventions" are basic principles or procedures. Document 208 conventions are noted in this section. 210 In examples, "C:" and "S:" indicate lines sent by the client and 211 server respectively. 213 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 214 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 215 document are to be interpreted as described in [KEYWORDS]. 217 The word "can" (not "may") is used to refer to a possible 218 circumstance or situation, as opposed to an optional facility of the 219 protocol. 221 "User" is used to refer to a human user, whereas "client" refers to 222 the software being run by the user. 224 "Connection" refers to the entire sequence of client/server 225 interaction from the initial establishment of the network connection 226 until its termination. 228 "Session" refers to the sequence of client/server interaction from 229 the time that a mailbox is selected (SELECT or EXAMINE command) until 230 the time that selection ends (SELECT or EXAMINE of another mailbox, 231 CLOSE command, or connection termination). 233 Characters are 7-bit US-ASCII unless otherwise specified. Other 234 character sets are indicated using a "CHARSET", as described in 235 [MIME-IMT] and defined in [CHARSET]. CHARSETs have important 236 additional semantics in addition to defining character set; refer to 237 these documents for more detail. 239 There are several protocol conventions in IMAP. These refer to 240 aspects of the specification which are not strictly part of the IMAP 241 protocol, but reflect generally-accepted practice. Implementations 242 need to be aware of these conventions, and avoid conflicts whether or 243 not they implement the convention. For example, "&" may not be used 244 as a hierarchy delimiter since it conflicts with the Mailbox 245 International Naming Convention, and other uses of "&" in mailbox 246 names are impacted as well. 248 1.3. Special Notes to Implementors 250 Implementors of the IMAP protocol are strongly encouraged to read the 251 IMAP implementation recommendations document [IMAP-IMPLEMENTATION] in 252 conjunction with this document, to help understand the intricacies of 253 this protocol and how best to build an interoperable product. 255 IMAP4rev1 is designed to be upwards compatible from the [IMAP2] and 256 unpublished IMAP2bis protocols. IMAP4rev1 is largely compatible with 257 the IMAP4 protocol described in RFC 1730; the exception being in 258 certain facilities added in RFC 1730 that proved problematic and were 259 subsequently removed. In the course of the evolution of IMAP4rev1, 260 some aspects in the earlier protocols have become obsolete. Obsolete 261 commands, responses, and data formats which an IMAP4rev1 262 implementation can encounter when used with an earlier implementation 263 are described in [IMAP-OBSOLETE]. 265 Other compatibility issues with IMAP2bis, the most common variant of 266 the earlier protocol, are discussed in [IMAP-COMPAT]. A full 267 discussion of compatibility issues with rare (and presumed extinct) 268 variants of [IMAP2] is in [IMAP-HISTORICAL]; this document is 269 primarily of historical interest. 271 IMAP was originally developed for the older [RFC-822] standard, and 272 as a consequence several fetch items in IMAP incorporate "RFC822" in 273 their name. With the exception of RFC822.SIZE, there are more modern 274 replacements; for example, the modern version of RFC822.HEADER is 275 BODY.PEEK[HEADER]. In all cases, "RFC822" should be interpreted as a 276 reference to the updated [RFC-5322] standard. 278 2. Protocol Overview 280 2.1. Link Level 282 The IMAP4rev1 protocol assumes a reliable data stream such as that 283 provided by TCP. When TCP is used, an IMAP4rev1 server listens on 284 port 143. 286 2.2. Commands and Responses 288 An IMAP4rev1 connection consists of the establishment of a client/ 289 server network connection, an initial greeting from the server, and 290 client/server interactions. These client/server interactions consist 291 of a client command, server data, and a server completion result 292 response. 294 All interactions transmitted by client and server are in the form of 295 lines, that is, strings that end with a CRLF. The protocol receiver 296 of an IMAP4rev1 client or server is either reading a line, or is 297 reading a sequence of octets with a known count followed by a line. 299 2.2.1. Client Protocol Sender and Server Protocol Receiver 301 The client command begins an operation. Each client command is 302 prefixed with an identifier (typically a short alphanumeric string, 303 e.g., A0001, A0002, etc.) called a "tag". A different tag is 304 generated by the client for each command. 306 Clients MUST follow the syntax outlined in this specification 307 strictly. It is a syntax error to send a command with missing or 308 extraneous spaces or arguments. 310 There are two cases in which a line from the client does not 311 represent a complete command. In one case, a command argument is 312 quoted with an octet count (see the description of literal in String 313 under Data Formats); in the other case, the command arguments require 314 server feedback (see the AUTHENTICATE command). In either case, the 315 server sends a command continuation request response if it is ready 316 for the octets (if appropriate) and the remainder of the command. 317 This response is prefixed with the token "+". 319 Note: If instead, the server detected an error in the command, it 320 sends a BAD completion response with a tag matching the command 321 (as described below) to reject the command and prevent the client 322 from sending any more of the command. 324 It is also possible for the server to send a completion response 325 for some other command (if multiple commands are in progress), or 326 untagged data. In either case, the command continuation request 327 is still pending; the client takes the appropriate action for the 328 response, and reads another response from the server. In all 329 cases, the client MUST send a complete command (including 330 receiving all command continuation request responses and command 331 continuations for the command) before initiating a new command. 333 The protocol receiver of an IMAP4rev1 server reads a command line 334 from the client, parses the command and its arguments, and transmits 335 server data and a server command completion result response. 337 2.2.2. Server Protocol Sender and Client Protocol Receiver 339 Data transmitted by the server to the client and status responses 340 that do not indicate command completion are prefixed with the token 341 "*", and are called untagged responses. 343 Server data MAY be sent as a result of a client command, or MAY be 344 sent unilaterally by the server. There is no syntactic difference 345 between server data that resulted from a specific command and server 346 data that were sent unilaterally. 348 The server completion result response indicates the success or 349 failure of the operation. It is tagged with the same tag as the 350 client command which began the operation. Thus, if more than one 351 command is in progress, the tag in a server completion response 352 identifies the command to which the response applies. There are 353 three possible server completion responses: OK (indicating success), 354 NO (indicating failure), or BAD (indicating a protocol error such as 355 unrecognized command or command syntax error). 357 Servers SHOULD enforce the syntax outlined in this specification 358 strictly. Any client command with a protocol syntax error, including 359 (but not limited to) missing or extraneous spaces or arguments, 360 SHOULD be rejected, and the client given a BAD server completion 361 response. 363 The protocol receiver of an IMAP4rev1 client reads a response line 364 from the server. It then takes action on the response based upon the 365 first token of the response, which can be a tag, a "*", or a "+". 367 A client MUST be prepared to accept any server response at all times. 368 This includes server data that was not requested. Server data SHOULD 369 be recorded, so that the client can reference its recorded copy 370 rather than sending a command to the server to request the data. In 371 the case of certain server data, the data MUST be recorded. 373 This topic is discussed in greater detail in the Server Responses 374 section. 376 2.3. Message Attributes 378 In addition to message text, each message has several attributes 379 associated with it. These attributes can be retrieved individually 380 or in conjunction with other attributes or message texts. 382 2.3.1. Message Numbers 384 Messages in IMAP4rev1 are accessed by one of two numbers; the unique 385 identifier or the message sequence number. 387 2.3.1.1. Unique Identifier (UID) Message Attribute 389 An unsigned 32-bit value assigned to each message, which when used 390 with the unique identifier validity value (see below) forms a 64-bit 391 value that MUST NOT refer to any other message in the mailbox or any 392 subsequent mailbox with the same name forever. Unique identifiers 393 are assigned in a strictly ascending fashion in the mailbox; as each 394 message is added to the mailbox it is assigned a higher UID than the 395 message(s) which were added previously. Unlike message sequence 396 numbers, unique identifiers are not necessarily contiguous. 398 The unique identifier of a message MUST NOT change during the 399 session, and SHOULD NOT change between sessions. Any change of 400 unique identifiers between sessions MUST be detectable using the 401 UIDVALIDITY mechanism discussed below. Persistent unique identifiers 402 are required for a client to resynchronize its state from a previous 403 session with the server (e.g., disconnected or offline access 404 clients); this is discussed further in [IMAP-DISC]. 406 Associated with every mailbox are two 32-bit unsigned values which 407 aid in unique identifier handling: the next unique identifier value 408 (UIDNEXT) and the unique identifier validity value (UIDVALIDITY). 410 The next unique identifier value is the predicted value that will be 411 assigned to a new message in the mailbox. Unless the unique 412 identifier validity also changes (see below), the next unique 413 identifier value MUST have the following two characteristics. First, 414 the next unique identifier value MUST NOT change unless new messages 415 are added to the mailbox; and second, the next unique identifier 416 value MUST change whenever new messages are added to the mailbox, 417 even if those new messages are subsequently expunged. 419 Note: The next unique identifier value is intended to provide a 420 means for a client to determine whether any messages have been 421 delivered to the mailbox since the previous time it checked this 422 value. It is not intended to provide any guarantee that any 423 message will have this unique identifier. A client can only 424 assume, at the time that it obtains the next unique identifier 425 value, that messages arriving after that time will have a UID 426 greater than or equal to that value. 428 The unique identifier validity value is sent in a UIDVALIDITY 429 response code in an OK untagged response at mailbox selection time. 431 If unique identifiers from an earlier session fail to persist in this 432 session, the unique identifier validity value MUST be greater than 433 the one used in the earlier session. 435 Note: Ideally, unique identifiers SHOULD persist at all times. 436 Although this specification recognizes that failure to persist can 437 be unavoidable in certain server environments, it STRONGLY 438 ENCOURAGES message store implementation techniques that avoid this 439 problem. For example: 441 1. Unique identifiers MUST be strictly ascending in the mailbox 442 at all times. If the physical message store is re-ordered by 443 a non-IMAP agent, this requires that the unique identifiers in 444 the mailbox be regenerated, since the former unique 445 identifiers are no longer strictly ascending as a result of 446 the re-ordering. 448 2. If the message store has no mechanism to store unique 449 identifiers, it must regenerate unique identifiers at each 450 session, and each session must have a unique UIDVALIDITY 451 value. 453 3. If the mailbox is deleted and a new mailbox with the same name 454 is created at a later date, the server must either keep track 455 of unique identifiers from the previous instance of the 456 mailbox, or it must assign a new UIDVALIDITY value to the new 457 instance of the mailbox. A good UIDVALIDITY value to use in 458 this case is a 32-bit representation of the creation date/time 459 of the mailbox. It is alright to use a constant such as 1, 460 but only if it guaranteed that unique identifiers will never 461 be reused, even in the case of a mailbox being deleted (or 462 renamed) and a new mailbox by the same name created at some 463 future time. 465 4. The combination of mailbox name, UIDVALIDITY, and UID must 466 refer to a single immutable message on that server forever. 467 In particular, the internal date, [RFC-5322] size, envelope, 468 body structure, and message texts (RFC822, RFC822.HEADER, 469 RFC822.TEXT, and all BODY[...] fetch data items) must never 470 change. This does not include message numbers, nor does it 471 include attributes that can be set by a STORE command (e.g., 472 FLAGS). 474 2.3.1.2. Message Sequence Number Message Attribute 476 A relative position from 1 to the number of messages in the mailbox. 477 This position MUST be ordered by ascending unique identifier. As 478 each new message is added, it is assigned a message sequence number 479 that is 1 higher than the number of messages in the mailbox before 480 that new message was added. 482 Message sequence numbers can be reassigned during the session. For 483 example, when a message is permanently removed (expunged) from the 484 mailbox, the message sequence number for all subsequent messages is 485 decremented. The number of messages in the mailbox is also 486 decremented. Similarly, a new message can be assigned a message 487 sequence number that was once held by some other message prior to an 488 expunge. 490 In addition to accessing messages by relative position in the 491 mailbox, message sequence numbers can be used in mathematical 492 calculations. For example, if an untagged "11 EXISTS" is received, 493 and previously an untagged "8 EXISTS" was received, three new 494 messages have arrived with message sequence numbers of 9, 10, and 11. 495 Another example, if message 287 in a 523 message mailbox has UID 496 12345, there are exactly 286 messages which have lesser UIDs and 236 497 messages which have greater UIDs. 499 2.3.2. Flags Message Attribute 501 A list of zero or more named tokens associated with the message. A 502 flag is set by its addition to this list, and is cleared by its 503 removal. There are two types of flags in IMAP4rev1. A flag of 504 either type can be permanent or session-only. 506 A system flag is a flag name that is pre-defined in this 507 specification. All system flags begin with "\". Certain system 508 flags (\Deleted and \Seen) have special semantics described 509 elsewhere. The currently-defined system flags are: 511 \Seen Message has been read 513 \Answered Message has been answered 515 \Flagged Message is "flagged" for urgent/special attention 517 \Deleted Message is "deleted" for removal by later EXPUNGE 519 \Draft Message has not completed composition (marked as a draft). 521 \Recent Message is "recently" arrived in this mailbox. This session 522 is the first session to have been notified about this message; if 523 the session is read-write, subsequent sessions will not see 524 \Recent set for this message. This flag can not be altered by the 525 client. 527 If it is not possible to determine whether or not this session is 528 the first session to be notified about a message, then that 529 message SHOULD be considered recent. 531 If multiple connections have the same mailbox selected 532 simultaneously, it is undefined which of these connections will 533 see newly-arrived messages with \Recent set and which will see it 534 without \Recent set. 536 A keyword is defined by the server implementation. Keywords do not 537 begin with "\". Servers MAY permit the client to define new keywords 538 in the mailbox (see the description of the PERMANENTFLAGS response 539 code for more information). 541 A flag can be permanent or session-only on a per-flag basis. 542 Permanent flags are those which the client can add or remove from the 543 message flags permanently; that is, concurrent and subsequent 544 sessions will see any change in permanent flags. Changes to session 545 flags are valid only in that session. 547 Note: The \Recent system flag is a special case of a session flag. 548 \Recent can not be used as an argument in a STORE or APPEND 549 command, and thus can not be changed at all. 551 2.3.3. Internal Date Message Attribute 553 The internal date and time of the message on the server. This is not 554 the date and time in the [RFC-5322] header, but rather a date and 555 time which reflects when the message was received. In the case of 556 messages delivered via [SMTP], this SHOULD be the date and time of 557 final delivery of the message as defined by [SMTP]. In the case of 558 messages delivered by the IMAP4rev1 COPY command, this SHOULD be the 559 internal date and time of the source message. In the case of 560 messages delivered by the IMAP4rev1 APPEND command, this SHOULD be 561 the date and time as specified in the APPEND command description. 562 All other cases are implementation defined. 564 2.3.4. [RFC-5322] Size Message Attribute 566 The number of octets in the message, as expressed in [RFC-5322] 567 format. 569 2.3.5. Envelope Structure Message Attribute 571 A parsed representation of the [RFC-5322] header of the message. 572 Note that the IMAP Envelope structure is not the same as an [SMTP] 573 envelope. 575 2.3.6. Body Structure Message Attribute 577 A parsed representation of the [MIME-IMB] body structure information 578 of the message. 580 2.4. Message Texts 582 In addition to being able to fetch the full [RFC-5322] text of a 583 message, IMAP4rev1 permits the fetching of portions of the full 584 message text. Specifically, it is possible to fetch the [RFC-5322] 585 message header, [RFC-5322] message body, a [MIME-IMB] body part, or a 586 [MIME-IMB] header. 588 3. State and Flow Diagram 590 Once the connection between client and server is established, an 591 IMAP4rev1 connection is in one of four states. The initial state is 592 identified in the server greeting. Most commands are only valid in 593 certain states. It is a protocol error for the client to attempt a 594 command while the connection is in an inappropriate state, and the 595 server will respond with a BAD or NO (depending upon server 596 implementation) command completion result. 598 3.1. Not Authenticated State 600 In the not authenticated state, the client MUST supply authentication 601 credentials before most commands will be permitted. This state is 602 entered when a connection starts unless the connection has been pre- 603 authenticated. 605 3.2. Authenticated State 607 In the authenticated state, the client is authenticated and MUST 608 select a mailbox to access before commands that affect messages will 609 be permitted. This state is entered when a pre-authenticated 610 connection starts, when acceptable authentication credentials have 611 been provided, after an error in selecting a mailbox, or after a 612 successful CLOSE command. 614 3.3. Selected State 616 In a selected state, a mailbox has been selected to access. This 617 state is entered when a mailbox has been successfully selected. 619 3.4. Logout State 621 In the logout state, the connection is being terminated. This state 622 can be entered as a result of a client request (via the LOGOUT 623 command) or by unilateral action on the part of either the client or 624 server. 626 If the client requests the logout state, the server MUST send an 627 untagged BYE response and a tagged OK response to the LOGOUT command 628 before the server closes the connection; and the client MUST read the 629 tagged OK response to the LOGOUT command before the client closes the 630 connection. 632 A server MUST NOT unilaterally close the connection without sending 633 an untagged BYE response that contains the reason for having done so. 634 A client SHOULD NOT unilaterally close the connection, and instead 635 SHOULD issue a LOGOUT command. If the server detects that the client 636 has unilaterally closed the connection, the server MAY omit the 637 untagged BYE response and simply close its connection. 639 +----------------------+ 640 |connection established| 641 +----------------------+ 642 || 643 \/ 644 +--------------------------------------+ 645 | server greeting | 646 +--------------------------------------+ 647 || (1) || (2) || (3) 648 \/ || || 649 +-----------------+ || || 650 |Not Authenticated| || || 651 +-----------------+ || || 652 || (7) || (4) || || 653 || \/ \/ || 654 || +----------------+ || 655 || | Authenticated |<=++ || 656 || +----------------+ || || 657 || || (7) || (5) || (6) || 658 || || \/ || || 659 || || +--------+ || || 660 || || |Selected|==++ || 661 || || +--------+ || 662 || || || (7) || 663 \/ \/ \/ \/ 664 +--------------------------------------+ 665 | Logout | 666 +--------------------------------------+ 667 || 668 \/ 669 +-------------------------------+ 670 |both sides close the connection| 671 +-------------------------------+ 673 (1) connection without pre-authentication (OK greeting) 674 (2) pre-authenticated connection (PREAUTH greeting) 675 (3) rejected connection (BYE greeting) 676 (4) successful LOGIN or AUTHENTICATE command 677 (5) successful SELECT or EXAMINE command 678 (6) CLOSE command, or failed SELECT or EXAMINE command 679 (7) LOGOUT command, server shutdown, or connection closed 681 4. Data Formats 683 IMAP4rev1 uses textual commands and responses. Data in IMAP4rev1 can 684 be in one of several forms: atom, number, string, parenthesized list, 685 or NIL. Note that a particular data item may take more than one 686 form; for example, a data item defined as using "astring" syntax may 687 be either an atom or a string. 689 4.1. Atom 691 An atom consists of one or more non-special characters. 693 4.2. Number 695 A number consists of one or more digit characters, and represents a 696 numeric value. 698 4.3. String 700 A string is in one of two forms: either literal or quoted string. 701 The literal form is the general form of string. The quoted string 702 form is an alternative that avoids the overhead of processing a 703 literal at the cost of limitations of characters which may be used. 705 A literal is a sequence of zero or more octets (including CR and LF), 706 prefix-quoted with an octet count in the form of an open brace ("{"), 707 the number of octets, close brace ("}"), and CRLF. In the case of 708 literals transmitted from server to client, the CRLF is immediately 709 followed by the octet data. In the case of literals transmitted from 710 client to server, the client MUST wait to receive a command 711 continuation request (described later in this document) before 712 sending the octet data (and the remainder of the command). 714 A quoted string is a sequence of zero or more 7-bit characters, 715 excluding CR and LF, with double quote (<">) characters at each end. 717 The empty string is represented as either "" (a quoted string with 718 zero characters between double quotes) or as {0} followed by CRLF (a 719 literal with an octet count of 0). 721 Note: Even if the octet count is 0, a client transmitting a 722 literal MUST wait to receive a command continuation request. 724 4.3.1. 8-bit and Binary Strings 726 8-bit textual and binary mail is supported through the use of a 727 [MIME-IMB] content transfer encoding. IMAP4rev1 implementations MAY 728 transmit 8-bit or multi-octet characters in literals, but SHOULD do 729 so only when the [CHARSET] is identified. 731 Although a BINARY body encoding is defined, unencoded binary strings 732 are not permitted. A "binary string" is any string with NUL 733 characters. Implementations MUST encode binary data into a textual 734 form, such as BASE64, before transmitting the data. A string with an 735 excessive amount of CTL characters MAY also be considered to be 736 binary. 738 4.4. Parenthesized List 740 Data structures are represented as a "parenthesized list"; a sequence 741 of data items, delimited by space, and bounded at each end by 742 parentheses. A parenthesized list can contain other parenthesized 743 lists, using multiple levels of parentheses to indicate nesting. 745 The empty list is represented as () -- a parenthesized list with no 746 members. 748 4.5. NIL 750 The special form "NIL" represents the non-existence of a particular 751 data item that is represented as a string or parenthesized list, as 752 distinct from the empty string "" or the empty parenthesized list (). 754 Note: NIL is never used for any data item which takes the form of 755 an atom. For example, a mailbox name of "NIL" is a mailbox named 756 NIL as opposed to a non-existent mailbox name. This is because 757 mailbox uses "astring" syntax which is an atom or a string. 758 Conversely, an addr-name of NIL is a non-existent personal name, 759 because addr-name uses "nstring" syntax which is NIL or a string, 760 but never an atom. 762 5. Operational Considerations 764 The following rules are listed here to ensure that all IMAP4rev1 765 implementations interoperate properly. 767 5.1. Mailbox Naming 769 Mailbox names are 7-bit. Client implementations MUST NOT attempt to 770 create 8-bit mailbox names, and SHOULD interpret any 8-bit mailbox 771 names returned by LIST or LSUB as UTF-8. Server implementations 772 SHOULD prohibit the creation of 8-bit mailbox names, and SHOULD NOT 773 return 8-bit mailbox names in LIST or LSUB. See Section 5.1.3 for 774 more information on how to represent non-ASCII mailbox names. 776 Note: 8-bit mailbox names were undefined in earlier versions of 777 this protocol. Some sites used a local 8-bit character set to 778 represent non-ASCII mailbox names. Such usage is not 779 interoperable, and is now formally deprecated. 781 The case-insensitive mailbox name INBOX is a special name reserved to 782 mean "the primary mailbox for this user on this server". (Note that 783 this special name may not exist on some servers for some users.) The 784 interpretation of all other names is implementation-dependent. 786 In particular, this specification takes no position on case 787 sensitivity in non-INBOX mailbox names. Some server implementations 788 are fully case-sensitive; others preserve case of a newly-created 789 name but otherwise are case-insensitive; and yet others coerce names 790 to a particular case. Client implementations MUST interact with any 791 of these. If a server implementation interprets non-INBOX mailbox 792 names as case-insensitive, it MUST treat names using the 793 international naming convention specially as described in 794 Section 5.1.3. 796 There are certain client considerations when creating a new mailbox 797 name: 799 1. Any character which is one of the atom-specials (see the Formal 800 Syntax) will require that the mailbox name be represented as a 801 quoted string or literal. 803 2. CTL and other non-graphic characters are difficult to represent 804 in a user interface and are best avoided. 806 3. Although the list-wildcard characters ("%" and "*") are valid in 807 a mailbox name, it is difficult to use such mailbox names with 808 the LIST and LSUB commands due to the conflict with wildcard 809 interpretation. 811 4. Usually, a character (determined by the server implementation) is 812 reserved to delimit levels of hierarchy. 814 5. Two characters, "#" and "&", have meanings by convention, and 815 should be avoided except when used in that convention. 817 5.1.1. Mailbox Hierarchy Naming 819 If it is desired to export hierarchical mailbox names, mailbox names 820 MUST be left-to-right hierarchical using a single character to 821 separate levels of hierarchy. The same hierarchy separator character 822 is used for all levels of hierarchy within a single name. 824 5.1.2. Mailbox Namespace Naming Convention 826 By convention, the first hierarchical element of any mailbox name 827 which begins with "#" identifies the "namespace" of the remainder of 828 the name. This makes it possible to disambiguate between different 829 types of mailbox stores, each of which have their own namespaces. 831 For example, implementations which offer access to USENET 832 newsgroups MAY use the "#news" namespace to partition the USENET 833 newsgroup namespace from that of other mailboxes. Thus, the 834 comp.mail.misc newsgroup would have a mailbox name of 835 "#news.comp.mail.misc", and the name "comp.mail.misc" can refer to 836 a different object (e.g., a user's private mailbox). 838 5.1.3. Mailbox International Naming Convention 840 By convention, international mailbox names in IMAP4rev1 are specified 841 using a modified version of the UTF-7 encoding described in [UTF-7]. 842 Modified UTF-7 may also be usable in servers that implement an 843 earlier version of this protocol. 845 In modified UTF-7, printable US-ASCII characters, except for "&", 846 represent themselves; that is, characters with octet values 0x20-0x25 847 and 0x27-0x7e. The character "&" (0x26) is represented by the two- 848 octet sequence "&-". 850 All other characters (octet values 0x00-0x1f and 0x7f-0xff) are 851 represented in modified BASE64, with a further modification from 852 [UTF-7] that "," is used instead of "/". Modified BASE64 MUST NOT be 853 used to represent any printing US-ASCII character which can represent 854 itself. Only characters inside the modified BASE64 alphabet are 855 permitted in modified BASE64 text. 857 "&" is used to shift to modified BASE64 and "-" to shift back to US- 858 ASCII. There is no implicit shift from BASE64 to US-ASCII, and null 859 shifts ("-&" while in BASE64; note that "&-" while in US-ASCII means 860 "&") are not permitted. However, all names start in US-ASCII, and 861 MUST end in US-ASCII; that is, a name that ends with a non-ASCII 862 ISO-10646 character MUST end with a "-"). 864 The purpose of these modifications is to correct the following 865 problems with UTF-7: 867 1. UTF-7 uses the "+" character for shifting; this conflicts with 868 the common use of "+" in mailbox names, in particular USENET 869 newsgroup names. 871 2. UTF-7's encoding is BASE64 which uses the "/" character; this 872 conflicts with the use of "/" as a popular hierarchy delimiter. 874 3. UTF-7 prohibits the unencoded usage of "\"; this conflicts with 875 the use of "\" as a popular hierarchy delimiter. 877 4. UTF-7 prohibits the unencoded usage of "~"; this conflicts with 878 the use of "~" in some servers as a home directory indicator. 880 5. UTF-7 permits multiple alternate forms to represent the same 881 string; in particular, printable US-ASCII characters can be 882 represented in encoded form. 884 Although modified UTF-7 is a convention, it establishes certain 885 requirements on server handling of any mailbox name with an embedded 886 "&" character. In particular, server implementations MUST preserve 887 the exact form of the modified BASE64 portion of a modified UTF-7 888 name and treat that text as case-sensitive, even if names are 889 otherwise case-insensitive or case-folded. 891 Server implementations SHOULD verify that any mailbox name with an 892 embedded "&" character, used as an argument to CREATE, is: in the 893 correctly modified UTF-7 syntax, has no superfluous shifts, and has 894 no encoding in modified BASE64 of any printing US-ASCII character 895 which can represent itself. However, client implementations MUST NOT 896 depend upon the server doing this, and SHOULD NOT attempt to create a 897 mailbox name with an embedded "&" character unless it complies with 898 the modified UTF-7 syntax. 900 Server implementations which export a mail store that does not follow 901 the modified UTF-7 convention MUST convert to modified UTF-7 any 902 mailbox name that contains either non-ASCII characters or the "&" 903 character. 905 For example, here is a mailbox name which mixes English, Chinese, 906 and Japanese text: ~peter/mail/&U,BTFw-/&ZeVnLIqe- 908 For example, the string "&Jjo!" is not a valid mailbox name 909 because it does not contain a shift to US-ASCII before the "!". 910 The correct form is "&Jjo-!". The string "&U,BTFw-&ZeVnLIqe-" is 911 not permitted because it contains a superfluous shift. The 912 correct form is "&U,BTF2XlZyyKng-". 914 5.2. Mailbox Size and Message Status Updates 916 At any time, a server can send data that the client did not request. 917 Sometimes, such behavior is REQUIRED. For example, agents other than 918 the server MAY add messages to the mailbox (e.g., new message 919 delivery), change the flags of the messages in the mailbox (e.g., 920 simultaneous access to the same mailbox by multiple agents), or even 921 remove messages from the mailbox. A server MUST send mailbox size 922 updates automatically if a mailbox size change is observed during the 923 processing of a command. A server SHOULD send message flag updates 924 automatically, without requiring the client to request such updates 925 explicitly. 927 Special rules exist for server notification of a client about the 928 removal of messages to prevent synchronization errors; see the 929 description of the EXPUNGE response for more detail. In particular, 930 it is NOT permitted to send an EXISTS response that would reduce the 931 number of messages in the mailbox; only the EXPUNGE response can do 932 this. 934 Regardless of what implementation decisions a client makes on 935 remembering data from the server, a client implementation MUST record 936 mailbox size updates. It MUST NOT assume that any command after the 937 initial mailbox selection will return the size of the mailbox. 939 5.3. Response when no Command in Progress 941 Server implementations are permitted to send an untagged response 942 (except for EXPUNGE) while there is no command in progress. Server 943 implementations that send such responses MUST deal with flow control 944 considerations. Specifically, they MUST either (1) verify that the 945 size of the data does not exceed the underlying transport's available 946 window size, or (2) use non-blocking writes. 948 5.4. Autologout Timer 950 If a server has an inactivity autologout timer that applies to 951 sessions after authentication, the duration of that timer MUST be at 952 least 30 minutes. The receipt of ANY command from the client during 953 that interval SHOULD suffice to reset the autologout timer. 955 5.5. Multiple Commands in Progress 957 The client MAY send another command without waiting for the 958 completion result response of a command, subject to ambiguity rules 959 (see below) and flow control constraints on the underlying data 960 stream. Similarly, a server MAY begin processing another command 961 before processing the current command to completion, subject to 962 ambiguity rules. However, any command continuation request responses 963 and command continuations MUST be negotiated before any subsequent 964 command is initiated. 966 The exception is if an ambiguity would result because of a command 967 that would affect the results of other commands. Clients MUST NOT 968 send multiple commands without waiting if an ambiguity would result. 969 If the server detects a possible ambiguity, it MUST execute commands 970 to completion in the order given by the client. 972 The most obvious example of ambiguity is when a command would affect 973 the results of another command, e.g., a FETCH of a message's flags 974 and a STORE of that same message's flags. 976 A non-obvious ambiguity occurs with commands that permit an untagged 977 EXPUNGE response (commands other than FETCH, STORE, and SEARCH), 978 since an untagged EXPUNGE response can invalidate sequence numbers in 979 a subsequent command. This is not a problem for FETCH, STORE, or 980 SEARCH commands because servers are prohibited from sending EXPUNGE 981 responses while any of those commands are in progress. Therefore, if 982 the client sends any command other than FETCH, STORE, or SEARCH, it 983 MUST wait for the completion result response before sending a command 984 with message sequence numbers. 986 Note: EXPUNGE responses are permitted while UID FETCH, UID STORE, 987 and UID SEARCH are in progress. If the client sends a UID 988 command, it MUST wait for a completion result response before 989 sending a command which uses message sequence numbers (this may 990 include UID SEARCH). Any message sequence numbers in an argument 991 to UID SEARCH are associated with messages prior to the effect of 992 any untagged EXPUNGE returned by the UID SEARCH. 994 For example, the following non-waiting command sequences are invalid: 996 FETCH + NOOP + STORE 998 STORE + COPY + FETCH 1000 COPY + COPY 1002 CHECK + FETCH 1004 The following are examples of valid non-waiting command sequences: 1006 FETCH + STORE + SEARCH + CHECK 1008 STORE + COPY + EXPUNGE 1010 UID SEARCH + UID SEARCH may be valid or invalid as a non-waiting 1011 command sequence, depending upon whether or not the second UID 1012 SEARCH contains message sequence numbers. 1014 6. Client Commands 1016 IMAP4rev1 commands are described in this section. Commands are 1017 organized by the state in which the command is permitted. Commands 1018 which are permitted in multiple states are listed in the minimum 1019 permitted state (for example, commands valid in authenticated and 1020 selected state are listed in the authenticated state commands). 1022 Command arguments, identified by "Arguments:" in the command 1023 descriptions below, are described by function, not by syntax. The 1024 precise syntax of command arguments is described in the Formal Syntax 1025 (Section 9). 1027 Some commands cause specific server responses to be returned; these 1028 are identified by "Responses:" in the command descriptions below. 1029 See the response descriptions in the Responses section for 1030 information on these responses, and the Formal Syntax section for the 1031 precise syntax of these responses. It is possible for server data to 1032 be transmitted as a result of any command. Thus, commands that do 1033 not specifically require server data specify "no specific responses 1034 for this command" instead of "none". 1036 The "Result:" in the command description refers to the possible 1037 tagged status responses to a command, and any special interpretation 1038 of these status responses. 1040 The state of a connection is only changed by successful commands 1041 which are documented as changing state. A rejected command (BAD 1042 response) never changes the state of the connection or of the 1043 selected mailbox. A failed command (NO response) generally does not 1044 change the state of the connection or of the selected mailbox; the 1045 exception being the SELECT and EXAMINE commands. 1047 6.1. Client Commands - Any State 1049 The following commands are valid in any state: CAPABILITY, NOOP, and 1050 LOGOUT. 1052 6.1.1. CAPABILITY Command 1054 Arguments: none 1056 Responses: REQUIRED untagged response: CAPABILITY 1058 Result: OK - capability completed 1059 BAD - command unknown or arguments invalid 1061 The CAPABILITY command requests a listing of capabilities that the 1062 server supports. The server MUST send a single untagged CAPABILITY 1063 response with "IMAP4rev1" as one of the listed capabilities before 1064 the (tagged) OK response. 1066 A capability name which begins with "AUTH=" indicates that the server 1067 supports that particular authentication mechanism. All such names 1068 are, by definition, part of this specification. For example, the 1069 authorization capability for an experimental "blurdybloop" 1070 authenticator would be "AUTH=XBLURDYBLOOP" and not 1071 "XAUTH=BLURDYBLOOP" or "XAUTH=XBLURDYBLOOP". 1073 Other capability names refer to extensions, revisions, or amendments 1074 to this specification. See the documentation of the CAPABILITY 1075 response for additional information. No capabilities, beyond the 1076 base IMAP4rev1 set defined in this specification, are enabled without 1077 explicit client action to invoke the capability. 1079 Client and server implementations MUST implement the STARTTLS, 1080 LOGINDISABLED, and AUTH=PLAIN (described in [PLAIN]) capabilities. 1081 See the Security Considerations section for important information. 1083 See the section entitled "Client Commands - Experimental/Expansion" 1084 for information about the form of site or implementation-specific 1085 capabilities. 1087 Example: C: abcd CAPABILITY 1088 S: * CAPABILITY IMAP4rev1 STARTTLS AUTH=GSSAPI 1089 LOGINDISABLED 1090 S: abcd OK CAPABILITY completed 1091 C: efgh STARTTLS 1092 S: efgh OK STARTLS completed 1093 1094 C: ijkl CAPABILITY 1095 S: * CAPABILITY IMAP4rev1 AUTH=GSSAPI AUTH=PLAIN 1096 S: ijkl OK CAPABILITY completed 1098 6.1.2. NOOP Command 1100 Arguments: none 1102 Responses: no specific responses for this command (but see below) 1104 Result: OK - noop completed 1105 BAD - command unknown or arguments invalid 1107 The NOOP command always succeeds. It does nothing. 1109 Since any command can return a status update as untagged data, the 1110 NOOP command can be used as a periodic poll for new messages or 1111 message status updates during a period of inactivity (this is the 1112 preferred method to do this). The NOOP command can also be used to 1113 reset any inactivity autologout timer on the server. 1115 Example: C: a002 NOOP 1116 S: a002 OK NOOP completed 1117 . . . 1118 C: a047 NOOP 1119 S: * 22 EXPUNGE 1120 S: * 23 EXISTS 1121 S: * 3 RECENT 1122 S: * 14 FETCH (FLAGS (\Seen \Deleted)) 1123 S: a047 OK NOOP completed 1125 6.1.3. LOGOUT Command 1127 Arguments: none 1129 Responses: REQUIRED untagged response: BYE 1131 Result: OK - logout completed 1132 BAD - command unknown or arguments invalid 1134 The LOGOUT command informs the server that the client is done with 1135 the connection. The server MUST send a BYE untagged response before 1136 the (tagged) OK response, and then close the network connection. 1138 Example: C: A023 LOGOUT 1139 S: * BYE IMAP4rev1 Server logging out 1140 S: A023 OK LOGOUT completed 1141 (Server and client then close the connection) 1143 6.2. Client Commands - Not Authenticated State 1145 In the not authenticated state, the AUTHENTICATE or LOGIN command 1146 establishes authentication and enters the authenticated state. The 1147 AUTHENTICATE command provides a general mechanism for a variety of 1148 authentication techniques, privacy protection, and integrity 1149 checking; whereas the LOGIN command uses a traditional user name and 1150 plaintext password pair and has no means of establishing privacy 1151 protection or integrity checking. 1153 The STARTTLS command is an alternate form of establishing session 1154 privacy protection and integrity checking, but does not establish 1155 authentication or enter the authenticated state. 1157 Server implementations MAY allow access to certain mailboxes without 1158 establishing authentication. This can be done by means of the 1159 ANONYMOUS [SASL] authenticator described in [ANONYMOUS]. An older 1160 convention is a LOGIN command using the userid "anonymous"; in this 1161 case, a password is required although the server may choose to accept 1162 any password. The restrictions placed on anonymous users are 1163 implementation-dependent. 1165 Once authenticated (including as anonymous), it is not possible to 1166 re-enter not authenticated state. 1168 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 1169 the following commands are valid in the not authenticated state: 1170 STARTTLS, AUTHENTICATE and LOGIN. See the Security Considerations 1171 section for important information about these commands. 1173 6.2.1. STARTTLS Command 1175 Arguments: none 1177 Responses: no specific response for this command 1179 Result: OK - starttls completed, begin TLS negotiation 1180 BAD - command unknown or arguments invalid 1182 A [TLS] negotiation begins immediately after the CRLF at the end of 1183 the tagged OK response from the server. Once a client issues a 1184 STARTTLS command, it MUST NOT issue further commands until a server 1185 response is seen and the [TLS] negotiation is complete. 1187 The server remains in the non-authenticated state, even if client 1188 credentials are supplied during the [TLS] negotiation. This does not 1189 preclude an authentication mechanism such as EXTERNAL (defined in 1190 [SASL]) from using client identity determined by the [TLS] 1191 negotiation. 1193 Once [TLS] has been started, the client MUST discard cached 1194 information about server capabilities and SHOULD re-issue the 1195 CAPABILITY command. This is necessary to protect against man-in- 1196 the-middle attacks which alter the capabilities list prior to 1197 STARTTLS. The server MAY advertise different capabilities, and in 1198 particular SHOULD NOT advertise the STARTTLS capability, after a 1199 successful STARTTLS command. 1201 Example: C: a001 CAPABILITY 1202 S: * CAPABILITY IMAP4rev1 STARTTLS LOGINDISABLED 1203 S: a001 OK CAPABILITY completed 1204 C: a002 STARTTLS 1205 S: a002 OK Begin TLS negotiation now 1206 1207 C: a003 CAPABILITY 1208 S: * CAPABILITY IMAP4rev1 AUTH=PLAIN 1209 S: a003 OK CAPABILITY completed 1210 C: a004 LOGIN joe password 1211 S: a004 OK LOGIN completed 1213 6.2.2. AUTHENTICATE Command 1215 Arguments: authentication mechanism name 1217 Responses: continuation data can be requested 1219 Result: OK - authenticate completed, now in authenticated state 1220 NO - authenticate failure: unsupported authentication 1221 mechanism, credentials rejected 1222 BAD - command unknown or arguments invalid, 1223 authentication exchange cancelled 1225 The AUTHENTICATE command indicates a [SASL] authentication mechanism 1226 to the server. If the server supports the requested authentication 1227 mechanism, it performs an authentication protocol exchange to 1228 authenticate and identify the client. It MAY also negotiate an 1229 OPTIONAL security layer for subsequent protocol interactions. If the 1230 requested authentication mechanism is not supported, the server 1231 SHOULD reject the AUTHENTICATE command by sending a tagged NO 1232 response. 1234 The AUTHENTICATE command does not support the optional "initial 1235 response" feature of [SASL]. Section 3 of [SASL] specifies how to 1236 handle an authentication mechanism which uses an initial response. 1238 The service name specified by this protocol's profile of [SASL] is 1239 "imap". 1241 The authentication protocol exchange consists of a series of server 1242 challenges and client responses that are specific to the 1243 authentication mechanism. A server challenge consists of a command 1244 continuation request response with the "+" token followed by a BASE64 1245 encoded string. The client response consists of a single line 1246 consisting of a BASE64 encoded string. If the client wishes to 1247 cancel an authentication exchange, it issues a line consisting of a 1248 single "*". If the server receives such a response, or if it 1249 receives an invalid BASE64 string (e.g. characters outside the 1250 BASE64 alphabet, or non-terminal "="), it MUST reject the 1251 AUTHENTICATE command by sending a tagged BAD response. 1253 If a security layer is negotiated through the [SASL] authentication 1254 exchange, it takes effect immediately following the CRLF that 1255 concludes the authentication exchange for the client, and the CRLF of 1256 the tagged OK response for the server. 1258 While client and server implementations MUST implement the 1259 AUTHENTICATE command itself, it is not required to implement any 1260 authentication mechanisms other than the PLAIN mechanism described in 1261 [PLAIN]. Also, an authentication mechanism is not required to 1262 support any security layers. 1264 Note: a server implementation MUST implement a configuration in 1265 which it does NOT permit any plaintext password mechanisms, unless 1266 either the STARTTLS command has been negotiated or some other 1267 mechanism that protects the session from password snooping has 1268 been provided. Server sites SHOULD NOT use any configuration 1269 which permits a plaintext password mechanism without such a 1270 protection mechanism against password snooping. Client and server 1271 implementations SHOULD implement additional [SASL] mechanisms that 1272 do not use plaintext passwords, such the GSSAPI mechanism 1273 described in [SASL] and/or the [DIGEST-MD5] mechanism. 1275 Servers and clients can support multiple authentication mechanisms. 1276 The server SHOULD list its supported authentication mechanisms in the 1277 response to the CAPABILITY command so that the client knows which 1278 authentication mechanisms to use. 1280 A server MAY include a CAPABILITY response code in the tagged OK 1281 response of a successful AUTHENTICATE command in order to send 1282 capabilities automatically. It is unnecessary for a client to send a 1283 separate CAPABILITY command if it recognizes these automatic 1284 capabilities. This should only be done if a security layer was not 1285 negotiated by the AUTHENTICATE command, because the tagged OK 1286 response as part of an AUTHENTICATE command is not protected by 1287 encryption/integrity checking. [SASL] requires the client to re- 1288 issue a CAPABILITY command in this case. The server MAY advertise 1289 different capabilities after a successful AUTHENTICATE command. 1291 If an AUTHENTICATE command fails with a NO response, the client MAY 1292 try another authentication mechanism by issuing another AUTHENTICATE 1293 command. It MAY also attempt to authenticate by using the LOGIN 1294 command (see Section 6.2.3 for more detail). In other words, the 1295 client MAY request authentication types in decreasing order of 1296 preference, with the LOGIN command as a last resort. 1298 The authorization identity passed from the client to the server 1299 during the authentication exchange is interpreted by the server as 1300 the user name whose privileges the client is requesting. 1302 Example: S: * OK IMAP4rev1 Server 1303 C: A001 AUTHENTICATE GSSAPI 1304 S: + 1305 C: YIIB+wYJKoZIhvcSAQICAQBuggHqMIIB5qADAgEFoQMCAQ6iBw 1306 MFACAAAACjggEmYYIBIjCCAR6gAwIBBaESGxB1Lndhc2hpbmd0 1307 b24uZWR1oi0wK6ADAgEDoSQwIhsEaW1hcBsac2hpdmFtcy5jYW 1308 Mud2FzaGluZ3Rvbi5lZHWjgdMwgdCgAwIBAaEDAgEDooHDBIHA 1309 cS1GSa5b+fXnPZNmXB9SjL8Ollj2SKyb+3S0iXMljen/jNkpJX 1310 AleKTz6BQPzj8duz8EtoOuNfKgweViyn/9B9bccy1uuAE2HI0y 1311 C/PHXNNU9ZrBziJ8Lm0tTNc98kUpjXnHZhsMcz5Mx2GR6dGknb 1312 I0iaGcRerMUsWOuBmKKKRmVMMdR9T3EZdpqsBd7jZCNMWotjhi 1313 vd5zovQlFqQ2Wjc2+y46vKP/iXxWIuQJuDiisyXF0Y8+5GTpAL 1314 pHDc1/pIGmMIGjoAMCAQGigZsEgZg2on5mSuxoDHEA1w9bcW9n 1315 FdFxDKpdrQhVGVRDIzcCMCTzvUboqb5KjY1NJKJsfjRQiBYBdE 1316 NKfzK+g5DlV8nrw81uOcP8NOQCLR5XkoMHC0Dr/80ziQzbNqhx 1317 O6652Npft0LQwJvenwDI13YxpwOdMXzkWZN/XrEqOWp6GCgXTB 1318 vCyLWLlWnbaUkZdEYbKHBPjd8t/1x5Yg== 1319 S: + YGgGCSqGSIb3EgECAgIAb1kwV6ADAgEFoQMCAQ+iSzBJoAMC 1320 AQGiQgRAtHTEuOP2BXb9sBYFR4SJlDZxmg39IxmRBOhXRKdDA0 1321 uHTCOT9Bq3OsUTXUlk0CsFLoa8j+gvGDlgHuqzWHPSQg== 1322 C: 1323 S: + YDMGCSqGSIb3EgECAgIBAAD/////6jcyG4GE3KkTzBeBiVHe 1324 ceP2CWY0SR0fAQAgAAQEBAQ= 1325 C: YDMGCSqGSIb3EgECAgIBAAD/////3LQBHXTpFfZgrejpLlLImP 1326 wkhbfa2QteAQAgAG1yYwE= 1327 S: A001 OK GSSAPI authentication successful 1329 Note: The line breaks within server challenges and client responses 1330 are for editorial clarity and are not in real authenticators. 1332 6.2.3. LOGIN Command 1334 Arguments: user name 1335 password 1337 Responses: no specific responses for this command 1339 Result: OK - login completed, now in authenticated state 1340 NO - login failure: user name or password rejected 1341 BAD - command unknown or arguments invalid 1343 The LOGIN command identifies the client to the server and carries the 1344 plaintext password authenticating this user. 1346 A server MAY include a CAPABILITY response code in the tagged OK 1347 response to a successful LOGIN command in order to send capabilities 1348 automatically. It is unnecessary for a client to send a separate 1349 CAPABILITY command if it recognizes these automatic capabilities. 1351 Example: C: a001 LOGIN SMITH SESAME 1352 S: a001 OK LOGIN completed 1354 Note: Use of the LOGIN command over an insecure network (such as the 1355 Internet) is a security risk, because anyone monitoring network 1356 traffic can obtain plaintext passwords. The LOGIN command SHOULD NOT 1357 be used except as a last resort, and it is recommended that client 1358 implementations have a means to disable any automatic use of the 1359 LOGIN command. 1361 Unless either the STARTTLS command has been negotiated or some other 1362 mechanism that protects the session from password snooping has been 1363 provided, a server implementation MUST implement a configuration in 1364 which it advertises the LOGINDISABLED capability and does NOT permit 1365 the LOGIN command. Server sites SHOULD NOT use any configuration 1366 which permits the LOGIN command without such a protection mechanism 1367 against password snooping. A client implementation MUST NOT send a 1368 LOGIN command if the LOGINDISABLED capability is advertised. 1370 6.3. Client Commands - Authenticated State 1372 In the authenticated state, commands that manipulate mailboxes as 1373 atomic entities are permitted. Of these commands, the SELECT and 1374 EXAMINE commands will select a mailbox for access and enter the 1375 selected state. 1377 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 1378 the following commands are valid in the authenticated state: SELECT, 1379 EXAMINE, CREATE, DELETE, RENAME, SUBSCRIBE, UNSUBSCRIBE, LIST, LSUB, 1380 STATUS, and APPEND. 1382 6.3.1. SELECT Command 1384 Arguments: mailbox name 1386 Responses: REQUIRED untagged responses: FLAGS, EXISTS, RECENT 1387 REQUIRED OK untagged responses: UNSEEN (if any unseen 1388 exist), PERMANENTFLAGS, 1389 UIDNEXT, UIDVALIDITY 1391 Result: OK - select completed, now in selected state 1392 NO - select failure, now in authenticated state: no 1393 such mailbox, can't access mailbox 1394 BAD - command unknown or arguments invalid 1396 The SELECT command selects a mailbox so that messages in the mailbox 1397 can be accessed. Before returning an OK to the client, the server 1398 MUST send the following untagged data to the client. Note that 1399 earlier versions of this protocol only required the FLAGS, EXISTS, 1400 and RECENT untagged data; consequently, client implementations SHOULD 1401 implement default behavior for missing data as discussed with the 1402 individual item. 1404 FLAGS Defined flags in the mailbox. See the description of the 1405 FLAGS response for more detail. 1407 EXISTS The number of messages in the mailbox. See the 1408 description of the EXISTS response for more detail. 1410 RECENT The number of messages with the \Recent flag set. See 1411 the description of the RECENT response for more detail. 1413 OK [UNSEEN ] The message sequence number of the first unseen 1414 message in the mailbox. If there are any unseen messages in the 1415 mailbox, an UNSEEN response MUST be sent, if not it MUST be 1416 omitted. If this is missing, the client can not make any 1417 assumptions about the first unseen message in the mailbox, and 1418 needs to issue a SEARCH command if it wants to find it. 1420 OK [PERMANENTFLAGS ()] A list of message flags that 1421 the client can change permanently. If this is missing, the client 1422 should assume that all flags can be changed permanently. 1424 OK [UIDNEXT ] The next unique identifier value. Refer to 1425 Section 2.3.1.1 for more information. If this is missing, the 1426 client can not make any assumptions about the next unique 1427 identifier value. 1429 OK [UIDVALIDITY ] The unique identifier validity value. Refer to 1430 Section 2.3.1.1 for more information. If this is missing, the 1431 server does not support unique identifiers. 1433 Only one mailbox can be selected at a time in a connection; 1434 simultaneous access to multiple mailboxes requires multiple 1435 connections. The SELECT command automatically deselects any 1436 currently selected mailbox before attempting the new selection. 1437 Consequently, if a mailbox is selected and a SELECT command that 1438 fails is attempted, no mailbox is selected. 1440 If the client is permitted to modify the mailbox, the server SHOULD 1441 prefix the text of the tagged OK response with the "[READ-WRITE]" 1442 response code. 1444 If the client is not permitted to modify the mailbox but is permitted 1445 read access, the mailbox is selected as read-only, and the server 1446 MUST prefix the text of the tagged OK response to SELECT with the 1447 "[READ-ONLY]" response code. Read-only access through SELECT differs 1448 from the EXAMINE command in that certain read-only mailboxes MAY 1449 permit the change of permanent state on a per-user (as opposed to 1450 global) basis. Netnews messages marked in a server-based .newsrc 1451 file are an example of such per-user permanent state that can be 1452 modified with read-only mailboxes. 1454 Example: C: A142 SELECT INBOX 1455 S: * 172 EXISTS 1456 S: * 1 RECENT 1457 S: * OK [UNSEEN 12] Message 12 is first unseen 1458 S: * OK [UIDVALIDITY 3857529045] UIDs valid 1459 S: * OK [UIDNEXT 4392] Predicted next UID 1460 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1461 S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited 1462 S: A142 OK [READ-WRITE] SELECT completed 1464 6.3.2. EXAMINE Command 1466 Arguments: mailbox name 1468 Responses: REQUIRED untagged responses: FLAGS, EXISTS, RECENT 1469 REQUIRED OK untagged responses: UNSEEN, PERMANENTFLAGS, 1470 UIDNEXT, UIDVALIDITY 1472 Result: OK - examine completed, now in selected state 1473 NO - examine failure, now in authenticated state: no 1474 such mailbox, can't access mailbox BAD - command unknown 1475 or arguments invalid 1477 The EXAMINE command is identical to SELECT and returns the same 1478 output; however, the selected mailbox is identified as read-only. No 1479 changes to the permanent state of the mailbox, including per-user 1480 state, are permitted; in particular, EXAMINE MUST NOT cause messages 1481 to lose the \Recent flag. 1483 The text of the tagged OK response to the EXAMINE command MUST begin 1484 with the "[READ-ONLY]" response code. 1486 Example: C: A932 EXAMINE blurdybloop 1487 S: * 17 EXISTS 1488 S: * 2 RECENT 1489 S: * OK [UNSEEN 8] Message 8 is first unseen 1490 S: * OK [UIDVALIDITY 3857529045] UIDs valid 1491 S: * OK [UIDNEXT 4392] Predicted next UID 1492 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1493 S: * OK [PERMANENTFLAGS ()] No permanent flags permitted 1494 S: A932 OK [READ-ONLY] EXAMINE completed 1496 6.3.3. CREATE Command 1498 Arguments: mailbox name 1500 Responses: no specific responses for this command 1502 Result: OK - create completed 1503 NO - create failure: can't create mailbox with that name 1504 BAD - command unknown or arguments invalid 1506 The CREATE command creates a mailbox with the given name. An OK 1507 response is returned only if a new mailbox with that name has been 1508 created. It is an error to attempt to create INBOX or a mailbox with 1509 a name that refers to an extant mailbox. Any error in creation will 1510 return a tagged NO response. 1512 If the mailbox name is suffixed with the server's hierarchy separator 1513 character (as returned from the server by a LIST command), this is a 1514 declaration that the client intends to create mailbox names under 1515 this name in the hierarchy. Server implementations that do not 1516 require this declaration MUST ignore the declaration. In any case, 1517 the name created is without the trailing hierarchy delimiter. 1519 If the server's hierarchy separator character appears elsewhere in 1520 the name, the server SHOULD create any superior hierarchical names 1521 that are needed for the CREATE command to be successfully completed. 1522 In other words, an attempt to create "foo/bar/zap" on a server in 1523 which "/" is the hierarchy separator character SHOULD create foo/ and 1524 foo/bar/ if they do not already exist. 1526 If a new mailbox is created with the same name as a mailbox which was 1527 deleted, its unique identifiers MUST be greater than any unique 1528 identifiers used in the previous incarnation of the mailbox UNLESS 1529 the new incarnation has a different unique identifier validity value. 1530 See the description of the UID command for more detail. 1532 Example: C: A003 CREATE owatagusiam/ 1533 S: A003 OK CREATE completed 1534 C: A004 CREATE owatagusiam/blurdybloop 1535 S: A004 OK CREATE completed 1537 Note: The interpretation of this example depends on whether "/" 1538 was returned as the hierarchy separator from LIST. If "/" is the 1539 hierarchy separator, a new level of hierarchy named "owatagusiam" 1540 with a member called "blurdybloop" is created. Otherwise, two 1541 mailboxes at the same hierarchy level are created. 1543 6.3.4. DELETE Command 1545 Arguments: mailbox name 1547 Responses: no specific responses for this command 1549 Result: OK - delete completed 1550 NO - delete failure: can't delete mailbox with that name 1551 BAD - command unknown or arguments invalid 1553 The DELETE command permanently removes the mailbox with the given 1554 name. A tagged OK response is returned only if the mailbox has been 1555 deleted. It is an error to attempt to delete INBOX or a mailbox name 1556 that does not exist. 1558 The DELETE command MUST NOT remove inferior hierarchical names. For 1559 example, if a mailbox "foo" has an inferior "foo.bar" (assuming "." 1560 is the hierarchy delimiter character), removing "foo" MUST NOT remove 1561 "foo.bar". It is an error to attempt to delete a name that has 1562 inferior hierarchical names and also has the \Noselect mailbox name 1563 attribute (see the description of the LIST response for more 1564 details). 1566 It is permitted to delete a name that has inferior hierarchical names 1567 and does not have the \Noselect mailbox name attribute. If the 1568 server implementation does not permit deleting the name while 1569 inferior hierarchical names exists the \Noselect mailbox name 1570 attribute is set for that name. In any case, all messages in that 1571 mailbox are removed by the DELETE command. 1573 The value of the highest-used unique identifier of the deleted 1574 mailbox MUST be preserved so that a new mailbox created with the same 1575 name will not reuse the identifiers of the former incarnation, UNLESS 1576 the new incarnation has a different unique identifier validity value. 1577 See the description of the UID command for more detail. 1579 Examples: C: A682 LIST "" * 1580 S: * LIST () "/" blurdybloop 1581 S: * LIST (\Noselect) "/" foo 1582 S: * LIST () "/" foo/bar 1583 S: A682 OK LIST completed 1584 C: A683 DELETE blurdybloop 1585 S: A683 OK DELETE completed 1586 C: A684 DELETE foo 1587 S: A684 NO Name "foo" has inferior hierarchical names 1588 C: A685 DELETE foo/bar 1589 S: A685 OK DELETE Completed 1590 C: A686 LIST "" * 1591 S: * LIST (\Noselect) "/" foo 1592 S: A686 OK LIST completed 1593 C: A687 DELETE foo 1594 S: A687 OK DELETE Completed 1595 C: A82 LIST "" * 1596 S: * LIST () "." blurdybloop 1597 S: * LIST () "." foo 1598 S: * LIST () "." foo.bar 1599 S: A82 OK LIST completed 1600 C: A83 DELETE blurdybloop 1601 S: A83 OK DELETE completed 1602 C: A84 DELETE foo 1603 S: A84 OK DELETE Completed 1604 C: A85 LIST "" * 1605 S: * LIST () "." foo.bar 1606 S: A85 OK LIST completed 1607 C: A86 LIST "" % 1608 S: * LIST (\Noselect) "." foo 1609 S: A86 OK LIST completed 1611 6.3.5. RENAME Command 1613 Arguments: existing mailbox name 1614 new mailbox name 1616 Responses: no specific responses for this command 1618 Result: OK - rename completed 1619 NO - rename failure: can't rename mailbox with that name, 1620 can't rename to mailbox with that name 1621 BAD - command unknown or arguments invalid 1623 The RENAME command changes the name of a mailbox. A tagged OK 1624 response is returned only if the mailbox has been renamed. It is an 1625 error to attempt to rename from a mailbox name that does not exist or 1626 to a mailbox name that already exists. Any error in renaming will 1627 return a tagged NO response. 1629 If the name has inferior hierarchical names, then the inferior 1630 hierarchical names MUST also be renamed. For example, a rename of 1631 "foo" to "zap" will rename "foo/bar" (assuming "/" is the hierarchy 1632 delimiter character) to "zap/bar". 1634 If the server's hierarchy separator character appears in the name, 1635 the server SHOULD create any superior hierarchical names that are 1636 needed for the RENAME command to complete successfully. In other 1637 words, an attempt to rename "foo/bar/zap" to baz/rag/zowie on a 1638 server in which "/" is the hierarchy separator character SHOULD 1639 create baz/ and baz/rag/ if they do not already exist. 1641 The value of the highest-used unique identifier of the old mailbox 1642 name MUST be preserved so that a new mailbox created with the same 1643 name will not reuse the identifiers of the former incarnation, UNLESS 1644 the new incarnation has a different unique identifier validity value. 1645 See the description of the UID command for more detail. 1647 Renaming INBOX is permitted, and has special behavior. It moves all 1648 messages in INBOX to a new mailbox with the given name, leaving INBOX 1649 empty. If the server implementation supports inferior hierarchical 1650 names of INBOX, these are unaffected by a rename of INBOX. 1652 Examples: C: A682 LIST "" * 1653 S: * LIST () "/" blurdybloop 1654 S: * LIST (\Noselect) "/" foo 1655 S: * LIST () "/" foo/bar 1656 S: A682 OK LIST completed 1657 C: A683 RENAME blurdybloop sarasoop 1658 S: A683 OK RENAME completed 1659 C: A684 RENAME foo zowie 1660 S: A684 OK RENAME Completed 1661 C: A685 LIST "" * 1662 S: * LIST () "/" sarasoop 1663 S: * LIST (\Noselect) "/" zowie 1664 S: * LIST () "/" zowie/bar 1665 S: A685 OK LIST completed 1667 C: Z432 LIST "" * 1668 S: * LIST () "." INBOX 1669 S: * LIST () "." INBOX.bar 1670 S: Z432 OK LIST completed 1671 C: Z433 RENAME INBOX old-mail 1672 S: Z433 OK RENAME completed 1673 C: Z434 LIST "" * 1674 S: * LIST () "." INBOX 1675 S: * LIST () "." INBOX.bar 1676 S: * LIST () "." old-mail 1677 S: Z434 OK LIST completed 1679 6.3.6. SUBSCRIBE Command 1681 Arguments: mailbox 1683 Responses: no specific responses for this command 1685 Result: OK - subscribe completed 1686 NO - subscribe failure: can't subscribe to that name 1687 BAD - command unknown or arguments invalid 1689 The SUBSCRIBE command adds the specified mailbox name to the server's 1690 set of "active" or "subscribed" mailboxes as returned by the LSUB 1691 command. This command returns a tagged OK response only if the 1692 subscription is successful. 1694 A server MAY validate the mailbox argument to SUBSCRIBE to verify 1695 that it exists. However, it MUST NOT unilaterally remove an existing 1696 mailbox name from the subscription list even if a mailbox by that 1697 name no longer exists. 1699 Note: This requirement is because a server site can choose to 1700 routinely remove a mailbox with a well-known name (e.g., "system- 1701 alerts") after its contents expire, with the intention of 1702 recreating it when new contents are appropriate. 1704 Example: C: A002 SUBSCRIBE #news.comp.mail.mime 1705 S: A002 OK SUBSCRIBE completed 1707 6.3.7. UNSUBSCRIBE Command 1709 Arguments: mailbox name 1711 Responses: no specific responses for this command 1713 Result: OK - unsubscribe completed 1714 NO - unsubscribe failure: can't unsubscribe that name 1715 BAD - command unknown or arguments invalid 1717 The UNSUBSCRIBE command removes the specified mailbox name from the 1718 server's set of "active" or "subscribed" mailboxes as returned by the 1719 LSUB command. This command returns a tagged OK response only if the 1720 unsubscription is successful. 1722 Example: C: A002 UNSUBSCRIBE #news.comp.mail.mime 1723 S: A002 OK UNSUBSCRIBE completed 1725 6.3.8. LIST Command 1727 Arguments: reference name 1728 mailbox name with possible wildcards 1730 Responses: untagged responses: LIST 1732 Result: OK - list completed 1733 NO - list failure: can't list that reference or name 1734 BAD - command unknown or arguments invalid 1736 The LIST command returns a subset of names from the complete set of 1737 all names available to the client. Zero or more untagged LIST 1738 replies are returned, containing the name attributes, hierarchy 1739 delimiter, and name; see the description of the LIST reply for more 1740 detail. 1742 The LIST command SHOULD return its data quickly, without undue delay. 1743 For example, it SHOULD NOT go to excess trouble to calculate the 1744 \Marked or \Unmarked status or perform other processing; if each name 1745 requires 1 second of processing, then a list of 1200 names would take 1746 20 minutes! 1747 An empty ("" string) reference name argument indicates that the 1748 mailbox name is interpreted as by SELECT. The returned mailbox names 1749 MUST match the supplied mailbox name pattern. A non-empty reference 1750 name argument is the name of a mailbox or a level of mailbox 1751 hierarchy, and indicates the context in which the mailbox name is 1752 interpreted. 1754 An empty ("" string) mailbox name argument is a special request to 1755 return the hierarchy delimiter and the root name of the name given in 1756 the reference. The value returned as the root MAY be the empty 1757 string if the reference is non-rooted or is an empty string. In all 1758 cases, a hierarchy delimiter (or NIL if there is no hierarchy) is 1759 returned. This permits a client to get the hierarchy delimiter (or 1760 find out that the mailbox names are flat) even when no mailboxes by 1761 that name currently exist. 1763 The reference and mailbox name arguments are interpreted into a 1764 canonical form that represents an unambiguous left-to-right 1765 hierarchy. The returned mailbox names will be in the interpreted 1766 form. 1768 Note: The interpretation of the reference argument is 1769 implementation-defined. It depends upon whether the server 1770 implementation has a concept of the "current working directory" 1771 and leading "break out characters", which override the current 1772 working directory. 1774 For example, on a server which exports a UNIX or NT filesystem, 1775 the reference argument contains the current working directory, and 1776 the mailbox name argument would contain the name as interpreted in 1777 the current working directory. 1779 If a server implementation has no concept of break out characters, 1780 the canonical form is normally the reference name appended with 1781 the mailbox name. Note that if the server implements the 1782 namespace convention (Section 5.1.2), "#" is a break out character 1783 and must be treated as such. 1785 If the reference argument is not a level of mailbox hierarchy 1786 (that is, it is a \NoInferiors name), and/or the reference 1787 argument does not end with the hierarchy delimiter, it is 1788 implementation-dependent how this is interpreted. For example, a 1789 reference of "foo/bar" and mailbox name of "rag/baz" could be 1790 interpreted as "foo/bar/rag/baz", "foo/barrag/baz", or "foo/rag/ 1791 baz". A client SHOULD NOT use such a reference argument except at 1792 the explicit request of the user. A hierarchical browser MUST NOT 1793 make any assumptions about server interpretation of the reference 1794 unless the reference is a level of mailbox hierarchy AND ends with 1795 the hierarchy delimiter. 1797 Any part of the reference argument that is included in the 1798 interpreted form SHOULD prefix the interpreted form. It SHOULD also 1799 be in the same form as the reference name argument. This rule 1800 permits the client to determine if the returned mailbox name is in 1801 the context of the reference argument, or if something about the 1802 mailbox argument overrode the reference argument. Without this rule, 1803 the client would have to have knowledge of the server's naming 1804 semantics including what characters are "breakouts" that override a 1805 naming context. 1807 For example, here are some examples of how references 1808 and mailbox names might be interpreted on a UNIX-based 1809 server: 1811 Reference Mailbox Name Interpretation 1812 ------------ ------------ -------------- 1813 ~smith/Mail/ foo.* ~smith/Mail/foo.* 1814 archive/ % archive/% 1815 #news. comp.mail.* #news.comp.mail.* 1816 ~smith/Mail/ /usr/doc/foo /usr/doc/foo 1817 archive/ ~fred/Mail/* ~fred/Mail/* 1819 The first three examples demonstrate interpretations in 1820 the context of the reference argument. Note that 1821 "~smith/Mail" SHOULD NOT be transformed into something 1822 like "/u2/users/smith/Mail", or it would be impossible 1823 for the client to determine that the interpretation was 1824 in the context of the reference. 1826 The character "*" is a wildcard, and matches zero or more characters 1827 at this position. The character "%" is similar to "*", but it does 1828 not match a hierarchy delimiter. If the "%" wildcard is the last 1829 character of a mailbox name argument, matching levels of hierarchy 1830 are also returned. If these levels of hierarchy are not also 1831 selectable mailboxes, they are returned with the \Noselect mailbox 1832 name attribute (see the description of the LIST response for more 1833 details). 1835 Server implementations are permitted to "hide" otherwise accessible 1836 mailboxes from the wildcard characters, by preventing certain 1837 characters or names from matching a wildcard in certain situations. 1838 For example, a UNIX-based server might restrict the interpretation of 1839 "*" so that an initial "/" character does not match. 1841 The special name INBOX is included in the output from LIST, if INBOX 1842 is supported by this server for this user and if the uppercase string 1843 "INBOX" matches the interpreted reference and mailbox name arguments 1844 with wildcards as described above. The criteria for omitting INBOX 1845 is whether SELECT INBOX will return failure; it is not relevant 1846 whether the user's real INBOX resides on this or some other server. 1848 Example: C: A101 LIST "" "" 1849 S: * LIST (\Noselect) "/" "" 1850 S: A101 OK LIST Completed 1851 C: A102 LIST #news.comp.mail.misc "" 1852 S: * LIST (\Noselect) "." #news. 1853 S: A102 OK LIST Completed 1854 C: A103 LIST /usr/staff/jones "" 1855 S: * LIST (\Noselect) "/" / 1856 S: A103 OK LIST Completed 1857 C: A202 LIST ~/Mail/ % 1858 S: * LIST (\Noselect) "/" ~/Mail/foo 1859 S: * LIST () "/" ~/Mail/meetings 1860 S: A202 OK LIST completed 1862 6.3.9. LSUB Command 1864 Arguments: reference name 1865 mailbox name with possible wildcards 1867 Responses: untagged responses: LSUB 1869 Result: OK - lsub completed 1870 NO - lsub failure: can't list that reference or name 1871 BAD - command unknown or arguments invalid 1873 The LSUB command returns a subset of names from the set of names that 1874 the user has declared as being "active" or "subscribed". Zero or 1875 more untagged LSUB replies are returned. The arguments to LSUB are 1876 in the same form as those for LIST. 1878 The returned untagged LSUB response MAY contain different mailbox 1879 flags from a LIST untagged response. If this should happen, the 1880 flags in the untagged LIST are considered more authoritative. 1882 A special situation occurs when using LSUB with the % wildcard. 1883 Consider what happens if "foo/bar" (with a hierarchy delimiter of 1884 "/") is subscribed but "foo" is not. A "%" wildcard to LSUB must 1885 return foo, not foo/bar, in the LSUB response, and it MUST be flagged 1886 with the \Noselect attribute. 1888 The server MUST NOT unilaterally remove an existing mailbox name from 1889 the subscription list even if a mailbox by that name no longer 1890 exists. 1892 Example: C: A002 LSUB "#news." "comp.mail.*" 1893 S: * LSUB () "." #news.comp.mail.mime 1894 S: * LSUB () "." #news.comp.mail.misc 1895 S: A002 OK LSUB completed 1896 C: A003 LSUB "#news." "comp.%" 1897 S: * LSUB (\NoSelect) "." #news.comp.mail 1898 S: A003 OK LSUB completed 1900 6.3.10. STATUS Command 1902 Arguments: mailbox name 1903 status data item names 1905 Responses: REQUIRED untagged responses: STATUS 1907 Result: OK - status completed 1908 NO - status failure: no status for that name 1909 BAD - command unknown or arguments invalid 1911 The STATUS command requests the status of the indicated mailbox. It 1912 does not change the currently selected mailbox, nor does it affect 1913 the state of any messages in the queried mailbox (in particular, 1914 STATUS MUST NOT cause messages to lose the \Recent flag). 1916 The STATUS command provides an alternative to opening a second 1917 IMAP4rev1 connection and doing an EXAMINE command on a mailbox to 1918 query that mailbox's status without deselecting the current mailbox 1919 in the first IMAP4rev1 connection. 1921 Unlike the LIST command, the STATUS command is not guaranteed to be 1922 fast in its response. Under certain circumstances, it can be quite 1923 slow. In some implementations, the server is obliged to open the 1924 mailbox read-only internally to obtain certain status information. 1925 Also unlike the LIST command, the STATUS command does not accept 1926 wildcards. 1928 Note: The STATUS command is intended to access the status of 1929 mailboxes other than the currently selected mailbox. Because the 1930 STATUS command can cause the mailbox to be opened internally, and 1931 because this information is available by other means on the 1932 selected mailbox, the STATUS command SHOULD NOT be used on the 1933 currently selected mailbox. 1935 The STATUS command MUST NOT be used as a "check for new messages 1936 in the selected mailbox" operation (refer to sections 7, 1937 Section 7.3.1, and Section 7.3.2 for more information about the 1938 proper method for new message checking). 1940 Because the STATUS command is not guaranteed to be fast in its 1941 results, clients SHOULD NOT expect to be able to issue many 1942 consecutive STATUS commands and obtain reasonable performance. 1944 The currently defined status data items that can be requested are: 1946 MESSAGES The number of messages in the mailbox. 1948 RECENT The number of messages with the \Recent flag set. 1950 UIDNEXT The next unique identifier value of the mailbox. Refer to 1951 Section 2.3.1.1 for more information. 1953 UIDVALIDITY The unique identifier validity value of the mailbox. 1954 Refer to Section 2.3.1.1 for more information. 1956 UNSEEN The number of messages which do not have the \Seen flag set. 1958 Example: C: A042 STATUS blurdybloop (UIDNEXT MESSAGES) 1959 S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) 1960 S: A042 OK STATUS completed 1962 6.3.11. APPEND Command 1964 Arguments: mailbox name 1965 OPTIONAL flag parenthesized list 1966 OPTIONAL date/time string 1967 message literal 1969 Responses: no specific responses for this command 1971 Result: OK - append completed 1972 NO - append error: can't append to that mailbox, error 1973 in flags or date/time or message text 1974 BAD - command unknown or arguments invalid 1976 The APPEND command appends the literal argument as a new message to 1977 the end of the specified destination mailbox. This argument SHOULD 1978 be in the format of an [RFC-5322] message. 8-bit characters are 1979 permitted in the message. A server implementation that is unable to 1980 preserve 8-bit data properly MUST be able to reversibly convert 8-bit 1981 APPEND data to 7-bit using a [MIME-IMB] content transfer encoding. 1983 Note: There may be exceptions, e.g., draft messages, in which 1984 required [RFC-5322] header lines are omitted in the message 1985 literal argument to APPEND. The full implications of doing so 1986 must be understood and carefully weighed. 1988 If a flag parenthesized list is specified, the flags SHOULD be set in 1989 the resulting message; otherwise, the flag list of the resulting 1990 message is set to empty by default. In either case, the Recent flag 1991 is also set. 1993 If a date-time is specified, the internal date SHOULD be set in the 1994 resulting message; otherwise, the internal date of the resulting 1995 message is set to the current date and time by default. 1997 If the append is unsuccessful for any reason, the mailbox MUST be 1998 restored to its state before the APPEND attempt; no partial appending 1999 is permitted. 2001 If the destination mailbox does not exist, a server MUST return an 2002 error, and MUST NOT automatically create the mailbox. Unless it is 2003 certain that the destination mailbox can not be created, the server 2004 MUST send the response code "[TRYCREATE]" as the prefix of the text 2005 of the tagged NO response. This gives a hint to the client that it 2006 can attempt a CREATE command and retry the APPEND if the CREATE is 2007 successful. 2009 If the mailbox is currently selected, the normal new message actions 2010 SHOULD occur. Specifically, the server SHOULD notify the client 2011 immediately via an untagged EXISTS response. If the server does not 2012 do so, the client MAY issue a NOOP command (or failing that, a CHECK 2013 command) after one or more APPEND commands. 2015 Example: C: A003 APPEND saved-messages (\Seen) {310} 2016 S: + Ready for literal data 2017 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST) 2018 C: From: Fred Foobar 2019 C: Subject: afternoon meeting 2020 C: To: mooch@owatagu.siam.edu 2021 C: Message-Id: 2022 C: MIME-Version: 1.0 2023 C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 2024 C: 2025 C: Hello Joe, do you think we can meet at 3:30 tomorrow? 2026 C: 2027 S: A003 OK APPEND completed 2029 Note: The APPEND command is not used for message delivery, because it 2030 does not provide a mechanism to transfer [SMTP] envelope information. 2032 6.4. Client Commands - Selected State 2034 In the selected state, commands that manipulate messages in a mailbox 2035 are permitted. 2037 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 2038 and the authenticated state commands (SELECT, EXAMINE, CREATE, 2039 DELETE, RENAME, SUBSCRIBE, UNSUBSCRIBE, LIST, LSUB, STATUS, and 2040 APPEND), the following commands are valid in the selected state: 2041 CHECK, CLOSE, EXPUNGE, SEARCH, FETCH, STORE, COPY, and UID. 2043 6.4.1. CHECK Command 2045 Arguments: none 2047 Responses: no specific responses for this command 2049 Result: OK - check completed 2050 BAD - command unknown or arguments invalid 2052 The CHECK command requests a checkpoint of the currently selected 2053 mailbox. A checkpoint refers to any implementation-dependent 2054 housekeeping associated with the mailbox (e.g., resolving the 2055 server's in-memory state of the mailbox with the state on its disk) 2056 that is not normally executed as part of each command. A checkpoint 2057 MAY take a non-instantaneous amount of real time to complete. If a 2058 server implementation has no such housekeeping considerations, CHECK 2059 is equivalent to NOOP. 2061 There is no guarantee that an EXISTS untagged response will happen as 2062 a result of CHECK. NOOP, not CHECK, SHOULD be used for new message 2063 polling. 2065 Example: C: FXXZ CHECK 2066 S: FXXZ OK CHECK Completed 2068 6.4.2. CLOSE Command 2070 Arguments: none 2072 Responses: no specific responses for this command 2074 Result: OK - close completed, now in authenticated state 2075 BAD - command unknown or arguments invalid 2077 The CLOSE command permanently removes all messages that have the 2078 \Deleted flag set from the currently selected mailbox, and returns to 2079 the authenticated state from the selected state. No untagged EXPUNGE 2080 responses are sent. 2082 No messages are removed, and no error is given, if the mailbox is 2083 selected by an EXAMINE command or is otherwise selected read-only. 2085 Even if a mailbox is selected, a SELECT, EXAMINE, or LOGOUT command 2086 MAY be issued without previously issuing a CLOSE command. The 2087 SELECT, EXAMINE, and LOGOUT commands implicitly close the currently 2088 selected mailbox without doing an expunge. However, when many 2089 messages are deleted, a CLOSE-LOGOUT or CLOSE-SELECT sequence is 2090 considerably faster than an EXPUNGE-LOGOUT or EXPUNGE-SELECT because 2091 no untagged EXPUNGE responses (which the client would probably 2092 ignore) are sent. 2094 Example: C: A341 CLOSE 2095 S: A341 OK CLOSE completed 2097 6.4.3. EXPUNGE Command 2099 Arguments: none 2101 Responses: untagged responses: EXPUNGE 2103 Result: OK - expunge completed 2104 NO - expunge failure: can't expunge (e.g., permission 2105 denied) 2106 BAD - command unknown or arguments invalid 2108 The EXPUNGE command permanently removes all messages that have the 2109 \Deleted flag set from the currently selected mailbox. Before 2110 returning an OK to the client, an untagged EXPUNGE response is sent 2111 for each message that is removed. Note that if any messages with the 2112 \Recent flag set are expunged, an untagged RECENT response is sent 2113 after the untagged EXPUNGE(s) to update the client's count of RECENT 2114 messages. 2116 Example: C: A202 EXPUNGE 2117 S: * 3 EXPUNGE 2118 S: * 3 EXPUNGE 2119 S: * 5 EXPUNGE 2120 S: * 8 EXPUNGE 2121 S: A202 OK EXPUNGE completed 2123 Note: In this example, messages 3, 4, 7, and 11 had the \Deleted flag 2124 set. See the description of the EXPUNGE response for further 2125 explanation. 2127 6.4.4. SEARCH Command 2129 Arguments: OPTIONAL [CHARSET] specification 2130 searching criteria (one or more) 2132 Responses: REQUIRED untagged response: SEARCH 2134 Result: OK - search completed 2135 NO - search error: can't search that [CHARSET] or 2136 criteria 2137 BAD - command unknown or arguments invalid 2139 The SEARCH command searches the mailbox for messages that match the 2140 given searching criteria. Searching criteria consist of one or more 2141 search keys. The untagged SEARCH response from the server contains a 2142 listing of message sequence numbers corresponding to those messages 2143 that match the searching criteria. 2145 When multiple keys are specified, the result is the intersection (AND 2146 function) of all the messages that match those keys. For example, 2147 the criteria DELETED FROM "SMITH" SINCE 1-Feb-1994 refers to all 2148 deleted messages from Smith that were placed in the mailbox since 2149 February 1, 1994. A search key can also be a parenthesized list of 2150 one or more search keys (e.g., for use with the OR and NOT keys). 2152 Server implementations MAY exclude [MIME-IMB] body parts with 2153 terminal content media types other than TEXT and MESSAGE from 2154 consideration in SEARCH matching. 2156 The OPTIONAL [CHARSET] specification consists of the word "CHARSET" 2157 followed by a registered [CHARSET]. It indicates the [CHARSET] of 2158 the strings that appear in the search criteria. [MIME-IMB] content 2159 transfer encodings, and [MIME-HDRS] strings in [RFC-5322]/[MIME-IMB] 2160 headers, MUST be decoded before comparing text. US-ASCII MUST be 2161 supported; other [CHARSET]s MAY be supported. 2163 If the server does not support the specified [CHARSET], it MUST 2164 return a tagged NO response (not a BAD). This response SHOULD 2165 contain the BADCHARSET response code, which MAY list the [CHARSET]s 2166 supported by the server. 2168 In all search keys that use strings, a message matches the key if the 2169 string is a substring of the associated text. The matching is case- 2170 insensitive. Note that the empty string is a substring; this is 2171 useful when doing a HEADER search. 2173 The defined search keys are as follows. Refer to the Formal Syntax 2174 section for the precise syntactic definitions of the arguments. 2176 Messages with message sequence numbers corresponding 2177 to the specified message sequence number set. 2179 ALL All messages in the mailbox; the default initial key for ANDing. 2181 ANSWERED Messages with the \Answered flag set. 2183 BCC Messages that contain the specified string in the 2184 envelope structure's BCC field. 2186 BEFORE Messages whose internal date (disregarding time and 2187 timezone) is earlier than the specified date. 2189 BODY Messages that contain the specified string in the body 2190 of the message. 2192 CC Messages that contain the specified string in the 2193 envelope structure's CC field. 2195 DELETED Messages with the \Deleted flag set. 2197 DRAFT Messages with the \Draft flag set. 2199 FLAGGED Messages with the \Flagged flag set. 2201 FROM Messages that contain the specified string in the 2202 envelope structure's FROM field. 2204 HEADER Messages that have a header with the 2205 specified field-name (as defined in [RFC-5322]) and that contains 2206 the specified string in the text of the header (what comes after 2207 the colon). If the string to search is zero-length, this matches 2208 all messages that have a header line with the specified field-name 2209 regardless of the contents. 2211 KEYWORD Messages with the specified keyword flag set. 2213 LARGER Messages with an [RFC-5322] size larger than the 2214 specified number of octets. 2216 NEW Messages that have the \Recent flag set but not the \Seen flag. 2217 This is functionally equivalent to "(RECENT UNSEEN)". 2219 NOT Messages that do not match the specified search 2220 key. 2222 OLD Messages that do not have the \Recent flag set. This is 2223 functionally equivalent to "NOT RECENT" (as opposed to "NOT NEW"). 2225 ON Messages whose internal date (disregarding time and 2226 timezone) is within the specified date. 2228 OR Messages that match either search 2229 key. 2231 RECENT Messages that have the \Recent flag set. 2233 SEEN Messages that have the \Seen flag set. 2235 SENTBEFORE Messages whose [RFC-5322] Date: header 2236 (disregarding time and timezone) is earlier than the specified 2237 date. 2239 SENTON Messages whose [RFC-5322] Date: header (disregarding 2240 time and timezone) is within the specified date. 2242 SENTSINCE Messages whose [RFC-5322] Date: header 2243 (disregarding time and timezone) is within or later than the 2244 specified date. 2246 SINCE Messages whose internal date (disregarding time and 2247 timezone) is within or later than the specified date. 2249 SMALLER Messages with an [RFC-5322] size smaller than the 2250 specified number of octets. 2252 SUBJECT Messages that contain the specified string in the 2253 envelope structure's SUBJECT field. 2255 TEXT Messages that contain the specified string in the 2256 header or body of the message. 2258 TO Messages that contain the specified string in the 2259 envelope structure's TO field. 2261 UID Messages with unique identifiers corresponding to 2262 the specified unique identifier set. Sequence set ranges are 2263 permitted. 2265 UNANSWERED Messages that do not have the \Answered flag set. 2267 UNDELETED Messages that do not have the \Deleted flag set. 2269 UNDRAFT Messages that do not have the \Draft flag set. 2271 UNFLAGGED Messages that do not have the \Flagged flag set. 2273 UNKEYWORD Messages that do not have the specified keyword 2274 flag set. 2276 UNSEEN Messages that do not have the \Seen flag set. 2278 Example: C: A282 SEARCH FLAGGED SINCE 1-Feb-1994 NOT FROM "Smith" 2279 S: * SEARCH 2 84 882 2280 S: A282 OK SEARCH completed 2281 C: A283 SEARCH TEXT "string not in mailbox" 2282 S: * SEARCH 2283 S: A283 OK SEARCH completed 2284 C: A284 SEARCH CHARSET UTF-8 TEXT {6} 2285 S: + Ready for literal text 2286 C: XXXXXX 2287 S: * SEARCH 43 2288 S: A284 OK SEARCH completed 2290 Note: Since this document is restricted to 7-bit ASCII text, it is 2291 not possible to show actual UTF-8 data. The "XXXXXX" is a 2292 placeholder for what would be 6 octets of 8-bit data in an actual 2293 transaction. 2295 6.4.5. FETCH Command 2297 Arguments: sequence set 2298 message data item names or macro 2300 Responses: untagged responses: FETCH 2302 Result: OK - fetch completed 2303 NO - fetch error: can't fetch that data 2304 BAD - command unknown or arguments invalid 2306 The FETCH command retrieves data associated with a message in the 2307 mailbox. The data items to be fetched can be either a single atom or 2308 a parenthesized list. 2310 Most data items, identified in the formal syntax under the msg-att- 2311 static rule, are static and MUST NOT change for any particular 2312 message. Other data items, identified in the formal syntax under the 2313 msg-att-dynamic rule, MAY change, either as a result of a STORE 2314 command or due to external events. 2316 For example, if a client receives an ENVELOPE for a message when 2317 it already knows the envelope, it can safely ignore the newly 2318 transmitted envelope. 2320 There are three macros which specify commonly-used sets of data 2321 items, and can be used instead of data items. A macro must be used 2322 by itself, and not in conjunction with other macros or data items. 2324 ALL Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE) 2326 FAST Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE) 2328 FULL Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE 2329 BODY) 2331 The currently defined data items that can be fetched are: 2333 BODY Non-extensible form of BODYSTRUCTURE. 2335 BODY[
]<> 2337 The text of a particular body section. The section 2338 specification is a set of zero or more part specifiers 2339 delimited by periods. A part specifier is either a part number 2340 or one of the following: HEADER, HEADER.FIELDS, 2341 HEADER.FIELDS.NOT, MIME, and TEXT. An empty section 2342 specification refers to the entire message, including the 2343 header. 2345 Every message has at least one part number. Non-[MIME-IMB] 2346 messages, and non-multipart [MIME-IMB] messages with no 2347 encapsulated message, only have a part 1. 2349 Multipart messages are assigned consecutive part numbers, as 2350 they occur in the message. If a particular part is of type 2351 message or multipart, its parts MUST be indicated by a period 2352 followed by the part number within that nested multipart part. 2354 A part of type MESSAGE/RFC822 also has nested part numbers, 2355 referring to parts of the MESSAGE part's body. 2357 The HEADER, HEADER.FIELDS, HEADER.FIELDS.NOT, and TEXT part 2358 specifiers can be the sole part specifier or can be prefixed by 2359 one or more numeric part specifiers, provided that the numeric 2360 part specifier refers to a part of type MESSAGE/RFC822. The 2361 MIME part specifier MUST be prefixed by one or more numeric 2362 part specifiers. 2364 The HEADER, HEADER.FIELDS, and HEADER.FIELDS.NOT part 2365 specifiers refer to the [RFC-5322] header of the message or of 2366 an encapsulated [MIME-IMT] MESSAGE/RFC822 message. 2367 HEADER.FIELDS and HEADER.FIELDS.NOT are followed by a list of 2368 field-name (as defined in [RFC-5322]) names, and return a 2369 subset of the header. The subset returned by HEADER.FIELDS 2370 contains only those header fields with a field-name that 2371 matches one of the names in the list; similarly, the subset 2372 returned by HEADER.FIELDS.NOT contains only the header fields 2373 with a non-matching field-name. The field-matching is case- 2374 insensitive but otherwise exact. Subsetting does not exclude 2375 the [RFC-5322] delimiting blank line between the header and the 2376 body; the blank line is included in all header fetches, except 2377 in the case of a message which has no body and no blank line. 2379 The MIME part specifier refers to the [MIME-IMB] header for 2380 this part. 2382 The TEXT part specifier refers to the text body of the message, 2383 omitting the [RFC-5322] header. 2385 Here is an example of a complex message with some of its 2386 part specifiers: 2388 HEADER ([RFC-5322] header of the message) 2389 TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 2390 1 TEXT/PLAIN 2391 2 APPLICATION/OCTET-STREAM 2392 3 MESSAGE/RFC822 2393 3.HEADER ([RFC-5322] header of the message) 2394 3.TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 2395 3.1 TEXT/PLAIN 2396 3.2 APPLICATION/OCTET-STREAM 2397 4 MULTIPART/MIXED 2398 4.1 IMAGE/GIF 2399 4.1.MIME ([MIME-IMB] header for the IMAGE/GIF) 2400 4.2 MESSAGE/RFC822 2401 4.2.HEADER ([RFC-5322] header of the message) 2402 4.2.TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 2403 4.2.1 TEXT/PLAIN 2404 4.2.2 MULTIPART/ALTERNATIVE 2405 4.2.2.1 TEXT/PLAIN 2406 4.2.2.2 TEXT/RICHTEXT 2408 It is possible to fetch a substring of the designated text. 2409 This is done by appending an open angle bracket ("<"), the 2410 octet position of the first desired octet, a period, the 2411 maximum number of octets desired, and a close angle bracket 2412 (">") to the part specifier. If the starting octet is beyond 2413 the end of the text, an empty string is returned. 2415 Any partial fetch that attempts to read beyond the end of the 2416 text is truncated as appropriate. A partial fetch that starts 2417 at octet 0 is returned as a partial fetch, even if this 2418 truncation happened. 2420 Note: This means that BODY[]<0.2048> of a 1500-octet message 2421 will return BODY[]<0> with a literal of size 1500, not 2422 BODY[]. 2424 Note: A substring fetch of a HEADER.FIELDS or 2425 HEADER.FIELDS.NOT part specifier is calculated after 2426 subsetting the header. 2428 The \Seen flag is implicitly set; if this causes the flags to 2429 change, they SHOULD be included as part of the FETCH responses. 2431 BODY.PEEK[
]<> An alternate form of BODY[
] 2432 that does not implicitly set the \Seen flag. 2434 BODYSTRUCTURE The [MIME-IMB] body structure of the message. This is 2435 computed by the server by parsing the [MIME-IMB] header fields in 2436 the [RFC-5322] header and [MIME-IMB] headers. 2438 ENVELOPE The envelope structure of the message. This is computed by 2439 the server by parsing the [RFC-5322] header into the component 2440 parts, defaulting various fields as necessary. 2442 FLAGS The flags that are set for this message. 2444 INTERNALDATE The internal date of the message. 2446 RFC822 Functionally equivalent to BODY[], differing in the syntax of 2447 the resulting untagged FETCH data (RFC822 is returned). 2449 RFC822.HEADER Functionally equivalent to BODY.PEEK[HEADER], 2450 differing in the syntax of the resulting untagged FETCH data 2451 (RFC822.HEADER is returned). 2453 RFC822.SIZE The [RFC-5322] size of the message. 2455 RFC822.TEXT Functionally equivalent to BODY[TEXT], differing in the 2456 syntax of the resulting untagged FETCH data (RFC822.TEXT is 2457 returned). 2459 UID The unique identifier for the message. 2461 Example: C: A654 FETCH 2:4 (FLAGS BODY[HEADER.FIELDS (DATE FROM)]) 2462 S: * 2 FETCH .... 2463 S: * 3 FETCH .... 2464 S: * 4 FETCH .... 2465 S: A654 OK FETCH completed 2467 6.4.6. STORE Command 2469 Arguments: sequence set 2470 message data item name 2471 value for message data item 2473 Responses: untagged responses: FETCH 2475 Result: OK - store completed 2476 NO - store error: can't store that data 2477 BAD - command unknown or arguments invalid 2479 The STORE command alters data associated with a message in the 2480 mailbox. Normally, STORE will return the updated value of the data 2481 with an untagged FETCH response. A suffix of ".SILENT" in the data 2482 item name prevents the untagged FETCH, and the server SHOULD assume 2483 that the client has determined the updated value itself or does not 2484 care about the updated value. 2486 Note: Regardless of whether or not the ".SILENT" suffix was used, 2487 the server SHOULD send an untagged FETCH response if a change to a 2488 message's flags from an external source is observed. The intent 2489 is that the status of the flags is determinate without a race 2490 condition. 2492 The currently defined data items that can be stored are: 2494 FLAGS Replace the flags for the message (other than 2495 \Recent) with the argument. The new value of the flags is 2496 returned as if a FETCH of those flags was done. 2498 FLAGS.SILENT Equivalent to FLAGS, but without returning 2499 a new value. 2501 +FLAGS Add the argument to the flags for the message. 2502 The new value of the flags is returned as if a FETCH of those 2503 flags was done. 2505 +FLAGS.SILENT Equivalent to +FLAGS, but without 2506 returning a new value. 2508 -FLAGS Remove the argument from the flags for the 2509 message. The new value of the flags is returned as if a FETCH of 2510 those flags was done. 2512 -FLAGS.SILENT Equivalent to -FLAGS, but without 2513 returning a new value. 2515 Example: C: A003 STORE 2:4 +FLAGS (\Deleted) 2516 S: * 2 FETCH (FLAGS (\Deleted \Seen)) 2517 S: * 3 FETCH (FLAGS (\Deleted)) 2518 S: * 4 FETCH (FLAGS (\Deleted \Flagged \Seen)) 2519 S: A003 OK STORE completed 2521 6.4.7. COPY Command 2523 Arguments: sequence set 2524 mailbox name 2526 Responses: no specific responses for this command 2528 Result: OK - copy completed 2529 NO - copy error: can't copy those messages or to that 2530 name 2531 BAD - command unknown or arguments invalid 2533 The COPY command copies the specified message(s) to the end of the 2534 specified destination mailbox. The flags and internal date of the 2535 message(s) SHOULD be preserved, and the Recent flag SHOULD be set, in 2536 the copy. 2538 If the destination mailbox does not exist, a server SHOULD return an 2539 error. It SHOULD NOT automatically create the mailbox. Unless it is 2540 certain that the destination mailbox can not be created, the server 2541 MUST send the response code "[TRYCREATE]" as the prefix of the text 2542 of the tagged NO response. This gives a hint to the client that it 2543 can attempt a CREATE command and retry the COPY if the CREATE is 2544 successful. 2546 If the COPY command is unsuccessful for any reason, server 2547 implementations MUST restore the destination mailbox to its state 2548 before the COPY attempt. 2550 Example: C: A003 COPY 2:4 MEETING 2551 S: A003 OK COPY completed 2553 6.4.8. UID Command 2555 Arguments: command name 2556 command arguments 2558 Responses: untagged responses: FETCH, SEARCH 2560 Result: OK - UID command completed 2561 NO - UID command error 2562 BAD - command unknown or arguments invalid 2564 The UID command has two forms. In the first form, it takes as its 2565 arguments a COPY, FETCH, or STORE command with arguments appropriate 2566 for the associated command. However, the numbers in the sequence set 2567 argument are unique identifiers instead of message sequence numbers. 2568 Sequence set ranges are permitted, but there is no guarantee that 2569 unique identifiers will be contiguous. 2571 A non-existent unique identifier is ignored without any error message 2572 generated. Thus, it is possible for a UID FETCH command to return an 2573 OK without any data or a UID COPY or UID STORE to return an OK 2574 without performing any operations. 2576 In the second form, the UID command takes a SEARCH command with 2577 SEARCH command arguments. The interpretation of the arguments is the 2578 same as with SEARCH; however, the numbers returned in a SEARCH 2579 response for a UID SEARCH command are unique identifiers instead of 2580 message sequence numbers. For example, the command UID SEARCH 1:100 2581 UID 443:557 returns the unique identifiers corresponding to the 2582 intersection of two sequence sets, the message sequence number range 2583 1:100 and the UID range 443:557. 2585 Note: in the above example, the UID range 443:557 appears. The 2586 same comment about a non-existent unique identifier being ignored 2587 without any error message also applies here. Hence, even if 2588 neither UID 443 or 557 exist, this range is valid and would 2589 include an existing UID 495. 2591 Also note that a UID range of 559:* always includes the UID of the 2592 last message in the mailbox, even if 559 is higher than any 2593 assigned UID value. This is because the contents of a range are 2594 independent of the order of the range endpoints. Thus, any UID 2595 range with * as one of the endpoints indicates at least one 2596 message (the message with the highest numbered UID), unless the 2597 mailbox is empty. 2599 The number after the "*" in an untagged FETCH response is always a 2600 message sequence number, not a unique identifier, even for a UID 2601 command response. However, server implementations MUST implicitly 2602 include the UID message data item as part of any FETCH response 2603 caused by a UID command, regardless of whether a UID was specified as 2604 a message data item to the FETCH. 2606 Note: The rule about including the UID message data item as part of a 2607 FETCH response primarily applies to the UID FETCH and UID STORE 2608 commands, including a UID FETCH command that does not include UID as 2609 a message data item. Although it is unlikely that the other UID 2610 commands will cause an untagged FETCH, this rule applies to these 2611 commands as well. 2613 Example: C: A999 UID FETCH 4827313:4828442 FLAGS 2614 S: * 23 FETCH (FLAGS (\Seen) UID 4827313) 2615 S: * 24 FETCH (FLAGS (\Seen) UID 4827943) 2616 S: * 25 FETCH (FLAGS (\Seen) UID 4828442) 2617 S: A999 OK UID FETCH completed 2619 6.5. Client Commands - Experimental/Expansion 2621 6.5.1. X Command 2623 Arguments: implementation defined 2625 Responses: implementation defined 2627 Result: OK - command completed 2628 NO - failure 2629 BAD - command unknown or arguments invalid 2631 Any command prefixed with an X is an experimental command. Commands 2632 which are not part of this specification, a standard or standards- 2633 track revision of this specification, or an IESG-approved 2634 experimental protocol, MUST use the X prefix. 2636 Any added untagged responses issued by an experimental command MUST 2637 also be prefixed with an X. Server implementations MUST NOT send any 2638 such untagged responses, unless the client requested it by issuing 2639 the associated experimental command. 2641 Example: C: a441 CAPABILITY 2642 S: * CAPABILITY IMAP4rev1 XPIG-LATIN 2643 S: a441 OK CAPABILITY completed 2644 C: A442 XPIG-LATIN 2645 S: * XPIG-LATIN ow-nay eaking-spay ig-pay atin-lay 2646 S: A442 OK XPIG-LATIN ompleted-cay 2648 7. Server Responses 2650 Server responses are in three forms: status responses, server data, 2651 and command continuation request. The information contained in a 2652 server response, identified by "Contents:" in the response 2653 descriptions below, is described by function, not by syntax. The 2654 precise syntax of server responses is described in the Formal Syntax 2655 section. 2657 The client MUST be prepared to accept any response at all times. 2659 Status responses can be tagged or untagged. Tagged status responses 2660 indicate the completion result (OK, NO, or BAD status) of a client 2661 command, and have a tag matching the command. 2663 Some status responses, and all server data, are untagged. An 2664 untagged response is indicated by the token "*" instead of a tag. 2665 Untagged status responses indicate server greeting, or server status 2666 that does not indicate the completion of a command (for example, an 2667 impending system shutdown alert). For historical reasons, untagged 2668 server data responses are also called "unsolicited data", although 2669 strictly speaking, only unilateral server data is truly 2670 "unsolicited". 2672 Certain server data MUST be recorded by the client when it is 2673 received; this is noted in the description of that data. Such data 2674 conveys critical information which affects the interpretation of all 2675 subsequent commands and responses (e.g., updates reflecting the 2676 creation or destruction of messages). 2678 Other server data SHOULD be recorded for later reference; if the 2679 client does not need to record the data, or if recording the data has 2680 no obvious purpose (e.g., a SEARCH response when no SEARCH command is 2681 in progress), the data SHOULD be ignored. 2683 An example of unilateral untagged server data occurs when the IMAP 2684 connection is in the selected state. In the selected state, the 2685 server checks the mailbox for new messages as part of command 2686 execution. Normally, this is part of the execution of every command; 2687 hence, a NOOP command suffices to check for new messages. If new 2688 messages are found, the server sends untagged EXISTS and RECENT 2689 responses reflecting the new size of the mailbox. Server 2690 implementations that offer multiple simultaneous access to the same 2691 mailbox SHOULD also send appropriate unilateral untagged FETCH and 2692 EXPUNGE responses if another agent changes the state of any message 2693 flags or expunges any messages. 2695 Command continuation request responses use the token "+" instead of a 2696 tag. These responses are sent by the server to indicate acceptance 2697 of an incomplete client command and readiness for the remainder of 2698 the command. 2700 7.1. Server Responses - Status Responses 2702 Status responses are OK, NO, BAD, PREAUTH and BYE. OK, NO, and BAD 2703 can be tagged or untagged. PREAUTH and BYE are always untagged. 2705 Status responses MAY include an OPTIONAL "response code". A response 2706 code consists of data inside square brackets in the form of an atom, 2707 possibly followed by a space and arguments. The response code 2708 contains additional information or status codes for client software 2709 beyond the OK/NO/BAD condition, and are defined when there is a 2710 specific action that a client can take based upon the additional 2711 information. 2713 The currently defined response codes are: 2715 ALERT The human-readable text contains a special alert that MUST be 2716 presented to the user in a fashion that calls the user's attention 2717 to the message. 2719 BADCHARSET Optionally followed by a parenthesized list of charsets. 2720 A SEARCH failed because the given charset is not supported by this 2721 implementation. If the optional list of charsets is given, this 2722 lists the charsets that are supported by this implementation. 2724 CAPABILITY Followed by a list of capabilities. This can appear in 2725 the initial OK or PREAUTH response to transmit an initial 2726 capabilities list. This makes it unnecessary for a client to send 2727 a separate CAPABILITY command if it recognizes this response. 2729 PARSE The human-readable text represents an error in parsing the 2730 [RFC-5322] header or [MIME-IMB] headers of a message in the 2731 mailbox. 2733 PERMANENTFLAGS Followed by a parenthesized list of flags, indicates 2734 which of the known flags the client can change permanently. Any 2735 flags that are in the FLAGS untagged response, but not the 2736 PERMANENTFLAGS list, can not be set permanently. If the client 2737 attempts to STORE a flag that is not in the PERMANENTFLAGS list, 2738 the server will either ignore the change or store the state change 2739 for the remainder of the current session only. The PERMANENTFLAGS 2740 list can also include the special flag \*, which indicates that it 2741 is possible to create new keywords by attempting to store those 2742 flags in the mailbox. 2744 READ-ONLY The mailbox is selected read-only, or its access while 2745 selected has changed from read-write to read-only. 2747 READ-WRITE The mailbox is selected read-write, or its access while 2748 selected has changed from read-only to read-write. 2750 TRYCREATE An APPEND or COPY attempt is failing because the target 2751 mailbox does not exist (as opposed to some other reason). This is 2752 a hint to the client that the operation can succeed if the mailbox 2753 is first created by the CREATE command. 2755 UIDNEXT Followed by a decimal number, indicates the next unique 2756 identifier value. Refer to Section 2.3.1.1 for more information. 2758 UIDVALIDITY Followed by a decimal number, indicates the unique 2759 identifier validity value. Refer to Section 2.3.1.1 for more 2760 information. 2762 UNSEEN Followed by a decimal number, indicates the number of the 2763 first message without the \Seen flag set. 2765 Additional response codes defined by particular client or server 2766 implementations SHOULD be prefixed with an "X" until they are added 2767 to a revision of this protocol. Client implementations SHOULD ignore 2768 response codes that they do not recognize. 2770 7.1.1. OK Response 2772 Contents: OPTIONAL response code 2773 human-readable text 2775 The OK response indicates an information message from the server. 2776 When tagged, it indicates successful completion of the associated 2777 command. The human-readable text MAY be presented to the user as an 2778 information message. The untagged form indicates an information-only 2779 message; the nature of the information MAY be indicated by a response 2780 code. 2782 The untagged form is also used as one of three possible greetings at 2783 connection startup. It indicates that the connection is not yet 2784 authenticated and that a LOGIN command is needed. 2786 Example: S: * OK IMAP4rev1 server ready 2787 C: A001 LOGIN fred blurdybloop 2788 S: * OK [ALERT] System shutdown in 10 minutes 2789 S: A001 OK LOGIN Completed 2791 7.1.2. NO Response 2793 Contents: OPTIONAL response code 2794 human-readable text 2796 The NO response indicates an operational error message from the 2797 server. When tagged, it indicates unsuccessful completion of the 2798 associated command. The untagged form indicates a warning; the 2799 command can still complete successfully. The human-readable text 2800 describes the condition. 2802 Example: C: A222 COPY 1:2 owatagusiam 2803 S: * NO Disk is 98% full, please delete unnecessary data 2804 S: A222 OK COPY completed 2805 C: A223 COPY 3:200 blurdybloop 2806 S: * NO Disk is 98% full, please delete unnecessary data 2807 S: * NO Disk is 99% full, please delete unnecessary data 2808 S: A223 NO COPY failed: disk is full 2810 7.1.3. BAD Response 2812 Contents: OPTIONAL response code 2813 human-readable text 2815 The BAD response indicates an error message from the server. When 2816 tagged, it reports a protocol-level error in the client's command; 2817 the tag indicates the command that caused the error. The untagged 2818 form indicates a protocol-level error for which the associated 2819 command can not be determined; it can also indicate an internal 2820 server failure. The human-readable text describes the condition. 2822 Example: C: ...very long command line... 2823 S: * BAD Command line too long 2824 C: ...empty line... 2825 S: * BAD Empty command line 2826 C: A443 EXPUNGE 2827 S: * BAD Disk crash, attempting salvage to a new disk! 2828 S: * OK Salvage successful, no data lost 2829 S: A443 OK Expunge completed 2831 7.1.4. PREAUTH Response 2833 Contents: OPTIONAL response code 2834 human-readable text 2836 The PREAUTH response is always untagged, and is one of three possible 2837 greetings at connection startup. It indicates that the connection 2838 has already been authenticated by external means; thus no LOGIN 2839 command is needed. 2841 Example: S: * PREAUTH IMAP4rev1 server logged in as Smith 2843 7.1.5. BYE Response 2845 Contents: OPTIONAL response code 2846 human-readable text 2848 The BYE response is always untagged, and indicates that the server is 2849 about to close the connection. The human-readable text MAY be 2850 displayed to the user in a status report by the client. The BYE 2851 response is sent under one of four conditions: 2853 1. as part of a normal logout sequence. The server will close the 2854 connection after sending the tagged OK response to the LOGOUT 2855 command. 2857 2. as a panic shutdown announcement. The server closes the 2858 connection immediately. 2860 3. as an announcement of an inactivity autologout. The server 2861 closes the connection immediately. 2863 4. as one of three possible greetings at connection startup, 2864 indicating that the server is not willing to accept a connection 2865 from this client. The server closes the connection immediately. 2867 The difference between a BYE that occurs as part of a normal LOGOUT 2868 sequence (the first case) and a BYE that occurs because of a failure 2869 (the other three cases) is that the connection closes immediately in 2870 the failure case. In all cases the client SHOULD continue to read 2871 response data from the server until the connection is closed; this 2872 will ensure that any pending untagged or completion responses are 2873 read and processed. 2875 Example: S: * BYE Autologout; idle for too long 2877 7.2. Server Responses - Server and Mailbox Status 2879 These responses are always untagged. This is how server and mailbox 2880 status data are transmitted from the server to the client. Many of 2881 these responses typically result from a command with the same name. 2883 7.2.1. CAPABILITY Response 2885 Contents: capability listing 2887 The CAPABILITY response occurs as a result of a CAPABILITY command. 2888 The capability listing contains a space-separated listing of 2889 capability names that the server supports. The capability listing 2890 MUST include the atom "IMAP4rev1". 2892 In addition, client and server implementations MUST implement the 2893 STARTTLS, LOGINDISABLED, and AUTH=PLAIN (described in [PLAIN]) 2894 capabilities. See the Security Considerations section for important 2895 information. 2897 A capability name which begins with "AUTH=" indicates that the server 2898 supports that particular authentication mechanism. 2900 The LOGINDISABLED capability indicates that the LOGIN command is 2901 disabled, and that the server will respond with a tagged NO response 2902 to any attempt to use the LOGIN command even if the user name and 2903 password are valid. An IMAP client MUST NOT issue the LOGIN command 2904 if the server advertises the LOGINDISABLED capability. 2906 Other capability names indicate that the server supports an 2907 extension, revision, or amendment to the IMAP4rev1 protocol. Server 2908 responses MUST conform to this document until the client issues a 2909 command that uses the associated capability. 2911 Capability names MUST either begin with "X" or be standard or 2912 standards-track IMAP4rev1 extensions, revisions, or amendments 2913 registered with IANA. A server MUST NOT offer unregistered or non- 2914 standard capability names, unless such names are prefixed with an 2915 "X". 2917 Client implementations SHOULD NOT require any capability name other 2918 than "IMAP4rev1", and MUST ignore any unknown capability names. 2920 A server MAY send capabilities automatically, by using the CAPABILITY 2921 response code in the initial PREAUTH or OK responses, and by sending 2922 an updated CAPABILITY response code in the tagged OK response as part 2923 of a successful authentication. It is unnecessary for a client to 2924 send a separate CAPABILITY command if it recognizes these automatic 2925 capabilities. 2927 Example: S: * CAPABILITY IMAP4rev1 STARTTLS AUTH=GSSAPI XPIG-LATIN 2929 7.2.2. LIST Response 2931 Contents: name attributes 2932 hierarchy delimiter 2933 name 2935 The LIST response occurs as a result of a LIST command. It returns a 2936 single name that matches the LIST specification. There can be 2937 multiple LIST responses for a single LIST command. 2939 Four name attributes are defined: 2941 \Noinferiors It is not possible for any child levels of hierarchy to 2942 exist under this name; no child levels exist now and none can be 2943 created in the future. 2945 \Noselect It is not possible to use this name as a selectable 2946 mailbox. 2948 \Marked The mailbox has been marked "interesting" by the server; the 2949 mailbox probably contains messages that have been added since the 2950 last time the mailbox was selected. 2952 \Unmarked The mailbox does not contain any additional messages since 2953 the last time the mailbox was selected. 2955 If it is not feasible for the server to determine whether or not the 2956 mailbox is "interesting", the server SHOULD NOT send either \Marked 2957 or \Unmarked. The server MUST NOT send more than one of \Marked, 2958 \Unmarked, and \Noselect for a single mailbox, and MAY send none of 2959 these. 2961 The hierarchy delimiter is a character used to delimit levels of 2962 hierarchy in a mailbox name. A client can use it to create child 2963 mailboxes, and to search higher or lower levels of naming hierarchy. 2964 All children of a top-level hierarchy node MUST use the same 2965 separator character. A NIL hierarchy delimiter means that no 2966 hierarchy exists; the name is a "flat" name. 2968 The name represents an unambiguous left-to-right hierarchy, and MUST 2969 be valid for use as a reference in LIST and LSUB commands. Unless 2970 \Noselect is indicated, the name MUST also be valid as an argument 2971 for commands, such as SELECT, that accept mailbox names. 2973 Example: S: * LIST (\Noselect) "/" ~/Mail/foo 2975 7.2.3. LSUB Response 2977 Contents: name attributes 2978 hierarchy delimiter 2979 name 2981 The LSUB response occurs as a result of an LSUB command. It returns 2982 a single name that matches the LSUB specification. There can be 2983 multiple LSUB responses for a single LSUB command. The data is 2984 identical in format to the LIST response. 2986 Example: S: * LSUB () "." #news.comp.mail.misc 2988 7.2.4. STATUS Response 2990 Contents: name 2991 status parenthesized list 2993 The STATUS response occurs as a result of an STATUS command. It 2994 returns the mailbox name that matches the STATUS specification and 2995 the requested mailbox status information. 2997 Example: S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) 2999 7.2.5. SEARCH Response 3001 Contents: zero or more numbers 3003 The SEARCH response occurs as a result of a SEARCH or UID SEARCH 3004 command. The number(s) refer to those messages that match the search 3005 criteria. For SEARCH, these are message sequence numbers; for UID 3006 SEARCH, these are unique identifiers. Each number is delimited by a 3007 space. 3009 Example: S: * SEARCH 2 3 6 3011 7.2.6. FLAGS Response 3013 Contents: flag parenthesized list 3015 The FLAGS response occurs as a result of a SELECT or EXAMINE command. 3016 The flag parenthesized list identifies the flags (at a minimum, the 3017 system-defined flags) that are applicable for this mailbox. Flags 3018 other than the system flags can also exist, depending on server 3019 implementation. 3021 The update from the FLAGS response MUST be recorded by the client. 3023 Example: S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 3025 7.3. Server Responses - Mailbox Size 3027 These responses are always untagged. This is how changes in the size 3028 of the mailbox are transmitted from the server to the client. 3029 Immediately following the "*" token is a number that represents a 3030 message count. 3032 7.3.1. EXISTS Response 3034 Contents: none 3036 The EXISTS response reports the number of messages in the mailbox. 3037 This response occurs as a result of a SELECT or EXAMINE command, and 3038 if the size of the mailbox changes (e.g., new messages). 3040 The update from the EXISTS response MUST be recorded by the client. 3042 Example: S: * 23 EXISTS 3044 7.3.2. RECENT Response 3046 Contents: none 3048 The RECENT response reports the number of messages with the \Recent 3049 flag set. This response occurs as a result of a SELECT or EXAMINE 3050 command, and if the size of the mailbox changes (e.g., new messages). 3052 Note: It is not guaranteed that the message sequence numbers of 3053 recent messages will be a contiguous range of the highest n 3054 messages in the mailbox (where n is the value reported by the 3055 RECENT response). Examples of situations in which this is not the 3056 case are: multiple clients having the same mailbox open (the first 3057 session to be notified will see it as recent, others will probably 3058 see it as non-recent), and when the mailbox is re-ordered by a 3059 non-IMAP agent. 3061 The only reliable way to identify recent messages is to look at 3062 message flags to see which have the \Recent flag set, or to do a 3063 SEARCH RECENT. 3065 The update from the RECENT response MUST be recorded by the client. 3067 Example: S: * 5 RECENT 3069 7.4. Server Responses - Message Status 3071 These responses are always untagged. This is how message data are 3072 transmitted from the server to the client, often as a result of a 3073 command with the same name. Immediately following the "*" token is a 3074 number that represents a message sequence number. 3076 7.4.1. EXPUNGE Response 3078 Contents: none 3080 The EXPUNGE response reports that the specified message sequence 3081 number has been permanently removed from the mailbox. The message 3082 sequence number for each successive message in the mailbox is 3083 immediately decremented by 1, and this decrement is reflected in 3084 message sequence numbers in subsequent responses (including other 3085 untagged EXPUNGE responses). 3087 The EXPUNGE response also decrements the number of messages in the 3088 mailbox; it is not necessary to send an EXISTS response with the new 3089 value. 3091 As a result of the immediate decrement rule, message sequence numbers 3092 that appear in a set of successive EXPUNGE responses depend upon 3093 whether the messages are removed starting from lower numbers to 3094 higher numbers, or from higher numbers to lower numbers. For 3095 example, if the last 5 messages in a 9-message mailbox are expunged, 3096 a "lower to higher" server will send five untagged EXPUNGE responses 3097 for message sequence number 5, whereas a "higher to lower server" 3098 will send successive untagged EXPUNGE responses for message sequence 3099 numbers 9, 8, 7, 6, and 5. 3101 An EXPUNGE response MUST NOT be sent when no command is in progress, 3102 nor while responding to a FETCH, STORE, or SEARCH command. This rule 3103 is necessary to prevent a loss of synchronization of message sequence 3104 numbers between client and server. A command is not "in progress" 3105 until the complete command has been received; in particular, a 3106 command is not "in progress" during the negotiation of command 3107 continuation. 3109 Note: UID FETCH, UID STORE, and UID SEARCH are different commands 3110 from FETCH, STORE, and SEARCH. An EXPUNGE response MAY be sent 3111 during a UID command. 3113 The update from the EXPUNGE response MUST be recorded by the client. 3115 Example: S: * 44 EXPUNGE 3117 7.4.2. FETCH Response 3119 Contents: message data 3121 The FETCH response returns data about a message to the client. The 3122 data are pairs of data item names and their values in parentheses. 3123 This response occurs as the result of a FETCH or STORE command, as 3124 well as by unilateral server decision (e.g., flag updates). 3126 The current data items are: 3128 BODY A form of BODYSTRUCTURE without extension data. 3130 BODY[
]<> 3132 A string expressing the body contents of the specified section. 3133 The string SHOULD be interpreted by the client according to the 3134 content transfer encoding, body type, and subtype. 3136 If the origin octet is specified, this string is a substring of 3137 the entire body contents, starting at that origin octet. This 3138 means that BODY[]<0> MAY be truncated, but BODY[] is NEVER 3139 truncated. 3141 Note: The origin octet facility MUST NOT be used by a server 3142 in a FETCH response unless the client specifically requested 3143 it by means of a FETCH of a BODY[
]<> data 3144 item. 3146 8-bit textual data is permitted if a [CHARSET] identifier is 3147 part of the body parameter parenthesized list for this section. 3148 Note that headers (part specifiers HEADER or MIME, or the 3149 header portion of a MESSAGE/RFC822 part), MUST be 7-bit; 8-bit 3150 characters are not permitted in headers. Note also that the 3151 [RFC-5322] delimiting blank line between the header and the 3152 body is not affected by header line subsetting; the blank line 3153 is always included as part of header data, except in the case 3154 of a message which has no body and no blank line. 3156 Non-textual data such as binary data MUST be transfer encoded 3157 into a textual form, such as BASE64, prior to being sent to the 3158 client. To derive the original binary data, the client MUST 3159 decode the transfer encoded string. 3161 BODYSTRUCTURE 3163 A parenthesized list that describes the [MIME-IMB] body 3164 structure of a message. This is computed by the server by 3165 parsing the [MIME-IMB] header fields, defaulting various fields 3166 as necessary. 3168 For example, a simple text message of 48 lines and 2279 octets 3169 can have a body structure of: ("TEXT" "PLAIN" ("CHARSET" "US- 3170 ASCII") NIL NIL "7BIT" 2279 48) 3172 Multiple parts are indicated by parenthesis nesting. Instead 3173 of a body type as the first element of the parenthesized list, 3174 there is a sequence of one or more nested body structures. The 3175 second element of the parenthesized list is the multipart 3176 subtype (mixed, digest, parallel, alternative, etc.). 3178 For example, a two part message consisting of a text and a 3179 BASE64-encoded text attachment can have a body structure of: 3180 (("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 1152 3181 23)("TEXT" "PLAIN" ("CHARSET" "US-ASCII" "NAME" "cc.diff") 3182 "<960723163407.20117h@cac.washington.edu>" "Compiler diff" 3183 "BASE64" 4554 73) "MIXED") 3185 Extension data follows the multipart subtype. Extension data 3186 is never returned with the BODY fetch, but can be returned with 3187 a BODYSTRUCTURE fetch. Extension data, if present, MUST be in 3188 the defined order. The extension data of a multipart body part 3189 are in the following order: 3191 body parameter parenthesized list A parenthesized list of 3192 attribute/value pairs [e.g., ("foo" "bar" "baz" "rag") where 3193 "bar" is the value of "foo", and "rag" is the value of 3194 "baz"] as defined in [MIME-IMB]. 3196 body disposition A parenthesized list, consisting of a 3197 disposition type string, followed by a parenthesized list of 3198 disposition attribute/value pairs as defined in 3199 [DISPOSITION]. 3201 body language A string or parenthesized list giving the body 3202 language value as defined in [LANGUAGE-TAGS]. 3204 body location A string giving the body content URI as defined 3205 in [LOCATION]. 3207 Any following extension data are not yet defined in this 3208 version of the protocol. Such extension data can consist of 3209 zero or more NILs, strings, numbers, or potentially nested 3210 parenthesized lists of such data. Client implementations that 3211 do a BODYSTRUCTURE fetch MUST be prepared to accept such 3212 extension data. Server implementations MUST NOT send such 3213 extension data until it has been defined by a revision of this 3214 protocol. 3216 The basic fields of a non-multipart body part are in the 3217 following order: 3219 body type A string giving the content media type name as 3220 defined in [MIME-IMB]. 3222 body subtype A string giving the content subtype name as 3223 defined in [MIME-IMB]. 3225 body parameter parenthesized list A parenthesized list of 3226 attribute/value pairs [e.g., ("foo" "bar" "baz" "rag") where 3227 "bar" is the value of "foo" and "rag" is the value of "baz"] 3228 as defined in [MIME-IMB]. 3230 body id A string giving the content id as defined in 3231 [MIME-IMB]. 3233 body description A string giving the content description as 3234 defined in [MIME-IMB]. 3236 body encoding A string giving the content transfer encoding as 3237 defined in [MIME-IMB]. 3239 body size A number giving the size of the body in octets. 3240 Note that this size is the size in its transfer encoding and 3241 not the resulting size after any decoding. 3243 A body type of type MESSAGE and subtype RFC822 contains, 3244 immediately after the basic fields, the envelope structure, 3245 body structure, and size in text lines of the encapsulated 3246 message. 3248 A body type of type TEXT contains, immediately after the basic 3249 fields, the size of the body in text lines. Note that this 3250 size is the size in its content transfer encoding and not the 3251 resulting size after any decoding. 3253 Extension data follows the basic fields and the type-specific 3254 fields listed above. Extension data is never returned with the 3255 BODY fetch, but can be returned with a BODYSTRUCTURE fetch. 3256 Extension data, if present, MUST be in the defined order. 3258 The extension data of a non-multipart body part are in the 3259 following order: 3261 body MD5 A string giving the body MD5 value as defined in 3262 [MD5]. 3264 body disposition A parenthesized list with the same content 3265 and function as the body disposition for a multipart body 3266 part. 3268 body language A string or parenthesized list giving the body 3269 language value as defined in [LANGUAGE-TAGS]. 3271 body location A string giving the body content URI as defined 3272 in [LOCATION]. 3274 Any following extension data are not yet defined in this 3275 version of the protocol, and would be as described above under 3276 multipart extension data. 3278 ENVELOPE 3280 A parenthesized list that describes the envelope structure of a 3281 message. This is computed by the server by parsing the 3282 [RFC-5322] header into the component parts, defaulting various 3283 fields as necessary. 3285 The fields of the envelope structure are in the following 3286 order: date, subject, from, sender, reply-to, to, cc, bcc, in- 3287 reply-to, and message-id. The date, subject, in-reply-to, and 3288 message-id fields are strings. The from, sender, reply-to, to, 3289 cc, and bcc fields are parenthesized lists of address 3290 structures. 3292 An address structure is a parenthesized list that describes an 3293 electronic mail address. The fields of an address structure 3294 are in the following order: personal name, [SMTP] at-domain- 3295 list (source route), mailbox name, and host name. 3297 [RFC-5322] group syntax is indicated by a special form of 3298 address structure in which the host name field is NIL. If the 3299 mailbox name field is also NIL, this is an end of group marker 3300 (semi-colon in RFC 822 syntax). If the mailbox name field is 3301 non-NIL, this is a start of group marker, and the mailbox name 3302 field holds the group name phrase. 3304 If the Date, Subject, In-Reply-To, and Message-ID header lines 3305 are absent in the [RFC-5322] header, the corresponding member 3306 of the envelope is NIL; if these header lines are present but 3307 empty the corresponding member of the envelope is the empty 3308 string. 3310 Note: some servers may return a NIL envelope member in the 3311 "present but empty" case. Clients SHOULD treat NIL and 3312 empty string as identical. 3314 Note: [RFC-5322] requires that all messages have a valid 3315 Date header. Therefore, the date member in the envelope can 3316 not be NIL or the empty string. 3318 Note: [RFC-5322] requires that the In-Reply-To and Message- 3319 ID headers, if present, have non-empty content. Therefore, 3320 the in-reply-to and message-id members in the envelope can 3321 not be the empty string. 3323 If the From, To, Cc, and Bcc header lines are absent in the 3324 [RFC-5322] header, or are present but empty, the corresponding 3325 member of the envelope is NIL. 3327 If the Sender or Reply-To lines are absent in the [RFC-5322] 3328 header, or are present but empty, the server sets the 3329 corresponding member of the envelope to be the same value as 3330 the from member (the client is not expected to know to do 3331 this). 3333 Note: [RFC-5322] requires that all messages have a valid 3334 From header. Therefore, the from, sender, and reply-to 3335 members in the envelope can not be NIL. 3337 FLAGS A parenthesized list of flags that are set for this message. 3339 INTERNALDATE A string representing the internal date of the message. 3341 RFC822 Equivalent to BODY[]. 3343 RFC822.HEADER Equivalent to BODY[HEADER]. Note that this did not 3344 result in \Seen being set, because RFC822.HEADER response data 3345 occurs as a result of a FETCH of RFC822.HEADER. BODY[HEADER] 3346 response data occurs as a result of a FETCH of BODY[HEADER] (which 3347 sets \Seen) or BODY.PEEK[HEADER] (which does not set \Seen). 3349 RFC822.SIZE A number expressing the [RFC-5322] size of the message. 3351 RFC822.TEXT Equivalent to BODY[TEXT]. 3353 UID A number expressing the unique identifier of the message. 3355 Example: S: * 23 FETCH (FLAGS (\Seen) RFC822.SIZE 44827) 3357 7.5. Server Responses - Command Continuation Request 3359 The command continuation request response is indicated by a "+" token 3360 instead of a tag. This form of response indicates that the server is 3361 ready to accept the continuation of a command from the client. The 3362 remainder of this response is a line of text. 3364 This response is used in the AUTHENTICATE command to transmit server 3365 data to the client, and request additional client data. This 3366 response is also used if an argument to any command is a literal. 3368 The client is not permitted to send the octets of the literal unless 3369 the server indicates that it is expected. This permits the server to 3370 process commands and reject errors on a line-by-line basis. The 3371 remainder of the command, including the CRLF that terminates a 3372 command, follows the octets of the literal. If there are any 3373 additional command arguments, the literal octets are followed by a 3374 space and those arguments. 3376 Example: C: A001 LOGIN {11} 3377 S: + Ready for additional command text 3378 C: FRED FOOBAR {7} 3379 S: + Ready for additional command text 3380 C: fat man 3381 S: A001 OK LOGIN completed 3382 C: A044 BLURDYBLOOP {102856} 3383 S: A044 BAD No such command as "BLURDYBLOOP" 3385 8. Sample IMAP4rev1 connection 3387 The following is a transcript of an IMAP4rev1 connection. A long 3388 line in this sample is broken for editorial clarity. 3390 S: * OK IMAP4rev1 Service Ready 3391 C: a001 login mrc secret 3392 S: a001 OK LOGIN completed 3393 C: a002 select inbox 3394 S: * 18 EXISTS 3395 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 3396 S: * 2 RECENT 3397 S: * OK [UNSEEN 17] Message 17 is the first unseen message 3398 S: * OK [UIDVALIDITY 3857529045] UIDs valid 3399 S: a002 OK [READ-WRITE] SELECT completed 3400 C: a003 fetch 12 full 3401 S: * 12 FETCH (FLAGS (\Seen) INTERNALDATE "17-Jul-1996 02:44:25 -0700" 3402 RFC822.SIZE 4286 ENVELOPE ("Wed, 17 Jul 1996 02:23:25 -0700 (PDT)" 3403 "IMAP4rev1 WG mtg summary and minutes" 3404 (("Terry Gray" NIL "gray" "cac.washington.edu")) 3405 (("Terry Gray" NIL "gray" "cac.washington.edu")) 3406 (("Terry Gray" NIL "gray" "cac.washington.edu")) 3407 ((NIL NIL "imap" "cac.washington.edu")) 3408 ((NIL NIL "minutes" "CNRI.Reston.VA.US") 3409 ("John Klensin" NIL "KLENSIN" "MIT.EDU")) NIL NIL 3410 "") 3411 BODY ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 3028 3412 92)) 3413 S: a003 OK FETCH completed 3414 C: a004 fetch 12 body[header] 3415 S: * 12 FETCH (BODY[HEADER] {342} 3416 S: Date: Wed, 17 Jul 1996 02:23:25 -0700 (PDT) 3417 S: From: Terry Gray 3418 S: Subject: IMAP4rev1 WG mtg summary and minutes 3419 S: To: imap@cac.washington.edu 3420 S: cc: minutes@CNRI.Reston.VA.US, John Klensin 3421 S: Message-Id: 3422 S: MIME-Version: 1.0 3423 S: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 3424 S: 3425 S: ) 3426 S: a004 OK FETCH completed 3427 C: a005 store 12 +flags \deleted 3428 S: * 12 FETCH (FLAGS (\Seen \Deleted)) 3429 S: a005 OK +FLAGS completed 3430 C: a006 logout 3431 S: * BYE IMAP4rev1 server terminating connection 3432 S: a006 OK LOGOUT completed 3433 9. Formal Syntax 3435 The following syntax specification uses the Augmented Backus-Naur 3436 Form (ABNF) notation as specified in [ABNF]. 3438 In the case of alternative or optional rules in which a later rule 3439 overlaps an earlier rule, the rule which is listed earlier MUST take 3440 priority. For example, "\Seen" when parsed as a flag is the \Seen 3441 flag name and not a flag-extension, even though "\Seen" can be parsed 3442 as a flag-extension. Some, but not all, instances of this rule are 3443 noted below. 3445 Note: [ABNF] rules MUST be followed strictly; in particular: 3447 (1) Except as noted otherwise, all alphabetic characters are case- 3448 insensitive. The use of upper or lower case characters to define 3449 token strings is for editorial clarity only. Implementations MUST 3450 accept these strings in a case-insensitive fashion. 3452 (2) In all cases, SP refers to exactly one space. It is NOT 3453 permitted to substitute TAB, insert additional spaces, or 3454 otherwise treat SP as being equivalent to LWSP. 3456 (3) The ASCII NUL character, %x00, MUST NOT be used at any time. 3458 address = "(" addr-name SP addr-adl SP addr-mailbox SP 3459 addr-host ")" 3461 addr-adl = nstring 3462 ; Holds route from [RFC-5322] route-addr if 3463 ; non-NIL 3465 addr-host = nstring 3466 ; NIL indicates [RFC-5322] group syntax. 3467 ; Otherwise, holds [RFC-5322] domain name 3469 addr-mailbox = nstring 3470 ; NIL indicates end of [RFC-5322] group; if 3471 ; non-NIL and addr-host is NIL, holds 3472 ; [RFC-5322] group name. 3473 ; Otherwise, holds [RFC-5322] local-part 3474 ; after removing [RFC-5322] quoting 3476 addr-name = nstring 3477 ; If non-NIL, holds phrase from [RFC-5322] 3478 ; mailbox after removing [RFC-5322] quoting 3480 append = "APPEND" SP mailbox [SP flag-list] [SP date-time] SP 3481 literal 3483 astring = 1*ASTRING-CHAR / string 3485 ASTRING-CHAR = ATOM-CHAR / resp-specials 3487 atom = 1*ATOM-CHAR 3489 ATOM-CHAR = 3491 atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards / 3492 quoted-specials / resp-specials 3494 authenticate = "AUTHENTICATE" SP auth-type *(CRLF base64) 3496 auth-type = atom 3497 ; Defined by [SASL] 3499 base64 = *(4base64-char) [base64-terminal] 3501 base64-char = ALPHA / DIGIT / "+" / "/" 3502 ; Case-sensitive 3504 base64-terminal = (2base64-char "==") / (3base64-char "=") 3506 body = "(" (body-type-1part / body-type-mpart) ")" 3508 body-extension = nstring / number / 3509 "(" body-extension *(SP body-extension) ")" 3510 ; Future expansion. Client implementations 3511 ; MUST accept body-extension fields. Server 3512 ; implementations MUST NOT generate 3513 ; body-extension fields except as defined by 3514 ; future standard or standards-track 3515 ; revisions of this specification. 3517 body-ext-1part = body-fld-md5 [SP body-fld-dsp [SP body-fld-lang 3518 [SP body-fld-loc *(SP body-extension)]]] 3519 ; MUST NOT be returned on non-extensible 3520 ; "BODY" fetch 3522 body-ext-mpart = body-fld-param [SP body-fld-dsp [SP body-fld-lang 3523 [SP body-fld-loc *(SP body-extension)]]] 3524 ; MUST NOT be returned on non-extensible 3525 ; "BODY" fetch 3527 body-fields = body-fld-param SP body-fld-id SP body-fld-desc SP 3528 body-fld-enc SP body-fld-octets 3530 body-fld-desc = nstring 3532 body-fld-dsp = "(" string SP body-fld-param ")" / nil 3534 body-fld-enc = (DQUOTE ("7BIT" / "8BIT" / "BINARY" / "BASE64"/ 3535 "QUOTED-PRINTABLE") DQUOTE) / string 3537 body-fld-id = nstring 3539 body-fld-lang = nstring / "(" string *(SP string) ")" 3541 body-fld-loc = nstring 3543 body-fld-lines = number 3545 body-fld-md5 = nstring 3547 body-fld-octets = number 3549 body-fld-param = "(" string SP string *(SP string SP string) ")" / nil 3551 body-type-1part = (body-type-basic / body-type-msg / body-type-text) 3552 [SP body-ext-1part] 3554 body-type-basic = media-basic SP body-fields 3555 ; MESSAGE subtype MUST NOT be "RFC822" 3557 body-type-mpart = 1*body SP media-subtype 3558 [SP body-ext-mpart] 3560 body-type-msg = media-message SP body-fields SP envelope 3561 SP body SP body-fld-lines 3563 body-type-text = media-text SP body-fields SP body-fld-lines 3565 capability = ("AUTH=" auth-type) / atom 3566 ; New capabilities MUST begin with "X" or be 3567 ; registered with IANA as standard or 3568 ; standards-track 3570 capability-data = "CAPABILITY" *(SP capability) SP "IMAP4rev1" 3571 *(SP capability) 3572 ; Servers MUST implement the STARTTLS, AUTH=PLAIN, 3573 ; and LOGINDISABLED capabilities 3574 ; Servers which offer RFC 1730 compatibility MUST 3575 ; list "IMAP4" as the first capability. 3577 CHAR8 = %x01-ff 3578 ; any OCTET except NUL, %x00 3580 charset = atom / quoted 3582 command = tag SP (command-any / command-auth / command-nonauth / 3583 command-select) CRLF 3584 ; Modal based on state 3586 command-any = "CAPABILITY" / "LOGOUT" / "NOOP" / x-command 3587 ; Valid in all states 3589 command-auth = append / create / delete / examine / list / lsub / 3590 rename / select / status / subscribe / unsubscribe 3591 ; Valid only in Authenticated or Selected state 3593 command-nonauth = login / authenticate / "STARTTLS" 3594 ; Valid only when in Not Authenticated state 3596 command-select = "CHECK" / "CLOSE" / "EXPUNGE" / copy / fetch / store / 3597 uid / search 3598 ; Valid only when in Selected state 3600 continue-req = "+" SP (resp-text / base64) CRLF 3602 copy = "COPY" SP sequence-set SP mailbox 3604 create = "CREATE" SP mailbox 3605 ; Use of INBOX gives a NO error 3607 date = date-text / DQUOTE date-text DQUOTE 3609 date-day = 1*2DIGIT 3610 ; Day of month 3612 date-day-fixed = (SP DIGIT) / 2DIGIT 3613 ; Fixed-format version of date-day 3615 date-month = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / 3616 "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec" 3618 date-text = date-day "-" date-month "-" date-year 3620 date-year = 4DIGIT 3622 date-time = DQUOTE date-day-fixed "-" date-month "-" date-year 3623 SP time SP zone DQUOTE 3625 delete = "DELETE" SP mailbox 3626 ; Use of INBOX gives a NO error 3628 digit-nz = %x31-39 3629 ; 1-9 3631 envelope = "(" env-date SP env-subject SP env-from SP 3632 env-sender SP env-reply-to SP env-to SP env-cc SP 3633 env-bcc SP env-in-reply-to SP env-message-id ")" 3635 env-bcc = "(" 1*address ")" / nil 3637 env-cc = "(" 1*address ")" / nil 3639 env-date = nstring 3641 env-from = "(" 1*address ")" / nil 3643 env-in-reply-to = nstring 3645 env-message-id = nstring 3647 env-reply-to = "(" 1*address ")" / nil 3649 env-sender = "(" 1*address ")" / nil 3651 env-subject = nstring 3653 env-to = "(" 1*address ")" / nil 3655 examine = "EXAMINE" SP mailbox 3657 fetch = "FETCH" SP sequence-set SP ("ALL" / "FULL" / "FAST" / 3658 fetch-att / "(" fetch-att *(SP fetch-att) ")") 3660 fetch-att = "ENVELOPE" / "FLAGS" / "INTERNALDATE" / 3661 "RFC822" [".HEADER" / ".SIZE" / ".TEXT"] / 3662 "BODY" ["STRUCTURE"] / "UID" / 3663 "BODY" section ["<" number "." nz-number ">"] / 3664 "BODY.PEEK" section ["<" number "." nz-number ">"] 3666 flag = "\Answered" / "\Flagged" / "\Deleted" / 3667 "\Seen" / "\Draft" / flag-keyword / flag-extension 3668 ; Does not include "\Recent" 3670 flag-extension = "\" atom 3671 ; Future expansion. Client implementations 3672 ; MUST accept flag-extension flags. Server 3673 ; implementations MUST NOT generate 3674 ; flag-extension flags except as defined by 3675 ; future standard or standards-track 3676 ; revisions of this specification. 3678 flag-fetch = flag / "\Recent" 3680 flag-keyword = atom 3682 flag-list = "(" [flag *(SP flag)] ")" 3684 flag-perm = flag / "\*" 3686 greeting = "*" SP (resp-cond-auth / resp-cond-bye) CRLF 3688 header-fld-name = astring 3690 header-list = "(" header-fld-name *(SP header-fld-name) ")" 3692 list = "LIST" SP mailbox SP list-mailbox 3694 list-mailbox = 1*list-char / string 3696 list-char = ATOM-CHAR / list-wildcards / resp-specials 3698 list-wildcards = "%" / "*" 3700 literal = "{" number "}" CRLF *CHAR8 3701 ; Number represents the number of CHAR8s 3703 login = "LOGIN" SP userid SP password 3705 lsub = "LSUB" SP mailbox SP list-mailbox 3707 mailbox = "INBOX" / astring 3708 ; INBOX is case-insensitive. All case variants of 3709 ; INBOX (e.g., "iNbOx") MUST be interpreted as INBOX 3710 ; not as an astring. An astring which consists of 3711 ; the case-insensitive sequence "I" "N" "B" "O" "X" 3712 ; is considered to be INBOX and not an astring. 3713 ; Refer to section 5.1 for further 3714 ; semantic details of mailbox names. 3716 mailbox-data = "FLAGS" SP flag-list / "LIST" SP mailbox-list / 3717 "LSUB" SP mailbox-list / "SEARCH" *(SP nz-number) / 3718 "STATUS" SP mailbox SP "(" [status-att-list] ")" / 3719 number SP "EXISTS" / number SP "RECENT" 3721 mailbox-list = "(" [mbx-list-flags] ")" SP 3722 (DQUOTE QUOTED-CHAR DQUOTE / nil) SP mailbox 3724 mbx-list-flags = *(mbx-list-oflag SP) mbx-list-sflag 3725 *(SP mbx-list-oflag) / 3726 mbx-list-oflag *(SP mbx-list-oflag) 3728 mbx-list-oflag = "\Noinferiors" / flag-extension 3729 ; Other flags; multiple possible per LIST response 3731 mbx-list-sflag = "\Noselect" / "\Marked" / "\Unmarked" 3732 ; Selectability flags; only one per LIST response 3734 media-basic = ((DQUOTE ("APPLICATION" / "AUDIO" / "IMAGE" / 3735 "MESSAGE" / "VIDEO") DQUOTE) / string) SP 3736 media-subtype 3737 ; Defined in [MIME-IMT] 3739 media-message = DQUOTE "MESSAGE" DQUOTE SP DQUOTE "RFC822" DQUOTE 3740 ; Defined in [MIME-IMT] 3742 media-subtype = string 3743 ; Defined in [MIME-IMT] 3745 media-text = DQUOTE "TEXT" DQUOTE SP media-subtype 3746 ; Defined in [MIME-IMT] 3748 message-data = nz-number SP ("EXPUNGE" / ("FETCH" SP msg-att)) 3750 msg-att = "(" (msg-att-dynamic / msg-att-static) 3751 *(SP (msg-att-dynamic / msg-att-static)) ")" 3753 msg-att-dynamic = "FLAGS" SP "(" [flag-fetch *(SP flag-fetch)] ")" 3754 ; MAY change for a message 3756 msg-att-static = "ENVELOPE" SP envelope / "INTERNALDATE" SP date-time / 3757 "RFC822" [".HEADER" / ".TEXT"] SP nstring / 3758 "RFC822.SIZE" SP number / 3759 "BODY" ["STRUCTURE"] SP body / 3760 "BODY" section ["<" number ">"] SP nstring / 3761 "UID" SP uniqueid 3762 ; MUST NOT change for a message 3764 nil = "NIL" 3766 nstring = string / nil 3768 number = 1*DIGIT 3769 ; Unsigned 32-bit integer 3770 ; (0 <= n < 4,294,967,296) 3772 nz-number = digit-nz *DIGIT 3773 ; Non-zero unsigned 32-bit integer 3774 ; (0 < n < 4,294,967,296) 3776 password = astring 3778 quoted = DQUOTE *QUOTED-CHAR DQUOTE 3780 QUOTED-CHAR = / 3781 "\" quoted-specials 3783 quoted-specials = DQUOTE / "\" 3785 rename = "RENAME" SP mailbox SP mailbox 3786 ; Use of INBOX as a destination gives a NO error 3788 response = *(continue-req / response-data) response-done 3790 response-data = "*" SP (resp-cond-state / resp-cond-bye / 3791 mailbox-data / message-data / capability-data) CRLF 3793 response-done = response-tagged / response-fatal 3795 response-fatal = "*" SP resp-cond-bye CRLF 3796 ; Server closes connection immediately 3798 response-tagged = tag SP resp-cond-state CRLF 3800 resp-cond-auth = ("OK" / "PREAUTH") SP resp-text 3801 ; Authentication condition 3803 resp-cond-bye = "BYE" SP resp-text 3805 resp-cond-state = ("OK" / "NO" / "BAD") SP resp-text 3806 ; Status condition 3808 resp-specials = "]" 3810 resp-text = ["[" resp-text-code "]" SP] text 3812 resp-text-code = "ALERT" / 3813 "BADCHARSET" [SP "(" charset *(SP charset) ")" ] / 3814 capability-data / "PARSE" / 3815 "PERMANENTFLAGS" SP "(" 3816 [flag-perm *(SP flag-perm)] ")" / 3817 "READ-ONLY" / "READ-WRITE" / "TRYCREATE" / 3818 "UIDNEXT" SP nz-number / "UIDVALIDITY" SP nz-number / 3819 "UNSEEN" SP nz-number / 3820 atom [SP 1*] 3822 search = "SEARCH" [SP "CHARSET" SP charset] 1*(SP search-key) 3823 ; CHARSET argument to MUST be registered with IANA 3825 search-key = "ALL" / "ANSWERED" / "BCC" SP astring / 3826 "BEFORE" SP date / "BODY" SP astring / 3827 "CC" SP astring / "DELETED" / "FLAGGED" / 3828 "FROM" SP astring / "KEYWORD" SP flag-keyword / 3829 "NEW" / "OLD" / "ON" SP date / "RECENT" / "SEEN" / 3830 "SINCE" SP date / "SUBJECT" SP astring / 3831 "TEXT" SP astring / "TO" SP astring / 3832 "UNANSWERED" / "UNDELETED" / "UNFLAGGED" / 3833 "UNKEYWORD" SP flag-keyword / "UNSEEN" / 3834 ; Above this line were in [IMAP2] 3835 "DRAFT" / "HEADER" SP header-fld-name SP astring / 3836 "LARGER" SP number / "NOT" SP search-key / 3837 "OR" SP search-key SP search-key / 3838 "SENTBEFORE" SP date / "SENTON" SP date / 3839 "SENTSINCE" SP date / "SMALLER" SP number / 3840 "UID" SP sequence-set / "UNDRAFT" / sequence-set / 3841 "(" search-key *(SP search-key) ")" 3843 section = "[" [section-spec] "]" 3845 section-msgtext = "HEADER" / "HEADER.FIELDS" [".NOT"] SP header-list / 3846 "TEXT" 3847 ; top-level or MESSAGE/RFC822 part 3849 section-part = nz-number *("." nz-number) 3850 ; body part nesting 3852 section-spec = section-msgtext / (section-part ["." section-text]) 3854 section-text = section-msgtext / "MIME" 3855 ; text other than actual body part (headers, etc.) 3857 select = "SELECT" SP mailbox 3859 seq-number = nz-number / "*" 3860 ; message sequence number (COPY, FETCH, STORE 3861 ; commands) or unique identifier (UID COPY, 3862 ; UID FETCH, UID STORE commands). 3863 ; * represents the largest number in use. In 3864 ; the case of message sequence numbers, it is 3865 ; the number of messages in a non-empty mailbox. 3867 ; In the case of unique identifiers, it is the 3868 ; unique identifier of the last message in the 3869 ; mailbox or, if the mailbox is empty, the 3870 ; mailbox's current UIDNEXT value. 3871 ; The server should respond with a tagged BAD 3872 ; response to a command that uses a message 3873 ; sequence number greater than the number of 3874 ; messages in the selected mailbox. This 3875 ; includes "*" if the selected mailbox is empty. 3877 seq-range = seq-number ":" seq-number 3878 ; two seq-number values and all values between 3879 ; these two regardless of order. 3880 ; Example: 2:4 and 4:2 are equivalent and indicate 3881 ; values 2, 3, and 4. 3882 ; Example: a unique identifier sequence range of 3883 ; 3291:* includes the UID of the last message in 3884 ; the mailbox, even if that value is less than 3291. 3886 sequence-set = (seq-number / seq-range) ["," sequence-set] 3887 ; set of seq-number values, regardless of order. 3888 ; Servers MAY coalesce overlaps and/or execute the 3889 ; sequence in any order. 3890 ; Example: a message sequence number set of 3891 ; 2,4:7,9,12:* for a mailbox with 15 messages is 3892 ; equivalent to 2,4,5,6,7,9,12,13,14,15 3893 ; Example: a message sequence number set of *:4,5:7 3894 ; for a mailbox with 10 messages is equivalent to 3895 ; 10,9,8,7,6,5,4,5,6,7 and MAY be reordered and 3896 ; overlap coalesced to be 4,5,6,7,8,9,10. 3898 status = "STATUS" SP mailbox SP 3899 "(" status-att *(SP status-att) ")" 3901 status-att = "MESSAGES" / "RECENT" / "UIDNEXT" / "UIDVALIDITY" / 3902 "UNSEEN" 3904 status-att-val = ("MESSAGES" SP number) / ("RECENT" SP number) / 3905 ("UIDNEXT" SP nz-number) / ("UIDVALIDITY" SP nz-number) / 3906 ("UNSEEN" SP number) 3908 status-att-list = status-att-val *(SP status-att-val) 3910 store = "STORE" SP sequence-set SP store-att-flags 3912 store-att-flags = (["+" / "-"] "FLAGS" [".SILENT"]) SP 3913 (flag-list / (flag *(SP flag))) 3915 string = quoted / literal 3917 subscribe = "SUBSCRIBE" SP mailbox 3919 tag = 1* 3921 text = 1*TEXT-CHAR 3923 TEXT-CHAR = 3925 time = 2DIGIT ":" 2DIGIT ":" 2DIGIT 3926 ; Hours minutes seconds 3928 uid = "UID" SP (copy / fetch / search / store) 3929 ; Unique identifiers used instead of message 3930 ; sequence numbers 3932 uniqueid = nz-number 3933 ; Strictly ascending 3935 unsubscribe = "UNSUBSCRIBE" SP mailbox 3937 userid = astring 3939 x-command = "X" atom 3941 zone = ("+" / "-") 4DIGIT 3942 ; Signed four-digit value of hhmm representing 3943 ; hours and minutes east of Greenwich (that is, 3944 ; the amount that the given time differs from 3945 ; Universal Time). Subtracting the timezone 3946 ; from the given time will give the UT form. 3947 ; The Universal Time zone is "+0000". 3949 10. Author's Note 3951 This document is a revision or rewrite of earlier documents, and 3952 supercedes the protocol specification in those documents: RFC 2060, 3953 RFC 1730, unpublished IMAP2bis.TXT document, RFC 1176, and RFC 1064. 3955 11. Security Considerations 3957 IMAP4rev1 protocol transactions, including electronic mail data, are 3958 sent in the clear over the network unless protection from snooping is 3959 negotiated. This can be accomplished either by the use of STARTTLS, 3960 negotiated privacy protection in the AUTHENTICATE command, or some 3961 other protection mechanism. 3963 11.1. STARTTLS Security Considerations 3965 IMAP client and server implementations MUST implement the 3966 TLS_RSA_WITH_RC4_128_MD5 [TLS] cipher suite, and SHOULD implement the 3967 TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA [TLS] cipher suite. This is 3968 important as it assures that any two compliant implementations can be 3969 configured to interoperate. All other cipher suites are OPTIONAL. 3970 Note that this is a change from section 2.1 of [IMAP-TLS]. 3972 During the [TLS] negotiation, the client MUST check its understanding 3973 of the server hostname against the server's identity as presented in 3974 the server Certificate message, in order to prevent man-in-the-middle 3975 attacks. If the match fails, the client SHOULD either ask for 3976 explicit user confirmation, or terminate the connection and indicate 3977 that the server's identity is suspect. Matching is performed 3978 according to these rules: 3980 The client MUST use the server hostname it used to open the 3981 connection as the value to compare against the server name as 3982 expressed in the server certificate. The client MUST NOT use any 3983 form of the server hostname derived from an insecure remote source 3984 (e.g., insecure DNS lookup). CNAME canonicalization is not done. 3986 If a subjectAltName extension of type dNSName is present in the 3987 certificate, it SHOULD be used as the source of the server's 3988 identity. 3990 Matching is case-insensitive. 3992 A "*" wildcard character MAY be used as the left-most name 3993 component in the certificate. For example, *.example.com would 3994 match a.example.com, foo.example.com, etc. but would not match 3995 example.com. 3997 If the certificate contains multiple names (e.g., more than one 3998 dNSName field), then a match with any one of the fields is 3999 considered acceptable. 4001 Both the client and server MUST check the result of the STARTTLS 4002 command and subsequent [TLS] negotiation to see whether acceptable 4003 authentication or privacy was achieved. 4005 11.2. Other Security Considerations 4007 A server error message for an AUTHENTICATE command which fails due to 4008 invalid credentials SHOULD NOT detail why the credentials are 4009 invalid. 4011 Use of the LOGIN command sends passwords in the clear. This can be 4012 avoided by using the AUTHENTICATE command with a [SASL] mechanism 4013 that does not use plaintext passwords, by first negotiating 4014 encryption via STARTTLS or some other protection mechanism. 4016 A server implementation MUST implement a configuration that, at the 4017 time of authentication, requires: 4018 (1) The STARTTLS command has been negotiated. 4019 OR 4020 (2) Some other mechanism that protects the session from password 4021 snooping has been provided. 4022 OR 4023 (3) The following measures are in place: 4024 (a) The LOGINDISABLED capability is advertised, and [SASL] mechanisms 4025 (such as PLAIN) using plaintext passwords are NOT advertised in the 4026 CAPABILITY list. 4027 AND 4028 (b) The LOGIN command returns an error even if the password is 4029 correct. 4030 AND 4031 (c) The AUTHENTICATE command returns an error with all [SASL] 4032 mechanisms that use plaintext passwords, even if the password is 4033 correct. 4035 A server error message for a failing LOGIN command SHOULD NOT specify 4036 that the user name, as opposed to the password, is invalid. 4038 A server SHOULD have mechanisms in place to limit or delay failed 4039 AUTHENTICATE/LOGIN attempts. 4041 Additional security considerations are discussed in the section 4042 discussing the AUTHENTICATE and LOGIN commands. 4044 12. IANA Considerations 4046 IMAP4 capabilities are registered by publishing a standards track or 4047 IESG approved experimental RFC. The registry is currently located 4048 at: http://www.iana.org/assignments/imap4-capabilities 4050 As this specification revises the STARTTLS and LOGINDISABLED 4051 extensions previously defined in [IMAP-TLS], IANA is requested to 4052 update the registry accordingly. 4054 13. References 4055 13.1. Normative References 4057 [ABNF] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 4058 Specifications: ABNF", STD 68, RFC 5234, January 2008, 4059 . 4061 [ANONYMOUS] 4062 Zeilenga, K., "Anonymous Simple Authentication and 4063 Security Layer (SASL) Mechanism", RFC 4505, June 2006, 4064 . 4066 [CHARSET] Freed, N. and J. Postel, "IANA Charset Registration 4067 Procedures", BCP 19, RFC 2978, October 2000, 4068 . 4070 [DIGEST-MD5] 4071 Leach, P. and C. Newman, "Using Digest Authentication as a 4072 SASL Mechanism", RFC 2831, May 2000, 4073 . 4075 [DISPOSITION] 4076 Troost, R., Dorner, S., and K. Moore, Ed., "Communicating 4077 Presentation Information in Internet Messages: The 4078 Content-Disposition Header Field", RFC 2183, August 1997, 4079 . 4081 [PLAIN] Zeilenga, K., Ed., "The PLAIN Simple Authentication and 4082 Security Layer (SASL) Mechanism", RFC 4616, August 2006, 4083 . 4085 [KEYWORDS] 4086 Bradner, S., "Key words for use in RFCs to Indicate 4087 Requirement Levels", BCP 14, RFC 2119, March 1997, 4088 . 4090 [LANGUAGE-TAGS] 4091 Alvestrand, H., "Content Language Headers", RFC 3282, May 4092 2002, . 4094 [LOCATION] 4095 Palme, J., Hopmann, A., and N. Shelness, "MIME 4096 Encapsulation of Aggregate Documents, such as HTML 4097 (MHTML)", RFC 2557, March 1999, 4098 . 4100 [MD5] Myers, J. and M. Rose, "The Content-MD5 Header Field", 4101 RFC 1864, October 1995, 4102 . 4104 [MIME-HDRS] 4105 Moore, K., "MIME (Multipurpose Internet Mail Extensions) 4106 Part Three: Message Header Extensions for Non-ASCII Text", 4107 RFC 2047, November 1996, 4108 . 4110 [MIME-IMB] 4111 Freed, N. and N. Borenstein, "Multipurpose Internet Mail 4112 Extensions (MIME) Part One: Format of Internet Message 4113 Bodies", RFC 2045, November 1996, 4114 . 4116 [MIME-IMT] 4117 Freed, N. and N. Borenstein, "Multipurpose Internet Mail 4118 Extensions (MIME) Part Two: Media Types", RFC 2046, 4119 November 1996, . 4121 [RFC-5322] 4122 Resnick, P., Ed., "Internet Message Format", RFC 5322, 4123 October 2008, . 4125 [SASL] Melnikov, A., Ed. and K. Zeilenga, Ed., "Simple 4126 Authentication and Security Layer (SASL)", RFC 4422, June 4127 2006, . 4129 [TLS] Dierks, T. and E. Rescorla, "The Transport Layer Security 4130 (TLS) Protocol Version 1.2", RFC 5246, August 2008, 4131 . 4133 [UTF-7] Goldsmith, D. and M. Davis, "UTF-7 A Mail-Safe 4134 Transformation Format of Unicode", RFC 2152, May 1997, 4135 . 4137 [IMAP-IMPLEMENTATION] 4138 Leiba, B., "IMAP4 Implementation Recommendations", 4139 RFC 2683, September 1999, 4140 . 4142 [IMAP-MULTIACCESS] 4143 Gahrns, M., "IMAP4 Multi-Accessed Mailbox Practice", 4144 RFC 2180, July 1997, 4145 . 4147 13.2. Informative References (related protocols) 4149 [IMAP-DISC] 4150 Melnikov, A., Ed., "Synchronization Operations for 4151 Disconnected IMAP4 Clients", RFC 4549, June 2006, 4152 . 4154 [IMAP-MODEL] 4155 Crispin, M., "Distributed Electronic Mail Models in 4156 IMAP4", RFC 1733, December 1994, 4157 . 4159 [ACAP] Newman, C. and J. G. Myers, "ACAP -- Application 4160 Configuration Access Protocol", RFC 2244, November 1997, 4161 . 4163 [SMTP] Klensin, J., "Simple Mail Transfer Protocol", RFC 5321, 4164 October 2008, . 4166 13.3. Informative References (historical aspects of IMAP and related 4167 protocols) 4169 [IMAP-COMPAT] 4170 Crispin, M., "IMAP4 Compatibility with IMAP2bis", 4171 RFC 2061, December 1996, 4172 . 4174 [IMAP-HISTORICAL] 4175 Crispin, M., "IMAP4 Compatibility with IMAP2 and 4176 IMAP2bis", RFC 1732, December 1994, 4177 . 4179 [IMAP-OBSOLETE] 4180 Crispin, M., "Internet Message Access Protocol - Obsolete 4181 Syntax", RFC 2062, December 1996, 4182 . 4184 [IMAP2] Crispin, M., "Interactive Mail Access Protocol: Version 4185 2", RFC 1176, August 1990, 4186 . 4188 [RFC-822] Crocker, D., "STANDARD FOR THE FORMAT OF ARPA INTERNET 4189 TEXT MESSAGES", STD 11, RFC 822, August 1982, 4190 . 4192 [RFC-821] Postel, J., "Simple Mail Transfer Protocol", STD 10, 4193 RFC 821, August 1982, 4194 . 4196 [IMAP-TLS] 4197 Newman, C., "Using TLS with IMAP, POP3 and ACAP", 4198 RFC 2595, June 1999, 4199 . 4201 Appendix A. Changes from RFC 3501 4203 1. Updated references. 4205 2. Applied errata: 261, 3032, 3093 4207 Appendix B. Acknowledgement 4209 Earlier versions of this document were edited by Mark Crispin. 4210 Sadly, he is no longer available to help with this work. Editor of 4211 this revisions is hoping that Mark would have approved. 4213 Thank you to Tony Hansen for helping with the index generation. 4215 Index 4217 + 4218 +FLAGS 54 4219 +FLAGS.SILENT 54 4221 - 4222 -FLAGS 55 4223 -FLAGS.SILENT 55 4225 A 4226 ALERT (response code) 59 4227 ALL (fetch item) 51 4228 ALL (search key) 48 4229 ANSWERED (search key) 48 4230 APPEND (command) 43 4231 AUTHENTICATE (command) 27 4233 B 4234 BAD (response) 61 4235 BADCHARSET (response code) 59 4236 BCC (search key) 48 4237 BEFORE (search key) 48 4238 BODY (fetch item) 51 4239 BODY (fetch result) 68 4240 BODY (search key) 48 4241 BODY.PEEK[
]<> (fetch item) 53 4242 BODYSTRUCTURE (fetch item) 53 4243 BODYSTRUCTURE (fetch result) 68 4244 BODY[
]<> (fetch result) 68 4245 BODY[
]<> (fetch item) 51 4246 BYE (response) 62 4247 Body Structure (message attribute) 13 4249 C 4250 CAPABILITY (command) 23 4251 CAPABILITY (response code) 59 4252 CAPABILITY (response) 63 4253 CC (search key) 48 4254 CHECK (command) 45 4255 CLOSE (command) 45 4256 COPY (command) 55 4257 CREATE (command) 33 4259 D 4260 DELETE (command) 34 4261 DELETED (search key) 48 4262 DRAFT (search key) 48 4264 E 4265 ENVELOPE (fetch item) 53 4266 ENVELOPE (fetch result) 71 4267 EXAMINE (command) 32 4268 EXPUNGE (command) 46 4269 EXPUNGE (response) 67 4270 Envelope Structure (message attribute) 12 4272 F 4273 FAST (fetch item) 51 4274 FETCH (command) 50 4275 FETCH (response) 68 4276 FLAGGED (search key) 48 4277 FLAGS (fetch item) 53 4278 FLAGS (fetch result) 72 4279 FLAGS (response) 65 4280 FLAGS (store command data item) 54 4281 FLAGS.SILENT (store command data item) 54 4282 FROM (search key) 48 4283 FULL (fetch item) 51 4284 Flags (message attribute) 11 4286 H 4287 HEADER (part specifier) 51 4288 HEADER (search key) 48 4289 HEADER.FIELDS (part specifier) 51 4290 HEADER.FIELDS.NOT (part specifier) 51 4292 I 4293 INTERNALDATE (fetch item) 53 4294 INTERNALDATE (fetch result) 72 4295 Internal Date (message attribute) 12 4297 K 4298 KEYWORD (search key) 48 4299 Keyword (type of flag) 12 4301 L 4302 LARGER (search key) 48 4303 LIST (command) 38 4304 LIST (response) 64 4305 LOGOUT (command) 25 4306 LSUB (command) 41 4307 LSUB (response) 65 4309 M 4310 MAY (specification requirement term) 5 4311 MESSAGES (status item) 43 4312 MIME (part specifier) 52 4313 MUST (specification requirement term) 5 4314 MUST NOT (specification requirement term) 5 4315 Message Sequence Number (message attribute) 10 4317 N 4318 NEW (search key) 48 4319 NO (response) 61 4320 NOOP (command) 24 4321 NOT (search key) 48 4323 O 4324 OK (response) 60 4325 OLD (search key) 48 4326 ON (search key) 49 4327 OPTIONAL (specification requirement term) 5 4328 OR (search key) 49 4330 P 4331 PARSE (response code) 59 4332 PERMANENTFLAGS (response code) 59 4333 PREAUTH (response) 61 4334 Permanent Flag (class of flag) 12 4336 R 4337 READ-ONLY (response code) 60 4338 READ-WRITE (response code) 60 4339 RECENT (search key) 49 4340 RECENT (status item) 43 4341 RECOMMENDED (specification requirement term) 5 4342 RENAME (command) 35 4343 REQUIRED (specification requirement term) 5 4344 RFC822 (fetch item) 53 4345 RFC822 (fetch result) 72 4346 RFC822.HEADER (fetch item) 53 4347 RFC822.HEADER (fetch result) 72 4348 RFC822.SIZE (fetch item) 53 4349 RFC822.SIZE (fetch result) 72 4350 RFC822.TEXT (fetch item) 53 4351 RFC822.TEXT (fetch result) 72 4353 S 4354 SEARCH (command) 47 4355 SEARCH (response) 65 4356 SEEN (search key) 49 4357 SELECT (command) 30 4358 SENTBEFORE (search key) 49 4359 SENTON (search key) 49 4360 SENTSINCE (search key) 49 4361 SHOULD (specification requirement term) 5 4362 SHOULD NOT (specification requirement term) 5 4363 SINCE (search key) 49 4364 SMALLER (search key) 49 4365 STARTTLS (command) 26 4366 STATUS (command) 42 4367 STATUS (response) 65 4368 STORE (command) 54 4369 SUBJECT (search key) 49 4370 SUBSCRIBE (command) 37 4371 Session Flag (class of flag) 12 4372 System Flag (type of flag) 11 4374 T 4375 TEXT (part specifier) 51 4376 TEXT (search key) 49 4377 TO (search key) 49 4378 TRYCREATE (response code) 60 4380 U 4381 UID (command) 56 4382 UID (fetch item) 53 4383 UID (fetch result) 72 4384 UID (search key) 49 4385 UIDNEXT (response code) 60 4386 UIDNEXT (status item) 43 4387 UIDVALIDITY (response code) 60 4388 UIDVALIDITY (status item) 43 4389 UNANSWERED (search key) 49 4390 UNDELETED (search key) 49 4391 UNDRAFT (search key) 49 4392 UNFLAGGED (search key) 49 4393 UNKEYWORD (search key) 50 4394 UNSEEN (response code) 60 4395 UNSEEN (search key) 50 4396 UNSEEN (status item) 43 4397 UNSUBSCRIBE (command) 38 4398 Unique Identifier (UID) (message attribute) 9 4400 X 4401 X (command) 57 4403 [ 4404 [RFC-5322] Size (message attribute) 12 4406 \ 4407 \Answered (system flag) 11 4408 \Deleted (system flag) 11 4409 \Draft (system flag) 11 4410 \Flagged (system flag) 11 4411 \Marked (mailbox name attribute) 64 4412 \Noinferiors (mailbox name attribute) 64 4413 \Noselect (mailbox name attribute) 64 4414 \Recent (system flag) 11 4415 \Seen (system flag) 11 4416 \Unmarked (mailbox name attribute) 64 4418 Author's Address 4420 Alexey Melnikov (editor) 4421 Isode Ltd 4422 14 Castle Mews 4423 Hampton, Middlesex TW12 2NP 4424 UK 4426 Email: Alexey.Melnikov@isode.com