idnits 2.17.00 (12 Aug 2021) /tmp/idnits30980/draft-ietf-extra-imap4rev2-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 are 13 instances of too long lines in the document, the longest one being 9 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 (July 9, 2019) is 1046 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 6237, but not defined == Missing Reference: 'IMAP-OBSOLETE' is mentioned on line 6232, but not defined == Missing Reference: 'IMAP-COMPAT' is mentioned on line 6222, but not defined == Missing Reference: 'IMAP-HISTORICAL' is mentioned on line 6227, but not defined == Missing Reference: 'RFC-822' is mentioned on line 6241, but not defined ** Obsolete undefined reference: RFC 822 (Obsoleted by RFC 2822) == Missing Reference: 'HEADER' is mentioned on line 5188, but not defined == Missing Reference: 'IMAP-DISC' is mentioned on line 6175, but not defined == Missing Reference: 'SMTP' is mentioned on line 6200, but not defined == Missing Reference: 'IMAP-URL' is mentioned on line 6214, but not defined == Missing Reference: 'UIDVALIDITY 3857529045' is mentioned on line 5171, but not defined == Missing Reference: 'UIDNEXT 4392' is mentioned on line 1613, but not defined == Missing Reference: 'RFC5258' is mentioned on line 6161, but not defined == Missing Reference: 'RFC2193' is mentioned on line 6166, but not defined == Missing Reference: 'RFC3348' is mentioned on line 6170, but not defined ** Obsolete undefined reference: RFC 3348 (Obsoleted by RFC 5258) == Missing Reference: 'UIDNEXT 2' is mentioned on line 3043, but not defined == Missing Reference: 'UIDVALIDITY 1' is mentioned on line 3114, but not defined == Missing Reference: 'IMAP-I18N' is mentioned on line 6180, but not defined == Missing Reference: 'TEXT' is mentioned on line 5125, but not defined == Missing Reference: 'UID' is mentioned on line 3828, but not defined == Missing Reference: 'RFC4314' is mentioned on line 6207, but not defined == Missing Reference: 'RFC2087' is mentioned on line 6211, but not defined ** Obsolete undefined reference: RFC 2087 (Obsoleted by RFC 9208) == Missing Reference: 'READ-WRITE' is mentioned on line 5172, but not defined == Missing Reference: 'RFC4422' is mentioned on line 5487, but not defined == Missing Reference: 'IMAP-TLS' is mentioned on line 6249, but not defined == Missing Reference: 'IMAP-MODEL' is mentioned on line 6186, but not defined == Missing Reference: 'IMAP-UTF-8' is mentioned on line 6268, but not defined == Missing Reference: 'ACAP' is mentioned on line 6196, but not defined == Missing Reference: 'RFC3516' is mentioned on line 6354, but not defined == Missing Reference: 'RFC-821' is mentioned on line 6245, but not defined ** Obsolete undefined reference: RFC 821 (Obsoleted by RFC 2821) ** 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: 11 errors (**), 0 flaws (~~), 31 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) B. Leiba, Ed. 5 Intended status: Standards Track Huawei Technologies 6 Expires: January 10, 2020 July 9, 2019 8 INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev2 9 draft-ietf-extra-imap4rev2-05 11 Abstract 13 The Internet Message Access Protocol, Version 4rev2 (IMAP4rev2) 14 allows a client to access and manipulate electronic mail messages on 15 a server. IMAP4rev2 permits manipulation of mailboxes (remote 16 message folders) in a way that is functionally equivalent to local 17 folders. IMAP4rev2 also provides the capability for an offline 18 client to resynchronize with the server. 20 IMAP4rev2 includes operations for creating, deleting, and renaming 21 mailboxes, checking for new messages, permanently removing messages, 22 setting and clearing flags, RFC 5322, RFC 2045 and RFC 2231 parsing, 23 searching, and selective fetching of message attributes, texts, and 24 portions thereof. Messages in IMAP4rev2 are accessed by the use of 25 numbers. These numbers are either message sequence numbers or unique 26 identifiers. 28 IMAP4rev2 does not specify a means of posting mail; this function is 29 handled by a mail submission protocol such as RFC 6409. 31 Status of This Memo 33 This Internet-Draft is submitted in full conformance with the 34 provisions of BCP 78 and BCP 79. 36 Internet-Drafts are working documents of the Internet Engineering 37 Task Force (IETF). Note that other groups may also distribute 38 working documents as Internet-Drafts. The list of current Internet- 39 Drafts is at https://datatracker.ietf.org/drafts/current/. 41 Internet-Drafts are draft documents valid for a maximum of six months 42 and may be updated, replaced, or obsoleted by other documents at any 43 time. It is inappropriate to use Internet-Drafts as reference 44 material or to cite them other than as "work in progress." 46 This Internet-Draft will expire on January 10, 2020. 48 Copyright Notice 50 Copyright (c) 2019 IETF Trust and the persons identified as the 51 document authors. All rights reserved. 53 This document is subject to BCP 78 and the IETF Trust's Legal 54 Provisions Relating to IETF Documents 55 (https://trustee.ietf.org/license-info) in effect on the date of 56 publication of this document. Please review these documents 57 carefully, as they describe your rights and restrictions with respect 58 to this document. Code Components extracted from this document must 59 include Simplified BSD License text as described in Section 4.e of 60 the Trust Legal Provisions and are provided without warranty as 61 described in the Simplified BSD License. 63 This document may contain material from IETF Documents or IETF 64 Contributions published or made publicly available before November 65 10, 2008. The person(s) controlling the copyright in some of this 66 material may not have granted the IETF Trust the right to allow 67 modifications of such material outside the IETF Standards Process. 68 Without obtaining an adequate license from the person(s) controlling 69 the copyright in such materials, this document may not be modified 70 outside the IETF Standards Process, and derivative works of it may 71 not be created outside the IETF Standards Process, except to format 72 it for publication as an RFC or to translate it into languages other 73 than English. 75 Table of Contents 77 1. How to Read This Document . . . . . . . . . . . . . . . . . . 5 78 1.1. Organization of This Document . . . . . . . . . . . . . . 5 79 1.2. Conventions Used in This Document . . . . . . . . . . . . 5 80 1.3. Special Notes to Implementors . . . . . . . . . . . . . . 6 81 2. Protocol Overview . . . . . . . . . . . . . . . . . . . . . . 7 82 2.1. Link Level . . . . . . . . . . . . . . . . . . . . . . . 7 83 2.2. Commands and Responses . . . . . . . . . . . . . . . . . 7 84 2.2.1. Client Protocol Sender and Server Protocol Receiver . 7 85 2.2.2. Server Protocol Sender and Client Protocol Receiver . 8 86 2.3. Message Attributes . . . . . . . . . . . . . . . . . . . 9 87 2.3.1. Message Numbers . . . . . . . . . . . . . . . . . . . 9 88 2.3.2. Flags Message Attribute . . . . . . . . . . . . . . . 11 89 2.3.3. Internal Date Message Attribute . . . . . . . . . . . 12 90 2.3.4. [RFC-5322] Size Message Attribute . . . . . . . . . . 13 91 2.3.5. Envelope Structure Message Attribute . . . . . . . . 13 92 2.3.6. Body Structure Message Attribute . . . . . . . . . . 13 93 2.4. Message Texts . . . . . . . . . . . . . . . . . . . . . . 13 94 3. State and Flow Diagram . . . . . . . . . . . . . . . . . . . 13 95 3.1. Not Authenticated State . . . . . . . . . . . . . . . . . 13 96 3.2. Authenticated State . . . . . . . . . . . . . . . . . . . 13 97 3.3. Selected State . . . . . . . . . . . . . . . . . . . . . 14 98 3.4. Logout State . . . . . . . . . . . . . . . . . . . . . . 14 99 4. Data Formats . . . . . . . . . . . . . . . . . . . . . . . . 16 100 4.1. Atom . . . . . . . . . . . . . . . . . . . . . . . . . . 16 101 4.1.1. Sequence set and UID set . . . . . . . . . . . . . . 16 102 4.2. Number . . . . . . . . . . . . . . . . . . . . . . . . . 16 103 4.3. String . . . . . . . . . . . . . . . . . . . . . . . . . 16 104 4.3.1. 8-bit and Binary Strings . . . . . . . . . . . . . . 17 105 4.4. Parenthesized List . . . . . . . . . . . . . . . . . . . 18 106 4.5. NIL . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 107 5. Operational Considerations . . . . . . . . . . . . . . . . . 18 108 5.1. Mailbox Naming . . . . . . . . . . . . . . . . . . . . . 18 109 5.1.1. Mailbox Hierarchy Naming . . . . . . . . . . . . . . 19 110 5.1.2. Namespaces . . . . . . . . . . . . . . . . . . . . . 20 111 5.2. Mailbox Size and Message Status Updates . . . . . . . . . 21 112 5.3. Response when no Command in Progress . . . . . . . . . . 21 113 5.4. Autologout Timer . . . . . . . . . . . . . . . . . . . . 22 114 5.5. Multiple Commands in Progress (Command Pipelining) . . . 22 115 6. Client Commands . . . . . . . . . . . . . . . . . . . . . . . 23 116 6.1. Client Commands - Any State . . . . . . . . . . . . . . . 24 117 6.1.1. CAPABILITY Command . . . . . . . . . . . . . . . . . 24 118 6.1.2. NOOP Command . . . . . . . . . . . . . . . . . . . . 25 119 6.1.3. LOGOUT Command . . . . . . . . . . . . . . . . . . . 25 120 6.2. Client Commands - Not Authenticated State . . . . . . . . 26 121 6.2.1. STARTTLS Command . . . . . . . . . . . . . . . . . . 26 122 6.2.2. AUTHENTICATE Command . . . . . . . . . . . . . . . . 27 123 6.2.3. LOGIN Command . . . . . . . . . . . . . . . . . . . . 30 124 6.3. Client Commands - Authenticated State . . . . . . . . . . 31 125 6.3.1. ENABLE Command . . . . . . . . . . . . . . . . . . . 31 126 6.3.2. SELECT Command . . . . . . . . . . . . . . . . . . . 33 127 6.3.3. EXAMINE Command . . . . . . . . . . . . . . . . . . . 35 128 6.3.4. CREATE Command . . . . . . . . . . . . . . . . . . . 35 129 6.3.5. DELETE Command . . . . . . . . . . . . . . . . . . . 36 130 6.3.6. RENAME Command . . . . . . . . . . . . . . . . . . . 38 131 6.3.7. SUBSCRIBE Command . . . . . . . . . . . . . . . . . . 40 132 6.3.8. UNSUBSCRIBE Command . . . . . . . . . . . . . . . . . 41 133 6.3.9. LIST Command . . . . . . . . . . . . . . . . . . . . 41 134 6.3.10. LSUB Command . . . . . . . . . . . . . . . . . . . . 58 135 6.3.11. NAMESPACE Command . . . . . . . . . . . . . . . . . . 59 136 6.3.12. STATUS Command . . . . . . . . . . . . . . . . . . . 63 137 6.3.13. APPEND Command . . . . . . . . . . . . . . . . . . . 65 138 6.3.14. IDLE Command . . . . . . . . . . . . . . . . . . . . 67 139 6.4. Client Commands - Selected State . . . . . . . . . . . . 69 140 6.4.1. CHECK Command . . . . . . . . . . . . . . . . . . . . 70 141 6.4.2. CLOSE Command . . . . . . . . . . . . . . . . . . . . 70 142 6.4.3. UNSELECT Command . . . . . . . . . . . . . . . . . . 71 143 6.4.4. EXPUNGE Command . . . . . . . . . . . . . . . . . . . 71 144 6.4.5. SEARCH Command . . . . . . . . . . . . . . . . . . . 72 145 6.4.6. FETCH Command . . . . . . . . . . . . . . . . . . . . 77 146 6.4.7. STORE Command . . . . . . . . . . . . . . . . . . . . 81 147 6.4.8. COPY Command . . . . . . . . . . . . . . . . . . . . 82 148 6.4.9. MOVE Command . . . . . . . . . . . . . . . . . . . . 83 149 6.4.10. UID Command . . . . . . . . . . . . . . . . . . . . . 85 150 6.5. Client Commands - Experimental/Expansion . . . . . . . . 87 151 6.5.1. X Command . . . . . . . . . . . . . . . . . . . 87 152 7. Server Responses . . . . . . . . . . . . . . . . . . . . . . 88 153 7.1. Server Responses - Status Responses . . . . . . . . . . . 89 154 7.1.1. OK Response . . . . . . . . . . . . . . . . . . . . . 96 155 7.1.2. NO Response . . . . . . . . . . . . . . . . . . . . . 96 156 7.1.3. BAD Response . . . . . . . . . . . . . . . . . . . . 97 157 7.1.4. PREAUTH Response . . . . . . . . . . . . . . . . . . 97 158 7.1.5. BYE Response . . . . . . . . . . . . . . . . . . . . 97 159 7.2. Server Responses - Server and Mailbox Status . . . . . . 98 160 7.2.1. The ENABLED Response . . . . . . . . . . . . . . . . 98 161 7.2.2. CAPABILITY Response . . . . . . . . . . . . . . . . . 98 162 7.2.3. LIST Response . . . . . . . . . . . . . . . . . . . . 99 163 7.2.4. LSUB Response . . . . . . . . . . . . . . . . . . . . 102 164 7.2.5. NAMESPACE Response . . . . . . . . . . . . . . . . . 103 165 7.2.6. STATUS Response . . . . . . . . . . . . . . . . . . . 103 166 7.2.7. ESEARCH Response . . . . . . . . . . . . . . . . . . 103 167 7.2.8. FLAGS Response . . . . . . . . . . . . . . . . . . . 104 168 7.3. Server Responses - Mailbox Size . . . . . . . . . . . . . 104 169 7.3.1. EXISTS Response . . . . . . . . . . . . . . . . . . . 104 170 7.4. Server Responses - Message Status . . . . . . . . . . . . 104 171 7.4.1. EXPUNGE Response . . . . . . . . . . . . . . . . . . 105 172 7.4.2. FETCH Response . . . . . . . . . . . . . . . . . . . 105 173 7.5. Server Responses - Command Continuation Request . . . . . 111 174 8. Sample IMAP4rev2 connection . . . . . . . . . . . . . . . . . 112 175 9. Formal Syntax . . . . . . . . . . . . . . . . . . . . . . . . 113 176 10. Author's Note . . . . . . . . . . . . . . . . . . . . . . . . 128 177 11. Security Considerations . . . . . . . . . . . . . . . . . . . 128 178 11.1. STARTTLS Security Considerations . . . . . . . . . . . . 128 179 11.2. COPYUID and APPENDUID response codes . . . . . . . . . . 129 180 11.3. Other Security Considerations . . . . . . . . . . . . . 129 181 12. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 130 182 12.1. Updates to IMAP4 Capabilities registry . . . . . . . . . 130 183 12.2. GSSAPI/SASL service name . . . . . . . . . . . . . . . . 130 184 13. References . . . . . . . . . . . . . . . . . . . . . . . . . 130 185 13.1. Normative References . . . . . . . . . . . . . . . . . . 130 186 13.2. Informative References (related protocols) . . . . . . . 133 187 13.3. Informative References (historical aspects of IMAP and 188 related protocols) . . . . . . . . . . . . . . . . . . . 135 189 Appendix A. Backward compatibility with IMAP4rev1 . . . . . . . 135 190 A.1. Mailbox International Naming Convention . . . . . . . . . 136 191 Appendix B. Backward compatibility with BINARY extension . . . . 137 192 Appendix C. Changes from RFC 3501 / IMAP4rev1 . . . . . . . . . 138 193 Appendix D. Acknowledgement . . . . . . . . . . . . . . . . . . 139 194 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 195 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 145 197 1. How to Read This Document 199 1.1. Organization of This Document 201 This document is written from the point of view of the implementor of 202 an IMAP4rev2 client or server. Beyond the protocol overview in 203 section 2, it is not optimized for someone trying to understand the 204 operation of the protocol. The material in sections 3 through 5 205 provides the general context and definitions with which IMAP4rev2 206 operates. 208 Sections 6, 7, and 9 describe the IMAP commands, responses, and 209 syntax, respectively. The relationships among these are such that it 210 is almost impossible to understand any of them separately. In 211 particular, do not attempt to deduce command syntax from the command 212 section alone; instead refer to the Formal Syntax section. 214 1.2. Conventions Used in This Document 216 "Conventions" are basic principles or procedures. Document 217 conventions are noted in this section. 219 In examples, "C:" and "S:" indicate lines sent by the client and 220 server respectively. 222 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 223 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 224 "OPTIONAL" in this document are to be interpreted as described in BCP 225 14 [RFC2119] [RFC8174] when, and only when, they appear in all 226 capitals, as shown here. 228 The word "can" (not "may") is used to refer to a possible 229 circumstance or situation, as opposed to an optional facility of the 230 protocol. 232 "User" is used to refer to a human user, whereas "client" refers to 233 the software being run by the user. 235 "Connection" refers to the entire sequence of client/server 236 interaction from the initial establishment of the network connection 237 until its termination. 239 "Session" refers to the sequence of client/server interaction from 240 the time that a mailbox is selected (SELECT or EXAMINE command) until 241 the time that selection ends (SELECT or EXAMINE of another mailbox, 242 CLOSE command, or connection termination). 244 Characters are 7-bit US-ASCII unless otherwise specified. Other 245 character sets are indicated using a "CHARSET", as described in 246 [MIME-IMT] and defined in [CHARSET]. CHARSETs have important 247 additional semantics in addition to defining character set; refer to 248 these documents for more detail. 250 There are several protocol conventions in IMAP. These refer to 251 aspects of the specification which are not strictly part of the IMAP 252 protocol, but reflect generally-accepted practice. Implementations 253 need to be aware of these conventions, and avoid conflicts whether or 254 not they implement the convention. For example, "&" may not be used 255 as a hierarchy delimiter since it conflicts with the Mailbox 256 International Naming Convention, and other uses of "&" in mailbox 257 names are impacted as well. 259 1.3. Special Notes to Implementors 261 Implementors of the IMAP protocol are strongly encouraged to read the 262 IMAP implementation recommendations document [IMAP-IMPLEMENTATION] in 263 conjunction with this document, to help understand the intricacies of 264 this protocol and how best to build an interoperable product. 266 IMAP4rev2 is designed to be upwards compatible from the [IMAP2] and 267 unpublished IMAP2bis protocols. IMAP4rev2 is largely compatible with 268 the IMAP4rev1 protocol described in RFC 3501 and the IMAP4 protocol 269 described in RFC 1730; the exception being in certain facilities 270 added in RFC 1730 that proved problematic and were subsequently 271 removed. In the course of the evolution of IMAP4rev2, some aspects 272 in the earlier protocols have become obsolete. Obsolete commands, 273 responses, and data formats which an IMAP4rev2 implementation can 274 encounter when used with an earlier implementation are described in 275 [IMAP-OBSOLETE]. 277 Other compatibility issues with IMAP2bis, the most common variant of 278 the earlier protocol, are discussed in [IMAP-COMPAT]. A full 279 discussion of compatibility issues with rare (and presumed extinct) 280 variants of [IMAP2] is in [IMAP-HISTORICAL]; this document is 281 primarily of historical interest. 283 IMAP was originally developed for the older [RFC-822] standard, and 284 as a consequence several fetch items in IMAP incorporate "RFC822" in 285 their name. With the exception of RFC822.SIZE, there are more modern 286 replacements; for example, the modern version of RFC822.HEADER is 287 BODY.PEEK[HEADER]. In all cases, "RFC822" should be interpreted as a 288 reference to the updated [RFC-5322] standard. 290 2. Protocol Overview 292 2.1. Link Level 294 The IMAP4rev2 protocol assumes a reliable data stream such as that 295 provided by TCP. When TCP is used, an IMAP4rev2 server listens on 296 port 143. 298 2.2. Commands and Responses 300 An IMAP4rev2 connection consists of the establishment of a client/ 301 server network connection, an initial greeting from the server, and 302 client/server interactions. These client/server interactions consist 303 of a client command, server data, and a server completion result 304 response. 306 All interactions transmitted by client and server are in the form of 307 lines, that is, strings that end with a CRLF. The protocol receiver 308 of an IMAP4rev2 client or server is either reading a line, or is 309 reading a sequence of octets with a known count followed by a line. 311 2.2.1. Client Protocol Sender and Server Protocol Receiver 313 The client command begins an operation. Each client command is 314 prefixed with an identifier (typically a short alphanumeric string, 315 e.g., A0001, A0002, etc.) called a "tag". A different tag is 316 generated by the client for each command. 318 Clients MUST follow the syntax outlined in this specification 319 strictly. It is a syntax error to send a command with missing or 320 extraneous spaces or arguments. 322 There are two cases in which a line from the client does not 323 represent a complete command. In one case, a command argument is 324 quoted with an octet count (see the description of literal in String 325 under Data Formats); in the other case, the command arguments require 326 server feedback (see the AUTHENTICATE command). In either case, the 327 server sends a command continuation request response if it is ready 328 for the octets (if appropriate) and the remainder of the command. 329 This response is prefixed with the token "+". 331 Note: If instead, the server detected an error in the command, it 332 sends a BAD completion response with a tag matching the command 333 (as described below) to reject the command and prevent the client 334 from sending any more of the command. 336 It is also possible for the server to send a completion response 337 for some other command (if multiple commands are in progress), or 338 untagged data. In either case, the command continuation request 339 is still pending; the client takes the appropriate action for the 340 response, and reads another response from the server. In all 341 cases, the client MUST send a complete command (including 342 receiving all command continuation request responses and command 343 continuations for the command) before initiating a new command. 345 The protocol receiver of an IMAP4rev2 server reads a command line 346 from the client, parses the command and its arguments, and transmits 347 server data and a server command completion result response. 349 2.2.2. Server Protocol Sender and Client Protocol Receiver 351 Data transmitted by the server to the client and status responses 352 that do not indicate command completion are prefixed with the token 353 "*", and are called untagged responses. 355 Server data MAY be sent as a result of a client command, or MAY be 356 sent unilaterally by the server. There is no syntactic difference 357 between server data that resulted from a specific command and server 358 data that were sent unilaterally. 360 The server completion result response indicates the success or 361 failure of the operation. It is tagged with the same tag as the 362 client command which began the operation. Thus, if more than one 363 command is in progress, the tag in a server completion response 364 identifies the command to which the response applies. There are 365 three possible server completion responses: OK (indicating success), 366 NO (indicating failure), or BAD (indicating a protocol error such as 367 unrecognized command or command syntax error). 369 Servers SHOULD enforce the syntax outlined in this specification 370 strictly. Any client command with a protocol syntax error, including 371 (but not limited to) missing or extraneous spaces or arguments, 372 SHOULD be rejected, and the client given a BAD server completion 373 response. 375 The protocol receiver of an IMAP4rev2 client reads a response line 376 from the server. It then takes action on the response based upon the 377 first token of the response, which can be a tag, a "*", or a "+". 379 A client MUST be prepared to accept any server response at all times. 380 This includes server data that was not requested. Server data SHOULD 381 be recorded, so that the client can reference its recorded copy 382 rather than sending a command to the server to request the data. In 383 the case of certain server data, the data MUST be recorded. 385 This topic is discussed in greater detail in the Server Responses 386 section. 388 2.3. Message Attributes 390 In addition to message text, each message has several attributes 391 associated with it. These attributes can be retrieved individually 392 or in conjunction with other attributes or message texts. 394 2.3.1. Message Numbers 396 Messages in IMAP4rev2 are accessed by one of two numbers; the unique 397 identifier or the message sequence number. 399 2.3.1.1. Unique Identifier (UID) Message Attribute 401 An unsigned 32-bit value assigned to each message, which when used 402 with the unique identifier validity value (see below) forms a 64-bit 403 value that MUST NOT refer to any other message in the mailbox or any 404 subsequent mailbox with the same name forever. Unique identifiers 405 are assigned in a strictly ascending fashion in the mailbox; as each 406 message is added to the mailbox it is assigned a higher UID than the 407 message(s) which were added previously. Unlike message sequence 408 numbers, unique identifiers are not necessarily contiguous. 410 The unique identifier of a message MUST NOT change during the 411 session, and SHOULD NOT change between sessions. Any change of 412 unique identifiers between sessions MUST be detectable using the 413 UIDVALIDITY mechanism discussed below. Persistent unique identifiers 414 are required for a client to resynchronize its state from a previous 415 session with the server (e.g., disconnected or offline access 416 clients); this is discussed further in [IMAP-DISC]. 418 Associated with every mailbox are two 32-bit unsigned values which 419 aid in unique identifier handling: the next unique identifier value 420 (UIDNEXT) and the unique identifier validity value (UIDVALIDITY). 422 The next unique identifier value is the predicted value that will be 423 assigned to a new message in the mailbox. Unless the unique 424 identifier validity also changes (see below), the next unique 425 identifier value MUST have the following two characteristics. First, 426 the next unique identifier value MUST NOT change unless new messages 427 are added to the mailbox; and second, the next unique identifier 428 value MUST change whenever new messages are added to the mailbox, 429 even if those new messages are subsequently expunged. 431 Note: The next unique identifier value is intended to provide a 432 means for a client to determine whether any messages have been 433 delivered to the mailbox since the previous time it checked this 434 value. It is not intended to provide any guarantee that any 435 message will have this unique identifier. A client can only 436 assume, at the time that it obtains the next unique identifier 437 value, that messages arriving after that time will have a UID 438 greater than or equal to that value. 440 The unique identifier validity value is sent in a UIDVALIDITY 441 response code in an OK untagged response at mailbox selection time. 442 If unique identifiers from an earlier session fail to persist in this 443 session, the unique identifier validity value MUST be greater than 444 the one used in the earlier session. 446 Note: Ideally, unique identifiers SHOULD persist at all times. 447 Although this specification recognizes that failure to persist can 448 be unavoidable in certain server environments, it STRONGLY 449 ENCOURAGES message store implementation techniques that avoid this 450 problem. For example: 452 1. Unique identifiers MUST be strictly ascending in the mailbox 453 at all times. If the physical message store is re-ordered by 454 a non-IMAP agent, this requires that the unique identifiers in 455 the mailbox be regenerated, since the former unique 456 identifiers are no longer strictly ascending as a result of 457 the re-ordering. 459 2. If the message store has no mechanism to store unique 460 identifiers, it must regenerate unique identifiers at each 461 session, and each session must have a unique UIDVALIDITY 462 value. 464 3. If the mailbox is deleted and a new mailbox with the same name 465 is created at a later date, the server must either keep track 466 of unique identifiers from the previous instance of the 467 mailbox, or it must assign a new UIDVALIDITY value to the new 468 instance of the mailbox. A good UIDVALIDITY value to use in 469 this case is a 32-bit representation of the creation date/time 470 of the mailbox. It is alright to use a constant such as 1, 471 but only if it guaranteed that unique identifiers will never 472 be reused, even in the case of a mailbox being deleted (or 473 renamed) and a new mailbox by the same name created at some 474 future time. 476 4. The combination of mailbox name, UIDVALIDITY, and UID must 477 refer to a single immutable message on that server forever. 478 In particular, the internal date, [RFC-5322] size, envelope, 479 body structure, and message texts (RFC822, RFC822.HEADER, 480 RFC822.TEXT, and all BODY[...] fetch data items) must never 481 change. This does not include message numbers, nor does it 482 include attributes that can be set by a STORE command (e.g., 483 FLAGS). 485 2.3.1.2. Message Sequence Number Message Attribute 487 A relative position from 1 to the number of messages in the mailbox. 488 This position MUST be ordered by ascending unique identifier. As 489 each new message is added, it is assigned a message sequence number 490 that is 1 higher than the number of messages in the mailbox before 491 that new message was added. 493 Message sequence numbers can be reassigned during the session. For 494 example, when a message is permanently removed (expunged) from the 495 mailbox, the message sequence number for all subsequent messages is 496 decremented. The number of messages in the mailbox is also 497 decremented. Similarly, a new message can be assigned a message 498 sequence number that was once held by some other message prior to an 499 expunge. 501 In addition to accessing messages by relative position in the 502 mailbox, message sequence numbers can be used in mathematical 503 calculations. For example, if an untagged "11 EXISTS" is received, 504 and previously an untagged "8 EXISTS" was received, three new 505 messages have arrived with message sequence numbers of 9, 10, and 11. 506 Another example, if message 287 in a 523 message mailbox has UID 507 12345, there are exactly 286 messages which have lesser UIDs and 236 508 messages which have greater UIDs. 510 2.3.2. Flags Message Attribute 512 A list of zero or more named tokens associated with the message. A 513 flag is set by its addition to this list, and is cleared by its 514 removal. There are two types of flags in IMAP4rev2. A flag of 515 either type can be permanent or session-only. 517 A system flag is a flag name that is pre-defined in this 518 specification and begin with "\". Certain system flags (\Deleted and 519 \Seen) have special semantics described elsewhere in this document. 520 The currently-defined system flags are: 522 \Seen Message has been read 524 \Answered Message has been answered 526 \Flagged Message is "flagged" for urgent/special attention 528 \Deleted Message is "deleted" for removal by later EXPUNGE 529 \Draft Message has not completed composition (marked as a draft). 531 \Recent This flag was in used in IMAP4rev1 and is now deprecated. 533 A keyword is defined by the server implementation. Keywords do not 534 begin with "\". Servers MAY permit the client to define new keywords 535 in the mailbox (see the description of the PERMANENTFLAGS response 536 code for more information). Some keywords that start with "$" are 537 also defined in this specification. 539 This document defines several keywords that were not originally 540 defined in RFC 3501, but which were found to be useful by client 541 implementations. These keywords SHOULD be supported (i.e. allowed in 542 APPEND, COPY, MOVE and SEARCH commands) by server implementations: 544 $Forwarded Message has been forwarded to another email address, 545 embedded within or attached to a new message. An email client 546 sets this keyword when it successfully forwards the message to 547 another email address. Typical usage of this keyword is to show a 548 different (or additional) icon for a message that has been 549 forwarded. Once set, the flag SHOULD NOT be cleared. 551 $MDNSent Message Disposition Notification was generated and sent for 552 this message. 554 A flag can be permanent or session-only on a per-flag basis. 555 Permanent flags are those which the client can add or remove from the 556 message flags permanently; that is, concurrent and subsequent 557 sessions will see any change in permanent flags. Changes to session 558 flags are valid only in that session. 560 2.3.3. Internal Date Message Attribute 562 The internal date and time of the message on the server. This is not 563 the date and time in the [RFC-5322] header, but rather a date and 564 time which reflects when the message was received. In the case of 565 messages delivered via [SMTP], this SHOULD be the date and time of 566 final delivery of the message as defined by [SMTP]. In the case of 567 messages delivered by the IMAP4rev2 COPY or MOVE command, this SHOULD 568 be the internal date and time of the source message. In the case of 569 messages delivered by the IMAP4rev2 APPEND command, this SHOULD be 570 the date and time as specified in the APPEND command description. 571 All other cases are implementation defined. 573 2.3.4. [RFC-5322] Size Message Attribute 575 The number of octets in the message, as expressed in [RFC-5322] 576 format. 578 2.3.5. Envelope Structure Message Attribute 580 A parsed representation of the [RFC-5322] header of the message. 581 Note that the IMAP Envelope structure is not the same as an [SMTP] 582 envelope. 584 2.3.6. Body Structure Message Attribute 586 A parsed representation of the [MIME-IMB] body structure information 587 of the message. 589 2.4. Message Texts 591 In addition to being able to fetch the full [RFC-5322] text of a 592 message, IMAP4rev2 permits the fetching of portions of the full 593 message text. Specifically, it is possible to fetch the [RFC-5322] 594 message header, [RFC-5322] message body, a [MIME-IMB] body part, or a 595 [MIME-IMB] header. 597 3. State and Flow Diagram 599 Once the connection between client and server is established, an 600 IMAP4rev2 connection is in one of four states. The initial state is 601 identified in the server greeting. Most commands are only valid in 602 certain states. It is a protocol error for the client to attempt a 603 command while the connection is in an inappropriate state, and the 604 server will respond with a BAD or NO (depending upon server 605 implementation) command completion result. 607 3.1. Not Authenticated State 609 In the not authenticated state, the client MUST supply authentication 610 credentials before most commands will be permitted. This state is 611 entered when a connection starts unless the connection has been pre- 612 authenticated. 614 3.2. Authenticated State 616 In the authenticated state, the client is authenticated and MUST 617 select a mailbox to access before commands that affect messages will 618 be permitted. This state is entered when a pre-authenticated 619 connection starts, when acceptable authentication credentials have 620 been provided, after an error in selecting a mailbox, or after a 621 successful CLOSE command. 623 3.3. Selected State 625 In a selected state, a mailbox has been selected to access. This 626 state is entered when a mailbox has been successfully selected. 628 3.4. Logout State 630 In the logout state, the connection is being terminated. This state 631 can be entered as a result of a client request (via the LOGOUT 632 command) or by unilateral action on the part of either the client or 633 server. 635 If the client requests the logout state, the server MUST send an 636 untagged BYE response and a tagged OK response to the LOGOUT command 637 before the server closes the connection; and the client MUST read the 638 tagged OK response to the LOGOUT command before the client closes the 639 connection. 641 A server MUST NOT unilaterally close the connection without sending 642 an untagged BYE response that contains the reason for having done so. 643 A client SHOULD NOT unilaterally close the connection, and instead 644 SHOULD issue a LOGOUT command. If the server detects that the client 645 has unilaterally closed the connection, the server MAY omit the 646 untagged BYE response and simply close its connection. 648 +----------------------+ 649 |connection established| 650 +----------------------+ 651 || 652 \/ 653 +--------------------------------------+ 654 | server greeting | 655 +--------------------------------------+ 656 || (1) || (2) || (3) 657 \/ || || 658 +-----------------+ || || 659 |Not Authenticated| || || 660 +-----------------+ || || 661 || (7) || (4) || || 662 || \/ \/ || 663 || +----------------+ || 664 || | Authenticated |<=++ || 665 || +----------------+ || || 666 || || (7) || (5) || (6) || 667 || || \/ || || 668 || || +--------+ || || 669 || || |Selected|==++ || 670 || || +--------+ || 671 || || || (7) || 672 \/ \/ \/ \/ 673 +--------------------------------------+ 674 | Logout | 675 +--------------------------------------+ 676 || 677 \/ 678 +-------------------------------+ 679 |both sides close the connection| 680 +-------------------------------+ 682 (1) connection without pre-authentication (OK greeting) 683 (2) pre-authenticated connection (PREAUTH greeting) 684 (3) rejected connection (BYE greeting) 685 (4) successful LOGIN or AUTHENTICATE command 686 (5) successful SELECT or EXAMINE command 687 (6) CLOSE command, unsolicited CLOSED response code or 688 failed SELECT or EXAMINE command 689 (7) LOGOUT command, server shutdown, or connection closed 691 4. Data Formats 693 IMAP4rev2 uses textual commands and responses. Data in IMAP4rev2 can 694 be in one of several forms: atom, number, string, parenthesized list, 695 or NIL. Note that a particular data item may take more than one 696 form; for example, a data item defined as using "astring" syntax may 697 be either an atom or a string. 699 4.1. Atom 701 An atom consists of one or more non-special characters. 703 4.1.1. Sequence set and UID set 705 A set of messages can be referenced by a sequence set containing 706 either message sequence numbers or unique identifiers. See Section 9 707 for details. Sequence sets can contain ranges (e.g. "5:50"), an 708 enumeration of specific message/UID numbers, a special symbol "*", or 709 a combination of the above. 711 A "UID set" is similar to the sequence set of unique identifiers; 712 however, the "*" value for a sequence number is not permitted. 714 4.2. Number 716 A number consists of one or more digit characters, and represents a 717 numeric value. 719 4.3. String 721 A string is in one of three forms: synchonizing literal, non- 722 synchronizing literal or quoted string. The synchronizing literal 723 form is the general form of string. The non-synchronizing literal 724 form is also the general form, but has length limitation. The quoted 725 string form is an alternative that avoids the overhead of processing 726 a literal at the cost of limitations of characters which may be used. 728 When the distinction between synchronizing and non-synchronizing 729 literals is not important, this document just uses the term 730 "literal". 732 A synchronizing literal is a sequence of zero or more octets 733 (including CR and LF), prefix-quoted with an octet count in the form 734 of an open brace ("{"), the number of octets, close brace ("}"), and 735 CRLF. In the case of synchronizing literals transmitted from server 736 to client, the CRLF is immediately followed by the octet data. In 737 the case of synchronizing literals transmitted from client to server, 738 the client MUST wait to receive a command continuation request 739 (described later in this document) before sending the octet data (and 740 the remainder of the command). 742 The non-synchronizing literal is an alternate form of synchronizing 743 literal, and it may appear in communication from client to server 744 instead of the synchonizing form of literal. The non-synchronizing 745 literal form MUST NOT be sent from server to client. The non- 746 synchronizing literal is distinguished from the synchronizing literal 747 by having a plus ("+") between the octet count and the closing brace 748 ("}"). The server does not generate a command continuation request 749 in response to a non-synchronizing literal, and clients are not 750 required to wait before sending the octets of a non- synchronizing 751 literal. Non-synchronizing literals MUST NOT be larger than 4096 752 octets. Any literal larger than 4096 bytes MUST be sent as a 753 synchronizing literal. (Non-synchronizing literals defined in this 754 document are the same as non-synchronizing literals defined by the 755 LITERAL- extension from [RFC7888]. See that document for details on 756 how to handle invalid non-synchronizing literals longer than 4096 757 octets and for interaction with other IMAP extensions.) 759 A quoted string is a sequence of zero or more Unicode characters, 760 excluding CR and LF, encoded in UTF-8, with double quote (<">) 761 characters at each end. 763 The empty string is represented as "" (a quoted string with zero 764 characters between double quotes), as {0} followed by CRLF (a 765 synchronizing literal with an octet count of 0) or as {0+} followed 766 by CRLF (a non-synchronizing literal with an octet count of 0). 768 Note: Even if the octet count is 0, a client transmitting a 769 synchronizing literal MUST wait to receive a command continuation 770 request. 772 4.3.1. 8-bit and Binary Strings 774 8-bit textual and binary mail is supported through the use of a 775 [MIME-IMB] content transfer encoding. IMAP4rev2 implementations MAY 776 transmit 8-bit or multi-octet characters in literals, but SHOULD do 777 so only when the [CHARSET] is identified. 779 IMAP4rev2 is compatible with [I18N-HDRS]. As a result, the 780 identified charset for header-field values with 8-bit content is 781 UTF-8 [UTF-8]. IMAP4rev2 implementations MUST accept and MAY 782 transmit [UTF-8] text in quoted-strings as long as the string does 783 not contain NUL, CR, or LF. This differs from IMAP4rev1 784 implementations. 786 Although a BINARY content transfer encoding is defined, unencoded 787 binary strings are not permitted, unless returned in a in 788 response to BINARY.PEEK[]<> or 789 BINARY[]<> FETCH data item. A "binary 790 string" is any string with NUL characters. A string with an 791 excessive amount of CTL characters MAY also be considered to be 792 binary. Unless returned in response to BINARY.PEEK[...]/BINARY[...] 793 FETCH, client and server implementations MUST encode binary data into 794 a textual form, such as BASE64, before transmitting the data. 796 4.4. Parenthesized List 798 Data structures are represented as a "parenthesized list"; a sequence 799 of data items, delimited by space, and bounded at each end by 800 parentheses. A parenthesized list can contain other parenthesized 801 lists, using multiple levels of parentheses to indicate nesting. 803 The empty list is represented as () -- a parenthesized list with no 804 members. 806 4.5. NIL 808 The special form "NIL" represents the non-existence of a particular 809 data item that is represented as a string or parenthesized list, as 810 distinct from the empty string "" or the empty parenthesized list (). 812 Note: NIL is never used for any data item which takes the form of 813 an atom. For example, a mailbox name of "NIL" is a mailbox named 814 NIL as opposed to a non-existent mailbox name. This is because 815 mailbox uses "astring" syntax which is an atom or a string. 816 Conversely, an addr-name of NIL is a non-existent personal name, 817 because addr-name uses "nstring" syntax which is NIL or a string, 818 but never an atom. 820 5. Operational Considerations 822 The following rules are listed here to ensure that all IMAP4rev2 823 implementations interoperate properly. 825 5.1. Mailbox Naming 827 In IMAP4rev2, Mailbox names are encoded in Net-Unicode [NET-UNICODE] 828 (this differs from IMAP4rev1). Client implementations MAY attempt to 829 create Net-Unicode mailbox names, and MUST interpret any 8-bit 830 mailbox names returned by LIST or LSUB as [NET-UNICODE]. Server 831 implementations MUST prohibit the creation of 8-bit mailbox names 832 that do not comply with Net-Unicode (however, servers MAY accept a 833 de-normalized UTF-8 mailbox name and convert it to Net-Unicode prior 834 to mailbox creation). 836 The case-insensitive mailbox name INBOX is a special name reserved to 837 mean "the primary mailbox for this user on this server". (Note that 838 this special name may not exist on some servers for some users.) The 839 interpretation of all other names is implementation-dependent. 841 In particular, this specification takes no position on case 842 sensitivity in non-INBOX mailbox names. Some server implementations 843 are fully case-sensitive in ASCII range; others preserve case of a 844 newly-created name but otherwise are case-insensitive; and yet others 845 coerce names to a particular case. Client implementations MUST 846 interact with any of these. 848 There are certain client considerations when creating a new mailbox 849 name: 851 1. Any character which is one of the atom-specials (see the Formal 852 Syntax) will require that the mailbox name be represented as a 853 quoted string or literal. 855 2. CTL and other non-graphic characters are difficult to represent 856 in a user interface and are best avoided. Servers MAY refuse to 857 create mailbox names containing Unicode CTL characters. 859 3. Although the list-wildcard characters ("%" and "*") are valid in 860 a mailbox name, it is difficult to use such mailbox names with 861 the LIST and LSUB commands due to the conflict with wildcard 862 interpretation. 864 4. Usually, a character (determined by the server implementation) is 865 reserved to delimit levels of hierarchy. 867 5. Two characters, "#" and "&", have meanings by convention, and 868 should be avoided except when used in that convention. 870 5.1.1. Mailbox Hierarchy Naming 872 If it is desired to export hierarchical mailbox names, mailbox names 873 MUST be left-to-right hierarchical using a single character to 874 separate levels of hierarchy. The same hierarchy separator character 875 is used for all levels of hierarchy within a single name. 877 5.1.2. Namespaces 879 Personal Namespace: A namespace that the server considers within the 880 personal scope of the authenticated user on a particular connection. 881 Typically, only the authenticated user has access to mailboxes in 882 their Personal Namespace. It is the part of the namespace that 883 belongs to the user that is allocated for mailboxes. If an INBOX 884 exists for a user, it MUST appear within the user's personal 885 namespace. In the typical case, there SHOULD be only one Personal 886 Namespace on a server. 888 Other Users' Namespace: A namespace that consists of mailboxes from 889 the Personal Namespaces of other users. To access mailboxes in the 890 Other Users' Namespace, the currently authenticated user MUST be 891 explicitly granted access rights. For example, it is common for a 892 manager to grant to their secretary access rights to their mailbox. 893 In the typical case, there SHOULD be only one Other Users' Namespace 894 on a server. 896 Shared Namespace: A namespace that consists of mailboxes that are 897 intended to be shared amongst users and do not exist within a user's 898 Personal Namespace. 900 The namespaces a server uses MAY differ on a per-user basis. 902 5.1.2.1. Historic Mailbox Namespace Naming Convention 904 By convention, the first hierarchical element of any mailbox name 905 which begins with "#" identifies the "namespace" of the remainder of 906 the name. This makes it possible to disambiguate between different 907 types of mailbox stores, each of which have their own namespaces. 909 For example, implementations which offer access to USENET 910 newsgroups MAY use the "#news" namespace to partition the USENET 911 newsgroup namespace from that of other mailboxes. Thus, the 912 comp.mail.misc newsgroup would have a mailbox name of 913 "#news.comp.mail.misc", and the name "comp.mail.misc" can refer to 914 a different object (e.g., a user's private mailbox). 916 Namespaces that include the "#" character are not IMAP URL [IMAP-URL] 917 friendly requiring the "#" character to be represented as %23 when 918 within URLs. As such, server implementers MAY instead consider using 919 namespace prefixes that do not contain the "#" character. 921 5.1.2.2. Common namespace models 923 Previous version of this protocol does not define a default server 924 namespace. Two common namespace models have evolved: 926 The "Personal Mailbox" model, in which the default namespace that is 927 presented consists of only the user's personal mailboxes. To access 928 shared mailboxes, the user must use an escape mechanism to reach 929 another namespace. 931 The "Complete Hierarchy" model, in which the default namespace that 932 is presented includes the user's personal mailboxes along with any 933 other mailboxes they have access to. 935 5.2. Mailbox Size and Message Status Updates 937 At any time, a server can send data that the client did not request. 938 Sometimes, such behavior is REQUIRED. For example, agents other than 939 the server MAY add messages to the mailbox (e.g., new message 940 delivery), change the flags of the messages in the mailbox (e.g., 941 simultaneous access to the same mailbox by multiple agents), or even 942 remove messages from the mailbox. A server MUST send mailbox size 943 updates automatically if a mailbox size change is observed during the 944 processing of a command. A server SHOULD send message flag updates 945 automatically, without requiring the client to request such updates 946 explicitly. 948 Special rules exist for server notification of a client about the 949 removal of messages to prevent synchronization errors; see the 950 description of the EXPUNGE response for more detail. In particular, 951 it is NOT permitted to send an EXISTS response that would reduce the 952 number of messages in the mailbox; only the EXPUNGE response can do 953 this. 955 Regardless of what implementation decisions a client makes on 956 remembering data from the server, a client implementation MUST record 957 mailbox size updates. It MUST NOT assume that any command after the 958 initial mailbox selection will return the size of the mailbox. 960 5.3. Response when no Command in Progress 962 Server implementations are permitted to send an untagged response 963 (except for EXPUNGE) while there is no command in progress. Server 964 implementations that send such responses MUST deal with flow control 965 considerations. Specifically, they MUST either (1) verify that the 966 size of the data does not exceed the underlying transport's available 967 window size, or (2) use non-blocking writes. 969 5.4. Autologout Timer 971 If a server has an inactivity autologout timer that applies to 972 sessions after authentication, the duration of that timer MUST be at 973 least 30 minutes. The receipt of ANY command from the client during 974 that interval SHOULD suffice to reset the autologout timer. 976 5.5. Multiple Commands in Progress (Command Pipelining) 978 The client MAY send another command without waiting for the 979 completion result response of a command, subject to ambiguity rules 980 (see below) and flow control constraints on the underlying data 981 stream. Similarly, a server MAY begin processing another command 982 before processing the current command to completion, subject to 983 ambiguity rules. However, any command continuation request responses 984 and command continuations MUST be negotiated before any subsequent 985 command is initiated. 987 The exception is if an ambiguity would result because of a command 988 that would affect the results of other commands. Clients MUST NOT 989 send multiple commands without waiting if an ambiguity would result. 990 If the server detects a possible ambiguity, it MUST execute commands 991 to completion in the order given by the client. 993 The most obvious example of ambiguity is when a command would affect 994 the results of another command, e.g., a FETCH of a message's flags 995 and a STORE of that same message's flags. 997 A non-obvious ambiguity occurs with commands that permit an untagged 998 EXPUNGE response (commands other than FETCH, STORE, and SEARCH), 999 since an untagged EXPUNGE response can invalidate sequence numbers in 1000 a subsequent command. This is not a problem for FETCH, STORE, or 1001 SEARCH commands because servers are prohibited from sending EXPUNGE 1002 responses while any of those commands are in progress. Therefore, if 1003 the client sends any command other than FETCH, STORE, or SEARCH, it 1004 MUST wait for the completion result response before sending a command 1005 with message sequence numbers. 1007 Note: EXPUNGE responses are permitted while UID FETCH, UID STORE, 1008 and UID SEARCH are in progress. If the client sends a UID 1009 command, it MUST wait for a completion result response before 1010 sending a command which uses message sequence numbers (this may 1011 include UID SEARCH). Any message sequence numbers in an argument 1012 to UID SEARCH are associated with messages prior to the effect of 1013 any untagged EXPUNGE returned by the UID SEARCH. 1015 For example, the following non-waiting command sequences are invalid: 1017 FETCH + NOOP + STORE 1019 STORE + COPY + FETCH 1021 COPY + COPY 1023 CHECK + FETCH 1025 The following are examples of valid non-waiting command sequences: 1027 FETCH + STORE + SEARCH + CHECK 1029 STORE + COPY + EXPUNGE 1031 UID SEARCH + UID SEARCH may be valid or invalid as a non-waiting 1032 command sequence, depending upon whether or not the second UID 1033 SEARCH contains message sequence numbers. 1035 6. Client Commands 1037 IMAP4rev2 commands are described in this section. Commands are 1038 organized by the state in which the command is permitted. Commands 1039 which are permitted in multiple states are listed in the minimum 1040 permitted state (for example, commands valid in authenticated and 1041 selected state are listed in the authenticated state commands). 1043 Command arguments, identified by "Arguments:" in the command 1044 descriptions below, are described by function, not by syntax. The 1045 precise syntax of command arguments is described in the Formal Syntax 1046 (Section 9). 1048 Some commands cause specific server responses to be returned; these 1049 are identified by "Responses:" in the command descriptions below. 1050 See the response descriptions in the Responses section for 1051 information on these responses, and the Formal Syntax section for the 1052 precise syntax of these responses. It is possible for server data to 1053 be transmitted as a result of any command. Thus, commands that do 1054 not specifically require server data specify "no specific responses 1055 for this command" instead of "none". 1057 The "Result:" in the command description refers to the possible 1058 tagged status responses to a command, and any special interpretation 1059 of these status responses. 1061 The state of a connection is only changed by successful commands 1062 which are documented as changing state. A rejected command (BAD 1063 response) never changes the state of the connection or of the 1064 selected mailbox. A failed command (NO response) generally does not 1065 change the state of the connection or of the selected mailbox; the 1066 exception being the SELECT and EXAMINE commands. 1068 6.1. Client Commands - Any State 1070 The following commands are valid in any state: CAPABILITY, NOOP, and 1071 LOGOUT. 1073 6.1.1. CAPABILITY Command 1075 Arguments: none 1077 Responses: REQUIRED untagged response: CAPABILITY 1079 Result: OK - capability completed 1080 BAD - command unknown or arguments invalid 1082 The CAPABILITY command requests a listing of capabilities that the 1083 server supports. The server MUST send a single untagged CAPABILITY 1084 response with "IMAP4rev2" as one of the listed capabilities before 1085 the (tagged) OK response. 1087 A capability name which begins with "AUTH=" indicates that the server 1088 supports that particular authentication mechanism. All such names 1089 are, by definition, part of this specification. For example, the 1090 authorization capability for an experimental "blurdybloop" 1091 authenticator would be "AUTH=XBLURDYBLOOP" and not 1092 "XAUTH=BLURDYBLOOP" or "XAUTH=XBLURDYBLOOP". 1094 Other capability names refer to extensions, revisions, or amendments 1095 to this specification. See the documentation of the CAPABILITY 1096 response for additional information. No capabilities, beyond the 1097 base IMAP4rev2 set defined in this specification, are enabled without 1098 explicit client action to invoke the capability. 1100 Client and server implementations MUST implement the STARTTLS, 1101 LOGINDISABLED, and AUTH=PLAIN (described in [PLAIN]) capabilities. 1102 See the Security Considerations section for important information. 1104 See the section entitled "Client Commands - Experimental/Expansion" 1105 for information about the form of site or implementation-specific 1106 capabilities. 1108 Example: C: abcd CAPABILITY 1109 S: * CAPABILITY IMAP4rev2 STARTTLS AUTH=GSSAPI 1110 LOGINDISABLED 1111 S: abcd OK CAPABILITY completed 1112 C: efgh STARTTLS 1113 S: efgh OK STARTLS completed 1114 1115 C: ijkl CAPABILITY 1116 S: * CAPABILITY IMAP4rev2 AUTH=GSSAPI AUTH=PLAIN 1117 S: ijkl OK CAPABILITY completed 1119 6.1.2. NOOP Command 1121 Arguments: none 1123 Responses: no specific responses for this command (but see below) 1125 Result: OK - noop completed 1126 BAD - command unknown or arguments invalid 1128 The NOOP command always succeeds. It does nothing. 1130 Since any command can return a status update as untagged data, the 1131 NOOP command can be used as a periodic poll for new messages or 1132 message status updates during a period of inactivity (this is the 1133 preferred method to do this). The NOOP command can also be used to 1134 reset any inactivity autologout timer on the server. 1136 Example: C: a002 NOOP 1137 S: a002 OK NOOP completed 1138 . . . 1139 C: a047 NOOP 1140 S: * 22 EXPUNGE 1141 S: * 23 EXISTS 1142 S: * 14 FETCH (UID 1305 FLAGS (\Seen \Deleted)) 1143 S: a047 OK NOOP completed 1145 6.1.3. LOGOUT Command 1147 Arguments: none 1149 Responses: REQUIRED untagged response: BYE 1151 Result: OK - logout completed 1152 BAD - command unknown or arguments invalid 1154 The LOGOUT command informs the server that the client is done with 1155 the connection. The server MUST send a BYE untagged response before 1156 the (tagged) OK response, and then close the network connection. 1158 Example: C: A023 LOGOUT 1159 S: * BYE IMAP4rev2 Server logging out 1160 S: A023 OK LOGOUT completed 1161 (Server and client then close the connection) 1163 6.2. Client Commands - Not Authenticated State 1165 In the not authenticated state, the AUTHENTICATE or LOGIN command 1166 establishes authentication and enters the authenticated state. The 1167 AUTHENTICATE command provides a general mechanism for a variety of 1168 authentication techniques, privacy protection, and integrity 1169 checking; whereas the LOGIN command uses a traditional user name and 1170 plaintext password pair and has no means of establishing privacy 1171 protection or integrity checking. 1173 The STARTTLS command is an alternate form of establishing session 1174 privacy protection and integrity checking, but does not by itself 1175 establish authentication or enter the authenticated state. 1177 Server implementations MAY allow access to certain mailboxes without 1178 establishing authentication. This can be done by means of the 1179 ANONYMOUS [SASL] authenticator described in [ANONYMOUS]. An older 1180 convention is a LOGIN command using the userid "anonymous"; in this 1181 case, a password is required although the server may choose to accept 1182 any password. The restrictions placed on anonymous users are 1183 implementation-dependent. 1185 Once authenticated (including as anonymous), it is not possible to 1186 re-enter not authenticated state. 1188 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 1189 the following commands are valid in the not authenticated state: 1190 STARTTLS, AUTHENTICATE and LOGIN. See the Security Considerations 1191 section for important information about these commands. 1193 6.2.1. STARTTLS Command 1195 Arguments: none 1197 Responses: no specific response for this command 1199 Result: OK - starttls completed, begin TLS negotiation 1200 BAD - command unknown or arguments invalid 1202 A [TLS] negotiation begins immediately after the CRLF at the end of 1203 the tagged OK response from the server. Once a client issues a 1204 STARTTLS command, it MUST NOT issue further commands until a server 1205 response is seen and the [TLS] negotiation is complete. 1207 The server remains in the non-authenticated state, even if client 1208 credentials are supplied during the [TLS] negotiation. This does not 1209 preclude an authentication mechanism such as EXTERNAL (defined in 1210 [SASL]) from using client identity determined by the [TLS] 1211 negotiation. 1213 Once [TLS] has been started, the client MUST discard cached 1214 information about server capabilities and SHOULD re-issue the 1215 CAPABILITY command. This is necessary to protect against man-in- 1216 the-middle attacks which alter the capabilities list prior to 1217 STARTTLS. The server MAY advertise different capabilities, and in 1218 particular SHOULD NOT advertise the STARTTLS capability, after a 1219 successful STARTTLS command. 1221 Example: C: a001 CAPABILITY 1222 S: * CAPABILITY IMAP4rev2 STARTTLS LOGINDISABLED 1223 S: a001 OK CAPABILITY completed 1224 C: a002 STARTTLS 1225 S: a002 OK Begin TLS negotiation now 1226 1227 C: a003 CAPABILITY 1228 S: * CAPABILITY IMAP4rev2 AUTH=PLAIN 1229 S: a003 OK CAPABILITY completed 1230 C: a004 LOGIN joe password 1231 S: a004 OK LOGIN completed 1233 6.2.2. AUTHENTICATE Command 1235 Arguments: SASL authentication mechanism name 1236 OPTIONAL initial response 1238 Responses: continuation data can be requested 1240 Result: OK - authenticate completed, now in authenticated state 1241 NO - authenticate failure: unsupported authentication 1242 mechanism, credentials rejected 1243 BAD - command unknown or arguments invalid, 1244 authentication exchange cancelled 1246 The AUTHENTICATE command indicates a [SASL] authentication mechanism 1247 to the server. If the server supports the requested authentication 1248 mechanism, it performs an authentication protocol exchange to 1249 authenticate and identify the client. It MAY also negotiate an 1250 OPTIONAL security layer for subsequent protocol interactions. If the 1251 requested authentication mechanism is not supported, the server 1252 SHOULD reject the AUTHENTICATE command by sending a tagged NO 1253 response. 1255 The AUTHENTICATE command supports the optional "initial response" 1256 feature defined in Section 5.1 of [SASL]. The client doesn't need to 1257 use it. If a SASL mechanism supports "initial response", but it is 1258 not specified by the client, the server handles this as specified in 1259 Section 3 of [SASL]. 1261 The service name specified by this protocol's profile of [SASL] is 1262 "imap". 1264 The authentication protocol exchange consists of a series of server 1265 challenges and client responses that are specific to the 1266 authentication mechanism. A server challenge consists of a command 1267 continuation request response with the "+" token followed by a BASE64 1268 encoded (see Section 4 of [RFC4648]) string. The client response 1269 consists of a single line consisting of a BASE64 encoded string. If 1270 the client wishes to cancel an authentication exchange, it issues a 1271 line consisting of a single "*". If the server receives such a 1272 response, or if it receives an invalid BASE64 string (e.g. 1273 characters outside the BASE64 alphabet, or non-terminal "="), it MUST 1274 reject the AUTHENTICATE command by sending a tagged BAD response. 1276 As with any other client response, this initial response MUST be 1277 encoded as BASE64. It also MUST be transmitted outside of a quoted 1278 string or literal. To send a zero-length initial response, the 1279 client MUST send a single pad character ("="). This indicates that 1280 the response is present, but is a zero-length string. 1282 When decoding the BASE64 data in the initial response, decoding 1283 errors MUST be treated as in any normal SASL client response, i.e. 1284 with a tagged BAD response. In particular, the server should check 1285 for any characters not explicitly allowed by the BASE64 alphabet, as 1286 well as any sequence of BASE64 characters that contains the pad 1287 character ('=') anywhere other than the end of the string (e.g., 1288 "=AAA" and "AAA=BBB" are not allowed). 1290 If the client uses an initial response with a SASL mechanism that 1291 does not support an initial response, the server MUST reject the 1292 command with a tagged BAD response. 1294 If a security layer is negotiated through the [SASL] authentication 1295 exchange, it takes effect immediately following the CRLF that 1296 concludes the authentication exchange for the client, and the CRLF of 1297 the tagged OK response for the server. 1299 While client and server implementations MUST implement the 1300 AUTHENTICATE command itself, it is not required to implement any 1301 authentication mechanisms other than the PLAIN mechanism described in 1302 [PLAIN]. Also, an authentication mechanism is not required to 1303 support any security layers. 1305 Note: a server implementation MUST implement a configuration in 1306 which it does NOT permit any plaintext password mechanisms, unless 1307 either the STARTTLS command has been negotiated or some other 1308 mechanism that protects the session from password snooping has 1309 been provided. Server sites SHOULD NOT use any configuration 1310 which permits a plaintext password mechanism without such a 1311 protection mechanism against password snooping. Client and server 1312 implementations SHOULD implement additional [SASL] mechanisms that 1313 do not use plaintext passwords, such the GSSAPI mechanism 1314 described in [SASL] and/or the [DIGEST-MD5] mechanism. 1316 Servers and clients can support multiple authentication mechanisms. 1317 The server SHOULD list its supported authentication mechanisms in the 1318 response to the CAPABILITY command so that the client knows which 1319 authentication mechanisms to use. 1321 A server MAY include a CAPABILITY response code in the tagged OK 1322 response of a successful AUTHENTICATE command in order to send 1323 capabilities automatically. It is unnecessary for a client to send a 1324 separate CAPABILITY command if it recognizes these automatic 1325 capabilities. This should only be done if a security layer was not 1326 negotiated by the AUTHENTICATE command, because the tagged OK 1327 response as part of an AUTHENTICATE command is not protected by 1328 encryption/integrity checking. [SASL] requires the client to re- 1329 issue a CAPABILITY command in this case. The server MAY advertise 1330 different capabilities after a successful AUTHENTICATE command. 1332 If an AUTHENTICATE command fails with a NO response, the client MAY 1333 try another authentication mechanism by issuing another AUTHENTICATE 1334 command. It MAY also attempt to authenticate by using the LOGIN 1335 command (see Section 6.2.3 for more detail). In other words, the 1336 client MAY request authentication types in decreasing order of 1337 preference, with the LOGIN command as a last resort. 1339 The authorization identity passed from the client to the server 1340 during the authentication exchange is interpreted by the server as 1341 the user name whose privileges the client is requesting. 1343 Example: S: * OK IMAP4rev2 Server 1344 C: A001 AUTHENTICATE GSSAPI 1345 S: + 1346 C: YIIB+wYJKoZIhvcSAQICAQBuggHqMIIB5qADAgEFoQMCAQ6iBw 1347 MFACAAAACjggEmYYIBIjCCAR6gAwIBBaESGxB1Lndhc2hpbmd0 1348 b24uZWR1oi0wK6ADAgEDoSQwIhsEaW1hcBsac2hpdmFtcy5jYW 1349 Mud2FzaGluZ3Rvbi5lZHWjgdMwgdCgAwIBAaEDAgEDooHDBIHA 1350 cS1GSa5b+fXnPZNmXB9SjL8Ollj2SKyb+3S0iXMljen/jNkpJX 1351 AleKTz6BQPzj8duz8EtoOuNfKgweViyn/9B9bccy1uuAE2HI0y 1352 C/PHXNNU9ZrBziJ8Lm0tTNc98kUpjXnHZhsMcz5Mx2GR6dGknb 1353 I0iaGcRerMUsWOuBmKKKRmVMMdR9T3EZdpqsBd7jZCNMWotjhi 1354 vd5zovQlFqQ2Wjc2+y46vKP/iXxWIuQJuDiisyXF0Y8+5GTpAL 1355 pHDc1/pIGmMIGjoAMCAQGigZsEgZg2on5mSuxoDHEA1w9bcW9n 1356 FdFxDKpdrQhVGVRDIzcCMCTzvUboqb5KjY1NJKJsfjRQiBYBdE 1357 NKfzK+g5DlV8nrw81uOcP8NOQCLR5XkoMHC0Dr/80ziQzbNqhx 1358 O6652Npft0LQwJvenwDI13YxpwOdMXzkWZN/XrEqOWp6GCgXTB 1359 vCyLWLlWnbaUkZdEYbKHBPjd8t/1x5Yg== 1360 S: + YGgGCSqGSIb3EgECAgIAb1kwV6ADAgEFoQMCAQ+iSzBJoAMC 1361 AQGiQgRAtHTEuOP2BXb9sBYFR4SJlDZxmg39IxmRBOhXRKdDA0 1362 uHTCOT9Bq3OsUTXUlk0CsFLoa8j+gvGDlgHuqzWHPSQg== 1363 C: 1364 S: + YDMGCSqGSIb3EgECAgIBAAD/////6jcyG4GE3KkTzBeBiVHe 1365 ceP2CWY0SR0fAQAgAAQEBAQ= 1366 C: YDMGCSqGSIb3EgECAgIBAAD/////3LQBHXTpFfZgrejpLlLImP 1367 wkhbfa2QteAQAgAG1yYwE= 1368 S: A001 OK GSSAPI authentication successful 1370 Note: The line breaks within server challenges and client responses 1371 are for editorial clarity and are not in real authenticators. 1373 6.2.3. LOGIN Command 1375 Arguments: user name 1376 password 1378 Responses: no specific responses for this command 1380 Result: OK - login completed, now in authenticated state 1381 NO - login failure: user name or password rejected 1382 BAD - command unknown or arguments invalid 1384 The LOGIN command identifies the client to the server and carries the 1385 plaintext password authenticating this user. 1387 A server MAY include a CAPABILITY response code in the tagged OK 1388 response to a successful LOGIN command in order to send capabilities 1389 automatically. It is unnecessary for a client to send a separate 1390 CAPABILITY command if it recognizes these automatic capabilities. 1392 Example: C: a001 LOGIN SMITH SESAME 1393 S: a001 OK LOGIN completed 1395 Note: Use of the LOGIN command over an insecure network (such as the 1396 Internet) is a security risk, because anyone monitoring network 1397 traffic can obtain plaintext passwords. The LOGIN command SHOULD NOT 1398 be used except as a last resort, and it is recommended that client 1399 implementations have a means to disable any automatic use of the 1400 LOGIN command. 1402 Unless either the client is accessing IMAP service on IMAPS port 1403 [RFC8314], the STARTTLS command has been negotiated or some other 1404 mechanism that protects the session from password snooping has been 1405 provided, a server implementation MUST implement a configuration in 1406 which it advertises the LOGINDISABLED capability and does NOT permit 1407 the LOGIN command. Server sites SHOULD NOT use any configuration 1408 which permits the LOGIN command without such a protection mechanism 1409 against password snooping. A client implementation MUST NOT send a 1410 LOGIN command if the LOGINDISABLED capability is advertised. 1412 6.3. Client Commands - Authenticated State 1414 In the authenticated state, commands that manipulate mailboxes as 1415 atomic entities are permitted. Of these commands, the SELECT and 1416 EXAMINE commands will select a mailbox for access and enter the 1417 selected state. 1419 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 1420 the following commands are valid in the authenticated state: ENABLE, 1421 SELECT, EXAMINE, NAMESPACE, CREATE, DELETE, RENAME, SUBSCRIBE, 1422 UNSUBSCRIBE, LIST, LSUB, STATUS, APPEND and IDLE. 1424 6.3.1. ENABLE Command 1426 Arguments: capability names 1428 Responses: no specific responses for this command 1430 Result: OK - Relevant capabilities enabled 1431 BAD - No arguments, or syntax error in an argument 1433 Several IMAP extensions allow the server to return unsolicited 1434 responses specific to these extensions in certain circumstances. 1435 However, servers cannot send those unsolicited responses (with the 1436 exception of response codes included in tagged or untagged OK/NO/BAD 1437 responses, which can always be sent) until they know that the clients 1438 support such extensions and thus won't choke on the extension 1439 response data. 1441 The ENABLE command provides an explicit indication from the client 1442 that it supports particular extensions. 1444 The ENABLE command takes a list of capability names, and requests the 1445 server to enable the named extensions. Once enabled using ENABLE, 1446 each extension remains active until the IMAP connection is closed. 1447 For each argument, the server does the following: 1449 o If the argument is not an extension known to the server, the 1450 server MUST ignore the argument. 1452 o If the argument is an extension known to the server, and it is not 1453 specifically permitted to be enabled using ENABLE, the server MUST 1454 ignore the argument. (Note that knowing about an extension 1455 doesn't necessarily imply supporting that extension.) 1457 o If the argument is an extension that is supported by the server 1458 and that needs to be enabled, the server MUST enable the extension 1459 for the duration of the connection. Note that once an extension 1460 is enabled, there is no way to disable it. 1462 If the ENABLE command is successful, the server MUST send an untagged 1463 ENABLED response Section 7.2.1. 1465 Clients SHOULD only include extensions that need to be enabled by the 1466 server. For example, a client can enable IMAP4rev2 specific 1467 behaviour when both IMAP4rev1 and IMAP4rev2 are advertised in the 1468 CAPABILITY response. Future RFCs may add to this list. 1470 The ENABLE command is only valid in the authenticated state, before 1471 any mailbox is selected. Clients MUST NOT issue ENABLE once they 1472 SELECT/EXAMINE a mailbox; however, server implementations don't have 1473 to check that no mailbox is selected or was previously selected 1474 during the duration of a connection. 1476 The ENABLE command can be issued multiple times in a session. It is 1477 additive; i.e., "ENABLE a b", followed by "ENABLE c" is the same as a 1478 single command "ENABLE a b c". When multiple ENABLE commands are 1479 issued, each corresponding ENABLED response SHOULD only contain 1480 extensions enabled by the corresponding ENABLE command. 1482 There are no limitations on pipelining ENABLE. For example, it is 1483 possible to send ENABLE and then immediately SELECT, or a LOGIN 1484 immediately followed by ENABLE. 1486 The server MUST NOT change the CAPABILITY list as a result of 1487 executing ENABLE; i.e., a CAPABILITY command issued right after an 1488 ENABLE command MUST list the same capabilities as a CAPABILITY 1489 command issued before the ENABLE command. This is demonstrated in 1490 the following example: 1492 C: t1 CAPABILITY 1493 S: * CAPABILITY IMAP4rev1 ID LITERAL+ ENABLE X-GOOD-IDEA 1494 S: t1 OK foo 1495 C: t2 ENABLE CONDSTORE X-GOOD-IDEA 1496 S: * ENABLED X-GOOD-IDEA 1497 S: t2 OK foo 1498 C: t3 CAPABILITY 1499 S: * CAPABILITY IMAP4rev1 ID LITERAL+ ENABLE X-GOOD-IDEA 1500 S: t3 OK foo again 1502 In the following example, the client enables CONDSTORE: 1504 C: a1 ENABLE CONDSTORE 1505 S: * ENABLED CONDSTORE 1506 S: a1 OK Conditional Store enabled 1508 6.3.1.1. Note to Designers of Extensions That May Use the ENABLE 1509 Command 1511 Designers of IMAP extensions are discouraged from creating extensions 1512 that require ENABLE unless there is no good alternative design. 1513 Specifically, extensions that cause potentially incompatible behavior 1514 changes to deployed server responses (and thus benefit from ENABLE) 1515 have a higher complexity cost than extensions that do not. 1517 6.3.2. SELECT Command 1519 Arguments: mailbox name 1521 Responses: REQUIRED untagged responses: FLAGS, EXISTS 1522 REQUIRED OK untagged responses: PERMANENTFLAGS, 1523 UIDNEXT, UIDVALIDITY 1525 Result: OK - select completed, now in selected state 1526 NO - select failure, now in authenticated state: no 1527 such mailbox, can't access mailbox 1528 BAD - command unknown or arguments invalid 1530 The SELECT command selects a mailbox so that messages in the mailbox 1531 can be accessed. Before returning an OK to the client, the server 1532 MUST send the following untagged data to the client. Note that 1533 earlier versions of this protocol only required the FLAGS and EXISTS 1534 untagged data; consequently, client implementations SHOULD implement 1535 default behavior for missing data as discussed with the individual 1536 item. 1538 FLAGS Defined flags in the mailbox. See the description of the 1539 FLAGS response for more detail. 1541 EXISTS The number of messages in the mailbox. See the 1542 description of the EXISTS response for more detail. 1544 OK [PERMANENTFLAGS ()] A list of message flags that 1545 the client can change permanently. If this is missing, the client 1546 should assume that all flags can be changed permanently. 1548 OK [UIDNEXT ] The next unique identifier value. Refer to 1549 Section 2.3.1.1 for more information. If this is missing, the 1550 client can not make any assumptions about the next unique 1551 identifier value. 1553 OK [UIDVALIDITY ] The unique identifier validity value. Refer to 1554 Section 2.3.1.1 for more information. If this is missing, the 1555 server does not support unique identifiers. 1557 Only one mailbox can be selected at a time in a connection; 1558 simultaneous access to multiple mailboxes requires multiple 1559 connections. The SELECT command automatically deselects any 1560 currently selected mailbox before attempting the new selection. 1561 Consequently, if a mailbox is selected and a SELECT command that 1562 fails is attempted, no mailbox is selected. When deselecting a 1563 selected mailbox, the server MUST return an untagged OK response with 1564 the "[CLOSED]" response code when the currently selected mailbox is 1565 closed (see Paragraph 10). 1567 If the client is permitted to modify the mailbox, the server SHOULD 1568 prefix the text of the tagged OK response with the "[READ-WRITE]" 1569 response code. 1571 If the client is not permitted to modify the mailbox but is permitted 1572 read access, the mailbox is selected as read-only, and the server 1573 MUST prefix the text of the tagged OK response to SELECT with the 1574 "[READ-ONLY]" response code. Read-only access through SELECT differs 1575 from the EXAMINE command in that certain read-only mailboxes MAY 1576 permit the change of permanent state on a per-user (as opposed to 1577 global) basis. Netnews messages marked in a server-based .newsrc 1578 file are an example of such per-user permanent state that can be 1579 modified with read-only mailboxes. 1581 Example: C: A142 SELECT INBOX 1582 S: * 172 EXISTS 1583 S: * OK [UIDVALIDITY 3857529045] UIDs valid 1584 S: * OK [UIDNEXT 4392] Predicted next UID 1585 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1586 S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited 1587 S: A142 OK [READ-WRITE] SELECT completed 1589 6.3.3. EXAMINE Command 1591 Arguments: mailbox name 1593 Responses: REQUIRED untagged responses: FLAGS, EXISTS 1594 REQUIRED OK untagged responses: PERMANENTFLAGS, 1595 UIDNEXT, UIDVALIDITY 1597 Result: OK - examine completed, now in selected state 1598 NO - examine failure, now in authenticated state: no 1599 such mailbox, can't access mailbox BAD - command unknown 1600 or arguments invalid 1602 The EXAMINE command is identical to SELECT and returns the same 1603 output; however, the selected mailbox is identified as read-only. No 1604 changes to the permanent state of the mailbox, including per-user 1605 state, are permitted. 1607 The text of the tagged OK response to the EXAMINE command MUST begin 1608 with the "[READ-ONLY]" response code. 1610 Example: C: A932 EXAMINE blurdybloop 1611 S: * 17 EXISTS 1612 S: * OK [UIDVALIDITY 3857529045] UIDs valid 1613 S: * OK [UIDNEXT 4392] Predicted next UID 1614 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1615 S: * OK [PERMANENTFLAGS ()] No permanent flags permitted 1616 S: A932 OK [READ-ONLY] EXAMINE completed 1618 6.3.4. CREATE Command 1620 Arguments: mailbox name 1622 Responses: no specific responses for this command 1624 Result: OK - create completed 1625 NO - create failure: can't create mailbox with that name 1626 BAD - command unknown or arguments invalid 1628 The CREATE command creates a mailbox with the given name. An OK 1629 response is returned only if a new mailbox with that name has been 1630 created. It is an error to attempt to create INBOX or a mailbox with 1631 a name that refers to an extant mailbox. Any error in creation will 1632 return a tagged NO response. If a client attempts to create a UTF-8 1633 mailbox name that is not a valid Net-Unicode name, the server MUST 1634 reject the creation or convert the name to Net-Unicode prior to 1635 creating the mailbox. 1637 If the mailbox name is suffixed with the server's hierarchy separator 1638 character (as returned from the server by a LIST command), this is a 1639 declaration that the client intends to create mailbox names under 1640 this name in the hierarchy. Server implementations that do not 1641 require this declaration MUST ignore the declaration. In any case, 1642 the name created is without the trailing hierarchy delimiter. 1644 If the server's hierarchy separator character appears elsewhere in 1645 the name, the server SHOULD create any superior hierarchical names 1646 that are needed for the CREATE command to be successfully completed. 1647 In other words, an attempt to create "foo/bar/zap" on a server in 1648 which "/" is the hierarchy separator character SHOULD create foo/ and 1649 foo/bar/ if they do not already exist. 1651 If a new mailbox is created with the same name as a mailbox which was 1652 deleted, its unique identifiers MUST be greater than any unique 1653 identifiers used in the previous incarnation of the mailbox UNLESS 1654 the new incarnation has a different unique identifier validity value. 1655 See the description of the UID command for more detail. 1657 Example: C: A003 CREATE owatagusiam/ 1658 S: A003 OK CREATE completed 1659 C: A004 CREATE owatagusiam/blurdybloop 1660 S: A004 OK CREATE completed 1662 Note: The interpretation of this example depends on whether "/" 1663 was returned as the hierarchy separator from LIST. If "/" is the 1664 hierarchy separator, a new level of hierarchy named "owatagusiam" 1665 with a member called "blurdybloop" is created. Otherwise, two 1666 mailboxes at the same hierarchy level are created. 1668 6.3.5. DELETE Command 1670 Arguments: mailbox name 1672 Responses: no specific responses for this command 1674 Result: OK - delete completed 1675 NO - delete failure: can't delete mailbox with that name 1676 BAD - command unknown or arguments invalid 1678 The DELETE command permanently removes the mailbox with the given 1679 name. A tagged OK response is returned only if the mailbox has been 1680 deleted. It is an error to attempt to delete INBOX or a mailbox name 1681 that does not exist. 1683 The DELETE command MUST NOT remove inferior hierarchical names. For 1684 example, if a mailbox "foo" has an inferior "foo.bar" (assuming "." 1685 is the hierarchy delimiter character), removing "foo" MUST NOT remove 1686 "foo.bar". It is an error to attempt to delete a name that has 1687 inferior hierarchical names and also has the \Noselect mailbox name 1688 attribute (see the description of the LIST response for more 1689 details). 1691 It is permitted to delete a name that has inferior hierarchical names 1692 and does not have the \Noselect mailbox name attribute. If the 1693 server implementation does not permit deleting the name while 1694 inferior hierarchical names exists the \Noselect mailbox name 1695 attribute is set for that name. In any case, all messages in that 1696 mailbox are removed by the DELETE command. 1698 The value of the highest-used unique identifier of the deleted 1699 mailbox MUST be preserved so that a new mailbox created with the same 1700 name will not reuse the identifiers of the former incarnation, UNLESS 1701 the new incarnation has a different unique identifier validity value. 1702 See the description of the UID command for more detail. 1704 Examples: C: A682 LIST "" * 1705 S: * LIST () "/" blurdybloop 1706 S: * LIST (\Noselect) "/" foo 1707 S: * LIST () "/" foo/bar 1708 S: A682 OK LIST completed 1709 C: A683 DELETE blurdybloop 1710 S: A683 OK DELETE completed 1711 C: A684 DELETE foo 1712 S: A684 NO Name "foo" has inferior hierarchical names 1713 C: A685 DELETE foo/bar 1714 S: A685 OK DELETE Completed 1715 C: A686 LIST "" * 1716 S: * LIST (\Noselect) "/" foo 1717 S: A686 OK LIST completed 1718 C: A687 DELETE foo 1719 S: A687 OK DELETE Completed 1720 C: A82 LIST "" * 1721 S: * LIST () "." blurdybloop 1722 S: * LIST () "." foo 1723 S: * LIST () "." foo.bar 1724 S: A82 OK LIST completed 1725 C: A83 DELETE blurdybloop 1726 S: A83 OK DELETE completed 1727 C: A84 DELETE foo 1728 S: A84 OK DELETE Completed 1729 C: A85 LIST "" * 1730 S: * LIST () "." foo.bar 1731 S: A85 OK LIST completed 1732 C: A86 LIST "" % 1733 S: * LIST (\Noselect) "." foo 1734 S: A86 OK LIST completed 1736 6.3.6. RENAME Command 1738 Arguments: existing mailbox name 1739 new mailbox name 1741 Responses: no specific responses for this command 1743 Result: OK - rename completed 1744 NO - rename failure: can't rename mailbox with that name, 1745 can't rename to mailbox with that name 1746 BAD - command unknown or arguments invalid 1748 The RENAME command changes the name of a mailbox. A tagged OK 1749 response is returned only if the mailbox has been renamed. It is an 1750 error to attempt to rename from a mailbox name that does not exist or 1751 to a mailbox name that already exists. Any error in renaming will 1752 return a tagged NO response. 1754 If the name has inferior hierarchical names, then the inferior 1755 hierarchical names MUST also be renamed. For example, a rename of 1756 "foo" to "zap" will rename "foo/bar" (assuming "/" is the hierarchy 1757 delimiter character) to "zap/bar". 1759 If the server's hierarchy separator character appears in the name, 1760 the server SHOULD create any superior hierarchical names that are 1761 needed for the RENAME command to complete successfully. In other 1762 words, an attempt to rename "foo/bar/zap" to baz/rag/zowie on a 1763 server in which "/" is the hierarchy separator character SHOULD 1764 create baz/ and baz/rag/ if they do not already exist. 1766 The value of the highest-used unique identifier of the old mailbox 1767 name MUST be preserved so that a new mailbox created with the same 1768 name will not reuse the identifiers of the former incarnation, UNLESS 1769 the new incarnation has a different unique identifier validity value. 1770 See the description of the UID command for more detail. 1772 Renaming INBOX is permitted, and has special behavior. It moves all 1773 messages in INBOX to a new mailbox with the given name, leaving INBOX 1774 empty. If the server implementation supports inferior hierarchical 1775 names of INBOX, these are unaffected by a rename of INBOX. 1777 Examples: C: A682 LIST "" * 1778 S: * LIST () "/" blurdybloop 1779 S: * LIST (\Noselect) "/" foo 1780 S: * LIST () "/" foo/bar 1781 S: A682 OK LIST completed 1782 C: A683 RENAME blurdybloop sarasoop 1783 S: A683 OK RENAME completed 1784 C: A684 RENAME foo zowie 1785 S: A684 OK RENAME Completed 1786 C: A685 LIST "" * 1787 S: * LIST () "/" sarasoop 1788 S: * LIST (\Noselect) "/" zowie 1789 S: * LIST () "/" zowie/bar 1790 S: A685 OK LIST completed 1792 C: Z432 LIST "" * 1793 S: * LIST () "." INBOX 1794 S: * LIST () "." INBOX.bar 1795 S: Z432 OK LIST completed 1796 C: Z433 RENAME INBOX old-mail 1797 S: Z433 OK RENAME completed 1798 C: Z434 LIST "" * 1799 S: * LIST () "." INBOX 1800 S: * LIST () "." INBOX.bar 1801 S: * LIST () "." old-mail 1802 S: Z434 OK LIST completed 1804 6.3.7. SUBSCRIBE Command 1806 Arguments: mailbox 1808 Responses: no specific responses for this command 1810 Result: OK - subscribe completed 1811 NO - subscribe failure: can't subscribe to that name 1812 BAD - command unknown or arguments invalid 1814 The SUBSCRIBE command adds the specified mailbox name to the server's 1815 set of "active" or "subscribed" mailboxes as returned by the LSUB 1816 command. This command returns a tagged OK response only if the 1817 subscription is successful. 1819 A server MAY validate the mailbox argument to SUBSCRIBE to verify 1820 that it exists. However, it MUST NOT unilaterally remove an existing 1821 mailbox name from the subscription list even if a mailbox by that 1822 name no longer exists. 1824 Note: This requirement is because a server site can choose to 1825 routinely remove a mailbox with a well-known name (e.g., "system- 1826 alerts") after its contents expire, with the intention of 1827 recreating it when new contents are appropriate. 1829 Example: C: A002 SUBSCRIBE #news.comp.mail.mime 1830 S: A002 OK SUBSCRIBE completed 1832 6.3.8. UNSUBSCRIBE Command 1834 Arguments: mailbox name 1836 Responses: no specific responses for this command 1838 Result: OK - unsubscribe completed 1839 NO - unsubscribe failure: can't unsubscribe that name 1840 BAD - command unknown or arguments invalid 1842 The UNSUBSCRIBE command removes the specified mailbox name from the 1843 server's set of "active" or "subscribed" mailboxes as returned by the 1844 LSUB command. This command returns a tagged OK response only if the 1845 unsubscription is successful. 1847 Example: C: A002 UNSUBSCRIBE #news.comp.mail.mime 1848 S: A002 OK UNSUBSCRIBE completed 1850 6.3.9. LIST Command 1852 Arguments (basic): reference name 1853 mailbox name with possible wildcards 1855 Arguments (extended): selection options (OPTIONAL) 1856 reference name 1857 mailbox patterns 1858 return options (OPTIONAL) 1860 Responses: untagged responses: LIST 1862 Result: OK - list completed 1863 NO - list failure: can't list that reference or name 1864 BAD - command unknown or arguments invalid 1866 THIS VERSION HAS ONLY AN INITIAL PASS AT ADDING THE EXTENDED LIST 1867 SYNTAX AND OPTIONS. THERE'S STILL A GOOD DEAL OR WORK TO DO ON IT, 1868 AND THE ABNF IS NOT THERE YET. 1870 The LIST command returns a subset of names from the complete set of 1871 all names available to the client. Zero or more untagged LIST 1872 replies are returned, containing the name attributes, hierarchy 1873 delimiter, and name; see the description of the LIST reply for more 1874 detail. 1876 The LIST command SHOULD return its data quickly, without undue delay. 1877 For example, it SHOULD NOT go to excess trouble to calculate the 1878 \Marked or \Unmarked status or perform other processing; if each name 1879 requires 1 second of processing, then a list of 1200 names would take 1880 20 minutes! 1882 The extended LIST command, introduced in [RFC5258] provides 1883 capabilities beyond that of the original IMAP LIST command. The 1884 extended syntax is being used if one of the following conditions is 1885 true: 1887 1. if the first word after the command name begins with a 1888 parenthesis ("LIST selection options") 1890 2. if the second word after the command name begins with a 1891 parenthesis ("multiple mailbox patterns") 1893 3. if the LIST command has more than 2 parameters ("LIST return 1894 options") 1896 An empty ("" string) reference name argument indicates that the 1897 mailbox name is interpreted as by SELECT. The returned mailbox names 1898 MUST match the supplied mailbox name pattern(s). A non-empty 1899 reference name argument is the name of a mailbox or a level of 1900 mailbox hierarchy, and indicates the context in which the mailbox 1901 name is interpreted. 1903 In the basic syntax only, an empty ("" string) mailbox name argument 1904 is a special request to return the hierarchy delimiter and the root 1905 name of the name given in the reference. The value returned as the 1906 root MAY be the empty string if the reference is non-rooted or is an 1907 empty string. In all cases, a hierarchy delimiter (or NIL if there 1908 is no hierarchy) is returned. This permits a client to get the 1909 hierarchy delimiter (or find out that the mailbox names are flat) 1910 even when no mailboxes by that name currently exist. 1912 In the extended syntax, any mailbox name arguments that are empty 1913 strings are ignored. There is no special meaning for empty mailbox 1914 names when the extended syntax is used. 1916 The reference and mailbox name arguments are interpreted into a 1917 canonical form that represents an unambiguous left-to-right 1918 hierarchy. The returned mailbox names will be in the interpreted 1919 form. 1921 Note: The interpretation of the reference argument is 1922 implementation-defined. It depends upon whether the server 1923 implementation has a concept of the "current working directory" 1924 and leading "break out characters", which override the current 1925 working directory. 1927 For example, on a server which exports a UNIX or NT filesystem, 1928 the reference argument contains the current working directory, and 1929 the mailbox name argument would contain the name as interpreted in 1930 the current working directory. 1932 If a server implementation has no concept of break out characters, 1933 the canonical form is normally the reference name appended with 1934 the mailbox name. Note that if the server implements the 1935 namespace convention (Section 5.1.2.1), "#" is a break out 1936 character and must be treated as such. 1938 If the reference argument is not a level of mailbox hierarchy 1939 (that is, it is a \NoInferiors name), and/or the reference 1940 argument does not end with the hierarchy delimiter, it is 1941 implementation-dependent how this is interpreted. For example, a 1942 reference of "foo/bar" and mailbox name of "rag/baz" could be 1943 interpreted as "foo/bar/rag/baz", "foo/barrag/baz", or "foo/rag/ 1944 baz". A client SHOULD NOT use such a reference argument except at 1945 the explicit request of the user. A hierarchical browser MUST NOT 1946 make any assumptions about server interpretation of the reference 1947 unless the reference is a level of mailbox hierarchy AND ends with 1948 the hierarchy delimiter. 1950 Any part of the reference argument that is included in the 1951 interpreted form SHOULD prefix the interpreted form. It SHOULD also 1952 be in the same form as the reference name argument. This rule 1953 permits the client to determine if the returned mailbox name is in 1954 the context of the reference argument, or if something about the 1955 mailbox argument overrode the reference argument. Without this rule, 1956 the client would have to have knowledge of the server's naming 1957 semantics including what characters are "breakouts" that override a 1958 naming context. 1960 For example, here are some examples of how references 1961 and mailbox names might be interpreted on a UNIX-based 1962 server: 1964 Reference Mailbox Name Interpretation 1965 ------------ ------------ -------------- 1966 ~smith/Mail/ foo.* ~smith/Mail/foo.* 1967 archive/ % archive/% 1968 #news. comp.mail.* #news.comp.mail.* 1969 ~smith/Mail/ /usr/doc/foo /usr/doc/foo 1970 archive/ ~fred/Mail/* ~fred/Mail/* 1972 The first three examples demonstrate interpretations in 1973 the context of the reference argument. Note that 1974 "~smith/Mail" SHOULD NOT be transformed into something 1975 like "/u2/users/smith/Mail", or it would be impossible 1976 for the client to determine that the interpretation was 1977 in the context of the reference. 1979 The character "*" is a wildcard, and matches zero or more characters 1980 at this position. The character "%" is similar to "*", but it does 1981 not match a hierarchy delimiter. If the "%" wildcard is the last 1982 character of a mailbox name argument, matching levels of hierarchy 1983 are also returned. If these levels of hierarchy are not also 1984 selectable mailboxes, they are returned with the \Noselect mailbox 1985 name attribute (see the description of the LIST response for more 1986 details). 1988 If multiple mailbox patterns are used (in the extended syntax), a 1989 mailbox matches if it matches at least one mailbox pattern. If a 1990 mailbox matches more than one pattern, it is still only returned 1991 once. Any syntactically valid pattern that is not accepted by a 1992 server for any reason MUST be silently ignored. 1994 Selection options tell the server to limit the mailbox names that are 1995 selected by the LIST operation. If selection options are used, the 1996 mailboxes returned are those that match both the list of mailbox 1997 patterns and the selection options. Unless a particular selection 1998 option provides special rules, the selection options are cumulative: 1999 a mailbox that matches the mailbox patterns is selected only if it 2000 also matches all of the selection options. (An example of a 2001 selection option with special rules is the RECURSIVEMATCH option.) 2003 Return options control what information is returned for each matched 2004 mailbox. Return options MUST NOT cause the server to report 2005 information about additional mailbox names other than those that 2006 match the patterns and selection options. If no return options are 2007 specified, the client is only expecting information about mailbox 2008 attributes. The server MAY return other information about the 2009 matched mailboxes, and clients MUST be able to handle that situation. 2011 Initial selection options and return options are defined in the 2012 following subsections, and new ones will also be defined in 2013 extensions. Initial options MUST be supported. Each non-initial 2014 option will be enabled by a capability string (one capability may 2015 enable multiple options), and a client MUST NOT send an option for 2016 which the server has not advertised support. A server MUST respond 2017 to options it does not recognize with a BAD response. The client 2018 SHOULD NOT specify any option more than once; however, if the client 2019 does this, the server MUST act as if it received the option only 2020 once. The order in which options are specified by the client is not 2021 significant. 2023 In general, each selection option except RECURSIVEMATCH will have a 2024 corresponding return option. The REMOTE selection option is an 2025 anomaly in this regard, and does not have a corresponding return 2026 option. That is because it expands, rather than restricts, the set 2027 of mailboxes that are returned. Future extensions to this 2028 specification should keep parallelism in mind and define a pair of 2029 corresponding options. 2031 Server implementations are permitted to "hide" otherwise accessible 2032 mailboxes from the wildcard characters, by preventing certain 2033 characters or names from matching a wildcard in certain situations. 2034 For example, a UNIX-based server might restrict the interpretation of 2035 "*" so that an initial "/" character does not match. 2037 The special name INBOX is included in the output from LIST, if INBOX 2038 is supported by this server for this user and if the uppercase string 2039 "INBOX" matches the interpreted reference and mailbox name arguments 2040 with wildcards as described above. The criteria for omitting INBOX 2041 is whether SELECT INBOX will return failure; it is not relevant 2042 whether the user's real INBOX resides on this or some other server. 2044 6.3.9.1. LIST Selection Options 2046 The selection options defined in this specification are as follows: 2048 SUBSCRIBED - causes the LIST command to list subscribed names, 2049 rather than the existing mailboxes. This will often be a subset 2050 of the actual mailboxes. It's also possible for this list to 2051 contain the names of mailboxes that don't exist. In any case, the 2052 list MUST include exactly those mailbox names that match the 2053 canonical list pattern and are subscribed to. This option is 2054 intended to supplement the LSUB command. Of particular note are 2055 the mailbox attributes as returned by this option, compared with 2056 what is returned by LSUB. With the latter, the attributes 2057 returned may not reflect the actual attribute status on the 2058 mailbox name, and the \NoSelect attribute has a second special 2059 meaning (it indicates that this mailbox is not, itself, 2060 subscribed, but that it has descendant mailboxes that are). With 2061 the SUBSCRIBED selection option described here, the attributes are 2062 accurate and complete, and have no special meanings. "LSUB" and 2063 "LIST (SUBSCRIBED)" are, thus, not the same thing, and some 2064 servers must do significant extra work to respond to "LIST 2065 (SUBSCRIBED)". Because of this, clients SHOULD continue to use 2066 "LSUB" unless they specifically want the additional information 2067 offered by "LIST (SUBSCRIBED)". 2069 This option defines a new mailbox attribute, "\Subscribed", that 2070 indicates that a mailbox name is subscribed to. The "\Subscribed" 2071 attribute MUST be supported and MUST be accurately computed when 2072 the SUBSCRIBED selection option is specified. 2074 Note that the SUBSCRIBED selection option implies the SUBSCRIBED 2075 return option (see below). 2077 REMOTE - causes the LIST command to show remote mailboxes as well as 2078 local ones, as described in [RFC2193]. This option is intended to 2079 replace the RLIST command and, in conjunction with the SUBSCRIBED 2080 selection option, the RLSUB command. 2082 This option defines a new mailbox attribute, "\Remote", that 2083 indicates that a mailbox is a remote mailbox. The "\Remote" 2084 attribute MUST be accurately computed when the REMOTE option is 2085 specified. 2087 The REMOTE selection option has no interaction with other options. 2088 Its effect is to tell the server to apply the other options, if 2089 any, to remote mailboxes, in addition to local ones. In 2090 particular, it has no interaction with RECURSIVEMATCH (see below). 2091 A request for (REMOTE RECURSIVEMATCH) is invalid, because a 2092 request for (RECURSIVEMATCH) is. A request for (REMOTE 2093 RECURSIVEMATCH SUBSCRIBED) is asking for all subscribed mailboxes, 2094 both local and remote. 2096 RECURSIVEMATCH - this option forces the server to return information 2097 about parent mailboxes that don't match other selection options, 2098 but have some submailboxes that do. Information about children is 2099 returned in the CHILDINFO extended data item, as described in 2100 Section 6.3.9.5. 2102 Note 1: In order for a parent mailbox to be returned, it still has 2103 to match the canonical LIST pattern. 2105 Note 2: When returning the CHILDINFO extended data item, it 2106 doesn't matter whether or not the submailbox matches the canonical 2107 LIST pattern. See also example 9 in Section 6.3.9.6. 2109 The RECURSIVEMATCH option MUST NOT occur as the only selection 2110 option (or only with REMOTE), as it only makes sense when other 2111 selection options are also used. The server MUST return BAD 2112 tagged response in such case. 2114 Note that even if the RECURSIVEMATCH option is specified, the 2115 client MUST still be able to handle a case when a CHILDINFO 2116 extended data item is returned and there are no submailboxes that 2117 meet the selection criteria of the subsequent LIST command, as 2118 they can be deleted/renamed after the LIST response was sent, but 2119 before the client had a chance to access them. 2121 6.3.9.2. LIST Return Options 2123 The return options defined in this specification are as follows: 2125 SUBSCRIBED - causes the LIST command to return subscription state 2126 for all matching mailbox names. The "\Subscribed" attribute MUST 2127 be supported and MUST be accurately computed when the SUBSCRIBED 2128 return option is specified. Further, all mailbox flags MUST be 2129 accurately computed (this differs from the behavior of the LSUB 2130 command). 2132 CHILDREN - requests mailbox child information as originally proposed 2133 in [RFC3348]. See Section 6.3.9.4, below, for details. This 2134 option MUST be supported by all servers. 2136 6.3.9.3. General Principles for Returning LIST Responses 2138 This section outlines several principles that can be used by server 2139 implementations of this document to decide whether a LIST response 2140 should be returned, as well as how many responses and what kind of 2141 information they may contain. 2143 1. At most one LIST response should be returned for each mailbox 2144 name that matches the canonical LIST pattern. Server 2145 implementors must not assume that clients will be able to 2146 assemble mailbox attributes and other information returned in 2147 multiple LIST responses. 2149 2. There are only two reasons for including a matching mailbox name 2150 in the responses to the LIST command (note that the server is 2151 allowed to return unsolicited responses at any time, and such 2152 responses are not governed by this rule): 2154 A. The mailbox name also satisfies the selection criteria. 2156 B. The mailbox name doesn't satisfy the selection criteria, but 2157 it has at least one descendant mailbox name that satisfies 2158 the selection criteria and that doesn't match the canonical 2159 LIST pattern. 2161 For more information on this case, see the CHILDINFO extended 2162 data item described in Section 6.3.9.5. Note that the 2163 CHILDINFO extended data item can only be returned when the 2164 RECURSIVEMATCH selection option is specified. 2166 3. Attributes returned in the same LIST response must be treated 2167 additively. For example, the following response 2169 S: * LIST (\Subscribed \NonExistent) "/" "Fruit/Peach" 2171 means that the "Fruit/Peach" mailbox doesn't exist, but it is 2172 subscribed. 2174 6.3.9.4. The CHILDREN Return Option 2176 The CHILDREN return option implements the Child Mailbox Extension, 2177 originally proposed by Mike Gahrns and Raymond Cheng, of Microsoft 2178 Corporation. Most of the information in this section is taken 2179 directly from their original specification [RFC3348]. The CHILDREN 2180 return option is simply an indication that the client wants this 2181 information; a server MAY provide it even if the option is not 2182 specified. 2184 Many IMAP4 clients present to the user a hierarchical view of the 2185 mailboxes that a user has access to. Rather than initially 2186 presenting to the user the entire mailbox hierarchy, it is often 2187 preferable to show to the user a collapsed outline list of the 2188 mailbox hierarchy (particularly if there is a large number of 2189 mailboxes). The user can then expand the collapsed outline hierarchy 2190 as needed. It is common to include within the collapsed hierarchy a 2191 visual clue (such as a ''+'') to indicate that there are child 2192 mailboxes under a particular mailbox. When the visual clue is 2193 clicked, the hierarchy list is expanded to show the child mailboxes. 2194 The CHILDREN return option provides a mechanism for a client to 2195 efficiently determine whether a particular mailbox has children, 2196 without issuing a LIST "" * or a LIST "" % for each mailbox name. 2197 The CHILDREN return option defines two new attributes that MUST be 2198 returned within a LIST response: \HasChildren and \HasNoChildren. 2200 Although these attributes MAY be returned in response to any LIST 2201 command, the CHILDREN return option is provided to indicate that the 2202 client particularly wants this information. If the CHILDREN return 2203 option is present, the server MUST return these attributes even if 2204 their computation is expensive. 2206 \HasChildren 2208 The presence of this attribute indicates that the mailbox has 2209 child mailboxes. A server SHOULD NOT set this attribute if 2210 there are child mailboxes and the user does not have permission 2211 to access any of them. In this case, \HasNoChildren SHOULD be 2212 used. In many cases, however, a server may not be able to 2213 efficiently compute whether a user has access to any child 2214 mailbox. Note that even though the \HasChildren attribute for a 2215 mailbox must be correct at the time of processing of the 2216 mailbox, a client must be prepared to deal with a situation when 2217 a mailbox is marked with the \HasChildren attribute, but no 2218 child mailbox appears in the response to the LIST command. This 2219 might happen, for example, due to children mailboxes being 2220 deleted or made inaccessible to the user (using access control) 2221 by another client before the server is able to list them. 2223 \HasNoChildren 2225 The presence of this attribute indicates that the mailbox has NO 2226 child mailboxes that are accessible to the currently 2227 authenticated user. 2229 It is an error for the server to return both a \HasChildren and a 2230 \HasNoChildren attribute in the same LIST response. 2232 Note: the \HasNoChildren attribute should not be confused with the 2233 IMAP4 defined attribute \NoInferiors, which indicates that no child 2234 mailboxes exist now and none can be created in the future. 2236 6.3.9.5. CHILDINFO Extended Data Item 2238 The CHILDINFO extended data item MUST NOT be returned unless the 2239 client has specified the RECURSIVEMATCH selection option. 2241 The CHILDINFO extended data item in a LIST response describes the 2242 selection criteria that has caused it to be returned and indicates 2243 that the mailbox has at least one descendant mailbox that matches the 2244 selection criteria. 2246 The LSUB command indicates this condition by using the "\NoSelect" 2247 attribute, but the LIST (SUBSCRIBED) command MUST NOT do that, since 2248 "\NoSelect" retains its original meaning here. Further, the 2249 CHILDINFO extended data item is more general, in that it can be used 2250 with any extended set of selection criteria. 2252 Note: Some servers allow for mailboxes to exist without requiring 2253 their parent to exist. For example, a mailbox "Customers/ABC" can 2254 exist while the mailbox "Customers" does not. As CHILDINFO extended 2255 data item is not allowed if the RECURSIVEMATCH selection option is 2256 not specified, such servers SHOULD use the "\NonExistent 2257 \HasChildren" attribute pair to signal to the client that there is a 2258 descendant mailbox that matches the selection criteria. See example 2259 11 in Section 6.3.9.6. 2261 The returned selection criteria allow the client to distinguish a 2262 solicited response from an unsolicited one, as well as to distinguish 2263 among solicited responses caused by multiple pipelined LIST commands 2264 that specify different criteria. 2266 Servers SHOULD ONLY return a non-matching mailbox name along with 2267 CHILDINFO if at least one matching child is not also being returned. 2268 That is, servers SHOULD suppress redundant CHILDINFO responses. 2270 Examples 8 and 10 in Section 6.3.9.6 demonstrate the difference 2271 between present CHILDINFO extended data item and the "\HasChildren" 2272 attribute. 2274 The following table summarizes interaction between the "\NonExistent" 2275 attribute and CHILDINFO (the first column indicates whether the 2276 parent mailbox exists): 2278 +--------+--------------+--------------------+----------------------+ 2279 | exists | meets the | has a child that | returned LIST- | 2280 | | selection | meets the | EXTENDED attributes | 2281 | | criteria | selection criteria | and CHILDINFO | 2282 +--------+--------------+--------------------+----------------------+ 2283 | no | no | no | no LIST response | 2284 | | | | returned | 2285 | yes | no | no | no LIST response | 2286 | | | | returned | 2287 | no | yes | no | (\NonExistent | 2288 | | | | ) | 2289 | yes | yes | no | () | 2290 | no | no | yes | (\NonExistent) + | 2291 | | | | CHILDINFO | 2292 | yes | no | yes | () + CHILDINFO | 2293 | no | yes | yes | (\NonExistent | 2294 | | | | ) + CHILDINFO | 2295 | yes | yes | yes | () + CHILDINFO | 2296 +--------+--------------+--------------------+----------------------+ 2298 where is one or more attributes that correspond to the 2299 selection criteria; for example, for the SUBSCRIBED option the 2300 is \Subscribed. 2302 6.3.9.6. LIST Command Examples 2304 This example shows some uses of the basic LIST command: 2306 Example: C: A101 LIST "" "" 2307 S: * LIST (\Noselect) "/" "" 2308 S: A101 OK LIST Completed 2309 C: A102 LIST #news.comp.mail.misc "" 2310 S: * LIST (\Noselect) "." #news. 2311 S: A102 OK LIST Completed 2312 C: A103 LIST /usr/staff/jones "" 2313 S: * LIST (\Noselect) "/" / 2314 S: A103 OK LIST Completed 2315 C: A202 LIST ~/Mail/ % 2316 S: * LIST (\Noselect) "/" ~/Mail/foo 2317 S: * LIST () "/" ~/Mail/meetings 2318 S: A202 OK LIST completed 2320 Extended examples: 2322 1: The first example shows the complete local hierarchy that will 2323 be used for the other examples. 2325 C: A01 LIST "" "*" 2326 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2327 S: * LIST () "/" "Fruit" 2328 S: * LIST () "/" "Fruit/Apple" 2329 S: * LIST () "/" "Fruit/Banana" 2330 S: * LIST () "/" "Tofu" 2331 S: * LIST () "/" "Vegetable" 2332 S: * LIST () "/" "Vegetable/Broccoli" 2333 S: * LIST () "/" "Vegetable/Corn" 2334 S: A01 OK done 2336 2: In the next example, we will see the subscribed mailboxes. This 2337 is similar to, but not equivalent with, . Note 2338 that the mailbox called "Fruit/Peach" is subscribed to, but does 2339 not actually exist (perhaps it was deleted while still 2340 subscribed). The "Fruit" mailbox is not subscribed to, but it 2341 has two subscribed children. The "Vegetable" mailbox is 2342 subscribed and has two children; one of them is subscribed as 2343 well. 2345 C: A02 LIST (SUBSCRIBED) "" "*" 2346 S: * LIST (\Marked \NoInferiors \Subscribed) "/" "inbox" 2347 S: * LIST (\Subscribed) "/" "Fruit/Banana" 2348 S: * LIST (\Subscribed \NonExistent) "/" "Fruit/Peach" 2349 S: * LIST (\Subscribed) "/" "Vegetable" 2350 S: * LIST (\Subscribed) "/" "Vegetable/Broccoli" 2351 S: A02 OK done 2353 3: The next example shows the use of the CHILDREN option. The 2354 client, without having to list the second level of hierarchy, 2355 now knows which of the top-level mailboxes have submailboxes 2356 (children) and which do not. Note that it's not necessary for 2357 the server to return the \HasNoChildren attribute for the inbox, 2358 because the \NoInferiors attribute already implies that, and has 2359 a stronger meaning. 2361 C: A03 LIST () "" "%" RETURN (CHILDREN) 2362 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2363 S: * LIST (\HasChildren) "/" "Fruit" 2364 S: * LIST (\HasNoChildren) "/" "Tofu" 2365 S: * LIST (\HasChildren) "/" "Vegetable" 2366 S: A03 OK done 2368 4: In this example, we see more mailboxes that reside on another 2369 server. This is similar to the command . 2371 C: A04 LIST (REMOTE) "" "%" RETURN (CHILDREN) 2372 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2373 S: * LIST (\HasChildren) "/" "Fruit" 2374 S: * LIST (\HasNoChildren) "/" "Tofu" 2375 S: * LIST (\HasChildren) "/" "Vegetable" 2376 S: * LIST (\Remote) "/" "Bread" 2377 S: * LIST (\HasChildren \Remote) "/" "Meat" 2378 S: A04 OK done 2380 5: The following example also requests the server to include 2381 mailboxes that reside on another server. The server returns 2382 information about all mailboxes that are subscribed. This is 2383 similar to the command . We also see the use of 2384 two selection options. 2386 C: A05 LIST (REMOTE SUBSCRIBED) "" "*" 2387 S: * LIST (\Marked \NoInferiors \Subscribed) "/" "inbox" 2388 S: * LIST (\Subscribed) "/" "Fruit/Banana" 2389 S: * LIST (\Subscribed \NonExistent) "/" "Fruit/Peach" 2390 S: * LIST (\Subscribed) "/" "Vegetable" 2391 S: * LIST (\Subscribed) "/" "Vegetable/Broccoli" 2392 S: * LIST (\Remote \Subscribed) "/" "Bread" 2393 S: A05 OK done 2395 6: The following example requests the server to include mailboxes 2396 that reside on another server. The server is asked to return 2397 subscription information for all returned mailboxes. This is 2398 different from the example above. 2400 Note that the output of this command is not a superset of the 2401 output in the previous example, as it doesn't include LIST 2402 response for the non-existent "Fruit/Peach". 2404 C: A06 LIST (REMOTE) "" "*" RETURN (SUBSCRIBED) 2405 S: * LIST (\Marked \NoInferiors \Subscribed) "/" "inbox" 2406 S: * LIST () "/" "Fruit" 2407 S: * LIST () "/" "Fruit/Apple" 2408 S: * LIST (\Subscribed) "/" "Fruit/Banana" 2409 S: * LIST () "/" "Tofu" 2410 S: * LIST (\Subscribed) "/" "Vegetable" 2411 S: * LIST (\Subscribed) "/" "Vegetable/Broccoli" 2412 S: * LIST () "/" "Vegetable/Corn" 2413 S: * LIST (\Remote \Subscribed) "/" "Bread" 2414 S: * LIST (\Remote) "/" "Meat" 2415 S: A06 OK done 2417 7: In the following example, the client has specified multiple 2418 mailbox patterns. Note that this example does not use the 2419 mailbox hierarchy used in the previous examples. 2421 C: BBB LIST "" ("INBOX" "Drafts" "Sent/%") 2422 S: * LIST () "/" "INBOX" 2423 S: * LIST (\NoInferiors) "/" "Drafts" 2424 S: * LIST () "/" "Sent/March2004" 2425 S: * LIST (\Marked) "/" "Sent/December2003" 2426 S: * LIST () "/" "Sent/August2004" 2427 S: BBB OK done 2429 8: The following example demonstrates the difference between the 2430 \HasChildren attribute and the CHILDINFO extended data item. 2432 Let's assume there is the following hierarchy: 2434 C: C01 LIST "" "*" 2435 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2436 S: * LIST () "/" "Foo" 2437 S: * LIST () "/" "Foo/Bar" 2438 S: * LIST () "/" "Foo/Baz" 2439 S: * LIST () "/" "Moo" 2440 S: C01 OK done 2442 If the client asks RETURN (CHILDREN), it will get this: 2444 C: CA3 LIST "" "%" RETURN (CHILDREN) 2445 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2446 S: * LIST (\HasChildren) "/" "Foo" 2447 S: * LIST (\HasNoChildren) "/" "Moo" 2448 S: CA3 OK done 2450 A) Let's also assume that the mailbox "Foo/Baz" is the only 2451 subscribed mailbox. Then we get this result: 2453 C: C02 LIST (SUBSCRIBED) "" "*" 2454 S: * LIST (\Subscribed) "/" "Foo/Baz" 2455 S: C02 OK done 2457 Now, if the client issues , the server 2458 will return no mailboxes (as the mailboxes "Moo", "Foo", and 2459 "Inbox" are NOT subscribed). However, if the client issues 2460 this: 2462 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2463 S: * LIST () "/" "Foo" ("CHILDINFO" ("SUBSCRIBED")) 2464 S: C04 OK done 2465 (i.e., the mailbox "Foo" is not subscribed, but it has a child 2466 that is.) 2468 A1) If the mailbox "Foo" had also been subscribed, the last 2469 command would return this: 2471 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2472 S: * LIST (\Subscribed) "/" "Foo" ("CHILDINFO" ("SUBSCRIBED")) 2473 S: C04 OK done 2475 or even this: 2477 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2478 S: * LIST (\Subscribed \HasChildren) "/" "Foo" ("CHILDINFO" 2479 ("SUBSCRIBED")) 2480 S: C04 OK done 2482 A2) If we assume instead that the mailbox "Foo" is not part of 2483 the original hierarchy and is not subscribed, the last command 2484 will give this result: 2486 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2487 S: * LIST (\NonExistent) "/" "Foo" ("CHILDINFO" ("SUBSCRIBED")) 2488 S: C04 OK done 2490 B) Now, let's assume that no mailbox is subscribed. In this 2491 case, the command will 2492 return no responses, as there are no subscribed children (even 2493 though "Foo" has children). 2495 C) And finally, suppose that only the mailboxes "Foo" and "Moo" 2496 are subscribed. In that case, we see this result: 2498 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" RETURN (CHILDREN) 2499 S: * LIST (\HasChildren \Subscribed) "/" "Foo" 2500 S: * LIST (\HasNoChildren \Subscribed) "/" "Moo" 2501 S: C04 OK done 2503 (which means that the mailbox "Foo" has children, but none of 2504 them is subscribed). 2506 9: The following example demonstrates that the CHILDINFO extended 2507 data item is returned whether or not children mailboxes match 2508 the canonical LIST pattern. 2510 Let's assume there is the following hierarchy: 2512 C: D01 LIST "" "*" 2513 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2514 S: * LIST () "/" "foo2" 2515 S: * LIST () "/" "foo2/bar1" 2516 S: * LIST () "/" "foo2/bar2" 2517 S: * LIST () "/" "baz2" 2518 S: * LIST () "/" "baz2/bar2" 2519 S: * LIST () "/" "baz2/bar22" 2520 S: * LIST () "/" "baz2/bar222" 2521 S: * LIST () "/" "eps2" 2522 S: * LIST () "/" "eps2/mamba" 2523 S: * LIST () "/" "qux2/bar2" 2524 S: D01 OK done 2526 And that the following mailboxes are subscribed: 2528 C: D02 LIST (SUBSCRIBED) "" "*" 2529 S: * LIST (\Subscribed) "/" "foo2/bar1" 2530 S: * LIST (\Subscribed) "/" "foo2/bar2" 2531 S: * LIST (\Subscribed) "/" "baz2/bar2" 2532 S: * LIST (\Subscribed) "/" "baz2/bar22" 2533 S: * LIST (\Subscribed) "/" "baz2/bar222" 2534 S: * LIST (\Subscribed) "/" "eps2" 2535 S: * LIST (\Subscribed) "/" "eps2/mamba" 2536 S: * LIST (\Subscribed) "/" "qux2/bar2" 2537 S: D02 OK done 2539 The client issues the following command first: 2541 C: D03 LIST (RECURSIVEMATCH SUBSCRIBED) "" "*2" 2542 S: * LIST () "/" "foo2" ("CHILDINFO" ("SUBSCRIBED")) 2543 S: * LIST (\Subscribed) "/" "foo2/bar2" 2544 S: * LIST (\Subscribed) "/" "baz2/bar2" 2545 S: * LIST (\Subscribed) "/" "baz2/bar22" 2546 S: * LIST (\Subscribed) "/" "baz2/bar222" 2547 S: * LIST (\Subscribed) "/" "eps2" ("CHILDINFO" ("SUBSCRIBED")) 2548 S: * LIST (\Subscribed) "/" "qux2/bar2" 2549 S: D03 OK done 2551 and the server may also include (but this would violate a SHOULD 2552 NOT in Section 3.5, because CHILDINFO is redundant) 2554 S: * LIST () "/" "baz2" ("CHILDINFO" ("SUBSCRIBED")) 2555 S: * LIST (\NonExistent) "/" "qux2" ("CHILDINFO" ("SUBSCRIBED")) 2557 The CHILDINFO extended data item is returned for mailboxes 2558 "foo2", "baz2", and "eps2", because all of them have subscribed 2559 children, even though for the mailbox "foo2" only one of the two 2560 subscribed children matches the pattern, for the mailbox "baz2" 2561 all the subscribed children match the pattern, and for the 2562 mailbox "eps2" none of the subscribed children matches the 2563 pattern. 2565 Note that if the client issues 2567 C: D03 LIST (RECURSIVEMATCH SUBSCRIBED) "" "*" 2568 S: * LIST () "/" "foo2" ("CHILDINFO" ("SUBSCRIBED")) 2569 S: * LIST (\Subscribed) "/" "foo2/bar1" 2570 S: * LIST (\Subscribed) "/" "foo2/bar2" 2571 S: * LIST () "/" "baz2" ("CHILDINFO" ("SUBSCRIBED")) 2572 S: * LIST (\Subscribed) "/" "baz2/bar2" 2573 S: * LIST (\Subscribed) "/" "baz2/bar22" 2574 S: * LIST (\Subscribed) "/" "baz2/bar222" 2575 S: * LIST (\Subscribed) "/" "eps2" ("CHILDINFO" ("SUBSCRIBED")) 2576 S: * LIST (\Subscribed) "/" "eps2/mamba" 2577 S: * LIST (\Subscribed) "/" "qux2/bar2" 2578 S: D03 OK done 2580 The LIST responses for mailboxes "foo2", "baz2", and "eps2" 2581 still have the CHILDINFO extended data item, even though this 2582 information is redundant and the client can determine it by 2583 itself. 2585 10: The following example shows usage of multiple mailbox patterns. 2586 It also demonstrates that the presence of the CHILDINFO extended 2587 data item doesn't necessarily imply \HasChildren. 2589 C: a1 LIST "" ("foo" "foo/*") 2590 S: * LIST () "/" foo 2591 S: a1 OK done 2593 C: a2 LIST (SUBSCRIBED) "" "foo/*" 2594 S: * LIST (\Subscribed \NonExistent) "/" foo/bar 2595 S: a2 OK done 2597 C: a3 LIST (SUBSCRIBED RECURSIVEMATCH) "" foo RETURN (CHILDREN) 2598 S: * LIST (\HasNoChildren) "/" foo ("CHILDINFO" ("SUBSCRIBED")) 2599 S: a3 OK done 2601 11: The following example shows how a server that supports missing 2602 mailbox hierarchy elements can signal to a client that didn't 2603 specify the RECURSIVEMATCH selection option that there is a 2604 child mailbox that matches the selection criteria. 2606 C: a1 LIST (REMOTE) "" * 2607 S: * LIST () "/" music/rock 2608 S: * LIST (\Remote) "/" also/jazz 2609 S: a1 OK done 2611 C: a2 LIST () "" % 2612 S: * LIST (\NonExistent \HasChildren) "/" music 2613 S: a2 OK done 2615 C: a3 LIST (REMOTE) "" % 2616 S: * LIST (\NonExistent \HasChildren) "/" music 2617 S: * LIST (\NonExistent \HasChildren) "/" also 2618 S: a3 OK done 2620 C: a3.1 LIST "" (% music/rock) 2621 S: * LIST () "/" music/rock 2622 S: a3.1 OK done 2624 Because "music/rock" is the only mailbox under "music", there's 2625 no need for the server to also return "music". However clients 2626 must handle both cases. 2628 6.3.10. LSUB Command 2630 Arguments: reference name 2631 mailbox name with possible wildcards 2633 Responses: untagged responses: LSUB 2635 Result: OK - lsub completed 2636 NO - lsub failure: can't list that reference or name 2637 BAD - command unknown or arguments invalid 2639 The LSUB command returns a subset of names from the set of names that 2640 the user has declared as being "active" or "subscribed". Zero or 2641 more untagged LSUB replies are returned. The arguments to LSUB are 2642 in the same form as those for LIST. 2644 The returned untagged LSUB response MAY contain different mailbox 2645 flags from a LIST untagged response. If this should happen, the 2646 flags in the untagged LIST are considered more authoritative. 2648 A special situation occurs when using LSUB with the % wildcard. 2649 Consider what happens if "foo/bar" (with a hierarchy delimiter of 2650 "/") is subscribed but "foo" is not. A "%" wildcard to LSUB must 2651 return foo, not foo/bar, in the LSUB response, and it MUST be flagged 2652 with the \Noselect attribute. 2654 The server MUST NOT unilaterally remove an existing mailbox name from 2655 the subscription list even if a mailbox by that name no longer 2656 exists. 2658 Example: C: A002 LSUB "#news." "comp.mail.*" 2659 S: * LSUB () "." #news.comp.mail.mime 2660 S: * LSUB () "." #news.comp.mail.misc 2661 S: A002 OK LSUB completed 2662 C: A003 LSUB "#news." "comp.%" 2663 S: * LSUB (\NoSelect) "." #news.comp.mail 2664 S: A003 OK LSUB completed 2666 6.3.11. NAMESPACE Command 2668 Arguments: none 2670 Responses: REQUIRED untagged responses: NAMESPACE 2672 Result: OK - command completed 2673 NO - Can't complete the command 2674 BAD - arguments invalid 2676 The NAMESPACE command causes a single ungagged NAMESPACE response to 2677 be returned. The untagged NAMESPACE response contains the prefix and 2678 hierarchy delimiter to the server's Personal Namespace(s), Other 2679 Users' Namespace(s), and Shared Namespace(s) that the server wishes 2680 to expose. The response will contain a NIL for any namespace class 2681 that is not available. Namespace_Response_Extensions MAY be included 2682 in the response. Namespace_Response_Extensions which are not on the 2683 IETF standards track, MUST be prefixed with an "X-". 2685 Example 1: 2687 In this example a server supports a single personal namespace. No 2688 leading prefix is used on personal mailboxes and "/" is the hierarchy 2689 delimiter. 2691 C: A001 NAMESPACE 2692 S: * NAMESPACE (("" "/")) NIL NIL 2693 S: A001 OK NAMESPACE command completed 2695 Example 2: 2697 A user logged on anonymously to a server. No personal mailboxes are 2698 associated with the anonymous user and the user does not have access 2699 to the Other Users' Namespace. No prefix is required to access 2700 shared mailboxes and the hierarchy delimiter is "." 2701 C: A001 NAMESPACE 2702 S: * NAMESPACE NIL NIL (("" ".")) 2703 S: A001 OK NAMESPACE command completed 2705 Example 3: 2707 A server that contains a Personal Namespace and a single Shared 2708 Namespace. 2710 C: A001 NAMESPACE 2711 S: * NAMESPACE (("" "/")) NIL (("Public Folders/" "/")) 2712 S: A001 OK NAMESPACE command completed 2714 Example 4: 2716 A server that contains a Personal Namespace, Other Users' Namespace 2717 and multiple Shared Namespaces. Note that the hierarchy delimiter 2718 used within each namespace can be different. 2720 C: A001 NAMESPACE 2721 S: * NAMESPACE (("" "/")) (("~" "/")) (("#shared/" "/") 2722 ("#public/" "/")("#ftp/" "/")("#news." ".")) 2723 S: A001 OK NAMESPACE command completed 2725 The prefix string allows a client to do things such as automatically 2726 creating personal mailboxes or LISTing all available mailboxes within 2727 a namespace. 2729 Example 5: 2731 A server that supports only the Personal Namespace, with a leading 2732 prefix of INBOX to personal mailboxes and a hierarchy delimiter of 2733 "." 2735 C: A001 NAMESPACE 2736 S: * NAMESPACE (("INBOX." ".")) NIL NIL 2737 S: A001 OK NAMESPACE command completed 2739 < Automatically create a mailbox to store sent items.> 2741 C: A002 CREATE "INBOX.Sent Mail" 2742 S: A002 OK CREATE command completed 2744 Although typically a server will support only a single Personal 2745 Namespace, and a single Other User's Namespace, circumstances exist 2746 where there MAY be multiples of these, and a client MUST be prepared 2747 for them. If a client is configured such that it is required to 2748 create a certain mailbox, there can be circumstances where it is 2749 unclear which Personal Namespaces it should create the mailbox in. 2750 In these situations a client SHOULD let the user select which 2751 namespaces to create the mailbox in. 2753 Example 6: 2755 In this example, a server supports 2 Personal Namespaces. In 2756 addition to the regular Personal Namespace, the user has an 2757 additional personal namespace to allow access to mailboxes in an MH 2758 format mailstore. 2760 The client is configured to save a copy of all mail sent by the user 2761 into a mailbox called 'Sent Mail'. Furthermore, after a message is 2762 deleted from a mailbox, the client is configured to move that message 2763 to a mailbox called 'Deleted Items'. 2765 Note that this example demonstrates how some extension flags can be 2766 passed to further describe the #mh namespace. 2768 C: A001 NAMESPACE 2769 S: * NAMESPACE (("" "/")("#mh/" "/" "X-PARAM" ("FLAG1" "FLAG2"))) 2770 NIL NIL 2771 S: A001 OK NAMESPACE command completed 2773 < It is desired to keep only one copy of sent mail. It is unclear 2774 which Personal Namespace the client should use to create the 'Sent 2775 Mail' mailbox. The user is prompted to select a namespace and 2776 only one 'Sent Mail' mailbox is created. > 2778 C: A002 CREATE "Sent Mail" 2779 S: A002 OK CREATE command completed 2781 < The client is designed so that it keeps two 'Deleted Items' 2782 mailboxes, one for each namespace. > 2784 C: A003 CREATE "Delete Items" 2785 S: A003 OK CREATE command completed 2787 C: A004 CREATE "#mh/Deleted Items" 2788 S: A004 OK CREATE command completed 2790 The next level of hierarchy following the Other Users' Namespace 2791 prefix SHOULD consist of , where is a user name 2792 as per the LOGIN or AUTHENTICATE command. 2794 A client can construct a LIST command by appending a "%" to the Other 2795 Users' Namespace prefix to discover the Personal Namespaces of other 2796 users that are available to the currently authenticated user. 2798 In response to such a LIST command, a server SHOULD NOT return user 2799 names that have not granted access to their personal mailboxes to the 2800 user in question. 2802 A server MAY return a LIST response containing only the names of 2803 users that have explicitly granted access to the user in question. 2805 Alternatively, a server MAY return NO to such a LIST command, 2806 requiring that a user name be included with the Other Users' 2807 Namespace prefix before listing any other user's mailboxes. 2809 Example 7: 2811 A server that supports providing a list of other user's mailboxes 2812 that are accessible to the currently logged on user. 2814 C: A001 NAMESPACE 2815 S: * NAMESPACE (("" "/")) (("Other Users/" "/")) NIL 2816 S: A001 OK NAMESPACE command completed 2818 C: A002 LIST "" "Other Users/%" 2819 S: * LIST () "/" "Other Users/Mike" 2820 S: * LIST () "/" "Other Users/Karen" 2821 S: * LIST () "/" "Other Users/Matthew" 2822 S: * LIST () "/" "Other Users/Tesa" 2823 S: A002 OK LIST command completed 2825 Example 8: 2827 A server that does not support providing a list of other user's 2828 mailboxes that are accessible to the currently logged on user. The 2829 mailboxes are listable if the client includes the name of the other 2830 user with the Other Users' Namespace prefix. 2832 C: A001 NAMESPACE 2833 S: * NAMESPACE (("" "/")) (("#Users/" "/")) NIL 2834 S: A001 OK NAMESPACE command completed 2836 < In this example, the currently logged on user has access to the 2837 Personal Namespace of user Mike, but the server chose to suppress 2838 this information in the LIST response. However, by appending the 2839 user name Mike (received through user input) to the Other Users' 2840 Namespace prefix, the client is able to get a listing of the 2841 personal mailboxes of user Mike. > 2843 C: A002 LIST "" "#Users/%" 2844 S: A002 NO The requested item could not be found. 2846 C: A003 LIST "" "#Users/Mike/%" 2847 S: * LIST () "/" "#Users/Mike/INBOX" 2848 S: * LIST () "/" "#Users/Mike/Foo" 2849 S: A003 OK LIST command completed. 2851 A prefix string might not contain a hierarchy delimiter, because in 2852 some cases it is not needed as part of the prefix. 2854 Example 9: 2856 A server that allows access to the Other Users' Namespace by 2857 prefixing the others' mailboxes with a '~' followed by , 2858 where is a user name as per the LOGIN or AUTHENTICATE 2859 command. 2861 C: A001 NAMESPACE 2862 S: * NAMESPACE (("" "/")) (("~" "/")) NIL 2863 S: A001 OK NAMESPACE command completed 2865 < List the mailboxes for user mark > 2867 C: A002 LIST "" "~mark/%" 2868 S: * LIST () "/" "~mark/INBOX" 2869 S: * LIST () "/" "~mark/foo" 2870 S: A002 OK LIST command completed 2872 6.3.12. STATUS Command 2874 Arguments: mailbox name 2875 status data item names 2877 Responses: REQUIRED untagged responses: STATUS 2879 Result: OK - status completed 2880 NO - status failure: no status for that name 2881 BAD - command unknown or arguments invalid 2883 The STATUS command requests the status of the indicated mailbox. It 2884 does not change the currently selected mailbox, nor does it affect 2885 the state of any messages in the queried mailbox. 2887 The STATUS command provides an alternative to opening a second 2888 IMAP4rev2 connection and doing an EXAMINE command on a mailbox to 2889 query that mailbox's status without deselecting the current mailbox 2890 in the first IMAP4rev2 connection. 2892 Unlike the LIST command, the STATUS command is not guaranteed to be 2893 fast in its response. Under certain circumstances, it can be quite 2894 slow. In some implementations, the server is obliged to open the 2895 mailbox read-only internally to obtain certain status information. 2896 Also unlike the LIST command, the STATUS command does not accept 2897 wildcards. 2899 Note: The STATUS command is intended to access the status of 2900 mailboxes other than the currently selected mailbox. Because the 2901 STATUS command can cause the mailbox to be opened internally, and 2902 because this information is available by other means on the 2903 selected mailbox, the STATUS command SHOULD NOT be used on the 2904 currently selected mailbox. 2906 The STATUS command MUST NOT be used as a "check for new messages 2907 in the selected mailbox" operation (refer to sections Section 7, 2908 Section 7.3.1 for more information about the proper method for new 2909 message checking). 2911 Because the STATUS command is not guaranteed to be fast in its 2912 results, clients SHOULD NOT expect to be able to issue many 2913 consecutive STATUS commands and obtain reasonable performance. 2915 The currently defined status data items that can be requested are: 2917 MESSAGES The number of messages in the mailbox. 2919 UIDNEXT The next unique identifier value of the mailbox. Refer to 2920 Section 2.3.1.1 for more information. 2922 UIDVALIDITY The unique identifier validity value of the mailbox. 2923 Refer to Section 2.3.1.1 for more information. 2925 UNSEEN The number of messages which do not have the \Seen flag set. 2927 SIZE The total size of the mailbox in octets. This is not strictly 2928 required to be an exact value, but it MUST be equal to or greater 2929 than the sum of the values of the RFC822.SIZE FETCH message data 2930 items (see Section 6.4.6) of all messages in the mailbox. 2932 Example: C: A042 STATUS blurdybloop (UIDNEXT MESSAGES) 2933 S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) 2934 S: A042 OK STATUS completed 2936 6.3.13. APPEND Command 2938 Arguments: mailbox name 2939 OPTIONAL flag parenthesized list 2940 OPTIONAL date/time string 2941 message literal 2943 Responses: no specific responses for this command 2945 Result: OK - append completed 2946 NO - append error: can't append to that mailbox, error 2947 in flags or date/time or message text 2948 BAD - command unknown or arguments invalid 2950 The APPEND command appends the literal argument as a new message to 2951 the end of the specified destination mailbox. This argument SHOULD 2952 be in the format of an [RFC-5322] or [I18N-HDRS] message. 8-bit 2953 characters are permitted in the message. A server implementation 2954 that is unable to preserve 8-bit data properly MUST be able to 2955 reversibly convert 8-bit APPEND data to 7-bit using a [MIME-IMB] 2956 content transfer encoding. 2958 Note: There may be exceptions, e.g., draft messages, in which 2959 required [RFC-5322] header lines are omitted in the message 2960 literal argument to APPEND. The full implications of doing so 2961 must be understood and carefully weighed. 2963 If a flag parenthesized list is specified, the flags SHOULD be set in 2964 the resulting message; otherwise, the flag list of the resulting 2965 message is set to empty by default. 2967 If a date-time is specified, the internal date SHOULD be set in the 2968 resulting message; otherwise, the internal date of the resulting 2969 message is set to the current date and time by default. 2971 If the append is unsuccessful for any reason, the mailbox MUST be 2972 restored to its state before the APPEND attempt; no partial appending 2973 is permitted. 2975 If the destination mailbox does not exist, a server MUST return an 2976 error, and MUST NOT automatically create the mailbox. Unless it is 2977 certain that the destination mailbox can not be created, the server 2978 MUST send the response code "[TRYCREATE]" as the prefix of the text 2979 of the tagged NO response. This gives a hint to the client that it 2980 can attempt a CREATE command and retry the APPEND if the CREATE is 2981 successful. 2983 On successful completion of an APPEND, the server SHOULD return an 2984 APPENDUID response code. 2986 In the case of a mailbox that has permissions set so that the client 2987 can APPEND to the mailbox, but not SELECT or EXAMINE it, the server 2988 SHOULD NOT send an APPENDUID response code as it would disclose 2989 information about the mailbox. 2991 In the case of a mailbox that has UIDNOTSTICKY status (see 2992 UIDNOTSTICKY response code definition), the server MAY omit the 2993 APPENDUID response code as it is not meaningful. 2995 If the server does not return the APPENDUID response codes, the 2996 client can discover this information by selecting the destination 2997 mailbox. The location of messages placed in the destination mailbox 2998 by APPEND can be determined by using FETCH and/or SEARCH commands 2999 (e.g., for Message-ID or some unique marker placed in the message in 3000 an APPEND). 3002 If the mailbox is currently selected, the normal new message actions 3003 SHOULD occur. Specifically, the server SHOULD notify the client 3004 immediately via an untagged EXISTS response. If the server does not 3005 do so, the client MAY issue a NOOP command (or failing that, a CHECK 3006 command) after one or more APPEND commands. 3008 Example: C: A003 APPEND saved-messages (\Seen) {310} 3009 S: + Ready for literal data 3010 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST) 3011 C: From: Fred Foobar 3012 C: Subject: afternoon meeting 3013 C: To: mooch@owatagu.siam.edu 3014 C: Message-Id: 3015 C: MIME-Version: 1.0 3016 C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 3017 C: 3018 C: Hello Joe, do you think we can meet at 3:30 tomorrow? 3019 C: 3020 S: A003 OK APPEND completed 3022 Example: C: A003 APPEND saved-messages (\Seen) {297} 3023 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST) 3024 C: From: Fred Foobar 3025 C: Subject: afternoon meeting 3026 C: To: mooch@example.com 3027 C: Message-Id: 3028 C: MIME-Version: 1.0 3029 C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 3030 C: 3031 C: Hello Joe, do you think we can meet at 3:30 tomorrow? 3032 C: 3033 S: A003 OK [APPENDUID 38505 3955] APPEND completed 3034 C: A004 COPY 2:4 meeting 3035 S: A004 OK [COPYUID 38505 304,319:320 3956:3958] Done 3036 C: A005 UID COPY 305:310 meeting 3037 S: A005 OK No matching messages, so nothing copied 3038 C: A006 COPY 2 funny 3039 S: A006 OK Done 3040 C: A007 SELECT funny 3041 S: * 1 EXISTS 3042 S: * OK [UIDVALIDITY 3857529045] Validity session-only 3043 S: * OK [UIDNEXT 2] Predicted next UID 3044 S: * NO [UIDNOTSTICKY] Non-persistent UIDs 3045 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 3046 S: * OK [PERMANENTFLAGS (\Deleted \Seen)] Limited 3047 S: A007 OK [READ-WRITE] SELECT completed 3049 In this example, A003 and A004 demonstrate successful appending and 3050 copying to a mailbox that returns the UIDs assigned to the messages. 3051 A005 is an example in which no messages were copied; this is because 3052 in A003, we see that message 2 had UID 304, and message 3 had UID 3053 319; therefore, UIDs 305 through 310 do not exist (refer to 3054 Section 2.3.1.1 for further explanation). A006 is an example of a 3055 message being copied that did not return a COPYUID; and, as expected, 3056 A007 shows that the mail store containing that mailbox does not 3057 support persistent UIDs. 3059 Note: The APPEND command is not used for message delivery, because 3060 it does not provide a mechanism to transfer [SMTP] envelope 3061 information. 3063 6.3.14. IDLE Command 3065 Arguments: none 3067 Responses: continuation data will be requested; the client sends the 3068 continuation data "DONE" to end the command 3070 Result: OK - IDLE completed after client sent "DONE" 3071 NO - failure: the server will not allow the IDLE command 3072 at this time 3073 BAD - command unknown or arguments invalid 3075 Without the IDLE command a client requires to poll the server for 3076 changes to the selected mailbox (new mail, deletions, flag changes). 3077 It's often more desirable to have the server transmit updates to the 3078 client in real time. This allows a user to see new mail immediately. 3079 The IDLE command allows a client to tell the server that it's ready 3080 to accept such real-time updates. 3082 The IDLE command is sent from the client to the server when the 3083 client is ready to accept unsolicited mailbox update messages. The 3084 server requests a response to the IDLE command using the continuation 3085 ("+") response. The IDLE command remains active until the client 3086 responds to the continuation, and as long as an IDLE command is 3087 active, the server is now free to send untagged EXISTS, EXPUNGE, 3088 FETCH, and other responses at any time. If the server choose to send 3089 unsolicited FETCH responses, they MUST include UID FETCH item. 3091 The IDLE command is terminated by the receipt of a "DONE" 3092 continuation from the client; such response satisfies the server's 3093 continuation request. At that point, the server MAY send any 3094 remaining queued untagged responses and then MUST immediately send 3095 the tagged response to the IDLE command and prepare to process other 3096 commands. As in the base specification, the processing of any new 3097 command may cause the sending of unsolicited untagged responses, 3098 subject to the ambiguity limitations. The client MUST NOT send a 3099 command while the server is waiting for the DONE, since the server 3100 will not be able to distinguish a command from a continuation. 3102 The server MAY consider a client inactive if it has an IDLE command 3103 running, and if such a server has an inactivity timeout it MAY log 3104 the client off implicitly at the end of its timeout period. Because 3105 of that, clients using IDLE are advised to terminate the IDLE and re- 3106 issue it at least every 29 minutes to avoid being logged off. This 3107 still allows a client to receive immediate mailbox updates even 3108 though it need only "poll" at half hour intervals. 3110 Example: C: A001 SELECT INBOX 3111 S: * FLAGS (\Deleted \Seen \Flagged) 3112 S: * OK [PERMANENTFLAGS (\Deleted \Seen \Flagged)] Limited 3113 S: * 3 EXISTS 3114 S: * OK [UIDVALIDITY 1] 3115 S: A001 OK [READ-WRITE] SELECT completed 3116 C: A002 IDLE 3117 S: + idling 3118 ...time passes; new mail arrives... 3119 S: * 4 EXISTS 3120 C: DONE 3121 S: A002 OK IDLE terminated 3122 ...another client expunges message 2 now... 3123 C: A003 FETCH 4 ALL 3124 S: * 4 FETCH (...) 3125 S: A003 OK FETCH completed 3126 C: A004 IDLE 3127 S: * 2 EXPUNGE 3128 S: * 3 EXISTS 3129 S: + idling 3130 ...time passes; another client expunges message 3... 3131 S: * 3 EXPUNGE 3132 S: * 2 EXISTS 3133 ...time passes; new mail arrives... 3134 S: * 3 EXISTS 3135 C: DONE 3136 S: A004 OK IDLE terminated 3137 C: A005 FETCH 3 ALL 3138 S: * 3 FETCH (...) 3139 S: A005 OK FETCH completed 3140 C: A006 IDLE 3142 6.4. Client Commands - Selected State 3144 In the selected state, commands that manipulate messages in a mailbox 3145 are permitted. 3147 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 3148 and the authenticated state commands (SELECT, EXAMINE, NAMESPACE, 3149 CREATE, DELETE, RENAME, SUBSCRIBE, UNSUBSCRIBE, LIST, LSUB , STATUS, 3150 and APPEND), the following commands are valid in the selected state: 3151 CHECK, CLOSE, UNSELECT, EXPUNGE, SEARCH, FETCH, STORE, COPY, MOVE, 3152 and UID. 3154 6.4.1. CHECK Command 3156 Arguments: none 3158 Responses: no specific responses for this command 3160 Result: OK - check completed 3161 BAD - command unknown or arguments invalid 3163 The CHECK command requests a checkpoint of the currently selected 3164 mailbox. A checkpoint refers to any implementation-dependent 3165 housekeeping associated with the mailbox (e.g., resolving the 3166 server's in-memory state of the mailbox with the state on its disk) 3167 that is not normally executed as part of each command. A checkpoint 3168 MAY take a non-instantaneous amount of real time to complete. If a 3169 server implementation has no such housekeeping considerations, CHECK 3170 is equivalent to NOOP. 3172 There is no guarantee that an EXISTS untagged response will happen as 3173 a result of CHECK. NOOP, not CHECK, SHOULD be used for new message 3174 polling. 3176 Example: C: FXXZ CHECK 3177 S: FXXZ OK CHECK Completed 3179 6.4.2. CLOSE Command 3181 Arguments: none 3183 Responses: no specific responses for this command 3185 Result: OK - close completed, now in authenticated state 3186 BAD - command unknown or arguments invalid 3188 The CLOSE command permanently removes all messages that have the 3189 \Deleted flag set from the currently selected mailbox, and returns to 3190 the authenticated state from the selected state. No untagged EXPUNGE 3191 responses are sent. 3193 No messages are removed, and no error is given, if the mailbox is 3194 selected by an EXAMINE command or is otherwise selected read-only. 3196 Even if a mailbox is selected, a SELECT, EXAMINE, or LOGOUT command 3197 MAY be issued without previously issuing a CLOSE command. The 3198 SELECT, EXAMINE, and LOGOUT commands implicitly close the currently 3199 selected mailbox without doing an expunge. However, when many 3200 messages are deleted, a CLOSE-LOGOUT or CLOSE-SELECT sequence is 3201 considerably faster than an EXPUNGE-LOGOUT or EXPUNGE-SELECT because 3202 no untagged EXPUNGE responses (which the client would probably 3203 ignore) are sent. 3205 Example: C: A341 CLOSE 3206 S: A341 OK CLOSE completed 3208 6.4.3. UNSELECT Command 3210 Arguments: none 3212 Responses: no specific responses for this command 3214 Result: OK - unselect completed, now in authenticated state 3215 BAD - no mailbox selected, or argument supplied but none 3216 permitted 3218 The UNSELECT command frees server's resources associated with the 3219 selected mailbox and returns the server to the authenticated state. 3220 This command performs the same actions as CLOSE, except that no 3221 messages are permanently removed from the currently selected mailbox. 3223 Example: C: A342 UNSELECT 3224 S: A342 OK Unselect completed 3226 6.4.4. EXPUNGE Command 3228 Arguments: none 3230 Responses: untagged responses: EXPUNGE 3232 Result: OK - expunge completed 3233 NO - expunge failure: can't expunge (e.g., permission 3234 denied) 3235 BAD - command unknown or arguments invalid 3237 The EXPUNGE command permanently removes all messages that have the 3238 \Deleted flag set from the currently selected mailbox. Before 3239 returning an OK to the client, an untagged EXPUNGE response is sent 3240 for each message that is removed. 3242 Example: C: A202 EXPUNGE 3243 S: * 3 EXPUNGE 3244 S: * 3 EXPUNGE 3245 S: * 5 EXPUNGE 3246 S: * 8 EXPUNGE 3247 S: A202 OK EXPUNGE completed 3249 Note: In this example, messages 3, 4, 7, and 11 had the \Deleted flag 3250 set. See the description of the EXPUNGE response for further 3251 explanation. 3253 6.4.5. SEARCH Command 3255 Arguments: OPTIONAL result specifier 3256 OPTIONAL [CHARSET] specification 3257 searching criteria (one or more) 3259 Responses: REQUIRED untagged response: ESEARCH 3261 Result: OK - search completed 3262 NO - search error: can't search that [CHARSET] or 3263 criteria 3264 BAD - command unknown or arguments invalid 3266 The SEARCH command searches the mailbox for messages that match the 3267 given searching criteria. 3269 The SEARCH command may contain result options. Result options 3270 control what kind of information is returned about messages matching 3271 the search criteria in an untagged ESEARCH response. If no result 3272 option is specified or empty list of options is specified "()", ALL 3273 is assumed (see below). The order of individual options is 3274 arbitrary. Individual options may contain parameters enclosed in 3275 parentheses (*). If an option has parameters, they consist of atoms 3276 and/or strings and/or lists in a specific order. Any options not 3277 defined by extensions that the server supports must be rejected with 3278 a BAD response. 3280 (*) - if an option has a mandatory parameter, which can always be 3281 represented as a number or a sequence-set, the option parameter does 3282 not need the enclosing (). See ABNF for more details. 3284 This document specifies the following result options: 3286 MIN 3288 Return the lowest message number/UID that satisfies the SEARCH 3289 criteria. 3291 If the SEARCH results in no matches, the server MUST NOT 3292 include the MIN result option in the ESEARCH response; however, 3293 it still MUST send the ESEARCH response. 3295 MAX 3296 Return the highest message number/UID that satisfies the SEARCH 3297 criteria. 3299 If the SEARCH results in no matches, the server MUST NOT 3300 include the MAX result option in the ESEARCH response; however, 3301 it still MUST send the ESEARCH response. 3303 ALL 3305 Return all message numbers/UIDs that satisfy the SEARCH 3306 criteria using the sequence-set syntax. Note, the client MUST 3307 NOT assume that messages/UIDs will be listed in any particular 3308 order. 3310 If the SEARCH results in no matches, the server MUST NOT 3311 include the ALL result option in the ESEARCH response; however, 3312 it still MUST send the ESEARCH response. 3314 COUNT Return number of the messages that satisfy the SEARCH 3315 criteria. This result option MUST always be included in the 3316 ESEARCH response. 3318 Note: future extensions to this document can allow servers to return 3319 multiple ESEARCH responses for a single extended SEARCH command. 3320 However all options specified above MUST result in a single ESEARCH 3321 response. These extensions will have to describe how results from 3322 multiple ESEARCH responses are to be amalgamated. 3324 Searching criteria consist of one or more search keys. 3326 When multiple keys are specified, the result is the intersection (AND 3327 function) of all the messages that match those keys. For example, 3328 the criteria DELETED FROM "SMITH" SINCE 1-Feb-1994 refers to all 3329 deleted messages from Smith that were placed in the mailbox since 3330 February 1, 1994. A search key can also be a parenthesized list of 3331 one or more search keys (e.g., for use with the OR and NOT keys). 3333 Server implementations MAY exclude [MIME-IMB] body parts with 3334 terminal content media types other than TEXT and MESSAGE from 3335 consideration in SEARCH matching. 3337 The OPTIONAL [CHARSET] specification consists of the word "CHARSET" 3338 followed by a registered [CHARSET]. It indicates the [CHARSET] of 3339 the strings that appear in the search criteria. [MIME-IMB] content 3340 transfer encodings, and [MIME-HDRS] strings in [RFC-5322]/[MIME-IMB] 3341 headers, MUST be decoded before comparing text. US-ASCII and UTF-8 3342 charsets MUST be supported; other [CHARSET]s MAY be supported. If 3343 "CHARSET" is not provided, an IMAP4rev2 server MUST assume UTF-8. 3345 If the server does not support the specified [CHARSET], it MUST 3346 return a tagged NO response (not a BAD). This response SHOULD 3347 contain the BADCHARSET response code, which MAY list the [CHARSET]s 3348 supported by the server. 3350 In all search keys that use strings, a message matches the key if the 3351 string is a substring of the associated text. The matching SHOULD be 3352 case-insensitive for characters within ASCII range. Consider using 3353 [IMAP-I18N] for language-sensitive case-insensitive searching. Note 3354 that the empty string is a substring; this is useful when doing a 3355 HEADER search in order to test for a header field presence in the 3356 message. 3358 The defined search keys are as follows. Refer to the Formal Syntax 3359 section for the precise syntactic definitions of the arguments. 3361 Messages with message sequence numbers corresponding 3362 to the specified message sequence number set. 3364 ALL All messages in the mailbox; the default initial key for ANDing. 3366 ANSWERED Messages with the \Answered flag set. 3368 BCC Messages that contain the specified string in the 3369 envelope structure's BCC field. 3371 BEFORE Messages whose internal date (disregarding time and 3372 timezone) is earlier than the specified date. 3374 BODY Messages that contain the specified string in the body 3375 of the message. 3377 CC Messages that contain the specified string in the 3378 envelope structure's CC field. 3380 DELETED Messages with the \Deleted flag set. 3382 DRAFT Messages with the \Draft flag set. 3384 FLAGGED Messages with the \Flagged flag set. 3386 FROM Messages that contain the specified string in the 3387 envelope structure's FROM field. 3389 HEADER Messages that have a header with the 3390 specified field-name (as defined in [RFC-5322]) and that contains 3391 the specified string in the text of the header (what comes after 3392 the colon). If the string to search is zero-length, this matches 3393 all messages that have a header line with the specified field-name 3394 regardless of the contents. 3396 KEYWORD Messages with the specified keyword flag set. 3398 LARGER Messages with an [RFC-5322] size larger than the 3399 specified number of octets. 3401 NEW [[Fix this]] Messages that have the \Recent flag set but not the 3402 \Seen flag. This is functionally equivalent to "(RECENT UNSEEN)". 3404 NOT Messages that do not match the specified search 3405 key. 3407 ON Messages whose internal date (disregarding time and 3408 timezone) is within the specified date. 3410 OR Messages that match either search 3411 key. 3413 SEEN Messages that have the \Seen flag set. 3415 SENTBEFORE Messages whose [RFC-5322] Date: header 3416 (disregarding time and timezone) is earlier than the specified 3417 date. 3419 SENTON Messages whose [RFC-5322] Date: header (disregarding 3420 time and timezone) is within the specified date. 3422 SENTSINCE Messages whose [RFC-5322] Date: header 3423 (disregarding time and timezone) is within or later than the 3424 specified date. 3426 SINCE Messages whose internal date (disregarding time and 3427 timezone) is within or later than the specified date. 3429 SMALLER Messages with an [RFC-5322] size smaller than the 3430 specified number of octets. 3432 SUBJECT Messages that contain the specified string in the 3433 envelope structure's SUBJECT field. 3435 TEXT Messages that contain the specified string in the 3436 header or body of the message. 3438 TO Messages that contain the specified string in the 3439 envelope structure's TO field. 3441 UID Messages with unique identifiers corresponding to 3442 the specified unique identifier set. Sequence set ranges are 3443 permitted. 3445 UNANSWERED Messages that do not have the \Answered flag set. 3447 UNDELETED Messages that do not have the \Deleted flag set. 3449 UNDRAFT Messages that do not have the \Draft flag set. 3451 UNFLAGGED Messages that do not have the \Flagged flag set. 3453 UNKEYWORD Messages that do not have the specified keyword 3454 flag set. 3456 UNSEEN Messages that do not have the \Seen flag set. 3458 Example: C: A282 SEARCH RETURN (MIN COUNT) FLAGGED 3459 SINCE 1-Feb-1994 NOT FROM "Smith" 3460 S: * ESEARCH (TAG "A282") MIN 2 COUNT 3 3461 S: A282 OK SEARCH completed 3463 Example: C: A283 SEARCH RETURN () FLAGGED 3464 SINCE 1-Feb-1994 NOT FROM "Smith" 3465 S: * ESEARCH (TAG "A283") ALL 2,10:11 3466 S: A283 OK SEARCH completed 3468 Example: C: A284 SEARCH TEXT "string not in mailbox" 3469 S: * ESEARCH (TAG "A284") 3470 S: A284 OK SEARCH completed 3471 C: A285 SEARCH CHARSET UTF-8 TEXT {6} 3472 S: + Ready for literal text 3473 C: XXXXXX 3474 S: * ESEARCH (TAG "A285") ALL 43 3475 S: A285 OK SEARCH completed 3477 Note: Since this document is restricted to 7-bit ASCII text, it is 3478 not possible to show actual UTF-8 data. The "XXXXXX" is a 3479 placeholder for what would be 6 octets of 8-bit data in an actual 3480 transaction. 3482 The following example demonstrates finding the first unseen message 3483 in the mailbox: 3485 Example: C: A284 SEARCH RETURN (MIN) UNSEEN 3486 S: * ESEARCH (TAG "A284") MIN 4 3487 S: A284 OK SEARCH completed 3489 The following example demonstrates that if the ESEARCH UID indicator 3490 is present, all data in the ESEARCH response is referring to UIDs; 3491 for example, the MIN result specifier will be followed by a UID. 3493 Example: C: A285 UID SEARCH RETURN (MIN MAX) 1:5000 3494 S: * ESEARCH (TAG "A285") UID MIN 7 MAX 3800 3495 S: A285 OK SEARCH completed 3497 The following example demonstrates returning the number of deleted 3498 messages: 3500 Example: C: A286 SEARCH RETURN (COUNT) DELETED 3501 S: * ESEARCH (TAG "A286") COUNT 15 3502 S: A286 OK SEARCH completed 3504 6.4.6. FETCH Command 3506 Arguments: sequence set 3507 message data item names or macro 3509 Responses: untagged responses: FETCH 3511 Result: OK - fetch completed 3512 NO - fetch error: can't fetch that data 3513 BAD - command unknown or arguments invalid 3515 The FETCH command retrieves data associated with a message in the 3516 mailbox. The data items to be fetched can be either a single atom or 3517 a parenthesized list. 3519 Most data items, identified in the formal syntax under the msg-att- 3520 static rule, are static and MUST NOT change for any particular 3521 message. Other data items, identified in the formal syntax under the 3522 msg-att-dynamic rule, MAY change, either as a result of a STORE 3523 command or due to external events. 3525 For example, if a client receives an ENVELOPE for a message when 3526 it already knows the envelope, it can safely ignore the newly 3527 transmitted envelope. 3529 There are three macros which specify commonly-used sets of data 3530 items, and can be used instead of data items. A macro must be used 3531 by itself, and not in conjunction with other macros or data items. 3533 ALL Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE) 3535 FAST Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE) 3536 FULL Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE 3537 BODY) 3539 The currently defined data items that can be fetched are: 3541 BINARY[]<> 3543 Requests that the specified section be transmitted after 3544 performing Content-Transfer-Encoding-related decoding. 3546 The argument, if present, requests that a subset of 3547 the data be returned. The semantics of a partial FETCH BINARY 3548 command are the same as for a partial FETCH BODY command, with 3549 the exception that the arguments refer to the DECODED 3550 section data. 3552 BINARY.PEEK[]<> An alternate form of 3553 BINARY[] that does not implicitly set the \Seen 3554 flag. 3556 BINARY.SIZE[] 3558 Requests the decoded size of the section (i.e., the size to 3559 expect in response to the corresponding FETCH BINARY request). 3561 Note: client authors are cautioned that this might be an 3562 expensive operation for some server implementations. 3563 Needlessly issuing this request could result in degraded 3564 performance due to servers having to calculate the value every 3565 time the request is issued. 3567 BODY Non-extensible form of BODYSTRUCTURE. 3569 BODY[
]<> 3571 The text of a particular body section. The section 3572 specification is a set of zero or more part specifiers 3573 delimited by periods. A part specifier is either a part number 3574 or one of the following: HEADER, HEADER.FIELDS, 3575 HEADER.FIELDS.NOT, MIME, and TEXT. An empty section 3576 specification refers to the entire message, including the 3577 header. 3579 Every message has at least one part number. Non-[MIME-IMB] 3580 messages, and non-multipart [MIME-IMB] messages with no 3581 encapsulated message, only have a part 1. 3583 Multipart messages are assigned consecutive part numbers, as 3584 they occur in the message. If a particular part is of type 3585 message or multipart, its parts MUST be indicated by a period 3586 followed by the part number within that nested multipart part. 3588 A part of type MESSAGE/RFC822 or MESSAGE/GLOBAL also has nested 3589 part numbers, referring to parts of the MESSAGE part's body. 3591 The HEADER, HEADER.FIELDS, HEADER.FIELDS.NOT, and TEXT part 3592 specifiers can be the sole part specifier or can be prefixed by 3593 one or more numeric part specifiers, provided that the numeric 3594 part specifier refers to a part of type MESSAGE/RFC822 or 3595 MESSAGE/GLOBAL. The MIME part specifier MUST be prefixed by 3596 one or more numeric part specifiers. 3598 The HEADER, HEADER.FIELDS, and HEADER.FIELDS.NOT part 3599 specifiers refer to the [RFC-5322] header of the message or of 3600 an encapsulated [MIME-IMT] MESSAGE/RFC822 or MESSAGE/GLOBAL 3601 message. HEADER.FIELDS and HEADER.FIELDS.NOT are followed by a 3602 list of field-name (as defined in [RFC-5322]) names, and return 3603 a subset of the header. The subset returned by HEADER.FIELDS 3604 contains only those header fields with a field-name that 3605 matches one of the names in the list; similarly, the subset 3606 returned by HEADER.FIELDS.NOT contains only the header fields 3607 with a non-matching field-name. The field-matching is ASCII 3608 range case-insensitive but otherwise exact. Subsetting does 3609 not exclude the [RFC-5322] delimiting blank line between the 3610 header and the body; the blank line is included in all header 3611 fetches, except in the case of a message which has no body and 3612 no blank line. 3614 The MIME part specifier refers to the [MIME-IMB] header for 3615 this part. 3617 The TEXT part specifier refers to the text body of the message, 3618 omitting the [RFC-5322] header. 3620 Here is an example of a complex message with some of its 3621 part specifiers: 3623 HEADER ([RFC-5322] header of the message) 3624 TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 3625 1 TEXT/PLAIN 3626 2 APPLICATION/OCTET-STREAM 3627 3 MESSAGE/RFC822 3628 3.HEADER ([RFC-5322] header of the message) 3629 3.TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 3630 3.1 TEXT/PLAIN 3631 3.2 APPLICATION/OCTET-STREAM 3632 4 MULTIPART/MIXED 3633 4.1 IMAGE/GIF 3634 4.1.MIME ([MIME-IMB] header for the IMAGE/GIF) 3635 4.2 MESSAGE/RFC822 3636 4.2.HEADER ([RFC-5322] header of the message) 3637 4.2.TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 3638 4.2.1 TEXT/PLAIN 3639 4.2.2 MULTIPART/ALTERNATIVE 3640 4.2.2.1 TEXT/PLAIN 3641 4.2.2.2 TEXT/RICHTEXT 3643 It is possible to fetch a substring of the designated text. 3644 This is done by appending an open angle bracket ("<"), the 3645 octet position of the first desired octet, a period, the 3646 maximum number of octets desired, and a close angle bracket 3647 (">") to the part specifier. If the starting octet is beyond 3648 the end of the text, an empty string is returned. 3650 Any partial fetch that attempts to read beyond the end of the 3651 text is truncated as appropriate. A partial fetch that starts 3652 at octet 0 is returned as a partial fetch, even if this 3653 truncation happened. 3655 Note: This means that BODY[]<0.2048> of a 1500-octet message 3656 will return BODY[]<0> with a literal of size 1500, not 3657 BODY[]. 3659 Note: A substring fetch of a HEADER.FIELDS or 3660 HEADER.FIELDS.NOT part specifier is calculated after 3661 subsetting the header. 3663 The \Seen flag is implicitly set; if this causes the flags to 3664 change, they SHOULD be included as part of the FETCH responses. 3666 BODY.PEEK[
]<> An alternate form of BODY[
] 3667 that does not implicitly set the \Seen flag. 3669 BODYSTRUCTURE The [MIME-IMB] body structure of the message. This is 3670 computed by the server by parsing the [MIME-IMB] header fields in 3671 the [RFC-5322] header and [MIME-IMB] headers. 3673 ENVELOPE The envelope structure of the message. This is computed by 3674 the server by parsing the [RFC-5322] header into the component 3675 parts, defaulting various fields as necessary. 3677 FLAGS The flags that are set for this message. 3679 INTERNALDATE The internal date of the message. 3681 RFC822 Functionally equivalent to BODY[], differing in the syntax of 3682 the resulting untagged FETCH data (RFC822 is returned). 3684 RFC822.HEADER Functionally equivalent to BODY.PEEK[HEADER], 3685 differing in the syntax of the resulting untagged FETCH data 3686 (RFC822.HEADER is returned). 3688 RFC822.SIZE The [RFC-5322] size of the message. 3690 RFC822.TEXT Functionally equivalent to BODY[TEXT], differing in the 3691 syntax of the resulting untagged FETCH data (RFC822.TEXT is 3692 returned). 3694 UID The unique identifier for the message. 3696 Example: C: A654 FETCH 2:4 (FLAGS BODY[HEADER.FIELDS (DATE FROM)]) 3697 S: * 2 FETCH .... 3698 S: * 3 FETCH .... 3699 S: * 4 FETCH .... 3700 S: A654 OK FETCH completed 3702 6.4.7. STORE Command 3704 Arguments: sequence set 3705 message data item name 3706 value for message data item 3708 Responses: untagged responses: FETCH 3710 Result: OK - store completed 3711 NO - store error: can't store that data 3712 BAD - command unknown or arguments invalid 3714 The STORE command alters data associated with a message in the 3715 mailbox. Normally, STORE will return the updated value of the data 3716 with an untagged FETCH response. A suffix of ".SILENT" in the data 3717 item name prevents the untagged FETCH, and the server SHOULD assume 3718 that the client has determined the updated value itself or does not 3719 care about the updated value. 3721 Note: Regardless of whether or not the ".SILENT" suffix was used, 3722 the server SHOULD send an untagged FETCH response if a change to a 3723 message's flags from an external source is observed. The intent 3724 is that the status of the flags is determinate without a race 3725 condition. 3727 The currently defined data items that can be stored are: 3729 FLAGS Replace the flags for the message with the 3730 argument. The new value of the flags is returned as if a FETCH of 3731 those flags was done. 3733 FLAGS.SILENT Equivalent to FLAGS, but without returning 3734 a new value. 3736 +FLAGS Add the argument to the flags for the message. 3737 The new value of the flags is returned as if a FETCH of those 3738 flags was done. 3740 +FLAGS.SILENT Equivalent to +FLAGS, but without 3741 returning a new value. 3743 -FLAGS Remove the argument from the flags for the 3744 message. The new value of the flags is returned as if a FETCH of 3745 those flags was done. 3747 -FLAGS.SILENT Equivalent to -FLAGS, but without 3748 returning a new value. 3750 Example: C: A003 STORE 2:4 +FLAGS (\Deleted) 3751 S: * 2 FETCH (FLAGS (\Deleted \Seen)) 3752 S: * 3 FETCH (FLAGS (\Deleted)) 3753 S: * 4 FETCH (FLAGS (\Deleted \Flagged \Seen)) 3754 S: A003 OK STORE completed 3756 6.4.8. COPY Command 3758 Arguments: sequence set 3759 mailbox name 3761 Responses: no specific responses for this command 3763 Result: OK - copy completed 3764 NO - copy error: can't copy those messages or to that 3765 name 3766 BAD - command unknown or arguments invalid 3768 The COPY command copies the specified message(s) to the end of the 3769 specified destination mailbox. The flags and internal date of the 3770 message(s) SHOULD be preserved in the copy. 3772 If the destination mailbox does not exist, a server SHOULD return an 3773 error. It SHOULD NOT automatically create the mailbox. Unless it is 3774 certain that the destination mailbox can not be created, the server 3775 MUST send the response code "[TRYCREATE]" as the prefix of the text 3776 of the tagged NO response. This gives a hint to the client that it 3777 can attempt a CREATE command and retry the COPY if the CREATE is 3778 successful. 3780 If the COPY command is unsuccessful for any reason, server 3781 implementations MUST restore the destination mailbox to its state 3782 before the COPY attempt. 3784 On successful completion of a COPY, the server SHOULD return a 3785 COPYUID response code. 3787 In the case of a mailbox that has permissions set so that the client 3788 can COPY to the mailbox, but not SELECT or EXAMINE it, the server 3789 SHOULD NOT send an COPYUID response code as it would disclose 3790 information about the mailbox. 3792 In the case of a mailbox that has UIDNOTSTICKY status (see the 3793 UIDNOTSTICKY response code), the server MAY omit the COPYUID response 3794 code as it is not meaningful. 3796 If the server does not return the COPYUID response code, the client 3797 can discover this information by selecting the destination mailbox. 3798 The location of messages placed in the destination mailbox by COPY 3799 can be determined by using FETCH and/or SEARCH commands (e.g., for 3800 Message-ID). 3802 Example: C: A003 COPY 2:4 MEETING 3803 S: A003 OK COPY completed 3805 6.4.9. MOVE Command 3807 Arguments: sequence set 3808 mailbox name 3810 Responses: no specific responses for this command 3812 Result: OK - move completed 3813 NO - move error: can't move those messages or to that 3814 name 3815 BAD - command unknown or arguments invalid 3817 The MOVE command moves the specified message(s) to the end of the 3818 specified destination mailbox. The flags and internal date of the 3819 message(s) SHOULD be preserved. 3821 This means that a new message is created in the target mailbox with a 3822 new UID, the original message is removed from the source mailbox, and 3823 it appears to the client as a single action. This has the same 3824 effect for each message as this sequence: 3826 1. [UID] COPY 3828 2. [UID] STORE +FLAGS.SILENT \DELETED 3830 3. UID EXPUNGE 3832 Although the effect of the MOVE is the same as the preceding steps, 3833 the semantics are not identical: The intermediate states produced by 3834 those steps do not occur, and the response codes are different. In 3835 particular, though the COPY and EXPUNGE response codes will be 3836 returned, response codes for a STORE MUST NOT be generated and the 3837 \Deleted flag MUST NOT be set for any message. 3839 Because a MOVE applies to a set of messages, it might fail partway 3840 through the set. Regardless of whether the command is successful in 3841 moving the entire set, each individual message SHOULD either be moved 3842 or unaffected. The server MUST leave each message in a state where 3843 it is in at least one of the source or target mailboxes (no message 3844 can be lost or orphaned). The server SHOULD NOT leave any message in 3845 both mailboxes (it would be bad for a partial failure to result in a 3846 bunch of duplicate messages). This is true even if the server 3847 returns a tagged NO response to the command. 3849 Because of the similarity of MOVE to COPY, extensions that affect 3850 COPY affect MOVE in the same way. Response codes such as TRYCREATE 3851 (see Section 7.1), as well as those defined by extensions, are sent 3852 as appropriate. 3854 Servers SHOULD send COPYUID in response to a UID MOVE (see 3855 Section 6.4.10) command. For additional information see Section 7.1. 3857 Servers are also advised to send the COPYUID response code in an 3858 untagged OK before sending EXPUNGE or moved responses. (Sending 3859 COPYUID in the tagged OK, as described in the UIDPLUS specification, 3860 means that clients first receive an EXPUNGE for a message and 3861 afterwards COPYUID for the same message. It can be unnecessarily 3862 difficult to process that sequence usefully.) 3864 An example: 3865 C: a UID MOVE 42:69 foo 3866 S: * OK [COPYUID 432432 42:69 1202:1229] 3867 S: * 22 EXPUNGE 3868 S: (more expunges) 3869 S: a OK Done 3871 Note that the server may send unrelated EXPUNGE responses as well, if 3872 any happen to have been expunged at the same time; this is normal 3873 IMAP operation. 3875 Note that moving a message to the currently selected mailbox (that 3876 is, where the source and target mailboxes are the same) is allowed 3877 when copying the message to the currently selected mailbox is 3878 allowed. 3880 The server may send EXPUNGE responses before the tagged response, so 3881 the client cannot safely send more commands with message sequence 3882 number arguments while the server is processing MOVE. 3884 MOVE and UID MOVE can be pipelined with other commands, but care has 3885 to be taken. Both commands modify sequence numbers and also allow 3886 unrelated EXPUNGE responses. The renumbering of other messages in 3887 the source mailbox following any EXPUNGE response can be surprising 3888 and makes it unsafe to pipeline any command that relies on message 3889 sequence numbers after a MOVE or UID MOVE. Similarly, MOVE cannot be 3890 pipelined with a command that might cause message renumbering. See 3891 Section 5.5, for more information about ambiguities as well as 3892 handling requirements for both clients and servers. 3894 6.4.10. UID Command 3896 Arguments: command name 3897 command arguments 3899 Responses: untagged responses: FETCH, ESEARCH 3901 Result: OK - UID command completed 3902 NO - UID command error 3903 BAD - command unknown or arguments invalid 3905 The UID command has three forms. In the first form, it takes as its 3906 arguments a COPY, MOVE, FETCH, or STORE command with arguments 3907 appropriate for the associated command. However, the numbers in the 3908 sequence set argument are unique identifiers instead of message 3909 sequence numbers. Sequence set ranges are permitted, but there is no 3910 guarantee that unique identifiers will be contiguous. 3912 A non-existent unique identifier is ignored without any error message 3913 generated. Thus, it is possible for a UID FETCH command to return an 3914 OK without any data or a UID COPY, UID MOVE or UID STORE to return an 3915 OK without performing any operations. 3917 In the second form, the UID command takes an EXPUNGE command with an 3918 extra parameter the specified a sequence set of UIDs to operate on. 3919 The UID EXPUNGE command permanently removes all messages that both 3920 have the \Deleted flag set and have a UID that is included in the 3921 specified sequence set from the currently selected mailbox. If a 3922 message either does not have the \Deleted flag set or has a UID that 3923 is not included in the specified sequence set, it is not affected. 3925 UID EXPUNGE is particularly useful for disconnected use clients. 3926 By using UID EXPUNGE instead of EXPUNGE when resynchronizing with 3927 the server, the client can ensure that it does not inadvertantly 3928 remove any messages that have been marked as \Deleted by other 3929 clients between the time that the client was last connected and 3930 the time the client resynchronizes. 3932 Example: C: A003 UID EXPUNGE 3000:3002 3933 S: * 3 EXPUNGE 3934 S: * 3 EXPUNGE 3935 S: * 3 EXPUNGE 3936 S: A003 OK UID EXPUNGE completed 3938 In the third form, the UID command takes a SEARCH command with SEARCH 3939 command arguments. The interpretation of the arguments is the same 3940 as with SEARCH; however, the numbers returned in a ESEARCH response 3941 for a UID SEARCH command are unique identifiers instead of message 3942 sequence numbers. Also, the corresponding ESEARCH response MUST 3943 include the UID indicator. For example, the command UID SEARCH 1:100 3944 UID 443:557 returns the unique identifiers corresponding to the 3945 intersection of two sequence sets, the message sequence number range 3946 1:100 and the UID range 443:557. 3948 Note: in the above example, the UID range 443:557 appears. The 3949 same comment about a non-existent unique identifier being ignored 3950 without any error message also applies here. Hence, even if 3951 neither UID 443 or 557 exist, this range is valid and would 3952 include an existing UID 495. 3954 Also note that a UID range of 559:* always includes the UID of the 3955 last message in the mailbox, even if 559 is higher than any 3956 assigned UID value. This is because the contents of a range are 3957 independent of the order of the range endpoints. Thus, any UID 3958 range with * as one of the endpoints indicates at least one 3959 message (the message with the highest numbered UID), unless the 3960 mailbox is empty. 3962 The number after the "*" in an untagged FETCH or EXPUNGE response is 3963 always a message sequence number, not a unique identifier, even for a 3964 UID command response. However, server implementations MUST 3965 implicitly include the UID message data item as part of any FETCH 3966 response caused by a UID command, regardless of whether a UID was 3967 specified as a message data item to the FETCH. 3969 Note: The rule about including the UID message data item as part of a 3970 FETCH response primarily applies to the UID FETCH and UID STORE 3971 commands, including a UID FETCH command that does not include UID as 3972 a message data item. Although it is unlikely that the other UID 3973 commands will cause an untagged FETCH, this rule applies to these 3974 commands as well. 3976 Example: C: A999 UID FETCH 4827313:4828442 FLAGS 3977 S: * 23 FETCH (FLAGS (\Seen) UID 4827313) 3978 S: * 24 FETCH (FLAGS (\Seen) UID 4827943) 3979 S: * 25 FETCH (FLAGS (\Seen) UID 4828442) 3980 S: A999 OK UID FETCH completed 3982 6.5. Client Commands - Experimental/Expansion 3984 6.5.1. X Command 3986 Arguments: implementation defined 3988 Responses: implementation defined 3990 Result: OK - command completed 3991 NO - failure 3992 BAD - command unknown or arguments invalid 3994 Any command prefixed with an X is an experimental command. Commands 3995 which are not part of this specification, a standard or standards- 3996 track revision of this specification, or an IESG-approved 3997 experimental protocol, MUST use the X prefix. 3999 Any added untagged responses issued by an experimental command MUST 4000 also be prefixed with an X. Server implementations MUST NOT send any 4001 such untagged responses, unless the client requested it by issuing 4002 the associated experimental command. 4004 Example: C: a441 CAPABILITY 4005 S: * CAPABILITY IMAP4rev2 XPIG-LATIN 4006 S: a441 OK CAPABILITY completed 4007 C: A442 XPIG-LATIN 4008 S: * XPIG-LATIN ow-nay eaking-spay ig-pay atin-lay 4009 S: A442 OK XPIG-LATIN ompleted-cay 4011 7. Server Responses 4013 Server responses are in three forms: status responses, server data, 4014 and command continuation request. The information contained in a 4015 server response, identified by "Contents:" in the response 4016 descriptions below, is described by function, not by syntax. The 4017 precise syntax of server responses is described in the Formal Syntax 4018 section. 4020 The client MUST be prepared to accept any response at all times. 4022 Status responses can be tagged or untagged. Tagged status responses 4023 indicate the completion result (OK, NO, or BAD status) of a client 4024 command, and have a tag matching the command. 4026 Some status responses, and all server data, are untagged. An 4027 untagged response is indicated by the token "*" instead of a tag. 4028 Untagged status responses indicate server greeting, or server status 4029 that does not indicate the completion of a command (for example, an 4030 impending system shutdown alert). For historical reasons, untagged 4031 server data responses are also called "unsolicited data", although 4032 strictly speaking, only unilateral server data is truly 4033 "unsolicited". 4035 Certain server data MUST be recorded by the client when it is 4036 received; this is noted in the description of that data. Such data 4037 conveys critical information which affects the interpretation of all 4038 subsequent commands and responses (e.g., updates reflecting the 4039 creation or destruction of messages). 4041 Other server data SHOULD be recorded for later reference; if the 4042 client does not need to record the data, or if recording the data has 4043 no obvious purpose (e.g., a SEARCH response when no SEARCH command is 4044 in progress), the data SHOULD be ignored. 4046 An example of unilateral untagged server data occurs when the IMAP 4047 connection is in the selected state. In the selected state, the 4048 server checks the mailbox for new messages as part of command 4049 execution. Normally, this is part of the execution of every command; 4050 hence, a NOOP command suffices to check for new messages. If new 4051 messages are found, the server sends untagged EXISTS response 4052 reflecting the new size of the mailbox. Server implementations that 4053 offer multiple simultaneous access to the same mailbox SHOULD also 4054 send appropriate unilateral untagged FETCH and EXPUNGE responses if 4055 another agent changes the state of any message flags or expunges any 4056 messages. 4058 Command continuation request responses use the token "+" instead of a 4059 tag. These responses are sent by the server to indicate acceptance 4060 of an incomplete client command and readiness for the remainder of 4061 the command. 4063 7.1. Server Responses - Status Responses 4065 Status responses are OK, NO, BAD, PREAUTH and BYE. OK, NO, and BAD 4066 can be tagged or untagged. PREAUTH and BYE are always untagged. 4068 Status responses MAY include an OPTIONAL "response code". A response 4069 code consists of data inside square brackets in the form of an atom, 4070 possibly followed by a space and arguments. The response code 4071 contains additional information or status codes for client software 4072 beyond the OK/NO/BAD condition, and are defined when there is a 4073 specific action that a client can take based upon the additional 4074 information. 4076 The currently defined response codes are: 4078 ALERT The human-readable text contains a special alert that MUST be 4079 presented to the user in a fashion that calls the user's attention 4080 to the message. 4082 ALREADYEXISTS 4084 The operation attempts to create something that already exists, 4085 such as when the CREATE or RENAME directories attempt to create 4086 a mailbox and there is already one of that name. 4088 C: o RENAME this that 4089 S: o NO [ALREADYEXISTS] Mailbox "that" already exists 4091 APPENDUID 4093 Followed by the UIDVALIDITY of the destination mailbox and the 4094 UID assigned to the appended message in the destination 4095 mailbox, indicates that the message has been appended to the 4096 destination mailbox with that UID. 4098 If the server also supports the [MULTIAPPEND] extension, and if 4099 multiple messages were appended in the APPEND command, then the 4100 second value is a UID set containing the UIDs assigned to the 4101 appended messages, in the order they were transmitted in the 4102 APPEND command. This UID set may not contain extraneous UIDs 4103 or the symbol "*". 4105 Note: the UID set form of the APPENDUID response code MUST 4106 NOT be used if only a single message was appended. In 4107 particular, a server MUST NOT send a range such as 123:123. 4108 This is because a client that does not support [MULTIAPPEND] 4109 expects only a single UID and not a UID set. 4111 UIDs are assigned in strictly ascending order in the mailbox 4112 (refer to Section 2.3.1.1); note that a range of 12:10 is 4113 exactly equivalent to 10:12 and refers to the sequence 4114 10,11,12. 4116 This response code is returned in a tagged OK response to the 4117 APPEND command. 4119 AUTHENTICATIONFAILED 4121 Authentication failed for some reason on which the server is 4122 unwilling to elaborate. Typically, this includes "unknown 4123 user" and "bad password". 4125 This is the same as not sending any response code, except that 4126 when a client sees AUTHENTICATIONFAILED, it knows that the 4127 problem wasn't, e.g., UNAVAILABLE, so there's no point in 4128 trying the same login/password again later. 4130 C: b LOGIN "fred" "foo" 4131 S: b NO [AUTHENTICATIONFAILED] Authentication failed 4133 AUTHORIZATIONFAILED Authentication succeeded in using the 4134 authentication identity, but the server cannot or will not allow 4135 the authentication identity to act as the requested authorization 4136 identity. This is only applicable when the authentication and 4137 authorization identities are different. C: c1 AUTHENTICATE PLAIN 4138 [...] 4139 S: c1 NO [AUTHORIZATIONFAILED] No such authorization-ID 4140 C: c2 AUTHENTICATE PLAIN 4141 [...] 4142 S: c2 NO [AUTHORIZATIONFAILED] Authenticator is not an admin 4144 BADCHARSET Optionally followed by a parenthesized list of charsets. 4145 A SEARCH failed because the given charset is not supported by this 4146 implementation. If the optional list of charsets is given, this 4147 lists the charsets that are supported by this implementation. 4149 CANNOT 4151 The operation violates some invariant of the server and can 4152 never succeed. 4154 C: l create "///////" 4155 S: l NO [CANNOT] Adjacent slashes are not supported 4157 CAPABILITY Followed by a list of capabilities. This can appear in 4158 the initial OK or PREAUTH response to transmit an initial 4159 capabilities list. This makes it unnecessary for a client to send 4160 a separate CAPABILITY command if it recognizes this response. 4162 CLIENTBUG 4164 The server has detected a client bug. This can accompany all 4165 of OK, NO, and BAD, depending on what the client bug is. 4167 C: k1 select "/archive/projects/experiment-iv" 4168 [...] 4169 S: k1 OK [READ-ONLY] Done 4170 C: k2 status "/archive/projects/experiment-iv" (messages) 4171 [...] 4172 S: k2 OK [CLIENTBUG] Done 4174 CLOSED 4176 The CLOSED response code has no parameters. A server return 4177 the CLOSED response code when the currently selected mailbox is 4178 closed implicitly using the SELECT/EXAMINE command on another 4179 mailbox. The CLOSED response code serves as a boundary between 4180 responses for the previously opened mailbox (which was closed) 4181 and the newly selected mailbox; all responses before the CLOSED 4182 response code relate to the mailbox that was closed, and all 4183 subsequent responses relate to the newly opened mailbox. 4185 There is no need to return the CLOSED response code on 4186 completion of the CLOSE or the UNSELECT command (or similar), 4187 whose purpose is to close the currently selected mailbox 4188 without opening a new one. 4190 The server can also return an unsolicited CLOSED response code 4191 when it wants to force the client to return to authenticated 4192 state. For example, the server can do that when the mailbox 4193 requires repairs or is deleted in another session. 4195 CONTACTADMIN 4197 The user should contact the system administrator or support 4198 desk. 4200 C: e login "fred" "foo" 4201 S: e OK [CONTACTADMIN] 4203 COPYUID 4205 Followed by the UIDVALIDITY of the destination mailbox, a UID 4206 set containing the UIDs of the message(s) in the source mailbox 4207 that were copied to the destination mailbox and containing the 4208 UIDs assigned to the copied message(s) in the destination 4209 mailbox, indicates that the message(s) have been copied to the 4210 destination mailbox with the stated UID(s). 4212 The source UID set is in the order the message(s) were copied; 4213 the destination UID set corresponds to the source UID set and 4214 is in the same order. Neither of the UID sets may contain 4215 extraneous UIDs or the symbol "*". 4217 UIDs are assigned in strictly ascending order in the mailbox 4218 (refer to Section 2.3.1.1); note that a range of 12:10 is 4219 exactly equivalent to 10:12 and refers to the sequence 4220 10,11,12. 4222 This response code is returned in a tagged OK response to the 4223 COPY command. 4225 CORRUPTION 4227 The server discovered that some relevant data (e.g., the 4228 mailbox) are corrupt. This response code does not include any 4229 information about what's corrupt, but the server can write that 4230 to its logfiles. 4232 C: i select "/archive/projects/experiment-iv" 4233 S: i NO [CORRUPTION] Cannot open mailbox 4235 EXPIRED 4237 Either authentication succeeded or the server no longer had the 4238 necessary data; either way, access is no longer permitted using 4239 that passphrase. The client or user should get a new 4240 passphrase. 4242 C: d login "fred" "foo" 4243 S: d NO [EXPIRED] That password isn't valid any more 4245 EXPUNGEISSUED 4247 Someone else has issued an EXPUNGE for the same mailbox. The 4248 client may want to issue NOOP soon. [IMAP-MULTIACCESS] 4249 discusses this subject in depth. 4251 C: h search from fred@example.com 4252 S: * SEARCH 1 2 3 5 8 13 21 42 4253 S: h OK [EXPUNGEISSUED] Search completed 4255 INUSE 4257 An operation has not been carried out because it involves 4258 sawing off a branch someone else is sitting on. Someone else 4259 may be holding an exclusive lock needed for this operation, or 4260 the operation may involve deleting a resource someone else is 4261 using, typically a mailbox. 4263 The operation may succeed if the client tries again later. 4265 C: g delete "/archive/projects/experiment-iv" 4266 S: g NO [INUSE] Mailbox in use 4268 LIMIT 4270 The operation ran up against an implementation limit of some 4271 kind, such as the number of flags on a single message or the 4272 number of flags used in a mailbox. 4274 C: m STORE 42 FLAGS f1 f2 f3 f4 f5 ... f250 4275 S: m NO [LIMIT] At most 32 flags in one mailbox supported 4277 NONEXISTENT 4279 The operation attempts to delete something that does not exist. 4280 Similar to ALREADYEXISTS. 4282 C: p RENAME this that 4283 S: p NO [NONEXISTENT] No such mailbox 4285 NOPERM 4287 The access control system (e.g., Access Control List (ACL), see 4288 [RFC4314] does not permit this user to carry out an operation, 4289 such as selecting or creating a mailbox. 4291 C: f select "/archive/projects/experiment-iv" 4292 S: f NO [NOPERM] Access denied 4294 OVERQUOTA 4296 The user would be over quota after the operation. (The user 4297 may or may not be over quota already.) 4299 Note that if the server sends OVERQUOTA but doesn't support the 4300 IMAP QUOTA extension defined by [RFC2087], then there is a 4301 quota, but the client cannot find out what the quota is. 4303 C: n1 uid copy 1:* oldmail 4304 S: n1 NO [OVERQUOTA] Sorry 4306 C: n2 uid copy 1:* oldmail 4307 S: n2 OK [OVERQUOTA] You are now over your soft quota 4309 PARSE The human-readable text represents an error in parsing the 4310 [RFC-5322] header or [MIME-IMB] headers of a message in the 4311 mailbox. 4313 PERMANENTFLAGS Followed by a parenthesized list of flags, indicates 4314 which of the known flags the client can change permanently. Any 4315 flags that are in the FLAGS untagged response, but not the 4316 PERMANENTFLAGS list, can not be set permanently. If the client 4317 attempts to STORE a flag that is not in the PERMANENTFLAGS list, 4318 the server will either ignore the change or store the state change 4319 for the remainder of the current session only. The PERMANENTFLAGS 4320 list can also include the special flag \*, which indicates that it 4321 is possible to create new keywords by attempting to store those 4322 flags in the mailbox. 4324 PRIVACYREQUIRED 4326 The operation is not permitted due to a lack of privacy. If 4327 Transport Layer Security (TLS) is not in use, the client could 4328 try STARTTLS (see Section 6.2.1) and then repeat the operation. 4330 C: d login "fred" "foo" 4331 S: d NO [PRIVACYREQUIRED] Connection offers no privacy 4333 C: d select inbox 4334 S: d NO [PRIVACYREQUIRED] Connection offers no privacy 4336 READ-ONLY The mailbox is selected read-only, or its access while 4337 selected has changed from read-write to read-only. 4339 READ-WRITE The mailbox is selected read-write, or its access while 4340 selected has changed from read-only to read-write. 4342 SERVERBUG 4344 The server encountered a bug in itself or violated one of its 4345 own invariants. 4347 C: j select "/archive/projects/experiment-iv" 4348 S: j NO [SERVERBUG] This should not happen 4350 TRYCREATE An APPEND or COPY attempt is failing because the target 4351 mailbox does not exist (as opposed to some other reason). This is 4352 a hint to the client that the operation can succeed if the mailbox 4353 is first created by the CREATE command. 4355 UIDNEXT Followed by a decimal number, indicates the next unique 4356 identifier value. Refer to Section 2.3.1.1 for more information. 4358 UIDNOTSTICKY 4360 The selected mailbox is supported by a mail store that does not 4361 support persistent UIDs; that is, UIDVALIDITY will be different 4362 each time the mailbox is selected. Consequently, APPEND or 4363 COPY to this mailbox will not return an APPENDUID or COPYUID 4364 response code. 4366 This response code is returned in an untagged NO response to 4367 the SELECT command. 4369 Note: servers SHOULD NOT have any UIDNOTSTICKY mail stores. 4370 This facility exists to support legacy mail stores in which 4371 it is technically infeasible to support persistent UIDs. 4372 This should be avoided when designing new mail stores. 4374 UIDVALIDITY Followed by a decimal number, indicates the unique 4375 identifier validity value. Refer to Section 2.3.1.1 for more 4376 information. 4378 UNAVAILABLE 4380 Temporary failure because a subsystem is down. For example, an 4381 IMAP server that uses a Lightweight Directory Access Protocol 4382 (LDAP) or Radius server for authentication might use this 4383 response code when the LDAP/Radius server is down. 4385 C: a LOGIN "fred" "foo" 4386 S: a NO [UNAVAILABLE] User's backend down for maintenance 4388 UNKNOWN-CTE 4390 The server does not know how to decode the section's Content- 4391 Transfer-Encoding. 4393 Additional response codes defined by particular client or server 4394 implementations SHOULD be prefixed with an "X" until they are added 4395 to a revision of this protocol. Client implementations SHOULD ignore 4396 response codes that they do not recognize. 4398 7.1.1. OK Response 4400 Contents: OPTIONAL response code 4401 human-readable text 4403 The OK response indicates an information message from the server. 4404 When tagged, it indicates successful completion of the associated 4405 command. The human-readable text MAY be presented to the user as an 4406 information message. The untagged form indicates an information-only 4407 message; the nature of the information MAY be indicated by a response 4408 code. 4410 The untagged form is also used as one of three possible greetings at 4411 connection startup. It indicates that the connection is not yet 4412 authenticated and that a LOGIN or an AUTHENTICATE command is needed. 4414 Example: S: * OK IMAP4rev2 server ready 4415 C: A001 LOGIN fred blurdybloop 4416 S: * OK [ALERT] System shutdown in 10 minutes 4417 S: A001 OK LOGIN Completed 4419 7.1.2. NO Response 4421 Contents: OPTIONAL response code 4422 human-readable text 4424 The NO response indicates an operational error message from the 4425 server. When tagged, it indicates unsuccessful completion of the 4426 associated command. The untagged form indicates a warning; the 4427 command can still complete successfully. The human-readable text 4428 describes the condition. 4430 Example: C: A222 COPY 1:2 owatagusiam 4431 S: * NO Disk is 98% full, please delete unnecessary data 4432 S: A222 OK COPY completed 4433 C: A223 COPY 3:200 blurdybloop 4434 S: * NO Disk is 98% full, please delete unnecessary data 4435 S: * NO Disk is 99% full, please delete unnecessary data 4436 S: A223 NO COPY failed: disk is full 4438 7.1.3. BAD Response 4440 Contents: OPTIONAL response code 4441 human-readable text 4443 The BAD response indicates an error message from the server. When 4444 tagged, it reports a protocol-level error in the client's command; 4445 the tag indicates the command that caused the error. The untagged 4446 form indicates a protocol-level error for which the associated 4447 command can not be determined; it can also indicate an internal 4448 server failure. The human-readable text describes the condition. 4450 Example: C: ...very long command line... 4451 S: * BAD Command line too long 4452 C: ...empty line... 4453 S: * BAD Empty command line 4454 C: A443 EXPUNGE 4455 S: * BAD Disk crash, attempting salvage to a new disk! 4456 S: * OK Salvage successful, no data lost 4457 S: A443 OK Expunge completed 4459 7.1.4. PREAUTH Response 4461 Contents: OPTIONAL response code 4462 human-readable text 4464 The PREAUTH response is always untagged, and is one of three possible 4465 greetings at connection startup. It indicates that the connection 4466 has already been authenticated by external means; thus no LOGIN/ 4467 AUTHENTICATE command is needed. 4469 Example: S: * PREAUTH IMAP4rev2 server logged in as Smith 4471 7.1.5. BYE Response 4473 Contents: OPTIONAL response code 4474 human-readable text 4476 The BYE response is always untagged, and indicates that the server is 4477 about to close the connection. The human-readable text MAY be 4478 displayed to the user in a status report by the client. The BYE 4479 response is sent under one of four conditions: 4481 1. as part of a normal logout sequence. The server will close the 4482 connection after sending the tagged OK response to the LOGOUT 4483 command. 4485 2. as a panic shutdown announcement. The server closes the 4486 connection immediately. 4488 3. as an announcement of an inactivity autologout. The server 4489 closes the connection immediately. 4491 4. as one of three possible greetings at connection startup, 4492 indicating that the server is not willing to accept a connection 4493 from this client. The server closes the connection immediately. 4495 The difference between a BYE that occurs as part of a normal LOGOUT 4496 sequence (the first case) and a BYE that occurs because of a failure 4497 (the other three cases) is that the connection closes immediately in 4498 the failure case. In all cases the client SHOULD continue to read 4499 response data from the server until the connection is closed; this 4500 will ensure that any pending untagged or completion responses are 4501 read and processed. 4503 Example: S: * BYE Autologout; idle for too long 4505 7.2. Server Responses - Server and Mailbox Status 4507 These responses are always untagged. This is how server and mailbox 4508 status data are transmitted from the server to the client. Many of 4509 these responses typically result from a command with the same name. 4511 7.2.1. The ENABLED Response 4513 Contents: capability listing 4515 The ENABLED response occurs as a result of an ENABLE command. The 4516 capability listing contains a space-separated listing of capability 4517 names that the server supports and that were successfully enabled. 4518 The ENABLED response may contain no capabilities, which means that no 4519 extensions listed by the client were successfully enabled. 4521 7.2.2. CAPABILITY Response 4523 Contents: capability listing 4524 The CAPABILITY response occurs as a result of a CAPABILITY command. 4525 The capability listing contains a space-separated listing of 4526 capability names that the server supports. The capability listing 4527 MUST include the atom "IMAP4rev2". 4529 In addition, client and server implementations MUST implement the 4530 STARTTLS, LOGINDISABLED, and AUTH=PLAIN (described in [PLAIN]) 4531 capabilities. See the Security Considerations section for important 4532 information. 4534 A capability name which begins with "AUTH=" indicates that the server 4535 supports that particular authentication mechanism. 4537 The LOGINDISABLED capability indicates that the LOGIN command is 4538 disabled, and that the server will respond with a tagged NO response 4539 to any attempt to use the LOGIN command even if the user name and 4540 password are valid. An IMAP client MUST NOT issue the LOGIN command 4541 if the server advertises the LOGINDISABLED capability. 4543 Other capability names indicate that the server supports an 4544 extension, revision, or amendment to the IMAP4rev2 protocol. Server 4545 responses MUST conform to this document until the client issues a 4546 command that uses the associated capability. 4548 Capability names MUST either begin with "X" or be standard or 4549 standards-track IMAP4rev2 extensions, revisions, or amendments 4550 registered with IANA. A server MUST NOT offer unregistered or non- 4551 standard capability names, unless such names are prefixed with an 4552 "X". 4554 Client implementations SHOULD NOT require any capability name other 4555 than "IMAP4rev2", and MUST ignore any unknown capability names. 4557 A server MAY send capabilities automatically, by using the CAPABILITY 4558 response code in the initial PREAUTH or OK responses, and by sending 4559 an updated CAPABILITY response code in the tagged OK response as part 4560 of a successful authentication. It is unnecessary for a client to 4561 send a separate CAPABILITY command if it recognizes these automatic 4562 capabilities. 4564 Example: S: * CAPABILITY IMAP4rev2 STARTTLS AUTH=GSSAPI XPIG-LATIN 4566 7.2.3. LIST Response 4568 Contents: name attributes 4569 hierarchy delimiter 4570 name 4572 The LIST response occurs as a result of a LIST command. It returns a 4573 single name that matches the LIST specification. There can be 4574 multiple LIST responses for a single LIST command. 4576 The following base name attributes are defined: 4578 \Noinferiors It is not possible for any child levels of hierarchy to 4579 exist under this name; no child levels exist now and none can be 4580 created in the future. 4582 \Noselect It is not possible to use this name as a selectable 4583 mailbox. 4585 \HasChildren The presence of this attribute indicates that the 4586 mailbox has child mailboxes. A server SHOULD NOT set this 4587 attribute if there are child mailboxes and the user does not have 4588 permission to access any of them. In this case, \HasNoChildren 4589 SHOULD be used. In many cases, however, a server may not be able 4590 to efficiently compute whether a user has access to any child 4591 mailbox. Note that even though the \HasChildren attribute for a 4592 mailbox must be correct at the time of processing of the mailbox, 4593 a client must be prepared to deal with a situation when a mailbox 4594 is marked with the \HasChildren attribute, but no child mailbox 4595 appears in the response to the LIST command. This might happen, 4596 for example, due to children mailboxes being deleted or made 4597 inaccessible to the user (using access control) by another client 4598 before the server is able to list them. 4600 \HasNoChildren The presence of this attribute indicates that the 4601 mailbox has NO child mailboxes that are accessible to the 4602 currently authenticated user. 4604 \Marked The mailbox has been marked "interesting" by the server; the 4605 mailbox probably contains messages that have been added since the 4606 last time the mailbox was selected. 4608 \Unmarked The mailbox does not contain any additional messages since 4609 the last time the mailbox was selected. 4611 It is an error for the server to return both a \HasChildren and a 4612 \HasNoChildren attribute in the same LIST response. 4614 Note: the \HasNoChildren attribute should not be confused with the 4615 \NoInferiors attribute, which indicates that no child mailboxes 4616 exist now and none can be created in the future. 4618 If it is not feasible for the server to determine whether or not the 4619 mailbox is "interesting", the server SHOULD NOT send either \Marked 4620 or \Unmarked. The server MUST NOT send more than one of \Marked, 4621 \Unmarked, and \Noselect for a single mailbox, and MAY send none of 4622 these. 4624 In addition to the base name attributes defined above, an IMAP server 4625 MAY also include any or all of the following attributes that denote 4626 "role" (or "special-use") of a mailbox. These attributes are 4627 included along with base attributes defined above. A given mailbox 4628 may have none, one, or more than one of these attributes. In some 4629 cases, a special use is advice to a client about what to put in that 4630 mailbox. In other cases, it's advice to a client about what to 4631 expect to find there. 4633 \All This mailbox presents all messages in the user's message store. 4634 Implementations MAY omit some messages, such as, perhaps, those in 4635 \Trash and \Junk. When this special use is supported, it is 4636 almost certain to represent a virtual mailbox. 4638 \Archive This mailbox is used to archive messages. The meaning of 4639 an "archival" mailbox is server-dependent; typically, it will be 4640 used to get messages out of the inbox, or otherwise keep them out 4641 of the user's way, while still making them accessible. 4643 \Drafts This mailbox is used to hold draft messages -- typically, 4644 messages that are being composed but have not yet been sent. In 4645 some server implementations, this might be a virtual mailbox, 4646 containing messages from other mailboxes that are marked with the 4647 "\Draft" message flag. Alternatively, this might just be advice 4648 that a client put drafts here. 4650 \Flagged This mailbox presents all messages marked in some way as 4651 "important". When this special use is supported, it is likely to 4652 represent a virtual mailbox collecting messages (from other 4653 mailboxes) that are marked with the "\Flagged" message flag. 4655 \Junk This mailbox is where messages deemed to be junk mail are 4656 held. Some server implementations might put messages here 4657 automatically. Alternatively, this might just be advice to a 4658 client-side spam filter. 4660 \Sent This mailbox is used to hold copies of messages that have been 4661 sent. Some server implementations might put messages here 4662 automatically. Alternatively, this might just be advice that a 4663 client save sent messages here. 4665 \Trash This mailbox is used to hold messages that have been deleted 4666 or marked for deletion. In some server implementations, this 4667 might be a virtual mailbox, containing messages from other 4668 mailboxes that are marked with the "\Deleted" message flag. 4669 Alternatively, this might just be advice that a client that 4670 chooses not to use the IMAP "\Deleted" model should use this as 4671 its trash location. In server implementations that strictly 4672 expect the IMAP "\Deleted" model, this special use is likely not 4673 to be supported. 4675 All of special-use attributes are OPTIONAL, and any given server or 4676 message store may support any combination of the attributes, or none 4677 at all. In most cases, there will likely be at most one mailbox with 4678 a given attribute for a given user, but in some server or message 4679 store implementations it might be possible for multiple mailboxes to 4680 have the same special-use attribute. 4682 Special-use attributes are likely to be user-specific. User Adam 4683 might share his \Sent mailbox with user Barb, but that mailbox is 4684 unlikely to also serve as Barb's \Sent mailbox. 4686 The hierarchy delimiter is a character used to delimit levels of 4687 hierarchy in a mailbox name. A client can use it to create child 4688 mailboxes, and to search higher or lower levels of naming hierarchy. 4689 All children of a top-level hierarchy node MUST use the same 4690 separator character. A NIL hierarchy delimiter means that no 4691 hierarchy exists; the name is a "flat" name. 4693 The name represents an unambiguous left-to-right hierarchy, and MUST 4694 be valid for use as a reference in LIST and LSUB commands. Unless 4695 \Noselect is indicated, the name MUST also be valid as an argument 4696 for commands, such as SELECT, that accept mailbox names. 4698 Example: S: * LIST (\Noselect) "/" ~/Mail/foo 4700 7.2.4. LSUB Response 4702 Contents: name attributes 4703 hierarchy delimiter 4704 name 4706 The LSUB response occurs as a result of an LSUB command. It returns 4707 a single name that matches the LSUB specification. There can be 4708 multiple LSUB responses for a single LSUB command. The data is 4709 identical in format to the LIST response. 4711 Example: S: * LSUB () "." #news.comp.mail.misc 4713 7.2.5. NAMESPACE Response 4715 Contents: the prefix and hierarchy delimiter to the server's 4716 Personal Namespace(s), Other Users' Namespace(s), and 4717 Shared Namespace(s) 4719 The NAMESPACE response occurs as a result of a NAMESPACE command. It 4720 contains the prefix and hierarchy delimiter to the server's Personal 4721 Namespace(s), Other Users' Namespace(s), and Shared Namespace(s) that 4722 the server wishes to expose. The response will contain a NIL for any 4723 namespace class that is not available. Namespace_Response_Extensions 4724 MAY be included in the response. Namespace_Response_Extensions which 4725 are not on the IETF standards track, MUST be prefixed with an "X-". 4727 Example: S: * NAMESPACE (("" "/")) (("~" "/")) NIL 4729 7.2.6. STATUS Response 4731 Contents: name 4732 status parenthesized list 4734 The STATUS response occurs as a result of an STATUS command. It 4735 returns the mailbox name that matches the STATUS specification and 4736 the requested mailbox status information. 4738 Example: S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) 4740 7.2.7. ESEARCH Response 4742 Contents: one or more search-return-data pairs 4744 The ESEARCH response occurs as a result of a SEARCH or UID SEARCH 4745 command. 4747 The ESEARCH response starts with an optional search correlator. If 4748 it is missing, then the response was not caused by a particular IMAP 4749 command, whereas if it is present, it contains the tag of the command 4750 that caused the response to be returned. 4752 The search correlator is followed by an optional UID indicator. If 4753 this indicator is present, all data in the ESEARCH response refers to 4754 UIDs, otherwise all returned data refers to message numbers. 4756 The rest of the ESEARCH response contains one or more search data 4757 pairs. Each pair starts with unique return item name, followed by a 4758 space and the corresponding data. Search data pairs may be returned 4759 in any order. Unless specified otherwise by an extension, any return 4760 item name SHOULD appear only once in an ESEARCH response. 4762 [[TBD: describe the most common search data pairs returned.]] 4764 Example: S: * ESEARCH UID COUNT 5 ALL 4:19,21,28 4766 Example: S: * ESEARCH (TAG "a567") UID COUNT 5 ALL 4:19,21,28 4768 Example: S: * ESEARCH COUNT 5 ALL 1:17,21 4770 7.2.8. FLAGS Response 4772 Contents: flag parenthesized list 4774 The FLAGS response occurs as a result of a SELECT or EXAMINE command. 4775 The flag parenthesized list identifies the flags (at a minimum, the 4776 system-defined flags) that are applicable for this mailbox. Flags 4777 other than the system flags can also exist, depending on server 4778 implementation. 4780 The update from the FLAGS response MUST be recorded by the client. 4782 Example: S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 4784 7.3. Server Responses - Mailbox Size 4786 These responses are always untagged. This is how changes in the size 4787 of the mailbox are transmitted from the server to the client. 4788 Immediately following the "*" token is a number that represents a 4789 message count. 4791 7.3.1. EXISTS Response 4793 Contents: none 4795 The EXISTS response reports the number of messages in the mailbox. 4796 This response occurs as a result of a SELECT or EXAMINE command, and 4797 if the size of the mailbox changes (e.g., new messages). 4799 The update from the EXISTS response MUST be recorded by the client. 4801 Example: S: * 23 EXISTS 4803 7.4. Server Responses - Message Status 4805 These responses are always untagged. This is how message data are 4806 transmitted from the server to the client, often as a result of a 4807 command with the same name. Immediately following the "*" token is a 4808 number that represents a message sequence number. 4810 7.4.1. EXPUNGE Response 4812 Contents: none 4814 The EXPUNGE response reports that the specified message sequence 4815 number has been permanently removed from the mailbox. The message 4816 sequence number for each successive message in the mailbox is 4817 immediately decremented by 1, and this decrement is reflected in 4818 message sequence numbers in subsequent responses (including other 4819 untagged EXPUNGE responses). 4821 The EXPUNGE response also decrements the number of messages in the 4822 mailbox; it is not necessary to send an EXISTS response with the new 4823 value. 4825 As a result of the immediate decrement rule, message sequence numbers 4826 that appear in a set of successive EXPUNGE responses depend upon 4827 whether the messages are removed starting from lower numbers to 4828 higher numbers, or from higher numbers to lower numbers. For 4829 example, if the last 5 messages in a 9-message mailbox are expunged, 4830 a "lower to higher" server will send five untagged EXPUNGE responses 4831 for message sequence number 5, whereas a "higher to lower server" 4832 will send successive untagged EXPUNGE responses for message sequence 4833 numbers 9, 8, 7, 6, and 5. 4835 An EXPUNGE response MUST NOT be sent when no command is in progress, 4836 nor while responding to a FETCH, STORE, or SEARCH command. This rule 4837 is necessary to prevent a loss of synchronization of message sequence 4838 numbers between client and server. A command is not "in progress" 4839 until the complete command has been received; in particular, a 4840 command is not "in progress" during the negotiation of command 4841 continuation. 4843 Note: UID FETCH, UID STORE, and UID SEARCH are different commands 4844 from FETCH, STORE, and SEARCH. An EXPUNGE response MAY be sent 4845 during a UID command. 4847 The update from the EXPUNGE response MUST be recorded by the client. 4849 Example: S: * 44 EXPUNGE 4851 7.4.2. FETCH Response 4853 Contents: message data 4855 The FETCH response returns data about a message to the client. The 4856 data are pairs of data item names and their values in parentheses. 4858 This response occurs as the result of a FETCH or STORE command, as 4859 well as by unilateral server decision (e.g., flag updates). 4861 The current data items are: 4863 BINARY[]<> 4865 An or expressing the content of the 4866 specified section after removing any Content-Transfer-Encoding- 4867 related encoding. If is present it refers to the 4868 offset within the DECODED section data. 4870 If the domain of the decoded data is "8bit" and the data does 4871 not contain the NUL octet, the server SHOULD return the data in 4872 a instead of a ; this allows the client to 4873 determine if the "8bit" data contains the NUL octet without 4874 having to explicitly scan the data stream for for NULs. 4876 Messaging clients and servers have been notoriously lax in 4877 their adherence to the Internet CRLF convention for terminating 4878 lines of textual data (text/* media types) in Internet 4879 protocols. When sending data in BINARY[...] FETCH data item, 4880 servers MUST ensure that textual line-oriented sections are 4881 always transmitted using the IMAP4 CRLF line termination 4882 syntax, regardless of the underlying storage representation of 4883 the data on the server. 4885 If the server does not know how to decode the section's 4886 Content-Transfer-Encoding, it MUST fail the request and issue a 4887 "NO" response that contains the "UNKNOWN-CTE" response code. 4889 BINARY.SIZE[] 4891 The size of the section after removing any Content-Transfer- 4892 Encoding-related encoding. The value returned MUST match the 4893 size of the or that will be returned by 4894 the corresponding FETCH BINARY request. 4896 If the server does not know how to decode the section's 4897 Content-Transfer-Encoding, it MUST fail the request and issue a 4898 "NO" response that contains the "UNKNOWN-CTE" response code. 4900 BODY A form of BODYSTRUCTURE without extension data. 4902 BODY[
]<> 4903 A string expressing the body contents of the specified section. 4904 The string SHOULD be interpreted by the client according to the 4905 content transfer encoding, body type, and subtype. 4907 If the origin octet is specified, this string is a substring of 4908 the entire body contents, starting at that origin octet. This 4909 means that BODY[]<0> MAY be truncated, but BODY[] is NEVER 4910 truncated. 4912 Note: The origin octet facility MUST NOT be used by a server 4913 in a FETCH response unless the client specifically requested 4914 it by means of a FETCH of a BODY[
]<> data 4915 item. 4917 8-bit textual data is permitted if a [CHARSET] identifier is 4918 part of the body parameter parenthesized list for this section. 4919 Note that headers (part specifiers HEADER or MIME, or the 4920 header portion of a MESSAGE/RFC822 or MESSAGE/GLOBAL part), MAY 4921 be in UTF-8. Note also that the [RFC-5322] delimiting blank 4922 line between the header and the body is not affected by header 4923 line subsetting; the blank line is always included as part of 4924 header data, except in the case of a message which has no body 4925 and no blank line. 4927 Non-textual data such as binary data MUST be transfer encoded 4928 into a textual form, such as BASE64, prior to being sent to the 4929 client. To derive the original binary data, the client MUST 4930 decode the transfer encoded string. 4932 BODYSTRUCTURE 4934 A parenthesized list that describes the [MIME-IMB] body 4935 structure of a message. This is computed by the server by 4936 parsing the [MIME-IMB] header fields, defaulting various fields 4937 as necessary. 4939 For example, a simple text message of 48 lines and 2279 octets 4940 can have a body structure of: ("TEXT" "PLAIN" ("CHARSET" "US- 4941 ASCII") NIL NIL "7BIT" 2279 48) 4943 Multiple parts are indicated by parenthesis nesting. Instead 4944 of a body type as the first element of the parenthesized list, 4945 there is a sequence of one or more nested body structures. The 4946 second element of the parenthesized list is the multipart 4947 subtype (mixed, digest, parallel, alternative, etc.). 4949 For example, a two part message consisting of a text and a 4950 BASE64-encoded text attachment can have a body structure of: 4952 (("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 1152 4953 23)("TEXT" "PLAIN" ("CHARSET" "US-ASCII" "NAME" "cc.diff") 4954 "<960723163407.20117h@cac.washington.edu>" "Compiler diff" 4955 "BASE64" 4554 73) "MIXED") 4957 Extension data follows the multipart subtype. Extension data 4958 is never returned with the BODY fetch, but can be returned with 4959 a BODYSTRUCTURE fetch. Extension data, if present, MUST be in 4960 the defined order. The extension data of a multipart body part 4961 are in the following order: 4963 body parameter parenthesized list A parenthesized list of 4964 attribute/value pairs [e.g., ("foo" "bar" "baz" "rag") where 4965 "bar" is the value of "foo", and "rag" is the value of 4966 "baz"] as defined in [MIME-IMB]. Servers SHOULD decode 4967 parameter value continuations as described in [RFC2231]. 4969 body disposition A parenthesized list, consisting of a 4970 disposition type string, followed by a parenthesized list of 4971 disposition attribute/value pairs as defined in 4972 [DISPOSITION]. Servers SHOULD decode parameter value 4973 continuations as described in [RFC2231]. 4975 body language A string or parenthesized list giving the body 4976 language value as defined in [LANGUAGE-TAGS]. 4978 body location A string giving the body content URI as defined 4979 in [LOCATION]. 4981 Any following extension data are not yet defined in this 4982 version of the protocol. Such extension data can consist of 4983 zero or more NILs, strings, numbers, or potentially nested 4984 parenthesized lists of such data. Client implementations that 4985 do a BODYSTRUCTURE fetch MUST be prepared to accept such 4986 extension data. Server implementations MUST NOT send such 4987 extension data until it has been defined by a revision of this 4988 protocol. 4990 The basic fields of a non-multipart body part are in the 4991 following order: 4993 body type A string giving the content media type name as 4994 defined in [MIME-IMB]. 4996 body subtype A string giving the content subtype name as 4997 defined in [MIME-IMB]. 4999 body parameter parenthesized list A parenthesized list of 5000 attribute/value pairs [e.g., ("foo" "bar" "baz" "rag") where 5001 "bar" is the value of "foo" and "rag" is the value of "baz"] 5002 as defined in [MIME-IMB]. 5004 body id A string giving the Content-ID header field value as 5005 defined in Section 7 of [MIME-IMB]. 5007 body description A string giving the Content-Description 5008 header field value as defined in Section 8 of [MIME-IMB]. 5010 body encoding A string giving the content transfer encoding as 5011 defined in Section 6 of [MIME-IMB]. 5013 body size A number giving the size of the body in octets. 5014 Note that this size is the size in its transfer encoding and 5015 not the resulting size after any decoding. 5017 A body type of type MESSAGE and subtype RFC822 contains, 5018 immediately after the basic fields, the envelope structure, 5019 body structure, and size in text lines of the encapsulated 5020 message. 5022 A body type of type TEXT contains, immediately after the basic 5023 fields, the size of the body in text lines. Note that this 5024 size is the size in its content transfer encoding and not the 5025 resulting size after any decoding. 5027 Extension data follows the basic fields and the type-specific 5028 fields listed above. Extension data is never returned with the 5029 BODY fetch, but can be returned with a BODYSTRUCTURE fetch. 5030 Extension data, if present, MUST be in the defined order. 5032 The extension data of a non-multipart body part are in the 5033 following order: 5035 body MD5 A string giving the body MD5 value as defined in 5036 [MD5]. 5038 body disposition A parenthesized list with the same content 5039 and function as the body disposition for a multipart body 5040 part. 5042 body language A string or parenthesized list giving the body 5043 language value as defined in [LANGUAGE-TAGS]. 5045 body location A string giving the body content URI as defined 5046 in [LOCATION]. 5048 Any following extension data are not yet defined in this 5049 version of the protocol, and would be as described above under 5050 multipart extension data. 5052 ENVELOPE 5054 A parenthesized list that describes the envelope structure of a 5055 message. This is computed by the server by parsing the 5056 [RFC-5322] header into the component parts, defaulting various 5057 fields as necessary. 5059 The fields of the envelope structure are in the following 5060 order: date, subject, from, sender, reply-to, to, cc, bcc, in- 5061 reply-to, and message-id. The date, subject, in-reply-to, and 5062 message-id fields are strings. The from, sender, reply-to, to, 5063 cc, and bcc fields are parenthesized lists of address 5064 structures. 5066 An address structure is a parenthesized list that describes an 5067 electronic mail address. The fields of an address structure 5068 are in the following order: personal name, [SMTP] at-domain- 5069 list (source route), mailbox name, and host name. 5071 [RFC-5322] group syntax is indicated by a special form of 5072 address structure in which the host name field is NIL. If the 5073 mailbox name field is also NIL, this is an end of group marker 5074 (semi-colon in RFC 822 syntax). If the mailbox name field is 5075 non-NIL, this is a start of group marker, and the mailbox name 5076 field holds the group name phrase. 5078 If the Date, Subject, In-Reply-To, and Message-ID header lines 5079 are absent in the [RFC-5322] header, the corresponding member 5080 of the envelope is NIL; if these header lines are present but 5081 empty the corresponding member of the envelope is the empty 5082 string. 5084 Note: some servers may return a NIL envelope member in the 5085 "present but empty" case. Clients SHOULD treat NIL and 5086 empty string as identical. 5088 Note: [RFC-5322] requires that all messages have a valid 5089 Date header. Therefore, the date member in the envelope can 5090 not be NIL or the empty string. 5092 Note: [RFC-5322] requires that the In-Reply-To and Message- 5093 ID headers, if present, have non-empty content. Therefore, 5094 the in-reply-to and message-id members in the envelope can 5095 not be the empty string. 5097 If the From, To, Cc, and Bcc header lines are absent in the 5098 [RFC-5322] header, or are present but empty, the corresponding 5099 member of the envelope is NIL. 5101 If the Sender or Reply-To lines are absent in the [RFC-5322] 5102 header, or are present but empty, the server sets the 5103 corresponding member of the envelope to be the same value as 5104 the from member (the client is not expected to know to do 5105 this). 5107 Note: [RFC-5322] requires that all messages have a valid 5108 From header. Therefore, the from, sender, and reply-to 5109 members in the envelope can not be NIL. 5111 FLAGS A parenthesized list of flags that are set for this message. 5113 INTERNALDATE A string representing the internal date of the message. 5115 RFC822 Equivalent to BODY[]. 5117 RFC822.HEADER Equivalent to BODY[HEADER]. Note that this did not 5118 result in \Seen being set, because RFC822.HEADER response data 5119 occurs as a result of a FETCH of RFC822.HEADER. BODY[HEADER] 5120 response data occurs as a result of a FETCH of BODY[HEADER] (which 5121 sets \Seen) or BODY.PEEK[HEADER] (which does not set \Seen). 5123 RFC822.SIZE A number expressing the [RFC-5322] size of the message. 5125 RFC822.TEXT Equivalent to BODY[TEXT]. 5127 UID A number expressing the unique identifier of the message. 5129 Example: S: * 23 FETCH (FLAGS (\Seen) RFC822.SIZE 44827) 5131 7.5. Server Responses - Command Continuation Request 5133 The command continuation request response is indicated by a "+" token 5134 instead of a tag. This form of response indicates that the server is 5135 ready to accept the continuation of a command from the client. The 5136 remainder of this response is a line of text. 5138 This response is used in the AUTHENTICATE command to transmit server 5139 data to the client, and request additional client data. This 5140 response is also used if an argument to any command is a 5141 synchronizing literal. 5143 The client is not permitted to send the octets of the synchronizing 5144 literal unless the server indicates that it is expected. This 5145 permits the server to process commands and reject errors on a line- 5146 by-line basis. The remainder of the command, including the CRLF that 5147 terminates a command, follows the octets of the literal. If there 5148 are any additional command arguments, the literal octets are followed 5149 by a space and those arguments. 5151 Example: C: A001 LOGIN {11} 5152 S: + Ready for additional command text 5153 C: FRED FOOBAR {7} 5154 S: + Ready for additional command text 5155 C: fat man 5156 S: A001 OK LOGIN completed 5157 C: A044 BLURDYBLOOP {102856} 5158 S: A044 BAD No such command as "BLURDYBLOOP" 5160 8. Sample IMAP4rev2 connection 5162 The following is a transcript of an IMAP4rev2 connection. A long 5163 line in this sample is broken for editorial clarity. 5165 S: * OK IMAP4rev2 Service Ready 5166 C: a001 login mrc secret 5167 S: a001 OK LOGIN completed 5168 C: a002 select inbox 5169 S: * 18 EXISTS 5170 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 5171 S: * OK [UIDVALIDITY 3857529045] UIDs valid 5172 S: a002 OK [READ-WRITE] SELECT completed 5173 C: a003 fetch 12 full 5174 S: * 12 FETCH (FLAGS (\Seen) INTERNALDATE "17-Jul-1996 02:44:25 -0700" 5175 RFC822.SIZE 4286 ENVELOPE ("Wed, 17 Jul 1996 02:23:25 -0700 (PDT)" 5176 "IMAP4rev2 WG mtg summary and minutes" 5177 (("Terry Gray" NIL "gray" "cac.washington.edu")) 5178 (("Terry Gray" NIL "gray" "cac.washington.edu")) 5179 (("Terry Gray" NIL "gray" "cac.washington.edu")) 5180 ((NIL NIL "imap" "cac.washington.edu")) 5181 ((NIL NIL "minutes" "CNRI.Reston.VA.US") 5182 ("John Klensin" NIL "KLENSIN" "MIT.EDU")) NIL NIL 5183 "") 5184 BODY ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 3028 5185 92)) 5186 S: a003 OK FETCH completed 5187 C: a004 fetch 12 body[header] 5188 S: * 12 FETCH (BODY[HEADER] {342} 5189 S: Date: Wed, 17 Jul 1996 02:23:25 -0700 (PDT) 5190 S: From: Terry Gray 5191 S: Subject: IMAP4rev2 WG mtg summary and minutes 5192 S: To: imap@cac.washington.edu 5193 S: cc: minutes@CNRI.Reston.VA.US, John Klensin 5194 S: Message-Id: 5195 S: MIME-Version: 1.0 5196 S: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 5197 S: 5198 S: ) 5199 S: a004 OK FETCH completed 5200 C: a005 store 12 +flags \deleted 5201 S: * 12 FETCH (FLAGS (\Seen \Deleted)) 5202 S: a005 OK +FLAGS completed 5203 C: a006 logout 5204 S: * BYE IMAP4rev2 server terminating connection 5205 S: a006 OK LOGOUT completed 5207 9. Formal Syntax 5209 The following syntax specification uses the Augmented Backus-Naur 5210 Form (ABNF) notation as specified in [ABNF]. 5212 In the case of alternative or optional rules in which a later rule 5213 overlaps an earlier rule, the rule which is listed earlier MUST take 5214 priority. For example, "\Seen" when parsed as a flag is the \Seen 5215 flag name and not a flag-extension, even though "\Seen" can be parsed 5216 as a flag-extension. Some, but not all, instances of this rule are 5217 noted below. 5219 Note: [ABNF] rules MUST be followed strictly; in particular: 5221 (1) Except as noted otherwise, all alphabetic characters are case- 5222 insensitive. The use of upper or lower case characters to define 5223 token strings is for editorial clarity only. Implementations MUST 5224 accept these strings in a case-insensitive fashion. 5226 (2) In all cases, SP refers to exactly one space. It is NOT 5227 permitted to substitute TAB, insert additional spaces, or 5228 otherwise treat SP as being equivalent to LWSP. 5230 (3) The ASCII NUL character, %x00, MUST NOT be used at any time. 5232 address = "(" addr-name SP addr-adl SP addr-mailbox SP 5233 addr-host ")" 5235 addr-adl = nstring 5236 ; Holds route from [RFC-5322] route-addr if 5237 ; non-NIL 5239 addr-host = nstring 5240 ; NIL indicates [RFC-5322] group syntax. 5241 ; Otherwise, holds [RFC-5322] domain name 5243 addr-mailbox = nstring 5244 ; NIL indicates end of [RFC-5322] group; if 5245 ; non-NIL and addr-host is NIL, holds 5246 ; [RFC-5322] group name. 5247 ; Otherwise, holds [RFC-5322] local-part 5248 ; after removing [RFC-5322] quoting 5250 addr-name = nstring 5251 ; If non-NIL, holds phrase from [RFC-5322] 5252 ; mailbox after removing [RFC-5322] quoting 5254 append = "APPEND" SP mailbox [SP flag-list] [SP date-time] SP 5255 literal 5257 append-uid = uniqueid 5259 astring = 1*ASTRING-CHAR / string 5260 ASTRING-CHAR = ATOM-CHAR / resp-specials 5262 atom = 1*ATOM-CHAR 5264 ATOM-CHAR = 5266 atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards / 5267 quoted-specials / resp-specials 5269 authenticate = "AUTHENTICATE" SP auth-type [SP initial-resp] 5270 *(CRLF base64) 5272 auth-type = atom 5273 ; Defined by [SASL] 5275 base64 = *(4base64-char) [base64-terminal] 5277 base64-char = ALPHA / DIGIT / "+" / "/" 5278 ; Case-sensitive 5280 base64-terminal = (2base64-char "==") / (3base64-char "=") 5282 body = "(" (body-type-1part / body-type-mpart) ")" 5284 body-extension = nstring / number / 5285 "(" body-extension *(SP body-extension) ")" 5286 ; Future expansion. Client implementations 5287 ; MUST accept body-extension fields. Server 5288 ; implementations MUST NOT generate 5289 ; body-extension fields except as defined by 5290 ; future standard or standards-track 5291 ; revisions of this specification. 5293 body-ext-1part = body-fld-md5 [SP body-fld-dsp [SP body-fld-lang 5294 [SP body-fld-loc *(SP body-extension)]]] 5295 ; MUST NOT be returned on non-extensible 5296 ; "BODY" fetch 5298 body-ext-mpart = body-fld-param [SP body-fld-dsp [SP body-fld-lang 5299 [SP body-fld-loc *(SP body-extension)]]] 5300 ; MUST NOT be returned on non-extensible 5301 ; "BODY" fetch 5303 body-fields = body-fld-param SP body-fld-id SP body-fld-desc SP 5304 body-fld-enc SP body-fld-octets 5306 body-fld-desc = nstring 5307 body-fld-dsp = "(" string SP body-fld-param ")" / nil 5309 body-fld-enc = (DQUOTE ("7BIT" / "8BIT" / "BINARY" / "BASE64"/ 5310 "QUOTED-PRINTABLE") DQUOTE) / string 5312 body-fld-id = nstring 5314 body-fld-lang = nstring / "(" string *(SP string) ")" 5316 body-fld-loc = nstring 5318 body-fld-lines = number 5320 body-fld-md5 = nstring 5322 body-fld-octets = number 5324 body-fld-param = "(" string SP string *(SP string SP string) ")" / nil 5326 body-type-1part = (body-type-basic / body-type-msg / body-type-text) 5327 [SP body-ext-1part] 5329 body-type-basic = media-basic SP body-fields 5330 ; MESSAGE subtype MUST NOT be "RFC822" or "GLOBAL" 5332 body-type-mpart = 1*body SP media-subtype 5333 [SP body-ext-mpart] 5334 ; MULTIPART body part 5336 body-type-msg = media-message SP body-fields SP envelope 5337 SP body SP body-fld-lines 5339 body-type-text = media-text SP body-fields SP body-fld-lines 5341 capability = ("AUTH=" auth-type) / atom 5342 ; New capabilities MUST begin with "X" or be 5343 ; registered with IANA as standard or 5344 ; standards-track 5346 capability-data = "CAPABILITY" *(SP capability) SP "IMAP4rev2" 5347 *(SP capability) 5348 ; Servers MUST implement the STARTTLS, AUTH=PLAIN, 5349 ; and LOGINDISABLED capabilities 5350 ; Servers which offer RFC 1730 compatibility MUST 5351 ; list "IMAP4" as the first capability. 5353 CHAR8 = %x01-ff 5354 ; any OCTET except NUL, %x00 5356 charset = atom / quoted 5358 command = tag SP (command-any / command-auth / command-nonauth / 5359 command-select) CRLF 5360 ; Modal based on state 5362 command-any = "CAPABILITY" / "LOGOUT" / "NOOP" / enable / x-command 5363 ; Valid in all states 5365 command-auth = append / create / delete / examine / list / lsub / 5366 Namespace-Command / 5367 rename / select / status / subscribe / unsubscribe / 5368 idle 5369 ; Valid only in Authenticated or Selected state 5371 command-nonauth = login / authenticate / "STARTTLS" 5372 ; Valid only when in Not Authenticated state 5374 command-select = "CHECK" / "CLOSE" / "UNSELECT" / "EXPUNGE" / copy / 5375 move / fetch / store / search / uid 5376 ; Valid only when in Selected state 5378 continue-req = "+" SP (resp-text / base64) CRLF 5380 copy = "COPY" SP sequence-set SP mailbox 5382 create = "CREATE" SP mailbox 5383 ; Use of INBOX gives a NO error 5385 date = date-text / DQUOTE date-text DQUOTE 5387 date-day = 1*2DIGIT 5388 ; Day of month 5390 date-day-fixed = (SP DIGIT) / 2DIGIT 5391 ; Fixed-format version of date-day 5393 date-month = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / 5394 "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec" 5396 date-text = date-day "-" date-month "-" date-year 5398 date-year = 4DIGIT 5400 date-time = DQUOTE date-day-fixed "-" date-month "-" date-year 5401 SP time SP zone DQUOTE 5403 delete = "DELETE" SP mailbox 5404 ; Use of INBOX gives a NO error 5406 digit-nz = %x31-39 5407 ; 1-9 5409 enable = "ENABLE" 1*(SP capability) 5411 enable-data = "ENABLED" *(SP capability) 5413 envelope = "(" env-date SP env-subject SP env-from SP 5414 env-sender SP env-reply-to SP env-to SP env-cc SP 5415 env-bcc SP env-in-reply-to SP env-message-id ")" 5417 env-bcc = "(" 1*address ")" / nil 5419 env-cc = "(" 1*address ")" / nil 5421 env-date = nstring 5423 env-from = "(" 1*address ")" / nil 5425 env-in-reply-to = nstring 5427 env-message-id = nstring 5429 env-reply-to = "(" 1*address ")" / nil 5431 env-sender = "(" 1*address ")" / nil 5433 env-subject = nstring 5435 env-to = "(" 1*address ")" / nil 5437 esearch-response = "ESEARCH" [search-correlator] [SP "UID"] 5438 *(SP search-return-data) 5439 ; ESEARCH response replaces SEARCH response 5440 ; from IMAP4rev1. 5442 examine = "EXAMINE" SP mailbox 5444 fetch = "FETCH" SP sequence-set SP ("ALL" / "FULL" / "FAST" / 5445 fetch-att / "(" fetch-att *(SP fetch-att) ")") 5447 fetch-att = "ENVELOPE" / "FLAGS" / "INTERNALDATE" / 5448 "RFC822" [".HEADER" / ".SIZE" / ".TEXT"] / 5449 "BODY" ["STRUCTURE"] / "UID" / 5450 "BODY" section [partial] / 5451 "BODY.PEEK" section [partial] / 5452 "BINARY" [".PEEK"] section-binary [partial] / 5453 "BINARY.SIZE" section-binary 5455 flag = "\Answered" / "\Flagged" / "\Deleted" / 5456 "\Seen" / "\Draft" / flag-keyword / flag-extension 5457 ; Does not include "\Recent" 5459 flag-extension = "\" atom 5460 ; Future expansion. Client implementations 5461 ; MUST accept flag-extension flags. Server 5462 ; implementations MUST NOT generate 5463 ; flag-extension flags except as defined by 5464 ; future standard or standards-track 5465 ; revisions of this specification. 5466 ; "\Recent" was defined in RFC 3501 5467 ; and is now deprecated. 5469 flag-fetch = flag 5471 flag-keyword = "$MDNSent" / "$Forwarded" / atom 5473 flag-list = "(" [flag *(SP flag)] ")" 5475 flag-perm = flag / "\*" 5477 greeting = "*" SP (resp-cond-auth / resp-cond-bye) CRLF 5479 header-fld-name = astring 5481 header-list = "(" header-fld-name *(SP header-fld-name) ")" 5483 idle = "IDLE" CRLF "DONE" 5485 initial-resp = (base64 / "=") 5486 ; "initial response" defined in 5487 ; Section 5.1 of [RFC4422] 5489 list = "LIST" SP mailbox SP list-mailbox 5491 list-mailbox = 1*list-char / string 5493 list-char = ATOM-CHAR / list-wildcards / resp-specials 5495 list-wildcards = "%" / "*" 5497 literal = "{" number ["+"] "}" CRLF *CHAR8 5498 ; represents the number of CHAR8s. 5499 ; A non-synchronizing literal is distinguished from 5500 ; a synchronizing literal by presence of the "+" 5501 ; before the closing "}". 5502 ; Non synchronizing literals are not allowed when 5503 ; sent from server to the client. 5505 literal8 = "~{" number "}" CRLF *OCTET 5506 ; represents the number of OCTETs 5507 ; in the response string. 5509 login = "LOGIN" SP userid SP password 5511 lsub = "LSUB" SP mailbox SP list-mailbox 5513 mailbox = "INBOX" / astring 5514 ; INBOX is case-insensitive. All case variants of 5515 ; INBOX (e.g., "iNbOx") MUST be interpreted as INBOX 5516 ; not as an astring. An astring which consists of 5517 ; the case-insensitive sequence "I" "N" "B" "O" "X" 5518 ; is considered to be INBOX and not an astring. 5519 ; Refer to section 5.1 for further 5520 ; semantic details of mailbox names. 5522 mailbox-data = "FLAGS" SP flag-list / "LIST" SP mailbox-list / 5523 "LSUB" SP mailbox-list / esearch-response / 5524 "STATUS" SP mailbox SP "(" [status-att-list] ")" / 5525 number SP "EXISTS" / Namespace-Response 5527 mailbox-list = "(" [mbx-list-flags] ")" SP 5528 (DQUOTE QUOTED-CHAR DQUOTE / nil) SP mailbox 5530 mbx-list-flags = *(mbx-list-oflag SP) mbx-list-sflag 5531 *(SP mbx-list-oflag) / 5532 mbx-list-oflag *(SP mbx-list-oflag) 5534 mbx-list-oflag = "\Noinferiors" / flag-extension 5535 ; Other flags; multiple possible per LIST response 5537 mbx-list-sflag = "\Noselect" / "\Marked" / "\Unmarked" 5538 ; Selectability flags; only one per LIST response 5540 media-basic = ((DQUOTE ("APPLICATION" / "AUDIO" / "IMAGE" / 5541 "MESSAGE" / "VIDEO" / "FONT") DQUOTE) / string) SP 5542 media-subtype 5543 ; Defined in [MIME-IMT]. 5544 ; FONT defined in RFC YYYY. 5546 media-message = DQUOTE "MESSAGE" DQUOTE SP 5547 DQUOTE ("RFC822" / "GLOBAL") DQUOTE 5548 ; Defined in [MIME-IMT] 5550 media-subtype = string 5551 ; Defined in [MIME-IMT] 5553 media-text = DQUOTE "TEXT" DQUOTE SP media-subtype 5554 ; Defined in [MIME-IMT] 5556 message-data = nz-number SP ("EXPUNGE" / ("FETCH" SP msg-att)) 5558 move = "MOVE" SP sequence-set SP mailbox 5560 msg-att = "(" (msg-att-dynamic / msg-att-static) 5561 *(SP (msg-att-dynamic / msg-att-static)) ")" 5563 msg-att-dynamic = "FLAGS" SP "(" [flag-fetch *(SP flag-fetch)] ")" 5564 ; MAY change for a message 5566 msg-att-static = "ENVELOPE" SP envelope / "INTERNALDATE" SP date-time / 5567 "RFC822" [".HEADER" / ".TEXT"] SP nstring / 5568 "RFC822.SIZE" SP number / 5569 "BODY" ["STRUCTURE"] SP body / 5570 "BODY" section ["<" number ">"] SP nstring / 5571 "BINARY" section-binary SP (nstring / literal8) / 5572 "BINARY.SIZE" section-binary SP number / 5573 "UID" SP uniqueid 5574 ; MUST NOT change for a message 5576 Namespace = nil / "(" 1*Namespace-Descr ")" 5578 Namespace-Command = "NAMESPACE" 5580 Namespace-Descr = "(" string SP 5581 (DQUOTE QUOTED-CHAR DQUOTE / nil) 5582 *(Namespace-Response-Extension) ")" 5584 Namespace-Response-Extension = SP string SP 5585 "(" string *(SP string) ")" 5587 Namespace-Response = "NAMESPACE" SP Namespace 5588 SP Namespace SP Namespace 5589 ; The first Namespace is the Personal Namespace(s) 5590 ; The second Namespace is the Other Users' Namespace(s) 5591 ; The third Namespace is the Shared Namespace(s) 5593 nil = "NIL" 5595 nstring = string / nil 5596 number = 1*DIGIT 5597 ; Unsigned 32-bit integer 5598 ; (0 <= n < 4,294,967,296) 5600 number64 = 1*DIGIT 5601 ; Unsigned 63-bit integer 5602 ; (0 <= n <= 9,223,372,036,854,775,807) 5604 nz-number = digit-nz *DIGIT 5605 ; Non-zero unsigned 32-bit integer 5606 ; (0 < n < 4,294,967,296) 5608 password = astring 5610 partial-range = number ["." nz-number] 5611 ; Copied from RFC 5092 (IMAP URL) 5613 partial = "<" number "." nz-number ">" 5614 ; Partial FETCH request. 0-based offset of 5615 ; the first octet, followed by the number of octets 5616 ; in the fragment. 5618 quoted = DQUOTE *QUOTED-CHAR DQUOTE 5620 QUOTED-CHAR = / 5621 "\" quoted-specials / UTF8-2 / UTF8-3 / UTF8-4 5623 quoted-specials = DQUOTE / "\" 5625 rename = "RENAME" SP mailbox SP mailbox 5626 ; Use of INBOX as a destination gives a NO error 5628 response = *(continue-req / response-data) response-done 5630 response-data = "*" SP (resp-cond-state / resp-cond-bye / 5631 mailbox-data / message-data / capability-data / 5632 enable-data) CRLF 5634 response-done = response-tagged / response-fatal 5636 response-fatal = "*" SP resp-cond-bye CRLF 5637 ; Server closes connection immediately 5639 response-tagged = tag SP resp-cond-state CRLF 5641 resp-code-apnd = "APPENDUID" SP nz-number SP append-uid 5643 resp-code-copy = "COPYUID" SP nz-number SP uid-set SP uid-set 5644 resp-cond-auth = ("OK" / "PREAUTH") SP resp-text 5645 ; Authentication condition 5647 resp-cond-bye = "BYE" SP resp-text 5649 resp-cond-state = ("OK" / "NO" / "BAD") SP resp-text 5650 ; Status condition 5652 resp-specials = "]" 5654 ;; ////Can we make "text" optional? Will this have any bad side effects? 5655 resp-text = ["[" resp-text-code "]" SP] text 5657 resp-text-code = "ALERT" / 5658 "BADCHARSET" [SP "(" charset *(SP charset) ")" ] / 5659 capability-data / "PARSE" / 5660 "PERMANENTFLAGS" SP "(" 5661 [flag-perm *(SP flag-perm)] ")" / 5662 "READ-ONLY" / "READ-WRITE" / "TRYCREATE" / 5663 "UIDNEXT" SP nz-number / "UIDVALIDITY" SP nz-number / 5664 resp-code-apnd / resp-code-copy / "UIDNOTSTICKY" / 5665 "UNAVAILABLE" / "AUTHENTICATIONFAILED" / 5666 "AUTHORIZATIONFAILED" / "EXPIRED" / 5667 "PRIVACYREQUIRED" / "CONTACTADMIN" / "NOPERM" / 5668 "INUSE" / "EXPUNGEISSUED" / "CORRUPTION" / 5669 "SERVERBUG" / "CLIENTBUG" / "CANNOT" / 5670 "LIMIT" / "OVERQUOTA" / "ALREADYEXISTS" / 5671 "NONEXISTENT" / 5672 "CLOSED" / 5673 "UNKNOWN-CTE" / 5674 atom [SP 1*] 5676 search = "SEARCH" [search-return-opts] 5677 SP search-program 5679 search-correlator = SP "(" "TAG" SP tag-string ")" 5681 search-key = "ALL" / "ANSWERED" / "BCC" SP astring / 5682 "BEFORE" SP date / "BODY" SP astring / 5683 "CC" SP astring / "DELETED" / "FLAGGED" / 5684 "FROM" SP astring / "KEYWORD" SP flag-keyword / 5685 "NEW" / "OLD" / "ON" SP date / "SEEN" / 5686 "SINCE" SP date / "SUBJECT" SP astring / 5687 "TEXT" SP astring / "TO" SP astring / 5688 "UNANSWERED" / "UNDELETED" / "UNFLAGGED" / 5689 "UNKEYWORD" SP flag-keyword / "UNSEEN" / 5690 ; Above this line were in [IMAP2] 5691 "DRAFT" / "HEADER" SP header-fld-name SP astring / 5692 "LARGER" SP number / "NOT" SP search-key / 5693 "OR" SP search-key SP search-key / 5694 "SENTBEFORE" SP date / "SENTON" SP date / 5695 "SENTSINCE" SP date / "SMALLER" SP number / 5696 "UID" SP sequence-set / "UNDRAFT" / sequence-set / 5697 "(" search-key *(SP search-key) ")" 5699 search-modifier-name = tagged-ext-label 5701 search-mod-params = tagged-ext-val 5702 ; This non-terminal shows recommended syntax 5703 ; for future extensions. 5705 search-program = ["CHARSET" SP charset SP] 5706 search-key *(SP search-key) 5707 ; CHARSET argument to SEARCH MUST be 5708 ; registered with IANA. 5710 search-ret-data-ext = search-modifier-name SP search-return-value 5711 ; Note that not every SEARCH return option 5712 ; is required to have the corresponding 5713 ; ESEARCH return data. 5715 search-return-data = "MIN" SP nz-number / 5716 "MAX" SP nz-number / 5717 "ALL" SP sequence-set / 5718 "COUNT" SP number / 5719 search-ret-data-ext 5720 ; All return data items conform to 5721 ; search-ret-data-ext syntax 5723 search-return-opts = SP "RETURN" SP "(" [search-return-opt 5724 *(SP search-return-opt)] ")" 5726 search-return-opt = "MIN" / "MAX" / "ALL" / "COUNT" / 5727 search-ret-opt-ext 5728 ; conforms to generic search-ret-opt-ext 5729 ; syntax 5731 search-ret-opt-ext = search-modifier-name [SP search-mod-params] 5733 search-return-value = tagged-ext-val 5734 ; Data for the returned search option. 5735 ; A single "nz-number"/"number"/"number64" value 5736 ; can be returned as an atom (i.e., without 5737 ; quoting). A sequence-set can be returned 5738 ; as an atom as well. 5740 section = "[" [section-spec] "]" 5742 section-binary = "[" [section-part] "]" 5744 section-msgtext = "HEADER" / "HEADER.FIELDS" [".NOT"] SP header-list / 5745 "TEXT" 5746 ; top-level or MESSAGE/RFC822 or MESSAGE/GLOBAL part 5748 section-part = nz-number *("." nz-number) 5749 ; body part reference. 5750 ; Allows for accessing nested body parts. 5752 section-spec = section-msgtext / (section-part ["." section-text]) 5754 section-text = section-msgtext / "MIME" 5755 ; text other than actual body part (headers, etc.) 5757 select = "SELECT" SP mailbox 5759 seq-number = nz-number / "*" 5760 ; message sequence number (COPY, FETCH, STORE 5761 ; commands) or unique identifier (UID COPY, 5762 ; UID FETCH, UID STORE commands). 5763 ; * represents the largest number in use. In 5764 ; the case of message sequence numbers, it is 5765 ; the number of messages in a non-empty mailbox. 5766 ; In the case of unique identifiers, it is the 5767 ; unique identifier of the last message in the 5768 ; mailbox or, if the mailbox is empty, the 5769 ; mailbox's current UIDNEXT value. 5770 ; The server should respond with a tagged BAD 5771 ; response to a command that uses a message 5772 ; sequence number greater than the number of 5773 ; messages in the selected mailbox. This 5774 ; includes "*" if the selected mailbox is empty. 5776 seq-range = seq-number ":" seq-number 5777 ; two seq-number values and all values between 5778 ; these two regardless of order. 5779 ; Example: 2:4 and 4:2 are equivalent and indicate 5780 ; values 2, 3, and 4. 5781 ; Example: a unique identifier sequence range of 5782 ; 3291:* includes the UID of the last message in 5783 ; the mailbox, even if that value is less than 3291. 5785 sequence-set = (seq-number / seq-range) ["," sequence-set] 5786 ; set of seq-number values, regardless of order. 5787 ; Servers MAY coalesce overlaps and/or execute the 5788 ; sequence in any order. 5789 ; Example: a message sequence number set of 5790 ; 2,4:7,9,12:* for a mailbox with 15 messages is 5791 ; equivalent to 2,4,5,6,7,9,12,13,14,15 5792 ; Example: a message sequence number set of *:4,5:7 5793 ; for a mailbox with 10 messages is equivalent to 5794 ; 10,9,8,7,6,5,4,5,6,7 and MAY be reordered and 5795 ; overlap coalesced to be 4,5,6,7,8,9,10. 5797 status = "STATUS" SP mailbox SP 5798 "(" status-att *(SP status-att) ")" 5800 status-att = "MESSAGES" / "UIDNEXT" / "UIDVALIDITY" / 5801 "UNSEEN" / "SIZE" 5803 status-att-val = ("MESSAGES" SP number) / 5804 ("UIDNEXT" SP nz-number) / 5805 ("UIDVALIDITY" SP nz-number) / 5806 ("UNSEEN" SP number) / 5807 ("SIZE" SP number64) 5808 ; Extensions to the STATUS responses 5809 ; should extend this production. 5810 ; Extensions should use the generic 5811 ; syntax defined by tagged-ext. 5813 status-att-list = status-att-val *(SP status-att-val) 5815 store = "STORE" SP sequence-set SP store-att-flags 5817 store-att-flags = (["+" / "-"] "FLAGS" [".SILENT"]) SP 5818 (flag-list / (flag *(SP flag))) 5820 string = quoted / literal 5822 subscribe = "SUBSCRIBE" SP mailbox 5824 tag = 1* 5826 tagged-ext-label = tagged-label-fchar *tagged-label-char 5827 ;; Is a valid RFC 3501 "atom". 5829 tagged-label-fchar = ALPHA / "-" / "_" / "." 5831 tagged-label-char = tagged-label-fchar / DIGIT / ":" 5833 tagged-ext-comp = astring / 5834 tagged-ext-comp *(SP tagged-ext-comp) / 5835 "(" tagged-ext-comp ")" 5836 ;; Extensions that follow this general 5837 ;; syntax should use nstring instead of 5838 ;; astring when appropriate in the context 5839 ;; of the extension. 5840 ;; Note that a message set or a "number" 5841 ;; can always be represented as an "atom". 5842 ;; An URL should be represented as 5843 ;; a "quoted" string. 5845 tagged-ext-simple = sequence-set / number / number64 5847 tagged-ext-val = tagged-ext-simple / 5848 "(" [tagged-ext-comp] ")" 5850 text = 1*TEXT-CHAR 5852 TEXT-CHAR = 5854 time = 2DIGIT ":" 2DIGIT ":" 2DIGIT 5855 ; Hours minutes seconds 5857 uid = "UID" SP 5858 (copy / move / fetch / search / store / uid-expunge) 5859 ; Unique identifiers used instead of message 5860 ; sequence numbers 5862 uid-expunge = "EXPUNGE" SP sequence-set 5863 ; Unique identifiers used instead of message 5864 ; sequence numbers 5866 uid-set = (uniqueid / uid-range) *("," uid-set) 5868 uid-range = (uniqueid ":" uniqueid) 5869 ; two uniqueid values and all values 5870 ; between these two regards of order. 5871 ; Example: 2:4 and 4:2 are equivalent. 5873 uniqueid = nz-number 5874 ; Strictly ascending 5876 unsubscribe = "UNSUBSCRIBE" SP mailbox 5878 userid = astring 5880 UTF8-2 = 5882 UTF8-3 = 5883 UTF8-4 = 5885 x-command = "X" atom 5887 zone = ("+" / "-") 4DIGIT 5888 ; Signed four-digit value of hhmm representing 5889 ; hours and minutes east of Greenwich (that is, 5890 ; the amount that the given time differs from 5891 ; Universal Time). Subtracting the timezone 5892 ; from the given time will give the UT form. 5893 ; The Universal Time zone is "+0000". 5895 10. Author's Note 5897 This document is a revision or rewrite of earlier documents, and 5898 supercedes the protocol specification in those documents: RFC 2060, 5899 RFC 1730, unpublished IMAP2bis.TXT document, RFC 1176, and RFC 1064. 5901 11. Security Considerations 5903 IMAP4rev2 protocol transactions, including electronic mail data, are 5904 sent in the clear over the network unless protection from snooping is 5905 negotiated. This can be accomplished either by the use of IMAPS 5906 service, STARTTLS command, negotiated privacy protection in the 5907 AUTHENTICATE command, or some other protection mechanism. 5909 11.1. STARTTLS Security Considerations 5911 IMAP client and server implementations MUST comply with relevant TLS 5912 recommendations from [RFC8314]. Additionally, when using TLS 1.2, 5913 IMAP implementations MUST implement 5914 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 cipher suite, and SHOULD 5915 implement the TLS_RSA_WITH_AES_128_CBC_SHA [TLS] cipher suite. This 5916 is important as it assures that any two compliant implementations can 5917 be configured to interoperate. Other TLS cipher suites recommended 5918 in RFC 7525 are RECOMMENDED: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 5919 TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 and 5920 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384. All other cipher suites are 5921 OPTIONAL. Note that this is a change from section 2.1 of [IMAP-TLS]. 5923 During the [TLS] negotiation, the client MUST check its understanding 5924 of the server hostname against the server's identity as presented in 5925 the server Certificate message, in order to prevent man-in-the-middle 5926 attacks. This procedure is described in [RFC7817]. 5928 Both the client and server MUST check the result of the STARTTLS 5929 command and subsequent [TLS] negotiation to see whether acceptable 5930 authentication and/or privacy was achieved. 5932 11.2. COPYUID and APPENDUID response codes 5934 The COPYUID and APPENDUID response codes return information about the 5935 mailbox, which may be considered sensitive if the mailbox has 5936 permissions set that permit the client to COPY or APPEND to the 5937 mailbox, but not SELECT or EXAMINE it. 5939 Consequently, these response codes SHOULD NOT be issued if the client 5940 does not have access to SELECT or EXAMINE the mailbox. 5942 11.3. Other Security Considerations 5944 A server error message for an AUTHENTICATE command which fails due to 5945 invalid credentials SHOULD NOT detail why the credentials are 5946 invalid. 5948 Use of the LOGIN command sends passwords in the clear. This can be 5949 avoided by using the AUTHENTICATE command with a [SASL] mechanism 5950 that does not use plaintext passwords, by first negotiating 5951 encryption via STARTTLS or some other protection mechanism. 5953 A server implementation MUST implement a configuration that, at the 5954 time of authentication, requires: 5955 (1) The STARTTLS command has been negotiated. 5956 OR 5957 (2) Some other mechanism that protects the session from password 5958 snooping has been provided. 5959 OR 5960 (3) The following measures are in place: 5961 (a) The LOGINDISABLED capability is advertised, and [SASL] mechanisms 5962 (such as PLAIN) using plaintext passwords are NOT advertised in the 5963 CAPABILITY list. 5964 AND 5965 (b) The LOGIN command returns an error even if the password is 5966 correct. 5967 AND 5968 (c) The AUTHENTICATE command returns an error with all [SASL] 5969 mechanisms that use plaintext passwords, even if the password is 5970 correct. 5972 A server error message for a failing LOGIN command SHOULD NOT specify 5973 that the user name, as opposed to the password, is invalid. 5975 A server SHOULD have mechanisms in place to limit or delay failed 5976 AUTHENTICATE/LOGIN attempts. 5978 Additional security considerations are discussed in the section 5979 discussing the AUTHENTICATE and LOGIN commands. 5981 12. IANA Considerations 5983 IANA is requested to update "Service Names and Transport Protocol 5984 Port Numbers" registry as follows: 5986 1. Registration for TCP "imap" port 143 should be updated to point 5987 to this document and RFC 3501. 5989 2. Registration for TCP "imaps" port 993 should be updated to point 5990 to this document, RFC 8314 and RFC 3501. 5992 3. Both UDP port 143 and UDP port 993 should be marked as "Reserved" 5993 in the registry. 5995 Additional IANA actions are specified in subsection of this section. 5997 12.1. Updates to IMAP4 Capabilities registry 5999 IMAP4 capabilities are registered by publishing a standards track or 6000 IESG approved informational or experimental RFC. The registry is 6001 currently located at: http://www.iana.org/assignments/ 6002 imap4-capabilities 6004 As this specification revises the STARTTLS and LOGINDISABLED 6005 extensions previously defined in [IMAP-TLS], IANA is requested to 6006 update registry entries for these 2 extensions to point to this 6007 document. 6009 12.2. GSSAPI/SASL service name 6011 GSSAPI/Kerberos/SASL service names are registered by publishing a 6012 standards track or IESG approved experimental RFC. The registry is 6013 currently located at: http://www.iana.org/assignments/gssapi-service- 6014 names 6016 IANA is requested to update the "imap" service name previously 6017 registered in RFC 3501, to point to this document. 6019 13. References 6021 13.1. Normative References 6023 [ABNF] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 6024 Specifications: ABNF", STD 68, RFC 5234, January 2008, 6025 . 6027 [ANONYMOUS] 6028 Zeilenga, K., "Anonymous Simple Authentication and 6029 Security Layer (SASL) Mechanism", RFC 4505, June 2006, 6030 . 6032 [CHARSET] Freed, N. and J. Postel, "IANA Charset Registration 6033 Procedures", BCP 19, RFC 2978, October 2000, 6034 . 6036 [DIGEST-MD5] 6037 Leach, P. and C. Newman, "Using Digest Authentication as a 6038 SASL Mechanism", RFC 2831, May 2000, 6039 . 6041 [DISPOSITION] 6042 Troost, R., Dorner, S., and K. Moore, Ed., "Communicating 6043 Presentation Information in Internet Messages: The 6044 Content-Disposition Header Field", RFC 2183, August 1997, 6045 . 6047 [PLAIN] Zeilenga, K., Ed., "The PLAIN Simple Authentication and 6048 Security Layer (SASL) Mechanism", RFC 4616, August 2006, 6049 . 6051 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 6052 Requirement Levels", BCP 14, RFC 2119, 6053 DOI 10.17487/RFC2119, March 1997, 6054 . 6056 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 6057 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 6058 May 2017, . 6060 [LANGUAGE-TAGS] 6061 Alvestrand, H., "Content Language Headers", RFC 3282, May 6062 2002, . 6064 [LOCATION] 6065 Palme, J., Hopmann, A., and N. Shelness, "MIME 6066 Encapsulation of Aggregate Documents, such as HTML 6067 (MHTML)", RFC 2557, March 1999, 6068 . 6070 [MD5] Myers, J. and M. Rose, "The Content-MD5 Header Field", 6071 RFC 1864, October 1995, 6072 . 6074 [MIME-HDRS] 6075 Moore, K., "MIME (Multipurpose Internet Mail Extensions) 6076 Part Three: Message Header Extensions for Non-ASCII Text", 6077 RFC 2047, November 1996, 6078 . 6080 [MIME-IMB] 6081 Freed, N. and N. Borenstein, "Multipurpose Internet Mail 6082 Extensions (MIME) Part One: Format of Internet Message 6083 Bodies", RFC 2045, November 1996, 6084 . 6086 [MIME-IMT] 6087 Freed, N. and N. Borenstein, "Multipurpose Internet Mail 6088 Extensions (MIME) Part Two: Media Types", RFC 2046, 6089 November 1996, . 6091 [RFC2231] Freed, N. and K. Moore, "MIME Parameter Value and Encoded 6092 Word Extensions: Character Sets, Languages, and 6093 Continuations", RFC 2231, DOI 10.17487/RFC2231, November 6094 1997, . 6096 [RFC-5322] 6097 Resnick, P., Ed., "Internet Message Format", RFC 5322, 6098 October 2008, . 6100 [SASL] Melnikov, A., Ed. and K. Zeilenga, Ed., "Simple 6101 Authentication and Security Layer (SASL)", RFC 4422, June 6102 2006, . 6104 [TLS] Dierks, T. and E. Rescorla, "The Transport Layer Security 6105 (TLS) Protocol Version 1.2", RFC 5246, August 2008, 6106 . 6108 [UTF-7] Goldsmith, D. and M. Davis, "UTF-7 A Mail-Safe 6109 Transformation Format of Unicode", RFC 2152, May 1997, 6110 . 6112 [UTF-8] Yergeau, F., "UTF-8, a transformation format of ISO 6113 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 6114 2003, . 6116 [MULTIAPPEND] 6117 Crispin, M., "Internet Message Access Protocol (IMAP) - 6118 MULTIAPPEND Extension", RFC 3502, March 2003, 6119 . 6121 [IMAP-IMPLEMENTATION] 6122 Leiba, B., "IMAP4 Implementation Recommendations", 6123 RFC 2683, September 1999, 6124 . 6126 [IMAP-MULTIACCESS] 6127 Gahrns, M., "IMAP4 Multi-Accessed Mailbox Practice", 6128 RFC 2180, July 1997, 6129 . 6131 [NET-UNICODE] 6132 Klensin, J. and M. Padlipsky, "Unicode Format for Network 6133 Interchange", RFC 5198, DOI 10.17487/RFC5198, March 2008, 6134 . 6136 [I18N-HDRS] 6137 Yang, A., Steele, S., and N. Freed, "Internationalized 6138 Email Headers", RFC 6532, DOI 10.17487/RFC6532, February 6139 2012, . 6141 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 6142 Encodings", RFC 4648, DOI 10.17487/RFC4648, October 2006, 6143 . 6145 [RFC7817] Melnikov, A., "Updated Transport Layer Security (TLS) 6146 Server Identity Check Procedure for Email-Related 6147 Protocols", RFC 7817, DOI 10.17487/RFC7817, March 2016, 6148 . 6150 [RFC7888] Melnikov, A., Ed., "IMAP4 Non-synchronizing Literals", 6151 RFC 7888, DOI 10.17487/RFC7888, May 2016, 6152 . 6154 [RFC8314] Moore, K. and C. Newman, "Cleartext Considered Obsolete: 6155 Use of Transport Layer Security (TLS) for Email Submission 6156 and Access", RFC 8314, DOI 10.17487/RFC8314, January 2018, 6157 . 6159 13.2. Informative References (related protocols) 6161 [RFC5258] Leiba, B. and A. Melnikov, "Internet Message Access 6162 Protocol version 4 - LIST Command Extensions", RFC 5258, 6163 DOI 10.17487/RFC5258, June 2008, 6164 . 6166 [RFC2193] Gahrns, M., "IMAP4 Mailbox Referrals", RFC 2193, 6167 DOI 10.17487/RFC2193, September 1997, 6168 . 6170 [RFC3348] Gahrns, M. and R. Cheng, "The Internet Message Action 6171 Protocol (IMAP4) Child Mailbox Extension", RFC 3348, 6172 DOI 10.17487/RFC3348, July 2002, 6173 . 6175 [IMAP-DISC] 6176 Melnikov, A., Ed., "Synchronization Operations for 6177 Disconnected IMAP4 Clients", RFC 4549, June 2006, 6178 . 6180 [IMAP-I18N] 6181 Newman, C., Gulbrandsen, A., and A. Melnikov, "Internet 6182 Message Access Protocol Internationalization", RFC 5255, 6183 DOI 10.17487/RFC5255, June 2008, 6184 . 6186 [IMAP-MODEL] 6187 Crispin, M., "Distributed Electronic Mail Models in 6188 IMAP4", RFC 1733, December 1994, 6189 . 6191 [IMAP-UTF-8] 6192 Resnick, P., Ed., Newman, C., Ed., and S. Shen, Ed., "IMAP 6193 Support for UTF-8", RFC 6855, DOI 10.17487/RFC6855, March 6194 2013, . 6196 [ACAP] Newman, C. and J. G. Myers, "ACAP -- Application 6197 Configuration Access Protocol", RFC 2244, November 1997, 6198 . 6200 [SMTP] Klensin, J., "Simple Mail Transfer Protocol", RFC 5321, 6201 October 2008, . 6203 [RFC3516] Nerenberg, L., "IMAP4 Binary Content Extension", RFC 3516, 6204 DOI 10.17487/RFC3516, April 2003, 6205 . 6207 [RFC4314] Melnikov, A., "IMAP4 Access Control List (ACL) Extension", 6208 RFC 4314, December 2005, 6209 . 6211 [RFC2087] Myers, J., "IMAP4 QUOTA extension", RFC 2087, January 6212 1997, . 6214 [IMAP-URL] 6215 Melnikov, A., Ed. and C. Newman, "IMAP URL Scheme", 6216 RFC 5092, DOI 10.17487/RFC5092, November 2007, 6217 . 6219 13.3. Informative References (historical aspects of IMAP and related 6220 protocols) 6222 [IMAP-COMPAT] 6223 Crispin, M., "IMAP4 Compatibility with IMAP2bis", 6224 RFC 2061, December 1996, 6225 . 6227 [IMAP-HISTORICAL] 6228 Crispin, M., "IMAP4 Compatibility with IMAP2 and 6229 IMAP2bis", RFC 1732, December 1994, 6230 . 6232 [IMAP-OBSOLETE] 6233 Crispin, M., "Internet Message Access Protocol - Obsolete 6234 Syntax", RFC 2062, December 1996, 6235 . 6237 [IMAP2] Crispin, M., "Interactive Mail Access Protocol: Version 6238 2", RFC 1176, August 1990, 6239 . 6241 [RFC-822] Crocker, D., "STANDARD FOR THE FORMAT OF ARPA INTERNET 6242 TEXT MESSAGES", STD 11, RFC 822, August 1982, 6243 . 6245 [RFC-821] Postel, J., "Simple Mail Transfer Protocol", STD 10, 6246 RFC 821, August 1982, 6247 . 6249 [IMAP-TLS] 6250 Newman, C., "Using TLS with IMAP, POP3 and ACAP", 6251 RFC 2595, June 1999, 6252 . 6254 Appendix A. Backward compatibility with IMAP4rev1 6256 An implementation that wants to remain compatible with IMAP4rev1 can 6257 advertise both IMAP4rev1 and IMAP4rev2 in its CAPABILITY response/ 6258 response code. While some IMAP4rev1 responses were removed in 6259 IMAP4rev2, their presence will not break IMAP4rev2-only clients. 6261 If both IMAP4rev1 and IMAP4rev2 are advertised, an IMAP client that 6262 wants to use IMAP4rev2 MUST issue an "ENABLE IMAP4rev2" command. 6264 Servers advertising both IMAP4rev1 and IMAP4rev2 SHOULD NOT generate 6265 UTF-8 quoted strings unless the client has issued "ENABLE IMAP4rev2". 6267 Consider implementation of mechanisms described or referenced in 6268 [IMAP-UTF-8] to achieve this goal. 6270 Servers advertising both IMAP4rev1 and IMAP4rev2, and clients 6271 intending to be compatible with IMAP4rev1 servers MUST be compatible 6272 with the international mailbox naming convention described in the 6273 following subsection. 6275 A.1. Mailbox International Naming Convention 6277 By convention, international mailbox names in IMAP4rev2 are specified 6278 using a modified version of the UTF-7 encoding described in [UTF-7]. 6279 Modified UTF-7 may also be usable in servers that implement an 6280 earlier version of this protocol. 6282 In modified UTF-7, printable US-ASCII characters, except for "&", 6283 represent themselves; that is, characters with octet values 0x20-0x25 6284 and 0x27-0x7e. The character "&" (0x26) is represented by the two- 6285 octet sequence "&-". 6287 All other characters (octet values 0x00-0x1f and 0x7f-0xff) are 6288 represented in modified BASE64, with a further modification from 6289 [UTF-7] that "," is used instead of "/". Modified BASE64 MUST NOT be 6290 used to represent any printing US-ASCII character which can represent 6291 itself. Only characters inside the modified BASE64 alphabet are 6292 permitted in modified BASE64 text. 6294 "&" is used to shift to modified BASE64 and "-" to shift back to US- 6295 ASCII. There is no implicit shift from BASE64 to US-ASCII, and null 6296 shifts ("-&" while in BASE64; note that "&-" while in US-ASCII means 6297 "&") are not permitted. However, all names start in US-ASCII, and 6298 MUST end in US-ASCII; that is, a name that ends with a non-ASCII 6299 ISO-10646 character MUST end with a "-"). 6301 The purpose of these modifications is to correct the following 6302 problems with UTF-7: 6304 1. UTF-7 uses the "+" character for shifting; this conflicts with 6305 the common use of "+" in mailbox names, in particular USENET 6306 newsgroup names. 6308 2. UTF-7's encoding is BASE64 which uses the "/" character; this 6309 conflicts with the use of "/" as a popular hierarchy delimiter. 6311 3. UTF-7 prohibits the unencoded usage of "\"; this conflicts with 6312 the use of "\" as a popular hierarchy delimiter. 6314 4. UTF-7 prohibits the unencoded usage of "~"; this conflicts with 6315 the use of "~" in some servers as a home directory indicator. 6317 5. UTF-7 permits multiple alternate forms to represent the same 6318 string; in particular, printable US-ASCII characters can be 6319 represented in encoded form. 6321 Although modified UTF-7 is a convention, it establishes certain 6322 requirements on server handling of any mailbox name with an embedded 6323 "&" character. In particular, server implementations MUST preserve 6324 the exact form of the modified BASE64 portion of a modified UTF-7 6325 name and treat that text as case-sensitive, even if names are 6326 otherwise case-insensitive or case-folded. 6328 Server implementations SHOULD verify that any mailbox name with an 6329 embedded "&" character, used as an argument to CREATE, is: in the 6330 correctly modified UTF-7 syntax, has no superfluous shifts, and has 6331 no encoding in modified BASE64 of any printing US-ASCII character 6332 which can represent itself. However, client implementations MUST NOT 6333 depend upon the server doing this, and SHOULD NOT attempt to create a 6334 mailbox name with an embedded "&" character unless it complies with 6335 the modified UTF-7 syntax. 6337 Server implementations which export a mail store that does not follow 6338 the modified UTF-7 convention MUST convert to modified UTF-7 any 6339 mailbox name that contains either non-ASCII characters or the "&" 6340 character. 6342 For example, here is a mailbox name which mixes English, Chinese, 6343 and Japanese text: ~peter/mail/&U,BTFw-/&ZeVnLIqe- 6345 For example, the string "&Jjo!" is not a valid mailbox name 6346 because it does not contain a shift to US-ASCII before the "!". 6347 The correct form is "&Jjo-!". The string "&U,BTFw-&ZeVnLIqe-" is 6348 not permitted because it contains a superfluous shift. The 6349 correct form is "&U,BTF2XlZyyKng-". 6351 Appendix B. Backward compatibility with BINARY extension 6353 IMAP4rev2 is incorporates subset of functionality provided by the 6354 BINARY extension [RFC3516], in particular it includes additional 6355 FETCH items (BINARY, BINARY.PEEK and BINARY.SIZE), but not extensions 6356 to the APPEND command. IMAP4rev2 implementations that supports full 6357 RFC 3516 functionality need to also advertise the BINARY token in the 6358 CAPABILITY response. 6360 Appendix C. Changes from RFC 3501 / IMAP4rev1 6362 The following is the plan for remaining changes. The plan might 6363 change over time. 6365 1. Fold in the following extensions/RFC: RFC 5530 (IMAP Response 6366 Codes, done), UIDPLUS (done), ENABLE (done), ESEARCH (done), 6367 SPECIAL-USE (list of new mailbox attributes is done), LITERAL- 6368 (done), NAMESPACE (done), SASL-IR (done), IDLE (done), MOVE 6369 (done). 6371 2. Add CLOSED response code (from CONDSTORE) - done 6373 3. Add support for $MDNSent and $Forwarded IMAP keywords - done. 6374 Add more examples showing their use? Also add other keywords 6375 like $Phishing, $Junk, $NonJunk? 6377 4. Require all unsolicited FETCH updates to include UID - done. 6379 5. Update recommendations on TLS ciphers to match UTA WG work (as 6380 per RFC 8314, RFC 7525 and RFC 7817) - done. 6382 6. Possibly fold in the following extensions/RFC: Base LIST- 6383 EXTENDED syntax plus deprecate LSUB (replace it with LIST 6384 \Subscribed) minus the requirement to support multiple list 6385 patterns, STATUS-in-LIST, SEARCHRES, BINARY (only the FETCH 6386 changes on leaf body part and make APPEND related ones optional. 6387 See the mailing list discussion) - done. 6389 7. Add STATUS SIZE (total mailbox size) - done Add STATUS DELETED 6390 (number of messages with \Deleted flag set)? Or DELETEDSIZE? 6392 8. Deprecate features: What should we do with NEW search key (which 6393 implies RECENT): deprecate it or just redefine it to ignore 6394 RECENT state? 6396 9. Drop UTF-7, all mailboxes are always in UTF-8 - done. 6398 10. Revise IANA registration of IMAP extensions and give advice on 6399 use of "X-" convention. 6401 11. Allow word-based searching (as per Chris Newman)? 6403 The following changes since RFC 3501 were done so far: 6405 1. Folded in IMAP UNSELECT (RFC 3691), UIDPLUS (RFC 4315), ESEARCH 6406 (RFC 4731), ENABLE (RFC 5161), IDLE (RFC 2177), SASL-IR (RFC 6407 4959) and MOVE (RFC 6851) extensions. Also folded RFC 5530 and 6408 FETCH side of the BINARY extension (RFC 3516). 6410 2. Clarified that server should decode parameter value 6411 continuations as described in [RFC2231]. This requirement was 6412 hidden in RFC 2231 itself. 6414 3. SEARCH command now requires to return ESEARCH response (SEARCH 6415 response is now deprecated). 6417 4. Added CLOSED response code from RFC 7162. 6419 5. Updated to use modern TLS-related recommendations as per RFC 6420 8314, RFC 7817, RFC 7525. 6422 6. For future extensibility extended ABNF for tagged-ext-simple to 6423 allow for bare number64. 6425 7. Added SHOULD level requirement on IMAP servers to support 6426 $MDNSent and $Forwarded keywords. 6428 8. Added STATUS SIZE. 6430 9. Mailbox names and message headers now allow for UTF-8. Support 6431 for Modified UTF-7 in mailbox names is not required, unless 6432 compatibility with IMAP4rev1 is desired. 6434 10. UNSEEN response code on SELECT/EXAMINE is now deprecated. 6436 11. RECENT response on SELECT/EXAMINE, \Recent flag, RECENT STATUS 6437 item are now deprecated. 6439 Appendix D. Acknowledgement 6441 Earlier versions of this document were edited by Mark Crispin. 6442 Sadly, he is no longer available to help with this work. Editors of 6443 this revisions are hoping that Mark would have approved. 6445 Chris Newman has contributed text on I18N and use of UTF-8 in 6446 messages and mailbox names. 6448 Thank you to Tony Hansen for helping with the index generation. 6450 This document incorporate text from RFC 4315, RFC 4466, RFC 4731, RFC 6451 5161, RFC 6154 so work done by authors/editors of these documents is 6452 appreciated. 6454 Index 6456 $ 6457 $Forwarded (predefined flag) 12 6458 $MDNSent (predefined flag) 12 6460 + 6461 +FLAGS 82 6462 +FLAGS.SILENT 82 6464 - 6465 -FLAGS 82 6466 -FLAGS.SILENT 82 6468 A 6469 ALERT (response code) 89 6470 ALL (fetch item) 77 6471 ALL (search key) 74 6472 ALL (search result option) 73 6473 ALREADYEXISTS (response code) 89 6474 ANSWERED (search key) 74 6475 APPEND (command) 65 6476 APPENDUID (response code) 89 6477 AUTHENTICATE (command) 27 6478 AUTHENTICATIONFAILED (response code) 90 6479 AUTHORIZATIONFAILED (response code) 90 6481 B 6482 BAD (response) 97 6483 BADCHARSET (response code) 90 6484 BCC (search key) 74 6485 BEFORE (search key) 74 6486 BINARY.PEEK[]<> (fetch item) 78 6487 BINARY.SIZE[] (fetch item) 78 6488 BINARY.SIZE[] (fetch result) 106 6489 BINARY[]<> (fetch result) 106 6490 BINARY[]<> (fetch item) 78 6491 BODY (fetch item) 78 6492 BODY (fetch result) 106 6493 BODY (search key) 74 6494 BODY.PEEK[
]<> (fetch item) 80 6495 BODYSTRUCTURE (fetch item) 81 6496 BODYSTRUCTURE (fetch result) 107 6497 BODY[
]<> (fetch result) 106 6498 BODY[
]<> (fetch item) 78 6499 BYE (response) 97 6500 Body Structure (message attribute) 13 6502 C 6503 CANNOT (response code) 91 6504 CAPABILITY (command) 24 6505 CAPABILITY (response code) 91 6506 CAPABILITY (response) 98 6507 CC (search key) 74 6508 CHECK (command) 70 6509 CLIENTBUG (response code) 91 6510 CLOSE (command) 70 6511 CLOSED (response code) 91 6512 CONTACTADMIN (response code) 92 6513 COPY (command) 82 6514 COPYUID (response code) 92 6515 CORRUPTION (response code) 92 6516 COUNT (search result option) 73 6517 CREATE (command) 35 6519 D 6520 DELETE (command) 36 6521 DELETED (search key) 74 6522 DRAFT (search key) 74 6524 E 6525 ENABLE (command) 31 6526 ENVELOPE (fetch item) 81 6527 ENVELOPE (fetch result) 110 6528 ESEARCH (response) 103 6529 EXAMINE (command) 35 6530 EXPIRED (response code) 92 6531 EXPUNGE (command) 71 6532 EXPUNGE (response) 105 6533 EXPUNGEISSUED (response code) 93 6534 Envelope Structure (message attribute) 13 6536 F 6537 FAST (fetch item) 77 6538 FETCH (command) 77 6539 FETCH (response) 105 6540 FLAGGED (search key) 74 6541 FLAGS (fetch item) 81 6542 FLAGS (fetch result) 111 6543 FLAGS (response) 104 6544 FLAGS (store command data item) 82 6545 FLAGS.SILENT (store command data item) 82 6546 FROM (search key) 74 6547 FULL (fetch item) 78 6548 Flags (message attribute) 11 6550 H 6551 HEADER (part specifier) 79 6552 HEADER (search key) 74 6553 HEADER.FIELDS (part specifier) 79 6554 HEADER.FIELDS.NOT (part specifier) 79 6556 I 6557 IDLE (command) 67 6558 INTERNALDATE (fetch item) 81 6559 INTERNALDATE (fetch result) 111 6560 INUSE (response code) 93 6561 Internal Date (message attribute) 12 6563 K 6564 KEYWORD (search key) 75 6565 Keyword (type of flag) 12 6567 L 6568 LARGER (search key) 75 6569 LIMIT (response code) 93 6570 LIST (command) 41 6571 LIST (response) 99 6572 LOGOUT (command) 25 6573 LSUB (command) 58 6574 LSUB (response) 102 6576 M 6577 MAX (search result option) 72 6578 MAY (specification requirement term) 5 6579 MESSAGES (status item) 64 6580 MIME (part specifier) 79 6581 MIN (search result option) 72 6582 MOVE (command) 83 6583 MUST (specification requirement term) 5 6584 MUST NOT (specification requirement term) 5 6585 Message Sequence Number (message attribute) 11 6587 N 6588 NAMESPACE (command) 59 6589 NAMESPACE (response) 103 6590 NEW (search key) 75 6591 NO (response) 96 6592 NONEXISTENT (response code) 93 6593 NOOP (command) 25 6594 NOPERM (response code) 93 6595 NOT (search key) 75 6596 NOT RECOMMENDED (specification requirement term) 5 6598 O 6599 OK (response) 96 6600 ON (search key) 75 6601 OPTIONAL (specification requirement term) 5 6602 OR (search key) 75 6603 OVERQUOTA (response code) 94 6605 P 6606 PARSE (response code) 94 6607 PERMANENTFLAGS (response code) 94 6608 PREAUTH (response) 97 6609 PRIVACYREQUIRED (response code) 94 6610 Permanent Flag (class of flag) 12 6611 Predefined keywords 12 6613 R 6614 READ-ONLY (response code) 95 6615 READ-WRITE (response code) 95 6616 RECOMMENDED (specification requirement term) 5 6617 RENAME (command) 38 6618 REQUIRED (specification requirement term) 5 6619 RFC822 (fetch item) 81 6620 RFC822 (fetch result) 111 6621 RFC822.HEADER (fetch item) 81 6622 RFC822.HEADER (fetch result) 111 6623 RFC822.SIZE (fetch item) 81 6624 RFC822.SIZE (fetch result) 111 6625 RFC822.TEXT (fetch item) 81 6626 RFC822.TEXT (fetch result) 111 6628 S 6629 SEARCH (command) 72 6630 SEEN (search key) 75 6631 SELECT (command) 33 6632 SENTBEFORE (search key) 75 6633 SENTON (search key) 75 6634 SENTSINCE (search key) 75 6635 SERVERBUG (response code) 95 6636 SHOULD (specification requirement term) 5 6637 SHOULD NOT (specification requirement term) 5 6638 SINCE (search key) 75 6639 SIZE (status item) 65 6640 SMALLER (search key) 75 6641 STARTTLS (command) 26 6642 STATUS (command) 63 6643 STATUS (response) 103 6644 STORE (command) 81 6645 SUBJECT (search key) 75 6646 SUBSCRIBE (command) 40 6647 Session Flag (class of flag) 12 6648 System Flag (type of flag) 11 6650 T 6651 TEXT (part specifier) 79 6652 TEXT (search key) 75 6653 TO (search key) 75 6654 TRYCREATE (response code) 95 6656 U 6657 UID (command) 85 6658 UID (fetch item) 81 6659 UID (fetch result) 111 6660 UID (search key) 76 6661 UIDNEXT (response code) 95 6662 UIDNEXT (status item) 64 6663 UIDNOTSTICKY (response code) 95 6664 UIDVALIDITY (response code) 95 6665 UIDVALIDITY (status item) 64 6666 UNANSWERED (search key) 76 6667 UNAVAILABLE (response code) 95 6668 UNDELETED (search key) 76 6669 UNDRAFT (search key) 76 6670 UNFLAGGED (search key) 76 6671 UNKEYWORD (search key) 76 6672 UNKNOWN-CTE (response code) 96 6673 UNSEEN (search key) 76 6674 UNSEEN (status item) 64 6675 UNSELECT (command) 71 6676 UNSUBSCRIBE (command) 41 6677 Unique Identifier (UID) (message attribute) 9 6679 X 6680 X (command) 87 6682 [ 6683 [RFC-5322] Size (message attribute) 13 6685 \ 6686 \All (mailbox name attribute) 101 6687 \Answered (system flag) 11 6688 \Archive (mailbox name attribute) 101 6689 \Deleted (system flag) 11 6690 \Draft (system flag) 12 6691 \Drafts (mailbox name attribute) 101 6692 \Flagged (mailbox name attribute) 101 6693 \Flagged (system flag) 11 6694 \HasChildren (mailbox name attribute) 100 6695 \HasNoChildren (mailbox name attribute) 100 6696 \Junk (mailbox name attribute) 101 6697 \Marked (mailbox name attribute) 100 6698 \Noinferiors (mailbox name attribute) 100 6699 \Noselect (mailbox name attribute) 100 6700 \Recent (system flag) 12 6701 \Seen (system flag) 11 6702 \Sent (mailbox name attribute) 101 6703 \Trash (mailbox name attribute) 101 6704 \Unmarked (mailbox name attribute) 100 6706 Authors' Addresses 6708 Alexey Melnikov (editor) 6709 Isode Ltd 6710 14 Castle Mews 6711 Hampton, Middlesex TW12 2NP 6712 UK 6714 Email: Alexey.Melnikov@isode.com 6716 Barry Leiba (editor) 6717 Huawei Technologies 6719 Phone: +1 646 827 0648 6720 Email: barryleiba@computer.org 6721 URI: http://internetmessagingtechnology.org/