idnits 2.17.1 draft-ietf-extra-imap4rev2-08.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 (November 19, 2019) is 1617 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 6365, but not defined == Missing Reference: 'IMAP-OBSOLETE' is mentioned on line 6360, but not defined == Missing Reference: 'IMAP-COMPAT' is mentioned on line 6350, but not defined == Missing Reference: 'IMAP-HISTORICAL' is mentioned on line 6355, but not defined == Missing Reference: 'RFC-822' is mentioned on line 6369, but not defined ** Obsolete undefined reference: RFC 822 (Obsoleted by RFC 2822) == Missing Reference: 'HEADER' is mentioned on line 5199, but not defined == Missing Reference: 'IMAP-DISC' is mentioned on line 6307, but not defined == Missing Reference: 'SMTP' is mentioned on line 6328, but not defined == Missing Reference: 'RFC7888' is mentioned on line 6303, but not defined -- Looks like a reference, but probably isn't: '1' on line 843 == Missing Reference: 'IMAP-URL' is mentioned on line 6342, but not defined == Missing Reference: 'UIDVALIDITY 3857529045' is mentioned on line 5182, but not defined == Missing Reference: 'UIDNEXT 4392' is mentioned on line 1650, but not defined == Missing Reference: 'RFC5258' is mentioned on line 6289, but not defined == Missing Reference: 'RFC2193' is mentioned on line 6294, but not defined == Missing Reference: 'RFC3348' is mentioned on line 6298, but not defined ** Obsolete undefined reference: RFC 3348 (Obsoleted by RFC 5258) == Missing Reference: 'UIDNEXT 2' is mentioned on line 3034, but not defined == Missing Reference: 'UIDVALIDITY 1' is mentioned on line 3107, but not defined == Missing Reference: 'IMAP-I18N' is mentioned on line 6312, but not defined == Missing Reference: 'UID' is mentioned on line 3797, but not defined == Missing Reference: 'RFC4314' is mentioned on line 6335, but not defined == Missing Reference: 'RFC2087' is mentioned on line 6339, but not defined ** Obsolete undefined reference: RFC 2087 (Obsoleted by RFC 9208) == Missing Reference: 'READ-WRITE' is mentioned on line 5183, but not defined == Missing Reference: 'RFC4422' is mentioned on line 5519, but not defined == Missing Reference: 'IMAP4' is mentioned on line 5605, but not defined == Missing Reference: 'Namespace-Response-Extensions' is mentioned on line 5671, but not defined == Missing Reference: 'IMAP-TLS' is mentioned on line 6377, but not defined == Missing Reference: 'IMAP-MODEL' is mentioned on line 6318, but not defined == Missing Reference: 'IMAP-UTF-8' is mentioned on line 6396, but not defined == Missing Reference: 'RFC3516' is mentioned on line 6486, but not defined == Missing Reference: 'RFC-821' is mentioned on line 6373, but not defined ** Obsolete undefined reference: RFC 821 (Obsoleted by RFC 2821) ** 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: 10 errors (**), 0 flaws (~~), 32 warnings (==), 4 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: May 22, 2020 November 19, 2019 8 INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev2 9 draft-ietf-extra-imap4rev2-08 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 May 22, 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 . . . . . . . . . . . . . . . . . . . 14 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 . . . . . . . . . . . . . . . . . 19 108 5.1. Mailbox Naming . . . . . . . . . . . . . . . . . . . . . 19 109 5.1.1. Mailbox Hierarchy Naming . . . . . . . . . . . . . . 20 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 . . . . . . . . . . 22 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 . . . . . . . . . . . . . . . . . . . 26 120 6.2. Client Commands - Not Authenticated State . . . . . . . . 26 121 6.2.1. STARTTLS Command . . . . . . . . . . . . . . . . . . 27 122 6.2.2. AUTHENTICATE Command . . . . . . . . . . . . . . . . 28 123 6.2.3. LOGIN Command . . . . . . . . . . . . . . . . . . . . 31 124 6.3. Client Commands - Authenticated State . . . . . . . . . . 31 125 6.3.1. ENABLE Command . . . . . . . . . . . . . . . . . . . 32 126 6.3.2. SELECT Command . . . . . . . . . . . . . . . . . . . 34 127 6.3.3. EXAMINE Command . . . . . . . . . . . . . . . . . . . 35 128 6.3.4. CREATE Command . . . . . . . . . . . . . . . . . . . 36 129 6.3.5. DELETE Command . . . . . . . . . . . . . . . . . . . 37 130 6.3.6. RENAME Command . . . . . . . . . . . . . . . . . . . 39 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. NAMESPACE Command . . . . . . . . . . . . . . . . . . 57 135 6.3.11. STATUS Command . . . . . . . . . . . . . . . . . . . 62 136 6.3.12. APPEND Command . . . . . . . . . . . . . . . . . . . 63 137 6.3.13. IDLE Command . . . . . . . . . . . . . . . . . . . . 66 138 6.4. Client Commands - Selected State . . . . . . . . . . . . 68 139 6.4.1. CLOSE Command . . . . . . . . . . . . . . . . . . . . 68 140 6.4.2. UNSELECT Command . . . . . . . . . . . . . . . . . . 69 141 6.4.3. EXPUNGE Command . . . . . . . . . . . . . . . . . . . 69 142 6.4.4. SEARCH Command . . . . . . . . . . . . . . . . . . . 70 143 6.4.5. FETCH Command . . . . . . . . . . . . . . . . . . . . 76 144 6.4.6. STORE Command . . . . . . . . . . . . . . . . . . . . 80 145 6.4.7. COPY Command . . . . . . . . . . . . . . . . . . . . 81 146 6.4.8. MOVE Command . . . . . . . . . . . . . . . . . . . . 82 147 6.4.9. UID Command . . . . . . . . . . . . . . . . . . . . . 84 148 6.5. Client Commands - Experimental/Expansion . . . . . . . . 85 149 6.5.1. X Command . . . . . . . . . . . . . . . . . . . 85 150 7. Server Responses . . . . . . . . . . . . . . . . . . . . . . 86 151 7.1. Server Responses - Status Responses . . . . . . . . . . . 87 152 7.1.1. OK Response . . . . . . . . . . . . . . . . . . . . . 95 153 7.1.2. NO Response . . . . . . . . . . . . . . . . . . . . . 95 154 7.1.3. BAD Response . . . . . . . . . . . . . . . . . . . . 96 155 7.1.4. PREAUTH Response . . . . . . . . . . . . . . . . . . 96 156 7.1.5. BYE Response . . . . . . . . . . . . . . . . . . . . 97 157 7.2. Server Responses - Server and Mailbox Status . . . . . . 97 158 7.2.1. The ENABLED Response . . . . . . . . . . . . . . . . 97 159 7.2.2. CAPABILITY Response . . . . . . . . . . . . . . . . . 98 160 7.2.3. LIST Response . . . . . . . . . . . . . . . . . . . . 99 161 7.2.4. NAMESPACE Response . . . . . . . . . . . . . . . . . 102 162 7.2.5. STATUS Response . . . . . . . . . . . . . . . . . . . 102 163 7.2.6. ESEARCH Response . . . . . . . . . . . . . . . . . . 103 164 7.2.7. FLAGS Response . . . . . . . . . . . . . . . . . . . 103 165 7.3. Server Responses - Mailbox Size . . . . . . . . . . . . . 104 166 7.3.1. EXISTS Response . . . . . . . . . . . . . . . . . . . 104 167 7.4. Server Responses - Message Status . . . . . . . . . . . . 104 168 7.4.1. EXPUNGE Response . . . . . . . . . . . . . . . . . . 104 169 7.4.2. FETCH Response . . . . . . . . . . . . . . . . . . . 105 170 7.5. Server Responses - Command Continuation Request . . . . . 111 171 8. Sample IMAP4rev2 connection . . . . . . . . . . . . . . . . . 111 172 9. Formal Syntax . . . . . . . . . . . . . . . . . . . . . . . . 112 173 10. Author's Note . . . . . . . . . . . . . . . . . . . . . . . . 129 174 11. Security Considerations . . . . . . . . . . . . . . . . . . . 129 175 11.1. STARTTLS Security Considerations . . . . . . . . . . . . 129 176 11.2. COPYUID and APPENDUID response codes . . . . . . . . . . 130 177 11.3. LIST command and Other Users' namespace . . . . . . . . 130 178 11.4. Other Security Considerations . . . . . . . . . . . . . 130 179 12. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 131 180 12.1. Updates to IMAP4 Capabilities registry . . . . . . . . . 131 181 12.2. GSSAPI/SASL service name . . . . . . . . . . . . . . . . 132 182 13. References . . . . . . . . . . . . . . . . . . . . . . . . . 132 183 13.1. Normative References . . . . . . . . . . . . . . . . . . 132 184 13.2. Informative References (related protocols) . . . . . . . 135 185 13.3. Informative References (historical aspects of IMAP and 186 related protocols) . . . . . . . . . . . . . . . . . . . 136 187 Appendix A. Backward compatibility with IMAP4rev1 . . . . . . . 137 188 A.1. Mailbox International Naming Convention for compatibility 189 with IMAP4rev1 . . . . . . . . . . . . . . . . . . . . . 137 190 Appendix B. Backward compatibility with BINARY extension . . . . 139 191 Appendix C. Changes from RFC 3501 / IMAP4rev1 . . . . . . . . . 139 192 Appendix D. Acknowledgement . . . . . . . . . . . . . . . . . . 141 193 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 194 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 147 196 1. How to Read This Document 198 1.1. Organization of This Document 200 This document is written from the point of view of the implementor of 201 an IMAP4rev2 client or server. Beyond the protocol overview in 202 section 2, it is not optimized for someone trying to understand the 203 operation of the protocol. The material in sections 3 through 5 204 provides the general context and definitions with which IMAP4rev2 205 operates. 207 Sections 6, 7, and 9 describe the IMAP commands, responses, and 208 syntax, respectively. The relationships among these are such that it 209 is almost impossible to understand any of them separately. In 210 particular, do not attempt to deduce command syntax from the command 211 section alone; instead refer to the Formal Syntax section. 213 1.2. Conventions Used in This Document 215 "Conventions" are basic principles or procedures. Document 216 conventions are noted in this section. 218 In examples, "C:" and "S:" indicate lines sent by the client and 219 server respectively. 221 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 222 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 223 "OPTIONAL" in this document are to be interpreted as described in BCP 224 14 [RFC2119] [RFC8174] when, and only when, they appear in all 225 capitals, as shown here. 227 The word "can" (not "may") is used to refer to a possible 228 circumstance or situation, as opposed to an optional facility of the 229 protocol. 231 "User" is used to refer to a human user, whereas "client" refers to 232 the software being run by the user. 234 "Connection" refers to the entire sequence of client/server 235 interaction from the initial establishment of the network connection 236 until its termination. 238 "Session" refers to the sequence of client/server interaction from 239 the time that a mailbox is selected (SELECT or EXAMINE command) until 240 the time that selection ends (SELECT or EXAMINE of another mailbox, 241 CLOSE command, UNSELECT command, or connection termination). 243 Characters are 7-bit US-ASCII unless otherwise specified. Other 244 character sets are indicated using a "CHARSET", as described in 245 [MIME-IMT] and defined in [CHARSET]. CHARSETs have important 246 additional semantics in addition to defining character set; refer to 247 these documents for more detail. 249 There are several protocol conventions in IMAP. These refer to 250 aspects of the specification which are not strictly part of the IMAP 251 protocol, but reflect generally-accepted practice. Implementations 252 need to be aware of these conventions, and avoid conflicts whether or 253 not they implement the convention. For example, "&" may not be used 254 as a hierarchy delimiter since it conflicts with the Mailbox 255 International Naming Convention, and other uses of "&" in mailbox 256 names are impacted as well. 258 1.3. Special Notes to Implementors 260 Implementors of the IMAP protocol are strongly encouraged to read the 261 IMAP implementation recommendations document [IMAP-IMPLEMENTATION] in 262 conjunction with this document, to help understand the intricacies of 263 this protocol and how best to build an interoperable product. 265 IMAP4rev2 is designed to be upwards compatible from the [IMAP2] and 266 unpublished IMAP2bis protocols. IMAP4rev2 is largely compatible with 267 the IMAP4rev1 protocol described in RFC 3501 and the IMAP4 protocol 268 described in RFC 1730; the exception being in certain facilities 269 added in RFC 1730 that proved problematic and were subsequently 270 removed. In the course of the evolution of IMAP4rev2, some aspects 271 in the earlier protocols have become obsolete. 273 Obsolete commands, responses, and data formats which an IMAP4rev2 274 implementation can encounter when used with an earlier implementation 275 are described in [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 (all BODY[...] fetch data 480 items) must never change. This does not include message 481 numbers, nor does it include attributes that can be set by a 482 STORE command (e.g., FLAGS). 484 2.3.1.2. Message Sequence Number Message Attribute 486 A relative position from 1 to the number of messages in the mailbox. 487 This position MUST be ordered by ascending unique identifier. As 488 each new message is added, it is assigned a message sequence number 489 that is 1 higher than the number of messages in the mailbox before 490 that new message was added. 492 Message sequence numbers can be reassigned during the session. For 493 example, when a message is permanently removed (expunged) from the 494 mailbox, the message sequence number for all subsequent messages is 495 decremented. The number of messages in the mailbox is also 496 decremented. Similarly, a new message can be assigned a message 497 sequence number that was once held by some other message prior to an 498 expunge. 500 In addition to accessing messages by relative position in the 501 mailbox, message sequence numbers can be used in mathematical 502 calculations. For example, if an untagged "11 EXISTS" is received, 503 and previously an untagged "8 EXISTS" was received, three new 504 messages have arrived with message sequence numbers of 9, 10, and 11. 505 Another example, if message 287 in a 523 message mailbox has UID 506 12345, there are exactly 286 messages which have lesser UIDs and 236 507 messages which have greater UIDs. 509 2.3.2. Flags Message Attribute 511 A list of zero or more named tokens associated with the message. A 512 flag is set by its addition to this list, and is cleared by its 513 removal. There are two types of flags in IMAP4rev2. A flag of 514 either type can be permanent or session-only. 516 A system flag is a flag name that is pre-defined in this 517 specification and begin with "\". 519 Certain system flags (\Deleted and \Seen) have special semantics 520 described elsewhere in this document. The currently-defined system 521 flags are: 523 \Seen Message has been read 525 \Answered Message has been answered 527 \Flagged Message is "flagged" for urgent/special attention 528 \Deleted Message is "deleted" for removal by later EXPUNGE 530 \Draft Message has not completed composition (marked as a draft). 532 \Recent This flag was in used in IMAP4rev1 and is now deprecated. 534 A keyword is defined by the server implementation. Keywords do not 535 begin with "\". Servers MAY permit the client to define new keywords 536 in the mailbox (see the description of the PERMANENTFLAGS response 537 code for more information). Some keywords that start with "$" are 538 also defined in this specification. 540 This document defines several keywords that were not originally 541 defined in RFC 3501, but which were found to be useful by client 542 implementations. These keywords SHOULD be supported (i.e. allowed in 543 APPEND, COPY, MOVE and SEARCH commands) by server implementations: 545 $Forwarded Message has been forwarded to another email address, 546 embedded within or attached to a new message. An email client 547 sets this keyword when it successfully forwards the message to 548 another email address. Typical usage of this keyword is to show a 549 different (or additional) icon for a message that has been 550 forwarded. Once set, the flag SHOULD NOT be cleared. 552 $Forwarded 554 $Forwarded 556 $MDNSent Message Disposition Notification [RFC8098] was generated 557 and sent for this message. 559 $MDNSent 561 A flag can be permanent or session-only on a per-flag basis. 562 Permanent flags are those which the client can add or remove from the 563 message flags permanently; that is, concurrent and subsequent 564 sessions will see any change in permanent flags. Changes to session 565 flags are valid only in that session. 567 2.3.3. Internal Date Message Attribute 569 The internal date and time of the message on the server. This is not 570 the date and time in the [RFC-5322] header, but rather a date and 571 time which reflects when the message was received. In the case of 572 messages delivered via [SMTP], this SHOULD be the date and time of 573 final delivery of the message as defined by [SMTP]. In the case of 574 messages delivered by the IMAP4rev2 COPY or MOVE command, this SHOULD 575 be the internal date and time of the source message. In the case of 576 messages delivered by the IMAP4rev2 APPEND command, this SHOULD be 577 the date and time as specified in the APPEND command description. 578 All other cases are implementation defined. 580 2.3.4. [RFC-5322] Size Message Attribute 582 The number of octets in the message, as expressed in [RFC-5322] 583 format. 585 2.3.5. Envelope Structure Message Attribute 587 A parsed representation of the [RFC-5322] header of the message. 588 Note that the IMAP Envelope structure is not the same as an [SMTP] 589 envelope. 591 2.3.6. Body Structure Message Attribute 593 A parsed representation of the [MIME-IMB] body structure information 594 of the message. 596 2.4. Message Texts 598 In addition to being able to fetch the full [RFC-5322] text of a 599 message, IMAP4rev2 permits the fetching of portions of the full 600 message text. Specifically, it is possible to fetch the [RFC-5322] 601 message header, [RFC-5322] message body, a [MIME-IMB] body part, or a 602 [MIME-IMB] header. 604 3. State and Flow Diagram 606 Once the connection between client and server is established, an 607 IMAP4rev2 connection is in one of four states. The initial state is 608 identified in the server greeting. Most commands are only valid in 609 certain states. It is a protocol error for the client to attempt a 610 command while the connection is in an inappropriate state, and the 611 server will respond with a BAD or NO (depending upon server 612 implementation) command completion result. 614 3.1. Not Authenticated State 616 In the not authenticated state, the client MUST supply authentication 617 credentials before most commands will be permitted. This state is 618 entered when a connection starts unless the connection has been pre- 619 authenticated. 621 3.2. Authenticated State 623 In the authenticated state, the client is authenticated and MUST 624 select a mailbox to access before commands that affect messages will 625 be permitted. This state is entered when a pre-authenticated 626 connection starts, when acceptable authentication credentials have 627 been provided, after an error in selecting a mailbox, or after a 628 successful CLOSE command. 630 3.3. Selected State 632 In a selected state, a mailbox has been selected to access. This 633 state is entered when a mailbox has been successfully selected. 635 3.4. Logout State 637 In the logout state, the connection is being terminated. This state 638 can be entered as a result of a client request (via the LOGOUT 639 command) or by unilateral action on the part of either the client or 640 server. 642 If the client requests the logout state, the server MUST send an 643 untagged BYE response and a tagged OK response to the LOGOUT command 644 before the server closes the connection; and the client MUST read the 645 tagged OK response to the LOGOUT command before the client closes the 646 connection. 648 A server SHOULD NOT unilaterally close the connection without sending 649 an untagged BYE response that contains the reason for having done so. 650 A client SHOULD NOT unilaterally close the connection, and instead 651 SHOULD issue a LOGOUT command. If the server detects that the client 652 has unilaterally closed the connection, the server MAY omit the 653 untagged BYE response and simply close its connection. 655 +----------------------+ 656 |connection established| 657 +----------------------+ 658 || 659 \/ 660 +--------------------------------------+ 661 | server greeting | 662 +--------------------------------------+ 663 || (1) || (2) || (3) 664 \/ || || 665 +-----------------+ || || 666 |Not Authenticated| || || 667 +-----------------+ || || 668 || (7) || (4) || || 669 || \/ \/ || 670 || +----------------+ || 671 || | Authenticated |<=++ || 672 || +----------------+ || || 673 || || (7) || (5) || (6) || 674 || || \/ || || 675 || || +--------+ || || 676 || || |Selected|==++ || 677 || || +--------+ || 678 || || || (7) || 679 \/ \/ \/ \/ 680 +--------------------------------------+ 681 | Logout | 682 +--------------------------------------+ 683 || 684 \/ 685 +-------------------------------+ 686 |both sides close the connection| 687 +-------------------------------+ 689 (1) connection without pre-authentication (OK greeting) 690 (2) pre-authenticated connection (PREAUTH greeting) 691 (3) rejected connection (BYE greeting) 692 (4) successful LOGIN or AUTHENTICATE command 693 (5) successful SELECT or EXAMINE command 694 (6) CLOSE command, unsolicited CLOSED response code or 695 failed SELECT or EXAMINE command 696 (7) LOGOUT command, server shutdown, or connection closed 698 4. Data Formats 700 IMAP4rev2 uses textual commands and responses. Data in IMAP4rev2 can 701 be in one of several forms: atom, number, string, parenthesized list, 702 or NIL. Note that a particular data item may take more than one 703 form; for example, a data item defined as using "astring" syntax may 704 be either an atom or a string. 706 4.1. Atom 708 An atom consists of one or more non-special characters. 710 4.1.1. Sequence set and UID set 712 A set of messages can be referenced by a sequence set containing 713 either message sequence numbers or unique identifiers. See Section 9 714 for details. Sequence sets can contain ranges (e.g. "5:50"), an 715 enumeration of specific message/UID numbers, a special symbol "*", or 716 a combination of the above. 718 A "UID set" is similar to the sequence set of unique identifiers; 719 however, the "*" value for a sequence number is not permitted. 721 4.2. Number 723 A number consists of one or more digit characters, and represents a 724 numeric value. 726 4.3. String 728 A string is in one of three forms: synchonizing literal, non- 729 synchronizing literal or quoted string. The synchronizing literal 730 form is the general form of string. The non-synchronizing literal 731 form is also the general form, but has length limitation. The quoted 732 string form is an alternative that avoids the overhead of processing 733 a literal at the cost of limitations of characters which may be used. 735 When the distinction between synchronizing and non-synchronizing 736 literals is not important, this document just uses the term 737 "literal". 739 A synchronizing literal is a sequence of zero or more octets 740 (including CR and LF), prefix-quoted with an octet count in the form 741 of an open brace ("{"), the number of octets, close brace ("}"), and 742 CRLF. In the case of synchronizing literals transmitted from server 743 to client, the CRLF is immediately followed by the octet data. In 744 the case of synchronizing literals transmitted from client to server, 745 the client MUST wait to receive a command continuation request 746 (described later in this document) before sending the octet data (and 747 the remainder of the command). 749 The non-synchronizing literal is an alternate form of synchronizing 750 literal, and it may appear in communication from client to server 751 instead of the synchonizing form of literal. The non-synchronizing 752 literal form MUST NOT be sent from server to client. The non- 753 synchronizing literal is distinguished from the synchronizing literal 754 by having a plus ("+") between the octet count and the closing brace 755 ("}"). The server does not generate a command continuation request 756 in response to a non-synchronizing literal, and clients are not 757 required to wait before sending the octets of a non- synchronizing 758 literal. Non-synchronizing literals MUST NOT be larger than 4096 759 octets. Any literal larger than 4096 bytes MUST be sent as a 760 synchronizing literal. (Non-synchronizing literals defined in this 761 document are the same as non-synchronizing literals defined by the 762 LITERAL- extension from [RFC7888]. See that document for details on 763 how to handle invalid non-synchronizing literals longer than 4096 764 octets and for interaction with other IMAP extensions.) 766 A quoted string is a sequence of zero or more Unicode characters, 767 excluding CR and LF, encoded in UTF-8, with double quote (<">) 768 characters at each end. 770 The empty string is represented as "" (a quoted string with zero 771 characters between double quotes), as {0} followed by CRLF (a 772 synchronizing literal with an octet count of 0) or as {0+} followed 773 by CRLF (a non-synchronizing literal with an octet count of 0). 775 Note: Even if the octet count is 0, a client transmitting a 776 synchronizing literal MUST wait to receive a command continuation 777 request. 779 4.3.1. 8-bit and Binary Strings 781 8-bit textual and binary mail is supported through the use of a 782 [MIME-IMB] content transfer encoding. IMAP4rev2 implementations MAY 783 transmit 8-bit or multi-octet characters in literals, but SHOULD do 784 so only when the [CHARSET] is identified. 786 IMAP4rev2 is compatible with [I18N-HDRS]. As a result, the 787 identified charset for header-field values with 8-bit content is 788 UTF-8 [UTF-8]. IMAP4rev2 implementations MUST accept and MAY 789 transmit [UTF-8] text in quoted-strings as long as the string does 790 not contain NUL, CR, or LF. This differs from IMAP4rev1 791 implementations. 793 Although a BINARY content transfer encoding is defined, unencoded 794 binary strings are not permitted, unless returned in a in 795 response to BINARY.PEEK[]<> or 796 BINARY[]<> FETCH data item. A "binary 797 string" is any string with NUL characters. A string with an 798 excessive amount of CTL characters MAY also be considered to be 799 binary. Unless returned in response to BINARY.PEEK[...]/BINARY[...] 800 FETCH, client and server implementations MUST encode binary data into 801 a textual form, such as BASE64, before transmitting the data. 803 4.4. Parenthesized List 805 Data structures are represented as a "parenthesized list"; a sequence 806 of data items, delimited by space, and bounded at each end by 807 parentheses. A parenthesized list can contain other parenthesized 808 lists, using multiple levels of parentheses to indicate nesting. 810 The empty list is represented as () -- a parenthesized list with no 811 members. 813 4.5. NIL 815 The special form "NIL" represents the non-existence of a particular 816 data item that is represented as a string or parenthesized list, as 817 distinct from the empty string "" or the empty parenthesized list (). 819 Note: NIL is never used for any data item which takes the form of 820 an atom. For example, a mailbox name of "NIL" is a mailbox named 821 NIL as opposed to a non-existent mailbox name. This is because 822 mailbox uses "astring" syntax which is an atom or a string. 823 Conversely, an addr-name of NIL is a non-existent personal name, 824 because addr-name uses "nstring" syntax which is NIL or a string, 825 but never an atom. 827 Examples: 829 The following LIST response: 831 * LIST () "/" NIL 833 is equivalent to: 834 * LIST () "/" "NIL" 836 as LIST response ABNF is using astring for mailbox name. 838 However, the following response 840 * FETCH 1 (BODY[1] NIL) 842 is not equivalent to: 843 * FETCH 1 (BODY[1] "NIL") 844 The former means absence of the body part, while the latter 845 means that it contains literal sequence of characters "NIL". 847 5. Operational Considerations 849 The following rules are listed here to ensure that all IMAP4rev2 850 implementations interoperate properly. 852 5.1. Mailbox Naming 854 In IMAP4rev2, Mailbox names are encoded in Net-Unicode [NET-UNICODE] 855 (this differs from IMAP4rev1). Client implementations MAY attempt to 856 create Net-Unicode mailbox names, and MUST interpret any 8-bit 857 mailbox names returned by LIST as [NET-UNICODE]. Server 858 implementations MUST prohibit the creation of 8-bit mailbox names 859 that do not comply with Net-Unicode (however, servers MAY accept a 860 de-normalized UTF-8 mailbox name and convert it to Net-Unicode prior 861 to mailbox creation). 863 The case-insensitive mailbox name INBOX is a special name reserved to 864 mean "the primary mailbox for this user on this server". (Note that 865 this special name may not exist on some servers for some users, for 866 example if the user has no access to personal namespace.) The 867 interpretation of all other names is implementation-dependent. 869 In particular, this specification takes no position on case 870 sensitivity in non-INBOX mailbox names. Some server implementations 871 are fully case-sensitive in ASCII range; others preserve case of a 872 newly-created name but otherwise are case-insensitive; and yet others 873 coerce names to a particular case. Client implementations MUST 874 interact with any of these. 876 There are certain client considerations when creating a new mailbox 877 name: 879 1. Any character which is one of the atom-specials (see the Formal 880 Syntax) will require that the mailbox name be represented as a 881 quoted string or literal. 883 2. CTL and other non-graphic characters are difficult to represent 884 in a user interface and are best avoided. Servers MAY refuse to 885 create mailbox names containing Unicode CTL characters. 887 3. Although the list-wildcard characters ("%" and "*") are valid in 888 a mailbox name, it is difficult to use such mailbox names with 889 the LIST command due to the conflict with wildcard 890 interpretation. 892 4. Usually, a character (determined by the server implementation) is 893 reserved to delimit levels of hierarchy. 895 5. Two characters, "#" and "&", have meanings by convention, and 896 should be avoided except when used in that convention. 898 5.1.1. Mailbox Hierarchy Naming 900 If it is desired to export hierarchical mailbox names, mailbox names 901 MUST be left-to-right hierarchical using a single character to 902 separate levels of hierarchy. The same hierarchy separator character 903 is used for all levels of hierarchy within a single name. 905 5.1.2. Namespaces 907 Personal Namespace: A namespace that the server considers within the 908 personal scope of the authenticated user on a particular connection. 909 Typically, only the authenticated user has access to mailboxes in 910 their Personal Namespace. It is the part of the namespace that 911 belongs to the user that is allocated for mailboxes. If an INBOX 912 exists for a user, it MUST appear within the user's personal 913 namespace. In the typical case, there SHOULD be only one Personal 914 Namespace on a server. 916 Other Users' Namespace: A namespace that consists of mailboxes from 917 the Personal Namespaces of other users. To access mailboxes in the 918 Other Users' Namespace, the currently authenticated user MUST be 919 explicitly granted access rights. For example, it is common for a 920 manager to grant to their secretary access rights to their mailbox. 921 In the typical case, there SHOULD be only one Other Users' Namespace 922 on a server. 924 Shared Namespace: A namespace that consists of mailboxes that are 925 intended to be shared amongst users and do not exist within a user's 926 Personal Namespace. 928 The namespaces a server uses MAY differ on a per-user basis. 930 5.1.2.1. Historic Mailbox Namespace Naming Convention 932 By convention, the first hierarchical element of any mailbox name 933 which begins with "#" identifies the "namespace" of the remainder of 934 the name. This makes it possible to disambiguate between different 935 types of mailbox stores, each of which have their own namespaces. 937 For example, implementations which offer access to USENET 938 newsgroups MAY use the "#news" namespace to partition the USENET 939 newsgroup namespace from that of other mailboxes. Thus, the 940 comp.mail.misc newsgroup would have a mailbox name of 941 "#news.comp.mail.misc", and the name "comp.mail.misc" can refer to 942 a different object (e.g., a user's private mailbox). 944 Namespaces that include the "#" character are not IMAP URL [IMAP-URL] 945 friendly requiring the "#" character to be represented as %23 when 946 within URLs. As such, server implementers MAY instead consider using 947 namespace prefixes that do not contain the "#" character. 949 5.1.2.2. Common namespace models 951 Previous version of this protocol does not define a default server 952 namespace. Two common namespace models have evolved: 954 The "Personal Mailbox" model, in which the default namespace that is 955 presented consists of only the user's personal mailboxes. To access 956 shared mailboxes, the user must use an escape mechanism to reach 957 another namespace. 959 The "Complete Hierarchy" model, in which the default namespace that 960 is presented includes the user's personal mailboxes along with any 961 other mailboxes they have access to. 963 5.2. Mailbox Size and Message Status Updates 965 At any time, a server can send data that the client did not request. 966 Sometimes, such behavior is REQUIRED. For example, agents other than 967 the server MAY add messages to the mailbox (e.g., new message 968 delivery), change the flags of the messages in the mailbox (e.g., 969 simultaneous access to the same mailbox by multiple agents), or even 970 remove messages from the mailbox. A server MUST send mailbox size 971 updates automatically if a mailbox size change is observed during the 972 processing of a command. A server SHOULD send message flag updates 973 automatically, without requiring the client to request such updates 974 explicitly. 976 Special rules exist for server notification of a client about the 977 removal of messages to prevent synchronization errors; see the 978 description of the EXPUNGE response for more detail. In particular, 979 it is NOT permitted to send an EXISTS response that would reduce the 980 number of messages in the mailbox; only the EXPUNGE response can do 981 this. 983 Regardless of what implementation decisions a client makes on 984 remembering data from the server, a client implementation MUST record 985 mailbox size updates. It MUST NOT assume that any command after the 986 initial mailbox selection will return the size of the mailbox. 988 5.3. Response when no Command in Progress 990 Server implementations are permitted to send an untagged response 991 (except for EXPUNGE) while there is no command in progress. Server 992 implementations that send such responses MUST deal with flow control 993 considerations. Specifically, they MUST either (1) verify that the 994 size of the data does not exceed the underlying transport's available 995 window size, or (2) use non-blocking writes. 997 5.4. Autologout Timer 999 If a server has an inactivity autologout timer that applies to 1000 sessions after authentication, the duration of that timer MUST be at 1001 least 30 minutes. The receipt of ANY command from the client during 1002 that interval SHOULD suffice to reset the autologout timer. 1004 5.5. Multiple Commands in Progress (Command Pipelining) 1006 The client MAY send another command without waiting for the 1007 completion result response of a command, subject to ambiguity rules 1008 (see below) and flow control constraints on the underlying data 1009 stream. Similarly, a server MAY begin processing another command 1010 before processing the current command to completion, subject to 1011 ambiguity rules. However, any command continuation request responses 1012 and command continuations MUST be negotiated before any subsequent 1013 command is initiated. 1015 The exception is if an ambiguity would result because of a command 1016 that would affect the results of other commands. Clients MUST NOT 1017 send multiple commands without waiting if an ambiguity would result. 1018 If the server detects a possible ambiguity, it MUST execute commands 1019 to completion in the order given by the client. 1021 The most obvious example of ambiguity is when a command would affect 1022 the results of another command, e.g., a FETCH of a message's flags 1023 and a STORE of that same message's flags. 1025 A non-obvious ambiguity occurs with commands that permit an untagged 1026 EXPUNGE response (commands other than FETCH, STORE, and SEARCH), 1027 since an untagged EXPUNGE response can invalidate sequence numbers in 1028 a subsequent command. This is not a problem for FETCH, STORE, or 1029 SEARCH commands because servers are prohibited from sending EXPUNGE 1030 responses while any of those commands are in progress. Therefore, if 1031 the client sends any command other than FETCH, STORE, or SEARCH, it 1032 MUST wait for the completion result response before sending a command 1033 with message sequence numbers. 1035 Note: EXPUNGE responses are permitted while UID FETCH, UID STORE, 1036 and UID SEARCH are in progress. If the client sends a UID 1037 command, it MUST wait for a completion result response before 1038 sending a command which uses message sequence numbers (this may 1039 include UID SEARCH). Any message sequence numbers in an argument 1040 to UID SEARCH are associated with messages prior to the effect of 1041 any untagged EXPUNGE returned by the UID SEARCH. 1043 For example, the following non-waiting command sequences are invalid: 1045 FETCH + NOOP + STORE 1047 STORE + COPY + FETCH 1049 COPY + COPY 1051 The following are examples of valid non-waiting command sequences: 1053 FETCH + STORE + SEARCH + NOOP 1055 STORE + COPY + EXPUNGE 1057 UID SEARCH + UID SEARCH may be valid or invalid as a non-waiting 1058 command sequence, depending upon whether or not the second UID 1059 SEARCH contains message sequence numbers. 1061 6. Client Commands 1063 IMAP4rev2 commands are described in this section. Commands are 1064 organized by the state in which the command is permitted. Commands 1065 which are permitted in multiple states are listed in the minimum 1066 permitted state (for example, commands valid in authenticated and 1067 selected state are listed in the authenticated state commands). 1069 Command arguments, identified by "Arguments:" in the command 1070 descriptions below, are described by function, not by syntax. The 1071 precise syntax of command arguments is described in the Formal Syntax 1072 (Section 9). 1074 Some commands cause specific server responses to be returned; these 1075 are identified by "Responses:" in the command descriptions below. 1076 See the response descriptions in the Responses section for 1077 information on these responses, and the Formal Syntax section for the 1078 precise syntax of these responses. It is possible for server data to 1079 be transmitted as a result of any command. Thus, commands that do 1080 not specifically require server data specify "no specific responses 1081 for this command" instead of "none". 1083 The "Result:" in the command description refers to the possible 1084 tagged status responses to a command, and any special interpretation 1085 of these status responses. 1087 The state of a connection is only changed by successful commands 1088 which are documented as changing state. A rejected command (BAD 1089 response) never changes the state of the connection or of the 1090 selected mailbox. A failed command (NO response) generally does not 1091 change the state of the connection or of the selected mailbox; the 1092 exception being the SELECT and EXAMINE commands. 1094 6.1. Client Commands - Any State 1096 The following commands are valid in any state: CAPABILITY, NOOP, and 1097 LOGOUT. 1099 6.1.1. CAPABILITY Command 1101 Arguments: none 1103 Responses: REQUIRED untagged response: CAPABILITY 1105 Result: OK - capability completed 1106 BAD - command unknown or arguments invalid 1108 The CAPABILITY command requests a listing of capabilities that the 1109 server supports. The server MUST send a single untagged CAPABILITY 1110 response with "IMAP4rev2" as one of the listed capabilities before 1111 the (tagged) OK response. 1113 A capability name which begins with "AUTH=" indicates that the server 1114 supports that particular authentication mechanism. All such names 1115 are, by definition, part of this specification. For example, the 1116 authorization capability for an experimental "blurdybloop" 1117 authenticator would be "AUTH=XBLURDYBLOOP" and not 1118 "XAUTH=BLURDYBLOOP" or "XAUTH=XBLURDYBLOOP". 1120 Other capability names refer to extensions, revisions, or amendments 1121 to this specification. See the documentation of the CAPABILITY 1122 response for additional information. No capabilities, beyond the 1123 base IMAP4rev2 set defined in this specification, are enabled without 1124 explicit client action to invoke the capability. 1126 Client and server implementations MUST implement the STARTTLS, 1127 LOGINDISABLED, and AUTH=PLAIN (described in [PLAIN]) capabilities. 1128 See the Security Considerations section for important information. 1130 See the section entitled "Client Commands - Experimental/Expansion" 1131 for information about the form of site or implementation-specific 1132 capabilities. 1134 Example: C: abcd CAPABILITY 1135 S: * CAPABILITY IMAP4rev2 STARTTLS AUTH=GSSAPI 1136 LOGINDISABLED 1137 S: abcd OK CAPABILITY completed 1138 C: efgh STARTTLS 1139 S: efgh OK STARTLS completed 1140 1141 C: ijkl CAPABILITY 1142 S: * CAPABILITY IMAP4rev2 AUTH=GSSAPI AUTH=PLAIN 1143 S: ijkl OK CAPABILITY completed 1145 6.1.2. NOOP Command 1147 Arguments: none 1149 Responses: no specific responses for this command (but see below) 1151 Result: OK - noop completed 1152 BAD - command unknown or arguments invalid 1154 The NOOP command always succeeds. It does nothing. 1156 Since any command can return a status update as untagged data, the 1157 NOOP command can be used as a periodic poll for new messages or 1158 message status updates during a period of inactivity (the IDLE 1159 command Section 6.3.13 should be used instead of NOOP if real-time 1160 updates to mailbox state are desirable). The NOOP command can also 1161 be used to reset any inactivity autologout timer on the server. 1163 Example: C: a002 NOOP 1164 S: a002 OK NOOP completed 1165 . . . 1166 C: a047 NOOP 1167 S: * 22 EXPUNGE 1168 S: * 23 EXISTS 1169 S: * 14 FETCH (UID 1305 FLAGS (\Seen \Deleted)) 1170 S: a047 OK NOOP completed 1172 6.1.3. LOGOUT Command 1174 Arguments: none 1176 Responses: REQUIRED untagged response: BYE 1178 Result: OK - logout completed 1179 BAD - command unknown or arguments invalid 1181 The LOGOUT command informs the server that the client is done with 1182 the connection. The server MUST send a BYE untagged response before 1183 the (tagged) OK response, and then close the network connection. 1185 Example: C: A023 LOGOUT 1186 S: * BYE IMAP4rev2 Server logging out 1187 S: A023 OK LOGOUT completed 1188 (Server and client then close the connection) 1190 6.2. Client Commands - Not Authenticated State 1192 In the not authenticated state, the AUTHENTICATE or LOGIN command 1193 establishes authentication and enters the authenticated state. The 1194 AUTHENTICATE command provides a general mechanism for a variety of 1195 authentication techniques, privacy protection, and integrity 1196 checking; whereas the LOGIN command uses a traditional user name and 1197 plaintext password pair and has no means of establishing privacy 1198 protection or integrity checking. 1200 The STARTTLS command is an alternate form of establishing session 1201 privacy protection and integrity checking, but does not by itself 1202 establish authentication or enter the authenticated state. 1204 Server implementations MAY allow access to certain mailboxes without 1205 establishing authentication. This can be done by means of the 1206 ANONYMOUS [SASL] authenticator described in [ANONYMOUS]. An older 1207 convention is a LOGIN command using the userid "anonymous"; in this 1208 case, a password is required although the server may choose to accept 1209 any password. The restrictions placed on anonymous users are 1210 implementation-dependent. 1212 Once authenticated (including as anonymous), it is not possible to 1213 re-enter not authenticated state. 1215 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 1216 the following commands are valid in the not authenticated state: 1217 STARTTLS, AUTHENTICATE and LOGIN. See the Security Considerations 1218 section for important information about these commands. 1220 6.2.1. STARTTLS Command 1222 Arguments: none 1224 Responses: no specific response for this command 1226 Result: OK - starttls completed, begin TLS negotiation 1227 BAD - command unknown or arguments invalid 1229 A [TLS] negotiation begins immediately after the CRLF at the end of 1230 the tagged OK response from the server. Once a client issues a 1231 STARTTLS command, it MUST NOT issue further commands until a server 1232 response is seen and the [TLS] negotiation is complete. 1234 The server remains in the non-authenticated state, even if client 1235 credentials are supplied during the [TLS] negotiation. This does not 1236 preclude an authentication mechanism such as EXTERNAL (defined in 1237 [SASL]) from using client identity determined by the [TLS] 1238 negotiation. 1240 Once [TLS] has been started, the client MUST discard cached 1241 information about server capabilities and SHOULD re-issue the 1242 CAPABILITY command. This is necessary to protect against man-in- 1243 the-middle attacks which alter the capabilities list prior to 1244 STARTTLS. The server MAY advertise different capabilities, and in 1245 particular SHOULD NOT advertise the STARTTLS capability, after a 1246 successful STARTTLS command. 1248 Example: C: a001 CAPABILITY 1249 S: * CAPABILITY IMAP4rev2 STARTTLS LOGINDISABLED 1250 S: a001 OK CAPABILITY completed 1251 C: a002 STARTTLS 1252 S: a002 OK Begin TLS negotiation now 1253 1254 C: a003 CAPABILITY 1255 S: * CAPABILITY IMAP4rev2 AUTH=PLAIN 1256 S: a003 OK CAPABILITY completed 1257 C: a004 LOGIN joe password 1258 S: a004 OK LOGIN completed 1260 6.2.2. AUTHENTICATE Command 1262 Arguments: SASL authentication mechanism name 1263 OPTIONAL initial response 1265 Responses: continuation data can be requested 1267 Result: OK - authenticate completed, now in authenticated state 1268 NO - authenticate failure: unsupported authentication 1269 mechanism, credentials rejected 1270 BAD - command unknown or arguments invalid, 1271 authentication exchange cancelled 1273 The AUTHENTICATE command indicates a [SASL] authentication mechanism 1274 to the server. If the server supports the requested authentication 1275 mechanism, it performs an authentication protocol exchange to 1276 authenticate and identify the client. It MAY also negotiate an 1277 OPTIONAL security layer for subsequent protocol interactions. If the 1278 requested authentication mechanism is not supported, the server 1279 SHOULD reject the AUTHENTICATE command by sending a tagged NO 1280 response. 1282 The AUTHENTICATE command supports the optional "initial response" 1283 feature defined in Section 5.1 of [SASL]. The client doesn't need to 1284 use it. If a SASL mechanism supports "initial response", but it is 1285 not specified by the client, the server handles this as specified in 1286 Section 3 of [SASL]. 1288 The service name specified by this protocol's profile of [SASL] is 1289 "imap". 1291 The authentication protocol exchange consists of a series of server 1292 challenges and client responses that are specific to the 1293 authentication mechanism. A server challenge consists of a command 1294 continuation request response with the "+" token followed by a BASE64 1295 encoded (see Section 4 of [RFC4648]) string. The client response 1296 consists of a single line consisting of a BASE64 encoded string. If 1297 the client wishes to cancel an authentication exchange, it issues a 1298 line consisting of a single "*". If the server receives such a 1299 response, or if it receives an invalid BASE64 string (e.g. 1300 characters outside the BASE64 alphabet, or non-terminal "="), it MUST 1301 reject the AUTHENTICATE command by sending a tagged BAD response. 1303 As with any other client response, this initial response MUST be 1304 encoded as BASE64. It also MUST be transmitted outside of a quoted 1305 string or literal. To send a zero-length initial response, the 1306 client MUST send a single pad character ("="). This indicates that 1307 the response is present, but is a zero-length string. 1309 When decoding the BASE64 data in the initial response, decoding 1310 errors MUST be treated as in any normal SASL client response, i.e. 1311 with a tagged BAD response. In particular, the server should check 1312 for any characters not explicitly allowed by the BASE64 alphabet, as 1313 well as any sequence of BASE64 characters that contains the pad 1314 character ('=') anywhere other than the end of the string (e.g., 1315 "=AAA" and "AAA=BBB" are not allowed). 1317 If the client uses an initial response with a SASL mechanism that 1318 does not support an initial response, the server MUST reject the 1319 command with a tagged BAD response. 1321 If a security layer is negotiated through the [SASL] authentication 1322 exchange, it takes effect immediately following the CRLF that 1323 concludes the authentication exchange for the client, and the CRLF of 1324 the tagged OK response for the server. 1326 While client and server implementations MUST implement the 1327 AUTHENTICATE command itself, it is not required to implement any 1328 authentication mechanisms other than the PLAIN mechanism described in 1329 [PLAIN]. Also, an authentication mechanism is not required to 1330 support any security layers. 1332 Note: a server implementation MUST implement a configuration in 1333 which it does NOT permit any plaintext password mechanisms, unless 1334 either the STARTTLS command has been negotiated or some other 1335 mechanism that protects the session from password snooping has 1336 been provided. Server sites SHOULD NOT use any configuration 1337 which permits a plaintext password mechanism without such a 1338 protection mechanism against password snooping. Client and server 1339 implementations SHOULD implement additional [SASL] mechanisms that 1340 do not use plaintext passwords, such the GSSAPI mechanism 1341 described in [SASL] and/or the SCRAM-SHA-256/SCRAM-SHA-256-PLUS 1342 [SCRAM-SHA-256] mechanisms. 1344 Servers and clients can support multiple authentication mechanisms. 1345 The server SHOULD list its supported authentication mechanisms in the 1346 response to the CAPABILITY command so that the client knows which 1347 authentication mechanisms to use. 1349 A server MAY include a CAPABILITY response code in the tagged OK 1350 response of a successful AUTHENTICATE command in order to send 1351 capabilities automatically. It is unnecessary for a client to send a 1352 separate CAPABILITY command if it recognizes these automatic 1353 capabilities. This should only be done if a security layer was not 1354 negotiated by the AUTHENTICATE command, because the tagged OK 1355 response as part of an AUTHENTICATE command is not protected by 1356 encryption/integrity checking. [SASL] requires the client to re- 1357 issue a CAPABILITY command in this case. The server MAY advertise 1358 different capabilities after a successful AUTHENTICATE command. 1360 If an AUTHENTICATE command fails with a NO response, the client MAY 1361 try another authentication mechanism by issuing another AUTHENTICATE 1362 command. It MAY also attempt to authenticate by using the LOGIN 1363 command (see Section 6.2.3 for more detail). In other words, the 1364 client MAY request authentication types in decreasing order of 1365 preference, with the LOGIN command as a last resort. 1367 The authorization identity passed from the client to the server 1368 during the authentication exchange is interpreted by the server as 1369 the user name whose privileges the client is requesting. 1371 Example: S: * OK IMAP4rev2 Server 1372 C: A001 AUTHENTICATE GSSAPI 1373 S: + 1374 C: YIIB+wYJKoZIhvcSAQICAQBuggHqMIIB5qADAgEFoQMCAQ6iBw 1375 MFACAAAACjggEmYYIBIjCCAR6gAwIBBaESGxB1Lndhc2hpbmd0 1376 b24uZWR1oi0wK6ADAgEDoSQwIhsEaW1hcBsac2hpdmFtcy5jYW 1377 Mud2FzaGluZ3Rvbi5lZHWjgdMwgdCgAwIBAaEDAgEDooHDBIHA 1378 cS1GSa5b+fXnPZNmXB9SjL8Ollj2SKyb+3S0iXMljen/jNkpJX 1379 AleKTz6BQPzj8duz8EtoOuNfKgweViyn/9B9bccy1uuAE2HI0y 1380 C/PHXNNU9ZrBziJ8Lm0tTNc98kUpjXnHZhsMcz5Mx2GR6dGknb 1381 I0iaGcRerMUsWOuBmKKKRmVMMdR9T3EZdpqsBd7jZCNMWotjhi 1382 vd5zovQlFqQ2Wjc2+y46vKP/iXxWIuQJuDiisyXF0Y8+5GTpAL 1383 pHDc1/pIGmMIGjoAMCAQGigZsEgZg2on5mSuxoDHEA1w9bcW9n 1384 FdFxDKpdrQhVGVRDIzcCMCTzvUboqb5KjY1NJKJsfjRQiBYBdE 1385 NKfzK+g5DlV8nrw81uOcP8NOQCLR5XkoMHC0Dr/80ziQzbNqhx 1386 O6652Npft0LQwJvenwDI13YxpwOdMXzkWZN/XrEqOWp6GCgXTB 1387 vCyLWLlWnbaUkZdEYbKHBPjd8t/1x5Yg== 1388 S: + YGgGCSqGSIb3EgECAgIAb1kwV6ADAgEFoQMCAQ+iSzBJoAMC 1389 AQGiQgRAtHTEuOP2BXb9sBYFR4SJlDZxmg39IxmRBOhXRKdDA0 1390 uHTCOT9Bq3OsUTXUlk0CsFLoa8j+gvGDlgHuqzWHPSQg== 1391 C: 1392 S: + YDMGCSqGSIb3EgECAgIBAAD/////6jcyG4GE3KkTzBeBiVHe 1393 ceP2CWY0SR0fAQAgAAQEBAQ= 1394 C: YDMGCSqGSIb3EgECAgIBAAD/////3LQBHXTpFfZgrejpLlLImP 1395 wkhbfa2QteAQAgAG1yYwE= 1396 S: A001 OK GSSAPI authentication successful 1398 Note: The line breaks within server challenges and client responses 1399 are for editorial clarity and are not in real authenticators. 1401 6.2.3. LOGIN Command 1403 Arguments: user name 1404 password 1406 Responses: no specific responses for this command 1408 Result: OK - login completed, now in authenticated state 1409 NO - login failure: user name or password rejected 1410 BAD - command unknown or arguments invalid 1412 The LOGIN command identifies the client to the server and carries the 1413 plaintext password authenticating this user. 1415 A server MAY include a CAPABILITY response code in the tagged OK 1416 response to a successful LOGIN command in order to send capabilities 1417 automatically. It is unnecessary for a client to send a separate 1418 CAPABILITY command if it recognizes these automatic capabilities. 1420 Example: C: a001 LOGIN SMITH SESAME 1421 S: a001 OK LOGIN completed 1423 Note: Use of the LOGIN command over an insecure network (such as the 1424 Internet) is a security risk, because anyone monitoring network 1425 traffic can obtain plaintext passwords. The LOGIN command SHOULD NOT 1426 be used except as a last resort, and it is recommended that client 1427 implementations have a means to disable any automatic use of the 1428 LOGIN command. 1430 Unless either the client is accessing IMAP service on IMAPS port 1431 [RFC8314], the STARTTLS command has been negotiated or some other 1432 mechanism that protects the session from password snooping has been 1433 provided, a server implementation MUST implement a configuration in 1434 which it advertises the LOGINDISABLED capability and does NOT permit 1435 the LOGIN command. Server sites SHOULD NOT use any configuration 1436 which permits the LOGIN command without such a protection mechanism 1437 against password snooping. A client implementation MUST NOT send a 1438 LOGIN command if the LOGINDISABLED capability is advertised. 1440 6.3. Client Commands - Authenticated State 1442 In the authenticated state, commands that manipulate mailboxes as 1443 atomic entities are permitted. Of these commands, the SELECT and 1444 EXAMINE commands will select a mailbox for access and enter the 1445 selected state. 1447 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 1448 the following commands are valid in the authenticated state: ENABLE, 1449 SELECT, EXAMINE, NAMESPACE, CREATE, DELETE, RENAME, SUBSCRIBE, 1450 UNSUBSCRIBE, LIST, STATUS, APPEND and IDLE. 1452 6.3.1. ENABLE Command 1454 Arguments: capability names 1456 Responses: no specific responses for this command 1458 Result: OK - Relevant capabilities enabled 1459 BAD - No arguments, or syntax error in an argument 1461 Several IMAP extensions allow the server to return unsolicited 1462 responses specific to these extensions in certain circumstances. 1463 However, servers cannot send those unsolicited responses (with the 1464 exception of response codes (see Section 7.1) included in tagged or 1465 untagged OK/NO/BAD responses, which can always be sent) until they 1466 know that the clients support such extensions and thus won't choke on 1467 the extension response data. 1469 The ENABLE command provides an explicit indication from the client 1470 that it supports particular extensions. It is designed such that the 1471 client can send a simple constant string with the extensions it 1472 supports, and the server will enable the shared subset that both 1473 support. 1475 The ENABLE command takes a list of capability names, and requests the 1476 server to enable the named extensions. Once enabled using ENABLE, 1477 each extension remains active until the IMAP connection is closed. 1478 For each argument, the server does the following: 1480 o If the argument is not an extension known to the server, the 1481 server MUST ignore the argument. 1483 o If the argument is an extension known to the server, and it is not 1484 specifically permitted to be enabled using ENABLE, the server MUST 1485 ignore the argument. (Note that knowing about an extension 1486 doesn't necessarily imply supporting that extension.) 1488 o If the argument is an extension that is supported by the server 1489 and that needs to be enabled, the server MUST enable the extension 1490 for the duration of the connection. Note that once an extension 1491 is enabled, there is no way to disable it. 1493 If the ENABLE command is successful, the server MUST send an untagged 1494 ENABLED response Section 7.2.1. 1496 Clients SHOULD only include extensions that need to be enabled by the 1497 server. For example, a client can enable IMAP4rev2 specific 1498 behaviour when both IMAP4rev1 and IMAP4rev2 are advertised in the 1499 CAPABILITY response. Future RFCs may add to this list. 1501 The ENABLE command is only valid in the authenticated state, before 1502 any mailbox is selected. Clients MUST NOT issue ENABLE once they 1503 SELECT/EXAMINE a mailbox; however, server implementations don't have 1504 to check that no mailbox is selected or was previously selected 1505 during the duration of a connection. 1507 The ENABLE command can be issued multiple times in a session. It is 1508 additive; i.e., "ENABLE a b", followed by "ENABLE c" is the same as a 1509 single command "ENABLE a b c". When multiple ENABLE commands are 1510 issued, each corresponding ENABLED response SHOULD only contain 1511 extensions enabled by the corresponding ENABLE command. 1513 There are no limitations on pipelining ENABLE. For example, it is 1514 possible to send ENABLE and then immediately SELECT, or a LOGIN 1515 immediately followed by ENABLE. 1517 The server MUST NOT change the CAPABILITY list as a result of 1518 executing ENABLE; i.e., a CAPABILITY command issued right after an 1519 ENABLE command MUST list the same capabilities as a CAPABILITY 1520 command issued before the ENABLE command. This is demonstrated in 1521 the following example: 1523 C: t1 CAPABILITY 1524 S: * CAPABILITY IMAP4rev1 ID LITERAL+ ENABLE X-GOOD-IDEA 1525 S: t1 OK foo 1526 C: t2 ENABLE CONDSTORE X-GOOD-IDEA 1527 S: * ENABLED X-GOOD-IDEA 1528 S: t2 OK foo 1529 C: t3 CAPABILITY 1530 S: * CAPABILITY IMAP4rev1 ID LITERAL+ ENABLE X-GOOD-IDEA 1531 S: t3 OK foo again 1533 In the following example, the client enables CONDSTORE: 1535 C: a1 ENABLE CONDSTORE 1536 S: * ENABLED CONDSTORE 1537 S: a1 OK Conditional Store enabled 1539 6.3.1.1. Note to Designers of Extensions That May Use the ENABLE 1540 Command 1542 Designers of IMAP extensions are discouraged from creating extensions 1543 that require ENABLE unless there is no good alternative design. 1544 Specifically, extensions that cause potentially incompatible behavior 1545 changes to deployed server responses (and thus benefit from ENABLE) 1546 have a higher complexity cost than extensions that do not. 1548 6.3.2. SELECT Command 1550 Arguments: mailbox name 1552 Responses: REQUIRED untagged responses: FLAGS, EXISTS 1553 REQUIRED OK untagged responses: PERMANENTFLAGS, 1554 UIDNEXT, UIDVALIDITY 1556 Result: OK - select completed, now in selected state 1557 NO - select failure, now in authenticated state: no 1558 such mailbox, can't access mailbox 1559 BAD - command unknown or arguments invalid 1561 The SELECT command selects a mailbox so that messages in the mailbox 1562 can be accessed. Before returning an OK to the client, the server 1563 MUST send the following untagged data to the client. Note that 1564 earlier versions of this protocol only required the FLAGS and EXISTS 1565 untagged data; consequently, client implementations SHOULD implement 1566 default behavior for missing data as discussed with the individual 1567 item. 1569 FLAGS Defined flags in the mailbox. See the description of the 1570 FLAGS response for more detail. 1572 EXISTS The number of messages in the mailbox. See the 1573 description of the EXISTS response for more detail. 1575 OK [PERMANENTFLAGS ()] A list of message flags that 1576 the client can change permanently. If this is missing, the client 1577 should assume that all flags can be changed permanently. 1579 OK [UIDNEXT ] The next unique identifier value. Refer to 1580 Section 2.3.1.1 for more information. 1582 OK [UIDNEXT ] If this is missing, the client can not make any 1583 assumptions about the next unique identifier value. 1585 OK [UIDVALIDITY ] The unique identifier validity value. Refer to 1586 Section 2.3.1.1 for more information. If this is missing, the 1587 server does not support unique identifiers. 1589 Only one mailbox can be selected at a time in a connection; 1590 simultaneous access to multiple mailboxes requires multiple 1591 connections. The SELECT command automatically deselects any 1592 currently selected mailbox before attempting the new selection. 1593 Consequently, if a mailbox is selected and a SELECT command that 1594 fails is attempted, no mailbox is selected. When deselecting a 1595 selected mailbox, the server MUST return an untagged OK response with 1596 the "[CLOSED]" response code when the currently selected mailbox is 1597 closed (see Paragraph 10). 1599 If the client is permitted to modify the mailbox, the server SHOULD 1600 prefix the text of the tagged OK response with the "[READ-WRITE]" 1601 response code. 1603 If the client is not permitted to modify the mailbox but is permitted 1604 read access, the mailbox is selected as read-only, and the server 1605 MUST prefix the text of the tagged OK response to SELECT with the 1606 "[READ-ONLY]" response code. Read-only access through SELECT differs 1607 from the EXAMINE command in that certain read-only mailboxes MAY 1608 permit the change of permanent state on a per-user (as opposed to 1609 global) basis. Netnews messages marked in a server-based .newsrc 1610 file are an example of such per-user permanent state that can be 1611 modified with read-only mailboxes. 1613 Example: C: A142 SELECT INBOX 1614 S: * 172 EXISTS 1615 S: * OK [UIDVALIDITY 3857529045] UIDs valid 1616 S: * OK [UIDNEXT 4392] Predicted next UID 1617 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1618 S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited 1619 S: A142 OK [READ-WRITE] SELECT completed 1621 Note that IMAP4rev1 compliant servers can also send the untagged 1622 RECENT response which was depractated in IMAP4rev2. E.g. "* 0 1623 RECENT". Pure IMAP4rev2 clients are advised to ignore the untagged 1624 RECENT response. 1626 6.3.3. EXAMINE Command 1628 Arguments: mailbox name 1630 Responses: REQUIRED untagged responses: FLAGS, EXISTS 1631 REQUIRED OK untagged responses: PERMANENTFLAGS, 1632 UIDNEXT, UIDVALIDITY 1634 Result: OK - examine completed, now in selected state 1635 NO - examine failure, now in authenticated state: no 1636 such mailbox, can't access mailbox BAD - command unknown 1637 or arguments invalid 1639 The EXAMINE command is identical to SELECT and returns the same 1640 output; however, the selected mailbox is identified as read-only. No 1641 changes to the permanent state of the mailbox, including per-user 1642 state, are permitted. 1644 The text of the tagged OK response to the EXAMINE command MUST begin 1645 with the "[READ-ONLY]" response code. 1647 Example: C: A932 EXAMINE blurdybloop 1648 S: * 17 EXISTS 1649 S: * OK [UIDVALIDITY 3857529045] UIDs valid 1650 S: * OK [UIDNEXT 4392] Predicted next UID 1651 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1652 S: * OK [PERMANENTFLAGS ()] No permanent flags permitted 1653 S: A932 OK [READ-ONLY] EXAMINE completed 1655 6.3.4. CREATE Command 1657 Arguments: mailbox name 1659 Responses: no specific responses for this command 1661 Result: OK - create completed 1662 NO - create failure: can't create mailbox with that name 1663 BAD - command unknown or arguments invalid 1665 The CREATE command creates a mailbox with the given name. An OK 1666 response is returned only if a new mailbox with that name has been 1667 created. It is an error to attempt to create INBOX or a mailbox with 1668 a name that refers to an extant mailbox. Any error in creation will 1669 return a tagged NO response. If a client attempts to create a UTF-8 1670 mailbox name that is not a valid Net-Unicode name, the server MUST 1671 reject the creation or convert the name to Net-Unicode prior to 1672 creating the mailbox. 1674 If the mailbox name is suffixed with the server's hierarchy separator 1675 character (as returned from the server by a LIST command), this is a 1676 declaration that the client intends to create mailbox names under 1677 this name in the hierarchy. Server implementations that do not 1678 require this declaration MUST ignore the declaration. In any case, 1679 the name created is without the trailing hierarchy delimiter. 1681 If the server's hierarchy separator character appears elsewhere in 1682 the name, the server SHOULD create any superior hierarchical names 1683 that are needed for the CREATE command to be successfully completed. 1684 In other words, an attempt to create "foo/bar/zap" on a server in 1685 which "/" is the hierarchy separator character SHOULD create foo/ and 1686 foo/bar/ if they do not already exist. 1688 If a new mailbox is created with the same name as a mailbox which was 1689 deleted, its unique identifiers MUST be greater than any unique 1690 identifiers used in the previous incarnation of the mailbox UNLESS 1691 the new incarnation has a different unique identifier validity value. 1692 See the description of the UID command for more detail. 1694 Example: C: A003 CREATE owatagusiam/ 1695 S: A003 OK CREATE completed 1696 C: A004 CREATE owatagusiam/blurdybloop 1697 S: A004 OK CREATE completed 1699 Note: The interpretation of this example depends on whether "/" 1700 was returned as the hierarchy separator from LIST. If "/" is the 1701 hierarchy separator, a new level of hierarchy named "owatagusiam" 1702 with a member called "blurdybloop" is created. Otherwise, two 1703 mailboxes at the same hierarchy level are created. 1705 6.3.5. DELETE Command 1707 Arguments: mailbox name 1709 Responses: no specific responses for this command 1711 Result: OK - delete completed 1712 NO - delete failure: can't delete mailbox with that name 1713 BAD - command unknown or arguments invalid 1715 The DELETE command permanently removes the mailbox with the given 1716 name. A tagged OK response is returned only if the mailbox has been 1717 deleted. It is an error to attempt to delete INBOX or a mailbox name 1718 that does not exist. 1720 The DELETE command MUST NOT remove inferior hierarchical names. For 1721 example, if a mailbox "foo" has an inferior "foo.bar" (assuming "." 1722 is the hierarchy delimiter character), removing "foo" MUST NOT remove 1723 "foo.bar". It is an error to attempt to delete a name that has 1724 inferior hierarchical names and also has the \Noselect mailbox name 1725 attribute (see the description of the LIST response for more 1726 details). 1728 It is permitted to delete a name that has inferior hierarchical names 1729 and does not have the \Noselect mailbox name attribute. If the 1730 server implementation does not permit deleting the name while 1731 inferior hierarchical names exists the \Noselect mailbox name 1732 attribute is set for that name. In any case, all messages in that 1733 mailbox are removed by the DELETE command. 1735 The value of the highest-used unique identifier of the deleted 1736 mailbox MUST be preserved so that a new mailbox created with the same 1737 name will not reuse the identifiers of the former incarnation, UNLESS 1738 the new incarnation has a different unique identifier validity value. 1739 See the description of the UID command for more detail. 1741 Examples: C: A682 LIST "" * 1742 S: * LIST () "/" blurdybloop 1743 S: * LIST (\Noselect) "/" foo 1744 S: * LIST () "/" foo/bar 1745 S: A682 OK LIST completed 1746 C: A683 DELETE blurdybloop 1747 S: A683 OK DELETE completed 1748 C: A684 DELETE foo 1749 S: A684 NO Name "foo" has inferior hierarchical names 1750 C: A685 DELETE foo/bar 1751 S: A685 OK DELETE Completed 1752 C: A686 LIST "" * 1753 S: * LIST (\Noselect) "/" foo 1754 S: A686 OK LIST completed 1755 C: A687 DELETE foo 1756 S: A687 OK DELETE Completed 1757 C: A82 LIST "" * 1758 S: * LIST () "." blurdybloop 1759 S: * LIST () "." foo 1760 S: * LIST () "." foo.bar 1761 S: A82 OK LIST completed 1762 C: A83 DELETE blurdybloop 1763 S: A83 OK DELETE completed 1764 C: A84 DELETE foo 1765 S: A84 OK DELETE Completed 1766 C: A85 LIST "" * 1767 S: * LIST () "." foo.bar 1768 S: A85 OK LIST completed 1769 C: A86 LIST "" % 1770 S: * LIST (\Noselect) "." foo 1771 S: A86 OK LIST completed 1773 6.3.6. RENAME Command 1775 Arguments: existing mailbox name 1776 new mailbox name 1778 Responses: no specific responses for this command 1780 Result: OK - rename completed 1781 NO - rename failure: can't rename mailbox with that name, 1782 can't rename to mailbox with that name 1783 BAD - command unknown or arguments invalid 1785 The RENAME command changes the name of a mailbox. A tagged OK 1786 response is returned only if the mailbox has been renamed. It is an 1787 error to attempt to rename from a mailbox name that does not exist or 1788 to a mailbox name that already exists. Any error in renaming will 1789 return a tagged NO response. 1791 If the name has inferior hierarchical names, then the inferior 1792 hierarchical names MUST also be renamed. For example, a rename of 1793 "foo" to "zap" will rename "foo/bar" (assuming "/" is the hierarchy 1794 delimiter character) to "zap/bar". 1796 If the server's hierarchy separator character appears in the name, 1797 the server SHOULD create any superior hierarchical names that are 1798 needed for the RENAME command to complete successfully. In other 1799 words, an attempt to rename "foo/bar/zap" to baz/rag/zowie on a 1800 server in which "/" is the hierarchy separator character SHOULD 1801 create baz/ and baz/rag/ if they do not already exist. 1803 The value of the highest-used unique identifier of the old mailbox 1804 name MUST be preserved so that a new mailbox created with the same 1805 name will not reuse the identifiers of the former incarnation, UNLESS 1806 the new incarnation has a different unique identifier validity value. 1807 See the description of the UID command for more detail. 1809 Renaming INBOX is permitted, and has special behavior. It moves all 1810 messages in INBOX to a new mailbox with the given name, leaving INBOX 1811 empty. If the server implementation supports inferior hierarchical 1812 names of INBOX, these are unaffected by a rename of INBOX. 1814 Examples: C: A682 LIST "" * 1815 S: * LIST () "/" blurdybloop 1816 S: * LIST (\Noselect) "/" foo 1817 S: * LIST () "/" foo/bar 1818 S: A682 OK LIST completed 1819 C: A683 RENAME blurdybloop sarasoop 1820 S: A683 OK RENAME completed 1821 C: A684 RENAME foo zowie 1822 S: A684 OK RENAME Completed 1823 C: A685 LIST "" * 1824 S: * LIST () "/" sarasoop 1825 S: * LIST (\Noselect) "/" zowie 1826 S: * LIST () "/" zowie/bar 1827 S: A685 OK LIST completed 1829 C: Z432 LIST "" * 1830 S: * LIST () "." INBOX 1831 S: * LIST () "." INBOX.bar 1832 S: Z432 OK LIST completed 1833 C: Z433 RENAME INBOX old-mail 1834 S: Z433 OK RENAME completed 1835 C: Z434 LIST "" * 1836 S: * LIST () "." INBOX 1837 S: * LIST () "." INBOX.bar 1838 S: * LIST () "." old-mail 1839 S: Z434 OK LIST completed 1841 6.3.7. SUBSCRIBE Command 1843 Arguments: mailbox 1845 Responses: no specific responses for this command 1847 Result: OK - subscribe completed 1848 NO - subscribe failure: can't subscribe to that name 1849 BAD - command unknown or arguments invalid 1851 The SUBSCRIBE command adds the specified mailbox name to the server's 1852 set of "active" or "subscribed" mailboxes as returned by the LIST 1853 (SUBSCRIBED) command. This command returns a tagged OK response only 1854 if the subscription is successful. 1856 A server MAY validate the mailbox argument to SUBSCRIBE to verify 1857 that it exists. However, it MUST NOT unilaterally remove an existing 1858 mailbox name from the subscription list even if a mailbox by that 1859 name no longer exists. 1861 Note: This requirement is because a server site can choose to 1862 routinely remove a mailbox with a well-known name (e.g., "system- 1863 alerts") after its contents expire, with the intention of 1864 recreating it when new contents are appropriate. 1866 Example: C: A002 SUBSCRIBE #news.comp.mail.mime 1867 S: A002 OK SUBSCRIBE completed 1869 6.3.8. UNSUBSCRIBE Command 1871 Arguments: mailbox name 1873 Responses: no specific responses for this command 1875 Result: OK - unsubscribe completed 1876 NO - unsubscribe failure: can't unsubscribe that name 1877 BAD - command unknown or arguments invalid 1879 The UNSUBSCRIBE command removes the specified mailbox name from the 1880 server's set of "active" or "subscribed" mailboxes as returned by the 1881 LIST (SUBSCRIBED) command. This command returns a tagged OK response 1882 only if the unsubscription is successful. 1884 Example: C: A002 UNSUBSCRIBE #news.comp.mail.mime 1885 S: A002 OK UNSUBSCRIBE completed 1887 6.3.9. LIST Command 1889 Arguments (basic): reference name 1890 mailbox name with possible wildcards 1892 Arguments (extended): selection options (OPTIONAL) 1893 reference name 1894 mailbox patterns 1895 return options (OPTIONAL) 1897 Responses: untagged responses: LIST 1899 Result: OK - list completed 1900 NO - list failure: can't list that reference or name 1901 BAD - command unknown or arguments invalid 1903 The LIST command returns a subset of names from the complete set of 1904 all names available to the client. Zero or more untagged LIST 1905 replies are returned, containing the name attributes, hierarchy 1906 delimiter, name, and possible extension information; see the 1907 description of the LIST reply for more detail. 1909 The LIST command SHOULD return its data quickly, without undue delay. 1910 For example, it SHOULD NOT go to excess trouble to calculate the 1911 \Marked or \Unmarked status or perform other processing; if each name 1912 requires 1 second of processing, then a list of 1200 names would take 1913 20 minutes! 1915 The extended LIST command, originally introduced in [RFC5258], 1916 provides capabilities beyond that of the original IMAP LIST command. 1917 The extended syntax is being used if one or more of the following 1918 conditions is true: 1920 1. if the first word after the command name begins with a 1921 parenthesis ("LIST selection options") 1923 2. if the second word after the command name begins with a 1924 parenthesis ("multiple mailbox patterns") 1926 3. if the LIST command has more than 2 parameters ("LIST return 1927 options") 1929 An empty ("" string) reference name argument indicates that the 1930 mailbox name is interpreted as by SELECT. The returned mailbox names 1931 MUST match the supplied mailbox name pattern(s). A non-empty 1932 reference name argument is the name of a mailbox or a level of 1933 mailbox hierarchy, and indicates the context in which the mailbox 1934 name is interpreted. Clients SHOULD use the empty reference 1935 argument. 1937 In the basic syntax only, an empty ("" string) mailbox name argument 1938 is a special request to return the hierarchy delimiter and the root 1939 name of the name given in the reference. The value returned as the 1940 root MAY be the empty string if the reference is non-rooted or is an 1941 empty string. In all cases, a hierarchy delimiter (or NIL if there 1942 is no hierarchy) is returned. This permits a client to get the 1943 hierarchy delimiter (or find out that the mailbox names are flat) 1944 even when no mailboxes by that name currently exist. 1946 In the extended syntax, any mailbox name arguments that are empty 1947 strings are ignored. There is no special meaning for empty mailbox 1948 names when the extended syntax is used. 1950 The reference and mailbox name arguments are interpreted into a 1951 canonical form that represents an unambiguous left-to-right 1952 hierarchy. The returned mailbox names will be in the interpreted 1953 form, 1955 that we call "canonical LIST pattern" later in this document. To 1956 define the term "canonical LIST pattern" formally: it refers to the 1957 canonical pattern constructed internally by the server from the 1958 reference and mailbox name arguments. 1960 Note: The interpretation of the reference argument is 1961 implementation-defined. It depends upon whether the server 1962 implementation has a concept of the "current working directory" 1963 and leading "break out characters", which override the current 1964 working directory. 1966 For example, on a server which exports a UNIX or NT filesystem, 1967 the reference argument contains the current working directory, and 1968 the mailbox name argument would contain the name as interpreted in 1969 the current working directory. 1971 If a server implementation has no concept of break out characters, 1972 the canonical form is normally the reference name appended with 1973 the mailbox name. Note that if the server implements the 1974 namespace convention (Section 5.1.2.1), "#" is a break out 1975 character and must be treated as such. 1977 If the reference argument is not a level of mailbox hierarchy 1978 (that is, it is a \NoInferiors name), and/or the reference 1979 argument does not end with the hierarchy delimiter, it is 1980 implementation-dependent how this is interpreted. For example, a 1981 reference of "foo/bar" and mailbox name of "rag/baz" could be 1982 interpreted as "foo/bar/rag/baz", "foo/barrag/baz", or "foo/rag/ 1983 baz". A client SHOULD NOT use such a reference argument except at 1984 the explicit request of the user. A hierarchical browser MUST NOT 1985 make any assumptions about server interpretation of the reference 1986 unless the reference is a level of mailbox hierarchy AND ends with 1987 the hierarchy delimiter. 1989 Any part of the reference argument that is included in the 1990 interpreted form SHOULD prefix the interpreted form. It SHOULD also 1991 be in the same form as the reference name argument. This rule 1992 permits the client to determine if the returned mailbox name is in 1993 the context of the reference argument, or if something about the 1994 mailbox argument overrode the reference argument. Without this rule, 1995 the client would have to have knowledge of the server's naming 1996 semantics including what characters are "breakouts" that override a 1997 naming context. 1999 For example, here are some examples of how references 2000 and mailbox names might be interpreted on a UNIX-based 2001 server: 2003 Reference Mailbox Name Interpretation 2004 ------------ ------------ -------------- 2005 ~smith/Mail/ foo.* ~smith/Mail/foo.* 2006 archive/ % archive/% 2007 #news. comp.mail.* #news.comp.mail.* 2008 ~smith/Mail/ /usr/doc/foo /usr/doc/foo 2009 archive/ ~fred/Mail/* ~fred/Mail/* 2011 The first three examples demonstrate interpretations in 2012 the context of the reference argument. Note that 2013 "~smith/Mail" SHOULD NOT be transformed into something 2014 like "/u2/users/smith/Mail", or it would be impossible 2015 for the client to determine that the interpretation was 2016 in the context of the reference. 2018 The character "*" is a wildcard, and matches zero or more characters 2019 at this position. The character "%" is similar to "*", but it does 2020 not match a hierarchy delimiter. If the "%" wildcard is the last 2021 character of a mailbox name argument, matching levels of hierarchy 2022 are also returned. If these levels of hierarchy are not also 2023 selectable mailboxes, they are returned with the \Noselect mailbox 2024 name attribute (see the description of the LIST response for more 2025 details). 2027 If multiple mailbox patterns are used (in the extended syntax), a 2028 mailbox matches if it matches at least one mailbox pattern. If a 2029 mailbox matches more than one pattern, it is still only returned 2030 once. Any syntactically valid pattern that is not accepted by a 2031 server for any reason MUST be silently ignored. 2033 Selection options tell the server to limit the mailbox names that are 2034 selected by the LIST operation. If selection options are used, the 2035 mailboxes returned are those that match both the list of canonical 2036 LIST patterns and the selection options. Unless a particular 2037 selection option provides special rules, the selection options are 2038 cumulative: a mailbox that matches the mailbox patterns is selected 2039 only if it also matches all of the selection options. (An example of 2040 a selection option with special rules is the RECURSIVEMATCH option.) 2042 Return options control what information is returned for each matched 2043 mailbox. Return options MUST NOT cause the server to report 2044 information about additional mailbox names other than those that 2045 match the canonical LIST patterns and selection options. If no 2046 return options are specified, the client is only expecting 2047 information about mailbox attributes. The server MAY return other 2048 information about the matched mailboxes, and clients MUST be able to 2049 handle that situation. 2051 Initial selection options and return options are defined in the 2052 following subsections, and new ones will also be defined in 2053 extensions. Initial options defined in this document MUST be 2054 supported. Each non-initial option will be enabled by a capability 2055 string (one capability may enable multiple options), and a client 2056 MUST NOT send an option for which the server has not advertised 2057 support. A server MUST respond to options it does not recognize with 2058 a BAD response. The client SHOULD NOT specify any option more than 2059 once; however, if the client does this, the server MUST act as if it 2060 received the option only once. The order in which options are 2061 specified by the client is not significant. 2063 In general, each selection option except RECURSIVEMATCH will have a 2064 corresponding return option. The REMOTE selection option is an 2065 anomaly in this regard, and does not have a corresponding return 2066 option. That is because it expands, rather than restricts, the set 2067 of mailboxes that are returned. Future extensions to this 2068 specification should keep parallelism in mind and define a pair of 2069 corresponding options. 2071 Server implementations are permitted to "hide" otherwise accessible 2072 mailboxes from the wildcard characters, by preventing certain 2073 characters or names from matching a wildcard in certain situations. 2074 For example, a UNIX-based server might restrict the interpretation of 2075 "*" so that an initial "/" character does not match. 2077 The special name INBOX is included in the output from LIST, if INBOX 2078 is supported by this server for this user and if the uppercase string 2079 "INBOX" matches the interpreted reference and mailbox name arguments 2080 with wildcards as described above. The criteria for omitting INBOX 2081 is whether SELECT INBOX will return failure; it is not relevant 2082 whether the user's real INBOX resides on this or some other server. 2084 6.3.9.1. LIST Selection Options 2086 The selection options defined in this specification are as follows: 2088 SUBSCRIBED - causes the LIST command to list subscribed names, 2089 rather than the existing mailboxes. This will often be a subset 2090 of the actual mailboxes. It's also possible for this list to 2091 contain the names of mailboxes that don't exist. In any case, the 2092 list MUST include exactly those mailbox names that match the 2093 canonical list pattern and are subscribed to. 2095 SUBSCRIBED - 2097 This option defines a mailbox attribute, "\Subscribed", that 2098 indicates that a mailbox name is subscribed to. The "\Subscribed" 2099 attribute MUST be supported and MUST be accurately computed when 2100 the SUBSCRIBED selection option is specified. 2102 Note that the SUBSCRIBED selection option implies the SUBSCRIBED 2103 return option (see below). 2105 REMOTE - causes the LIST command to show remote mailboxes as well as 2106 local ones, as described in [RFC2193]. This option is intended to 2107 replace the RLIST command and, in conjunction with the SUBSCRIBED 2108 selection option, the RLSUB command. Servers that don't support 2109 remote mailboxes just ignore this option. 2111 This option defines a mailbox attribute, "\Remote", that indicates 2112 that a mailbox is a remote mailbox. The "\Remote" attribute MUST 2113 be accurately computed when the REMOTE option is specified. 2115 The REMOTE selection option has no interaction with other options. 2116 Its effect is to tell the server to apply the other options, if 2117 any, to remote mailboxes, in addition to local ones. In 2118 particular, it has no interaction with RECURSIVEMATCH (see below). 2119 A request for (REMOTE RECURSIVEMATCH) is invalid, because a 2120 request for (RECURSIVEMATCH) is also invalid. A request for 2121 (REMOTE RECURSIVEMATCH SUBSCRIBED) is asking for all subscribed 2122 mailboxes, both local and remote. 2124 RECURSIVEMATCH - this option forces the server to return information 2125 about parent mailboxes that don't match other selection options, 2126 but have some submailboxes that do. Information about children is 2127 returned in the CHILDINFO extended data item, as described in 2128 Section 6.3.9.5. 2130 Note 1: In order for a parent mailbox to be returned, it still has 2131 to match the canonical LIST pattern. 2133 Note 2: When returning the CHILDINFO extended data item, it 2134 doesn't matter whether or not the submailbox matches the canonical 2135 LIST pattern. See also example 9 in Section 6.3.9.6. 2137 The RECURSIVEMATCH option MUST NOT occur as the only selection 2138 option (or only with REMOTE), as it only makes sense when other 2139 selection options are also used. The server MUST return BAD 2140 tagged response in such case. 2142 Note that even if the RECURSIVEMATCH option is specified, the 2143 client MUST still be able to handle a case when a CHILDINFO 2144 extended data item is returned and there are no submailboxes that 2145 meet the selection criteria of the subsequent LIST command, as 2146 they can be deleted/renamed after the LIST response was sent, but 2147 before the client had a chance to access them. 2149 6.3.9.2. LIST Return Options 2151 The return options defined in this specification are as follows: 2153 SUBSCRIBED - causes the LIST command to return subscription state 2154 for all matching mailbox names. The "\Subscribed" attribute MUST 2155 be supported and MUST be accurately computed when the SUBSCRIBED 2156 return option is specified. Further, all mailbox flags MUST be 2157 accurately computed (this differs from the behavior of the 2158 obsolete LSUB command from IMAP4rev1). 2160 CHILDREN - requests mailbox child information as originally proposed 2161 in [RFC3348]. See Section 6.3.9.4, below, for details. 2163 CHILDREN - This option MUST be supported by all servers. 2165 6.3.9.3. General Principles for Returning LIST Responses 2167 This section outlines several principles that can be used by server 2168 implementations of this document to decide whether a LIST response 2169 should be returned, as well as how many responses and what kind of 2170 information they may contain. 2172 1. At most one LIST response should be returned for each mailbox 2173 name that matches the canonical LIST pattern. Server 2174 implementors must not assume that clients will be able to 2175 assemble mailbox attributes and other information returned in 2176 multiple LIST responses. 2178 2. There are only two reasons for including a matching mailbox name 2179 in the responses to the LIST command (note that the server is 2180 allowed to return unsolicited responses at any time, and such 2181 responses are not governed by this rule): 2183 A. The mailbox name also satisfies the selection criteria. 2185 B. The mailbox name doesn't satisfy the selection criteria, but 2186 it has at least one descendant mailbox name that satisfies 2187 the selection criteria and that doesn't match the canonical 2188 LIST pattern. 2190 For more information on this case, see the CHILDINFO extended 2191 data item described in Section 6.3.9.5. Note that the 2192 CHILDINFO extended data item can only be returned when the 2193 RECURSIVEMATCH selection option is specified. 2195 3. Attributes returned in the same LIST response must be treated 2196 additively. For example, the following response 2198 S: * LIST (\Subscribed \NonExistent) "/" "Fruit/Peach" 2200 means that the "Fruit/Peach" mailbox doesn't exist, but it is 2201 subscribed. 2203 6.3.9.4. The CHILDREN Return Option 2205 The CHILDREN return option implements the Child Mailbox Extension, 2206 originally proposed by Mike Gahrns and Raymond Cheng, of Microsoft 2207 Corporation. Most of the information in this section is taken 2208 directly from their original specification [RFC3348]. The CHILDREN 2209 return option is simply an indication that the client wants this 2210 information; a server MAY provide it even if the option is not 2211 specified. 2213 Many IMAP4 clients present to the user a hierarchical view of the 2214 mailboxes that a user has access to. Rather than initially 2215 presenting to the user the entire mailbox hierarchy, it is often 2216 preferable to show to the user a collapsed outline list of the 2217 mailbox hierarchy (particularly if there is a large number of 2218 mailboxes). The user can then expand the collapsed outline hierarchy 2219 as needed. It is common to include within the collapsed hierarchy a 2220 visual clue (such as a ''+'') to indicate that there are child 2221 mailboxes under a particular mailbox. When the visual clue is 2222 clicked, the hierarchy list is expanded to show the child mailboxes. 2223 The CHILDREN return option provides a mechanism for a client to 2224 efficiently determine whether a particular mailbox has children, 2225 without issuing a LIST "" * or a LIST "" % for each mailbox name. 2226 The CHILDREN return option defines two new attributes that MUST be 2227 returned within a LIST response: \HasChildren and \HasNoChildren. 2228 Although these attributes MAY be returned in response to any LIST 2229 command, the CHILDREN return option is provided to indicate that the 2230 client particularly wants this information. If the CHILDREN return 2231 option is present, the server MUST return these attributes even if 2232 their computation is expensive. 2234 \HasChildren 2236 The presence of this attribute indicates that the mailbox has 2237 child mailboxes. A server SHOULD NOT set this attribute if 2238 there are child mailboxes and the user does not have permission 2239 to access any of them. In this case, \HasNoChildren SHOULD be 2240 used. In many cases, however, a server may not be able to 2241 efficiently compute whether a user has access to any child 2242 mailbox. Note that even though the \HasChildren attribute for a 2243 mailbox must be correct at the time of processing of the 2244 mailbox, a client must be prepared to deal with a situation when 2245 a mailbox is marked with the \HasChildren attribute, but no 2246 child mailbox appears in the response to the LIST command. This 2247 might happen, for example, due to children mailboxes being 2248 deleted or made inaccessible to the user (using access control) 2249 by another client before the server is able to list them. 2251 \HasNoChildren 2253 The presence of this attribute indicates that the mailbox has NO 2254 child mailboxes that are accessible to the currently 2255 authenticated user. 2257 It is an error for the server to return both a \HasChildren and a 2258 \HasNoChildren attribute in the same LIST response. 2260 Note: the \HasNoChildren attribute should not be confused with the 2261 the \NoInferiors attribute, which indicates that no child mailboxes 2262 exist now and none can be created in the future. 2264 6.3.9.5. CHILDINFO Extended Data Item 2266 The CHILDINFO extended data item MUST NOT be returned unless the 2267 client has specified the RECURSIVEMATCH selection option. 2269 The CHILDINFO extended data item in a LIST response describes the 2270 selection criteria that has caused it to be returned and indicates 2271 that the mailbox has at least one descendant mailbox that matches the 2272 selection criteria. 2274 Note: Some servers allow for mailboxes to exist without requiring 2275 their parent to exist. For example, a mailbox "Customers/ABC" can 2276 exist while the mailbox "Customers" does not. As CHILDINFO extended 2277 data item is not allowed if the RECURSIVEMATCH selection option is 2278 not specified, such servers SHOULD use the "\NonExistent 2279 \HasChildren" attribute pair to signal to the client that there is a 2280 descendant mailbox that matches the selection criteria. See example 2281 11 in Section 6.3.9.6. 2283 The returned selection criteria allow the client to distinguish a 2284 solicited response from an unsolicited one, as well as to distinguish 2285 among solicited responses caused by multiple pipelined LIST commands 2286 that specify different criteria. 2288 Servers SHOULD ONLY return a non-matching mailbox name along with 2289 CHILDINFO if at least one matching child is not also being returned. 2290 That is, servers SHOULD suppress redundant CHILDINFO responses. 2292 Examples 8 and 10 in Section 6.3.9.6 demonstrate the difference 2293 between present CHILDINFO extended data item and the "\HasChildren" 2294 attribute. 2296 The following table summarizes interaction between the "\NonExistent" 2297 attribute and CHILDINFO (the first column indicates whether the 2298 parent mailbox exists): 2300 +--------+--------------+--------------------+----------------------+ 2301 | exists | meets the | has a child that | returned LIST- | 2302 | | selection | meets the | EXTENDED attributes | 2303 | | criteria | selection criteria | and CHILDINFO | 2304 +--------+--------------+--------------------+----------------------+ 2305 | no | no | no | no LIST response | 2306 | | | | returned | 2307 | yes | no | no | no LIST response | 2308 | | | | returned | 2309 | no | yes | no | (\NonExistent | 2310 | | | | ) | 2311 | yes | yes | no | () | 2312 | no | no | yes | (\NonExistent) + | 2313 | | | | CHILDINFO | 2314 | yes | no | yes | () + CHILDINFO | 2315 | no | yes | yes | (\NonExistent | 2316 | | | | ) + CHILDINFO | 2317 | yes | yes | yes | () + CHILDINFO | 2318 +--------+--------------+--------------------+----------------------+ 2320 where is one or more attributes that correspond to the 2321 selection criteria; for example, for the SUBSCRIBED option the 2322 is \Subscribed. 2324 6.3.9.6. LIST Command Examples 2326 This example shows some uses of the basic LIST command: 2328 Example: C: A101 LIST "" "" 2329 S: * LIST (\Noselect) "/" "" 2330 S: A101 OK LIST Completed 2331 C: A102 LIST #news.comp.mail.misc "" 2332 S: * LIST (\Noselect) "." #news. 2333 S: A102 OK LIST Completed 2334 C: A103 LIST /usr/staff/jones "" 2335 S: * LIST (\Noselect) "/" / 2336 S: A103 OK LIST Completed 2337 C: A202 LIST ~/Mail/ % 2338 S: * LIST (\Noselect) "/" ~/Mail/foo 2339 S: * LIST () "/" ~/Mail/meetings 2340 S: A202 OK LIST completed 2342 Extended examples: 2344 1: The first example shows the complete local hierarchy that will 2345 be used for the other examples. 2347 C: A01 LIST "" "*" 2348 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2349 S: * LIST () "/" "Fruit" 2350 S: * LIST () "/" "Fruit/Apple" 2351 S: * LIST () "/" "Fruit/Banana" 2352 S: * LIST () "/" "Tofu" 2353 S: * LIST () "/" "Vegetable" 2354 S: * LIST () "/" "Vegetable/Broccoli" 2355 S: * LIST () "/" "Vegetable/Corn" 2356 S: A01 OK done 2358 2: In the next example, we will see the subscribed mailboxes. This 2359 is similar to, but not equivalent with, . Note 2360 that the mailbox called "Fruit/Peach" is subscribed to, but does 2361 not actually exist (perhaps it was deleted while still 2362 subscribed). The "Fruit" mailbox is not subscribed to, but it 2363 has two subscribed children. The "Vegetable" mailbox is 2364 subscribed and has two children; one of them is subscribed as 2365 well. 2367 C: A02 LIST (SUBSCRIBED) "" "*" 2368 S: * LIST (\Marked \NoInferiors \Subscribed) "/" "inbox" 2369 S: * LIST (\Subscribed) "/" "Fruit/Banana" 2370 S: * LIST (\Subscribed \NonExistent) "/" "Fruit/Peach" 2371 S: * LIST (\Subscribed) "/" "Vegetable" 2372 S: * LIST (\Subscribed) "/" "Vegetable/Broccoli" 2373 S: A02 OK done 2375 3: The next example shows the use of the CHILDREN option. The 2376 client, without having to list the second level of hierarchy, 2377 now knows which of the top-level mailboxes have submailboxes 2378 (children) and which do not. Note that it's not necessary for 2379 the server to return the \HasNoChildren attribute for the inbox, 2380 because the \NoInferiors attribute already implies that, and has 2381 a stronger meaning. 2383 C: A03 LIST () "" "%" RETURN (CHILDREN) 2384 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2385 S: * LIST (\HasChildren) "/" "Fruit" 2386 S: * LIST (\HasNoChildren) "/" "Tofu" 2387 S: * LIST (\HasChildren) "/" "Vegetable" 2388 S: A03 OK done 2390 4: In this example, we see more mailboxes that reside on another 2391 server. This is similar to the command . 2393 C: A04 LIST (REMOTE) "" "%" RETURN (CHILDREN) 2394 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2395 S: * LIST (\HasChildren) "/" "Fruit" 2396 S: * LIST (\HasNoChildren) "/" "Tofu" 2397 S: * LIST (\HasChildren) "/" "Vegetable" 2398 S: * LIST (\Remote) "/" "Bread" 2399 S: * LIST (\HasChildren \Remote) "/" "Meat" 2400 S: A04 OK done 2402 5: The following example also requests the server to include 2403 mailboxes that reside on another server. The server returns 2404 information about all mailboxes that are subscribed. This is 2405 similar to the command . We also see the use of 2406 two selection options. 2408 C: A05 LIST (REMOTE SUBSCRIBED) "" "*" 2409 S: * LIST (\Marked \NoInferiors \Subscribed) "/" "inbox" 2410 S: * LIST (\Subscribed) "/" "Fruit/Banana" 2411 S: * LIST (\Subscribed \NonExistent) "/" "Fruit/Peach" 2412 S: * LIST (\Subscribed) "/" "Vegetable" 2413 S: * LIST (\Subscribed) "/" "Vegetable/Broccoli" 2414 S: * LIST (\Remote \Subscribed) "/" "Bread" 2415 S: A05 OK done 2417 6: The following example requests the server to include mailboxes 2418 that reside on another server. The server is asked to return 2419 subscription information for all returned mailboxes. This is 2420 different from the example above. 2422 Note that the output of this command is not a superset of the 2423 output in the previous example, as it doesn't include LIST 2424 response for the non-existent "Fruit/Peach". 2426 C: A06 LIST (REMOTE) "" "*" RETURN (SUBSCRIBED) 2427 S: * LIST (\Marked \NoInferiors \Subscribed) "/" "inbox" 2428 S: * LIST () "/" "Fruit" 2429 S: * LIST () "/" "Fruit/Apple" 2430 S: * LIST (\Subscribed) "/" "Fruit/Banana" 2431 S: * LIST () "/" "Tofu" 2432 S: * LIST (\Subscribed) "/" "Vegetable" 2433 S: * LIST (\Subscribed) "/" "Vegetable/Broccoli" 2434 S: * LIST () "/" "Vegetable/Corn" 2435 S: * LIST (\Remote \Subscribed) "/" "Bread" 2436 S: * LIST (\Remote) "/" "Meat" 2437 S: A06 OK done 2439 7: In the following example, the client has specified multiple 2440 mailbox patterns. Note that this example does not use the 2441 mailbox hierarchy used in the previous examples. 2443 C: BBB LIST "" ("INBOX" "Drafts" "Sent/%") 2444 S: * LIST () "/" "INBOX" 2445 S: * LIST (\NoInferiors) "/" "Drafts" 2446 S: * LIST () "/" "Sent/March2004" 2447 S: * LIST (\Marked) "/" "Sent/December2003" 2448 S: * LIST () "/" "Sent/August2004" 2449 S: BBB OK done 2451 8: The following example demonstrates the difference between the 2452 \HasChildren attribute and the CHILDINFO extended data item. 2454 Let's assume there is the following hierarchy: 2456 C: C01 LIST "" "*" 2457 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2458 S: * LIST () "/" "Foo" 2459 S: * LIST () "/" "Foo/Bar" 2460 S: * LIST () "/" "Foo/Baz" 2461 S: * LIST () "/" "Moo" 2462 S: C01 OK done 2464 If the client asks RETURN (CHILDREN), it will get this: 2466 C: CA3 LIST "" "%" RETURN (CHILDREN) 2467 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2468 S: * LIST (\HasChildren) "/" "Foo" 2469 S: * LIST (\HasNoChildren) "/" "Moo" 2470 S: CA3 OK done 2472 A) Let's also assume that the mailbox "Foo/Baz" is the only 2473 subscribed mailbox. Then we get this result: 2475 C: C02 LIST (SUBSCRIBED) "" "*" 2476 S: * LIST (\Subscribed) "/" "Foo/Baz" 2477 S: C02 OK done 2479 Now, if the client issues , the server 2480 will return no mailboxes (as the mailboxes "Moo", "Foo", and 2481 "Inbox" are NOT subscribed). However, if the client issues 2482 this: 2484 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2485 S: * LIST () "/" "Foo" ("CHILDINFO" ("SUBSCRIBED")) 2486 S: C04 OK done 2488 (i.e., the mailbox "Foo" is not subscribed, but it has a child 2489 that is.) 2491 A1) If the mailbox "Foo" had also been subscribed, the last 2492 command would return this: 2494 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2495 S: * LIST (\Subscribed) "/" "Foo" ("CHILDINFO" ("SUBSCRIBED")) 2496 S: C04 OK done 2498 or even this: 2500 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2501 S: * LIST (\Subscribed \HasChildren) "/" "Foo" ("CHILDINFO" 2502 ("SUBSCRIBED")) 2503 S: C04 OK done 2505 A2) If we assume instead that the mailbox "Foo" is not part of 2506 the original hierarchy and is not subscribed, the last command 2507 will give this result: 2509 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2510 S: * LIST (\NonExistent) "/" "Foo" ("CHILDINFO" ("SUBSCRIBED")) 2511 S: C04 OK done 2512 B) Now, let's assume that no mailbox is subscribed. In this 2513 case, the command will 2514 return no responses, as there are no subscribed children (even 2515 though "Foo" has children). 2517 C) And finally, suppose that only the mailboxes "Foo" and "Moo" 2518 are subscribed. In that case, we see this result: 2520 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" RETURN (CHILDREN) 2521 S: * LIST (\HasChildren \Subscribed) "/" "Foo" 2522 S: * LIST (\HasNoChildren \Subscribed) "/" "Moo" 2523 S: C04 OK done 2525 (which means that the mailbox "Foo" has children, but none of 2526 them is subscribed). 2528 9: The following example demonstrates that the CHILDINFO extended 2529 data item is returned whether or not children mailboxes match 2530 the canonical LIST pattern. 2532 Let's assume there is the following hierarchy: 2534 C: D01 LIST "" "*" 2535 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2536 S: * LIST () "/" "foo2" 2537 S: * LIST () "/" "foo2/bar1" 2538 S: * LIST () "/" "foo2/bar2" 2539 S: * LIST () "/" "baz2" 2540 S: * LIST () "/" "baz2/bar2" 2541 S: * LIST () "/" "baz2/bar22" 2542 S: * LIST () "/" "baz2/bar222" 2543 S: * LIST () "/" "eps2" 2544 S: * LIST () "/" "eps2/mamba" 2545 S: * LIST () "/" "qux2/bar2" 2546 S: D01 OK done 2548 And that the following mailboxes are subscribed: 2550 C: D02 LIST (SUBSCRIBED) "" "*" 2551 S: * LIST (\Subscribed) "/" "foo2/bar1" 2552 S: * LIST (\Subscribed) "/" "foo2/bar2" 2553 S: * LIST (\Subscribed) "/" "baz2/bar2" 2554 S: * LIST (\Subscribed) "/" "baz2/bar22" 2555 S: * LIST (\Subscribed) "/" "baz2/bar222" 2556 S: * LIST (\Subscribed) "/" "eps2" 2557 S: * LIST (\Subscribed) "/" "eps2/mamba" 2558 S: * LIST (\Subscribed) "/" "qux2/bar2" 2559 S: D02 OK done 2560 The client issues the following command first: 2562 C: D03 LIST (RECURSIVEMATCH SUBSCRIBED) "" "*2" 2563 S: * LIST () "/" "foo2" ("CHILDINFO" ("SUBSCRIBED")) 2564 S: * LIST (\Subscribed) "/" "foo2/bar2" 2565 S: * LIST (\Subscribed) "/" "baz2/bar2" 2566 S: * LIST (\Subscribed) "/" "baz2/bar22" 2567 S: * LIST (\Subscribed) "/" "baz2/bar222" 2568 S: * LIST (\Subscribed) "/" "eps2" ("CHILDINFO" ("SUBSCRIBED")) 2569 S: * LIST (\Subscribed) "/" "qux2/bar2" 2570 S: D03 OK done 2572 and the server may also include (but this would violate a SHOULD 2573 NOT in Section 3.5, because CHILDINFO is redundant) 2575 S: * LIST () "/" "baz2" ("CHILDINFO" ("SUBSCRIBED")) 2576 S: * LIST (\NonExistent) "/" "qux2" ("CHILDINFO" ("SUBSCRIBED")) 2578 The CHILDINFO extended data item is returned for mailboxes 2579 "foo2", "baz2", and "eps2", because all of them have subscribed 2580 children, even though for the mailbox "foo2" only one of the two 2581 subscribed children matches the pattern, for the mailbox "baz2" 2582 all the subscribed children match the pattern, and for the 2583 mailbox "eps2" none of the subscribed children matches the 2584 pattern. 2586 Note that if the client issues 2588 C: D03 LIST (RECURSIVEMATCH SUBSCRIBED) "" "*" 2589 S: * LIST () "/" "foo2" ("CHILDINFO" ("SUBSCRIBED")) 2590 S: * LIST (\Subscribed) "/" "foo2/bar1" 2591 S: * LIST (\Subscribed) "/" "foo2/bar2" 2592 S: * LIST () "/" "baz2" ("CHILDINFO" ("SUBSCRIBED")) 2593 S: * LIST (\Subscribed) "/" "baz2/bar2" 2594 S: * LIST (\Subscribed) "/" "baz2/bar22" 2595 S: * LIST (\Subscribed) "/" "baz2/bar222" 2596 S: * LIST (\Subscribed) "/" "eps2" ("CHILDINFO" ("SUBSCRIBED")) 2597 S: * LIST (\Subscribed) "/" "eps2/mamba" 2598 S: * LIST (\Subscribed) "/" "qux2/bar2" 2599 S: D03 OK done 2601 The LIST responses for mailboxes "foo2", "baz2", and "eps2" 2602 still have the CHILDINFO extended data item, even though this 2603 information is redundant and the client can determine it by 2604 itself. 2606 10: The following example shows usage of multiple mailbox patterns. 2607 It also demonstrates that the presence of the CHILDINFO extended 2608 data item doesn't necessarily imply \HasChildren. 2610 C: a1 LIST "" ("foo" "foo/*") 2611 S: * LIST () "/" foo 2612 S: a1 OK done 2614 C: a2 LIST (SUBSCRIBED) "" "foo/*" 2615 S: * LIST (\Subscribed \NonExistent) "/" foo/bar 2616 S: a2 OK done 2618 C: a3 LIST (SUBSCRIBED RECURSIVEMATCH) "" foo RETURN (CHILDREN) 2619 S: * LIST (\HasNoChildren) "/" foo ("CHILDINFO" ("SUBSCRIBED")) 2620 S: a3 OK done 2622 11: The following example shows how a server that supports missing 2623 mailbox hierarchy elements can signal to a client that didn't 2624 specify the RECURSIVEMATCH selection option that there is a 2625 child mailbox that matches the selection criteria. 2627 C: a1 LIST (REMOTE) "" * 2628 S: * LIST () "/" music/rock 2629 S: * LIST (\Remote) "/" also/jazz 2630 S: a1 OK done 2632 C: a2 LIST () "" % 2633 S: * LIST (\NonExistent \HasChildren) "/" music 2634 S: a2 OK done 2636 C: a3 LIST (REMOTE) "" % 2637 S: * LIST (\NonExistent \HasChildren) "/" music 2638 S: * LIST (\NonExistent \HasChildren) "/" also 2639 S: a3 OK done 2641 C: a3.1 LIST "" (% music/rock) 2642 S: * LIST () "/" music/rock 2643 S: a3.1 OK done 2645 Because "music/rock" is the only mailbox under "music", there's 2646 no need for the server to also return "music". However clients 2647 must handle both cases. 2649 6.3.10. NAMESPACE Command 2651 Arguments: none 2653 Responses: REQUIRED untagged responses: NAMESPACE 2654 Result: OK - command completed 2655 NO - Can't complete the command 2656 BAD - arguments invalid 2658 The NAMESPACE command causes a single ungagged NAMESPACE response to 2659 be returned. The untagged NAMESPACE response contains the prefix and 2660 hierarchy delimiter to the server's Personal Namespace(s), Other 2661 Users' Namespace(s), and Shared Namespace(s) that the server wishes 2662 to expose. The response will contain a NIL for any namespace class 2663 that is not available. Namespace-Response-Extensions ABNF non 2664 terminal is defined for extensibility and MAY be included in the 2665 response. 2667 Namespace-Response-Extensions which are not on the IETF standards 2668 track, MUST be prefixed with an "X-". 2670 Example 1: 2672 In this example a server supports a single personal namespace. No 2673 leading prefix is used on personal mailboxes and "/" is the hierarchy 2674 delimiter. 2676 C: A001 NAMESPACE 2677 S: * NAMESPACE (("" "/")) NIL NIL 2678 S: A001 OK NAMESPACE command completed 2680 Example 2: 2682 A user logged on anonymously to a server. No personal mailboxes are 2683 associated with the anonymous user and the user does not have access 2684 to the Other Users' Namespace. No prefix is required to access 2685 shared mailboxes and the hierarchy delimiter is "." 2687 C: A001 NAMESPACE 2688 S: * NAMESPACE NIL NIL (("" ".")) 2689 S: A001 OK NAMESPACE command completed 2691 Example 3: 2693 A server that contains a Personal Namespace and a single Shared 2694 Namespace. 2696 C: A001 NAMESPACE 2697 S: * NAMESPACE (("" "/")) NIL (("Public Folders/" "/")) 2698 S: A001 OK NAMESPACE command completed 2700 Example 4: 2702 A server that contains a Personal Namespace, Other Users' Namespace 2703 and multiple Shared Namespaces. Note that the hierarchy delimiter 2704 used within each namespace can be different. 2706 C: A001 NAMESPACE 2707 S: * NAMESPACE (("" "/")) (("~" "/")) (("#shared/" "/") 2708 ("#public/" "/")("#ftp/" "/")("#news." ".")) 2709 S: A001 OK NAMESPACE command completed 2711 The prefix string allows a client to do things such as automatically 2712 creating personal mailboxes or LISTing all available mailboxes within 2713 a namespace. 2715 Example 5: 2717 A server that supports only the Personal Namespace, with a leading 2718 prefix of INBOX to personal mailboxes and a hierarchy delimiter of 2719 "." 2721 C: A001 NAMESPACE 2722 S: * NAMESPACE (("INBOX." ".")) NIL NIL 2723 S: A001 OK NAMESPACE command completed 2725 < Automatically create a mailbox to store sent items.> 2727 C: A002 CREATE "INBOX.Sent Mail" 2728 S: A002 OK CREATE command completed 2730 Although typically a server will support only a single Personal 2731 Namespace, and a single Other User's Namespace, circumstances exist 2732 where there MAY be multiples of these, and a client MUST be prepared 2733 for them. If a client is configured such that it is required to 2734 create a certain mailbox, there can be circumstances where it is 2735 unclear which Personal Namespaces it should create the mailbox in. 2736 In these situations a client SHOULD let the user select which 2737 namespaces to create the mailbox in or just use the first personal 2738 namespace. 2740 Example 6: 2742 In this example, a server supports 2 Personal Namespaces. In 2743 addition to the regular Personal Namespace, the user has an 2744 additional personal namespace to allow access to mailboxes in an MH 2745 format mailstore. 2747 The client is configured to save a copy of all mail sent by the user 2748 into a mailbox called 'Sent Mail'. Furthermore, after a message is 2749 deleted from a mailbox, the client is configured to move that message 2750 to a mailbox called 'Deleted Items'. 2752 Note that this example demonstrates how some extension flags can be 2753 passed to further describe the #mh namespace. 2755 C: A001 NAMESPACE 2756 S: * NAMESPACE (("" "/")("#mh/" "/" "X-PARAM" ("FLAG1" "FLAG2"))) 2757 NIL NIL 2758 S: A001 OK NAMESPACE command completed 2760 < It is desired to keep only one copy of sent mail. It is unclear 2761 which Personal Namespace the client should use to create the 'Sent 2762 Mail' mailbox. The user is prompted to select a namespace and 2763 only one 'Sent Mail' mailbox is created. > 2765 C: A002 CREATE "Sent Mail" 2766 S: A002 OK CREATE command completed 2768 < The client is designed so that it keeps two 'Deleted Items' 2769 mailboxes, one for each namespace. > 2771 C: A003 CREATE "Delete Items" 2772 S: A003 OK CREATE command completed 2774 C: A004 CREATE "#mh/Deleted Items" 2775 S: A004 OK CREATE command completed 2777 The next level of hierarchy following the Other Users' Namespace 2778 prefix SHOULD consist of , where is a user name 2779 as per the LOGIN or AUTHENTICATE command. 2781 A client can construct a LIST command by appending a "%" to the Other 2782 Users' Namespace prefix to discover the Personal Namespaces of other 2783 users that are available to the currently authenticated user. 2785 In response to such a LIST command, a server SHOULD NOT return user 2786 names that have not granted access to their personal mailboxes to the 2787 user in question. 2789 A server MAY return a LIST response containing only the names of 2790 users that have explicitly granted access to the user in question. 2792 Alternatively, a server MAY return NO to such a LIST command, 2793 requiring that a user name be included with the Other Users' 2794 Namespace prefix before listing any other user's mailboxes. 2796 Example 7: 2798 A server that supports providing a list of other user's mailboxes 2799 that are accessible to the currently logged on user. 2801 C: A001 NAMESPACE 2802 S: * NAMESPACE (("" "/")) (("Other Users/" "/")) NIL 2803 S: A001 OK NAMESPACE command completed 2805 C: A002 LIST "" "Other Users/%" 2806 S: * LIST () "/" "Other Users/Mike" 2807 S: * LIST () "/" "Other Users/Karen" 2808 S: * LIST () "/" "Other Users/Matthew" 2809 S: * LIST () "/" "Other Users/Tesa" 2810 S: A002 OK LIST command completed 2812 Example 8: 2814 A server that does not support providing a list of other user's 2815 mailboxes that are accessible to the currently logged on user. The 2816 mailboxes are listable if the client includes the name of the other 2817 user with the Other Users' Namespace prefix. 2819 C: A001 NAMESPACE 2820 S: * NAMESPACE (("" "/")) (("#Users/" "/")) NIL 2821 S: A001 OK NAMESPACE command completed 2823 < In this example, the currently logged on user has access to the 2824 Personal Namespace of user Mike, but the server chose to suppress 2825 this information in the LIST response. However, by appending the 2826 user name Mike (received through user input) to the Other Users' 2827 Namespace prefix, the client is able to get a listing of the 2828 personal mailboxes of user Mike. > 2830 C: A002 LIST "" "#Users/%" 2831 S: A002 NO The requested item could not be found. 2833 C: A003 LIST "" "#Users/Mike/%" 2834 S: * LIST () "/" "#Users/Mike/INBOX" 2835 S: * LIST () "/" "#Users/Mike/Foo" 2836 S: A003 OK LIST command completed. 2838 A prefix string might not contain a hierarchy delimiter, because in 2839 some cases it is not needed as part of the prefix. 2841 Example 9: 2843 A server that allows access to the Other Users' Namespace by 2844 prefixing the others' mailboxes with a '~' followed by , 2845 where is a user name as per the LOGIN or AUTHENTICATE 2846 command. 2848 C: A001 NAMESPACE 2849 S: * NAMESPACE (("" "/")) (("~" "/")) NIL 2850 S: A001 OK NAMESPACE command completed 2852 < List the mailboxes for user mark > 2854 C: A002 LIST "" "~mark/%" 2855 S: * LIST () "/" "~mark/INBOX" 2856 S: * LIST () "/" "~mark/foo" 2857 S: A002 OK LIST command completed 2859 6.3.11. STATUS Command 2861 Arguments: mailbox name 2862 status data item names 2864 Responses: REQUIRED untagged responses: STATUS 2866 Result: OK - status completed 2867 NO - status failure: no status for that name 2868 BAD - command unknown or arguments invalid 2870 The STATUS command requests the status of the indicated mailbox. It 2871 does not change the currently selected mailbox, nor does it affect 2872 the state of any messages in the queried mailbox. 2874 The STATUS command provides an alternative to opening a second 2875 IMAP4rev2 connection and doing an EXAMINE command on a mailbox to 2876 query that mailbox's status without deselecting the current mailbox 2877 in the first IMAP4rev2 connection. 2879 Unlike the LIST command, the STATUS command is not guaranteed to be 2880 fast in its response. Under certain circumstances, it can be quite 2881 slow. In some implementations, the server is obliged to open the 2882 mailbox read-only internally to obtain certain status information. 2883 Also unlike the LIST command, the STATUS command does not accept 2884 wildcards. 2886 Note: The STATUS command is intended to access the status of 2887 mailboxes other than the currently selected mailbox. Because the 2888 STATUS command can cause the mailbox to be opened internally, and 2889 because this information is available by other means on the 2890 selected mailbox, the STATUS command SHOULD NOT be used on the 2891 currently selected mailbox. 2893 The STATUS command MUST NOT be used as a "check for new messages 2894 in the selected mailbox" operation (refer to sections Section 7, 2895 Section 7.3.1 for more information about the proper method for new 2896 message checking). 2898 Because the STATUS command is not guaranteed to be fast in its 2899 results, clients SHOULD NOT expect to be able to issue many 2900 consecutive STATUS commands and obtain reasonable performance. 2902 The currently defined status data items that can be requested are: 2904 MESSAGES The number of messages in the mailbox. 2906 UIDNEXT The next unique identifier value of the mailbox. Refer to 2907 Section 2.3.1.1 for more information. 2909 UIDVALIDITY The unique identifier validity value of the mailbox. 2910 Refer to Section 2.3.1.1 for more information. 2912 UNSEEN The number of messages which do not have the \Seen flag set. 2914 DELETED The number of messages which have the \Deleted flag set. 2916 SIZE The total size of the mailbox in octets. This is not strictly 2917 required to be an exact value, but it MUST be equal to or greater 2918 than the sum of the values of the RFC822.SIZE FETCH message data 2919 items (see Section 6.4.5) of all messages in the mailbox. 2921 SIZE 2923 Example: C: A042 STATUS blurdybloop (UIDNEXT MESSAGES) 2924 S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) 2925 S: A042 OK STATUS completed 2927 6.3.12. APPEND Command 2929 Arguments: mailbox name 2930 OPTIONAL flag parenthesized list 2931 OPTIONAL date/time string 2932 message literal 2934 Responses: no specific responses for this command 2936 Result: OK - append completed 2937 NO - append error: can't append to that mailbox, error 2938 in flags or date/time or message text 2939 BAD - command unknown or arguments invalid 2941 The APPEND command appends the literal argument as a new message to 2942 the end of the specified destination mailbox. This argument SHOULD 2943 be in the format of an [RFC-5322] or [I18N-HDRS] message. 8-bit 2944 characters are permitted in the message. A server implementation 2945 that is unable to preserve 8-bit data properly MUST be able to 2946 reversibly convert 8-bit APPEND data to 7-bit using a [MIME-IMB] 2947 content transfer encoding. 2949 Note: There may be exceptions, e.g., draft messages, in which 2950 required [RFC-5322] header lines are omitted in the message 2951 literal argument to APPEND. The full implications of doing so 2952 must be understood and carefully weighed. 2954 If a flag parenthesized list is specified, the flags SHOULD be set in 2955 the resulting message; otherwise, the flag list of the resulting 2956 message is set to empty by default. 2958 If a date-time is specified, the internal date SHOULD be set in the 2959 resulting message; otherwise, the internal date of the resulting 2960 message is set to the current date and time by default. 2962 If the append is unsuccessful for any reason, the mailbox MUST be 2963 restored to its state before the APPEND attempt; no partial appending 2964 is permitted. 2966 If the destination mailbox does not exist, a server MUST return an 2967 error, and MUST NOT automatically create the mailbox. Unless it is 2968 certain that the destination mailbox can not be created, the server 2969 MUST send the response code "[TRYCREATE]" as the prefix of the text 2970 of the tagged NO response. This gives a hint to the client that it 2971 can attempt a CREATE command and retry the APPEND if the CREATE is 2972 successful. 2974 On successful completion of an APPEND, the server SHOULD return an 2975 APPENDUID response code. 2977 In the case of a mailbox that has permissions set so that the client 2978 can APPEND to the mailbox, but not SELECT or EXAMINE it, the server 2979 SHOULD NOT send an APPENDUID response code as it would disclose 2980 information about the mailbox. 2982 In the case of a mailbox that has UIDNOTSTICKY status (see 2983 UIDNOTSTICKY response code definition), the server MAY omit the 2984 APPENDUID response code as it is not meaningful. 2986 If the server does not return the APPENDUID response codes, the 2987 client can discover this information by selecting the destination 2988 mailbox. The location of messages placed in the destination mailbox 2989 by APPEND can be determined by using FETCH and/or SEARCH commands 2990 (e.g., for Message-ID or some unique marker placed in the message in 2991 an APPEND). 2993 If the mailbox is currently selected, the normal new message actions 2994 SHOULD occur. Specifically, the server SHOULD notify the client 2995 immediately via an untagged EXISTS response. If the server does not 2996 do so, the client MAY issue a NOOP command after one or more APPEND 2997 commands. 2999 Example: C: A003 APPEND saved-messages (\Seen) {310} 3000 S: + Ready for literal data 3001 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST) 3002 C: From: Fred Foobar 3003 C: Subject: afternoon meeting 3004 C: To: mooch@owatagu.siam.edu 3005 C: Message-Id: 3006 C: MIME-Version: 1.0 3007 C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 3008 C: 3009 C: Hello Joe, do you think we can meet at 3:30 tomorrow? 3010 C: 3011 S: A003 OK APPEND completed 3013 Example: C: A003 APPEND saved-messages (\Seen) {297} 3014 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST) 3015 C: From: Fred Foobar 3016 C: Subject: afternoon meeting 3017 C: To: mooch@example.com 3018 C: Message-Id: 3019 C: MIME-Version: 1.0 3020 C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 3021 C: 3022 C: Hello Joe, do you think we can meet at 3:30 tomorrow? 3023 C: 3024 S: A003 OK [APPENDUID 38505 3955] APPEND completed 3025 C: A004 COPY 2:4 meeting 3026 S: A004 OK [COPYUID 38505 304,319:320 3956:3958] Done 3027 C: A005 UID COPY 305:310 meeting 3028 S: A005 OK No matching messages, so nothing copied 3029 C: A006 COPY 2 funny 3030 S: A006 OK Done 3031 C: A007 SELECT funny 3032 S: * 1 EXISTS 3033 S: * OK [UIDVALIDITY 3857529045] Validity session-only 3034 S: * OK [UIDNEXT 2] Predicted next UID 3035 S: * NO [UIDNOTSTICKY] Non-persistent UIDs 3036 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 3037 S: * OK [PERMANENTFLAGS (\Deleted \Seen)] Limited 3038 S: A007 OK [READ-WRITE] SELECT completed 3040 In this example, A003 and A004 demonstrate successful appending and 3041 copying to a mailbox that returns the UIDs assigned to the messages. 3042 A005 is an example in which no messages were copied; this is because 3043 in A003, we see that message 2 had UID 304, and message 3 had UID 3044 319; therefore, UIDs 305 through 310 do not exist (refer to 3045 Section 2.3.1.1 for further explanation). A006 is an example of a 3046 message being copied that did not return a COPYUID; and, as expected, 3047 A007 shows that the mail store containing that mailbox does not 3048 support persistent UIDs. 3050 Note: The APPEND command is not used for message delivery, because 3051 it does not provide a mechanism to transfer [SMTP] envelope 3052 information. 3054 6.3.13. IDLE Command 3056 Arguments: none 3058 Responses: continuation data will be requested; the client sends the 3059 continuation data "DONE" to end the command 3061 Result: OK - IDLE completed after client sent "DONE" 3062 NO - failure: the server will not allow the IDLE command 3063 at this time 3064 BAD - command unknown or arguments invalid 3066 Without the IDLE command a client requires to poll the server for 3067 changes to the selected mailbox (new mail, deletions, flag changes). 3068 It's often more desirable to have the server transmit updates to the 3069 client in real time. This allows a user to see new mail immediately. 3070 The IDLE command allows a client to tell the server that it's ready 3071 to accept such real-time updates. 3073 The IDLE command is sent from the client to the server when the 3074 client is ready to accept unsolicited mailbox 3076 update messages. The server requests a response to the IDLE command 3077 using the continuation ("+") response. The IDLE command remains 3078 active until the client responds to the continuation, and as long as 3079 an IDLE command is active, the server is now free to send untagged 3080 EXISTS, EXPUNGE, FETCH, and other responses at any time. If the 3081 server choose to send unsolicited FETCH responses, they MUST include 3082 UID FETCH item. 3084 The IDLE command is terminated by the receipt of a "DONE" 3085 continuation from the client; such response satisfies the server's 3086 continuation request. At that point, the server MAY send any 3087 remaining queued untagged responses and then MUST immediately send 3088 the tagged response to the IDLE command and prepare to process other 3089 commands. As for other commands, the processing of any new command 3090 may cause the sending of unsolicited untagged responses, subject to 3091 the ambiguity limitations. The client MUST NOT send a command while 3092 the server is waiting for the DONE, since the server will not be able 3093 to distinguish a command from a continuation. 3095 The server MAY consider a client inactive if it has an IDLE command 3096 running, and if such a server has an inactivity timeout it MAY log 3097 the client off implicitly at the end of its timeout period. Because 3098 of that, clients using IDLE are advised to terminate the IDLE and re- 3099 issue it at least every 29 minutes to avoid being logged off. This 3100 still allows a client to receive immediate mailbox updates even 3101 though it need only "poll" at half hour intervals. 3103 Example: C: A001 SELECT INBOX 3104 S: * FLAGS (\Deleted \Seen \Flagged) 3105 S: * OK [PERMANENTFLAGS (\Deleted \Seen \Flagged)] Limited 3106 S: * 3 EXISTS 3107 S: * OK [UIDVALIDITY 1] 3108 S: A001 OK [READ-WRITE] SELECT completed 3109 C: A002 IDLE 3110 S: + idling 3111 ...time passes; new mail arrives... 3112 S: * 4 EXISTS 3113 C: DONE 3114 S: A002 OK IDLE terminated 3115 ...another client expunges message 2 now... 3116 C: A003 FETCH 4 ALL 3117 S: * 4 FETCH (...) 3118 S: A003 OK FETCH completed 3119 C: A004 IDLE 3120 S: * 2 EXPUNGE 3121 S: * 3 EXISTS 3122 S: + idling 3123 ...time passes; another client expunges message 3... 3124 S: * 3 EXPUNGE 3125 S: * 2 EXISTS 3126 ...time passes; new mail arrives... 3127 S: * 3 EXISTS 3128 C: DONE 3129 S: A004 OK IDLE terminated 3130 C: A005 FETCH 3 ALL 3131 S: * 3 FETCH (...) 3132 S: A005 OK FETCH completed 3133 C: A006 IDLE 3135 6.4. Client Commands - Selected State 3137 In the selected state, commands that manipulate messages in a mailbox 3138 are permitted. 3140 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 3141 and the authenticated state commands (SELECT, EXAMINE, NAMESPACE, 3142 CREATE, DELETE, RENAME, SUBSCRIBE, UNSUBSCRIBE, LIST, STATUS, and 3143 APPEND), the following commands are valid in the selected state: 3144 CLOSE, UNSELECT, EXPUNGE, SEARCH, FETCH, STORE, COPY, MOVE, and UID. 3146 6.4.1. CLOSE Command 3148 Arguments: none 3150 Responses: no specific responses for this command 3151 Result: OK - close completed, now in authenticated state 3152 BAD - command unknown or arguments invalid 3154 The CLOSE command permanently removes all messages that have the 3155 \Deleted flag set from the currently selected mailbox, and returns to 3156 the authenticated state from the selected state. No untagged EXPUNGE 3157 responses are sent. 3159 No messages are removed, and no error is given, if the mailbox is 3160 selected by an EXAMINE command or is otherwise selected read-only. 3162 Even if a mailbox is selected, a SELECT, EXAMINE, or LOGOUT command 3163 MAY be issued without previously issuing a CLOSE command. The 3164 SELECT, EXAMINE, and LOGOUT commands implicitly close the currently 3165 selected mailbox without doing an expunge. However, when many 3166 messages are deleted, a CLOSE-LOGOUT or CLOSE-SELECT sequence is 3167 considerably faster than an EXPUNGE-LOGOUT or EXPUNGE-SELECT because 3168 no untagged EXPUNGE responses (which the client would probably 3169 ignore) are sent. 3171 Example: C: A341 CLOSE 3172 S: A341 OK CLOSE completed 3174 6.4.2. UNSELECT Command 3176 Arguments: none 3178 Responses: no specific responses for this command 3180 Result: OK - unselect completed, now in authenticated state 3181 BAD - no mailbox selected, or argument supplied but none 3182 permitted 3184 The UNSELECT command frees server's resources associated with the 3185 selected mailbox and returns the server to the authenticated state. 3186 This command performs the same actions as CLOSE, except that no 3187 messages are permanently removed from the currently selected mailbox. 3189 Example: C: A342 UNSELECT 3190 S: A342 OK Unselect completed 3192 6.4.3. EXPUNGE Command 3194 Arguments: none 3196 Responses: untagged responses: EXPUNGE 3198 Result: OK - expunge completed 3199 NO - expunge failure: can't expunge (e.g., permission 3200 denied) 3201 BAD - command unknown or arguments invalid 3203 The EXPUNGE command permanently removes all messages that have the 3204 \Deleted flag set from the currently selected mailbox. Before 3205 returning an OK to the client, an untagged EXPUNGE response is sent 3206 for each message that is removed. 3208 Example: C: A202 EXPUNGE 3209 S: * 3 EXPUNGE 3210 S: * 3 EXPUNGE 3211 S: * 5 EXPUNGE 3212 S: * 8 EXPUNGE 3213 S: A202 OK EXPUNGE completed 3215 Note: In this example, messages 3, 4, 7, and 11 had the \Deleted flag 3216 set. See the description of the EXPUNGE response for further 3217 explanation. 3219 6.4.4. SEARCH Command 3221 Arguments: OPTIONAL result specifier 3222 OPTIONAL [CHARSET] specification 3223 searching criteria (one or more) 3225 Responses: REQUIRED untagged response: ESEARCH 3227 Result: OK - search completed 3228 NO - search error: can't search that [CHARSET] or 3229 criteria 3230 BAD - command unknown or arguments invalid 3232 The SEARCH command searches the mailbox for messages that match the 3233 given searching criteria. 3235 The SEARCH command may contain result options. Result options 3236 control what kind of information is returned about messages matching 3237 the search criteria in an untagged ESEARCH response. If no result 3238 option is specified or empty list of options is specified "()", ALL 3239 is assumed (see below). 3241 The order of individual options is arbitrary. Individual options may 3242 contain parameters enclosed in parentheses (*). If an option has 3243 parameters, they consist of atoms and/or strings and/or lists in a 3244 specific order. Any options not defined by extensions that the 3245 server supports must be rejected with a BAD response. 3247 (*) - if an option has a mandatory parameter, which can always be 3248 represented as a number or a sequence-set, the option parameter does 3249 not need the enclosing (). See ABNF for more details. 3251 This document specifies the following result options: 3253 MIN 3255 Return the lowest message number/UID that satisfies the SEARCH 3256 criteria. 3258 If the SEARCH results in no matches, the server MUST NOT 3259 include the MIN result option in the ESEARCH response; however, 3260 it still MUST send the ESEARCH response. 3262 MAX 3264 Return the highest message number/UID that satisfies the SEARCH 3265 criteria. 3267 If the SEARCH results in no matches, the server MUST NOT 3268 include the MAX result option in the ESEARCH response; however, 3269 it still MUST send the ESEARCH response. 3271 ALL 3273 Return all message numbers/UIDs that satisfy the SEARCH 3274 criteria using the sequence-set syntax. Note, the client MUST 3275 NOT assume that messages/UIDs will be listed in any particular 3276 order. 3278 If the SEARCH results in no matches, the server MUST NOT 3279 include the ALL result option in the ESEARCH response; however, 3280 it still MUST send the ESEARCH response. 3282 COUNT Return number of the messages that satisfy the SEARCH 3283 criteria. This result option MUST always be included in the 3284 ESEARCH response. 3286 Note: future extensions to this document can allow servers to return 3287 multiple ESEARCH responses for a single extended SEARCH command. 3288 However all options specified above MUST result in a single ESEARCH 3289 response. 3291 These extensions will have to describe how results from multiple 3292 ESEARCH responses are to be amalgamated. 3294 Searching criteria consist of one or more search keys. 3296 When multiple keys are specified, the result is the intersection (AND 3297 function) of all the messages that match those keys. For example, 3298 the criteria DELETED FROM "SMITH" SINCE 1-Feb-1994 refers to all 3299 deleted messages from Smith that were placed in the mailbox since 3300 February 1, 1994. A search key can also be a parenthesized list of 3301 one or more search keys (e.g., for use with the OR and NOT keys). 3303 Server implementations MAY exclude [MIME-IMB] body parts with 3304 terminal content media types other than TEXT and MESSAGE from 3305 consideration in SEARCH matching. 3307 The OPTIONAL [CHARSET] specification consists of the word "CHARSET" 3308 followed by a registered [CHARSET]. It indicates the [CHARSET] of 3309 the strings that appear in the search criteria. [MIME-IMB] content 3310 transfer encodings, and [MIME-HDRS] strings in [RFC-5322]/[MIME-IMB] 3311 headers, MUST be decoded before comparing text. Servers MUST support 3312 US-ASCII and UTF-8 charsets; other [CHARSET]s MAY be supported. 3313 Clients SHOULD use UTF-8. Note that if "CHARSET" is not provided 3314 IMAP4rev2 server MUST assume UTF-8, so selecting CHARSET UTF-8 is 3315 redundant. It is permitted for improved compatibility with existing 3316 IMAP4rev1 clients. 3318 If the server does not support the specified [CHARSET], it MUST 3319 return a tagged NO response (not a BAD). This response SHOULD 3320 contain the BADCHARSET response code, which MAY list the [CHARSET]s 3321 supported by the server. 3323 In all search keys that use strings, a message matches the key if the 3324 string is a substring of the associated text. The matching SHOULD be 3325 case-insensitive for characters within ASCII range. Consider using 3326 [IMAP-I18N] for language-sensitive case-insensitive searching. Note 3327 that the empty string is a substring; this is useful when doing a 3328 HEADER search in order to test for a header field presence in the 3329 message. 3331 The defined search keys are as follows. Refer to the Formal Syntax 3332 section for the precise syntactic definitions of the arguments. 3334 3336 Messages with message sequence numbers corresponding 3337 to the specified message sequence number set. 3339 ALL All messages in the mailbox; the default initial key for ANDing. 3341 ANSWERED Messages with the \Answered flag set. 3343 BCC Messages that contain the specified string in the 3344 envelope structure's BCC field. 3346 BEFORE Messages whose internal date (disregarding time and 3347 timezone) is earlier than the specified date. 3349 BODY Messages that contain the specified string in the body 3350 of the message. Unlike TEXT (see below), this doesn't match any 3351 header fields. 3353 CC Messages that contain the specified string in the 3354 envelope structure's CC field. 3356 DELETED Messages with the \Deleted flag set. 3358 DRAFT Messages with the \Draft flag set. 3360 FLAGGED Messages with the \Flagged flag set. 3362 FROM Messages that contain the specified string in the 3363 envelope structure's FROM field. 3365 HEADER Messages that have a header with the 3366 specified field-name (as defined in [RFC-5322]) and that contains 3367 the specified string in the text of the header (what comes after 3368 the colon). If the string to search is zero-length, this matches 3369 all messages that have a header line with the specified field-name 3370 regardless of the contents. Servers should use substring search 3371 for this SEARCH item, as clients can use it for automatic 3372 processing not initiated by end users. For example this can be 3373 used for searching for Message-ID or Content-Type header field 3374 values that need to be exact, or for searches in header fields 3375 that the IMAP server might not know anything about. 3377 KEYWORD Messages with the specified keyword flag set. 3379 LARGER Messages with an [RFC-5322] size larger than the 3380 specified number of octets. 3382 NOT Messages that do not match the specified search 3383 key. 3385 ON Messages whose internal date (disregarding time and 3386 timezone) is within the specified date. 3388 OR Messages that match either search 3389 key. 3391 SEEN Messages that have the \Seen flag set. 3393 SENTBEFORE Messages whose [RFC-5322] Date: header 3394 (disregarding time and timezone) is earlier than the specified 3395 date. 3397 SENTON Messages whose [RFC-5322] Date: header (disregarding 3398 time and timezone) is within the specified date. 3400 SENTSINCE Messages whose [RFC-5322] Date: header 3401 (disregarding time and timezone) is within or later than the 3402 specified date. 3404 SINCE Messages whose internal date (disregarding time and 3405 timezone) is within or later than the specified date. 3407 SMALLER Messages with an [RFC-5322] size smaller than the 3408 specified number of octets. 3410 SUBJECT Messages that contain the specified string in the 3411 envelope structure's SUBJECT field. 3413 TEXT Messages that contain the specified string in the 3414 header (including MIME header fields) or body of the message. 3416 TO Messages that contain the specified string in the 3417 envelope structure's TO field. 3419 UID Messages with unique identifiers corresponding to 3420 the specified unique identifier set. Sequence set ranges are 3421 permitted. 3423 UNANSWERED Messages that do not have the \Answered flag set. 3425 UNDELETED Messages that do not have the \Deleted flag set. 3427 UNDRAFT Messages that do not have the \Draft flag set. 3429 UNFLAGGED Messages that do not have the \Flagged flag set. 3431 UNKEYWORD Messages that do not have the specified keyword 3432 flag set. 3434 UNSEEN Messages that do not have the \Seen flag set. 3436 Example: C: A282 SEARCH RETURN (MIN COUNT) FLAGGED 3437 SINCE 1-Feb-1994 NOT FROM "Smith" 3438 S: * ESEARCH (TAG "A282") MIN 2 COUNT 3 3439 S: A282 OK SEARCH completed 3441 Example: C: A283 SEARCH RETURN () FLAGGED 3442 SINCE 1-Feb-1994 NOT FROM "Smith" 3443 S: * ESEARCH (TAG "A283") ALL 2,10:11 3444 S: A283 OK SEARCH completed 3446 Example: C: A284 SEARCH TEXT "string not in mailbox" 3447 S: * ESEARCH (TAG "A284") 3448 S: A284 OK SEARCH completed 3449 C: A285 SEARCH CHARSET UTF-8 TEXT {6} 3450 S: + Ready for literal text 3451 C: XXXXXX 3452 S: * ESEARCH (TAG "A285") ALL 43 3453 S: A285 OK SEARCH completed 3455 Note: Since this document is restricted to 7-bit ASCII text, it is 3456 not possible to show actual UTF-8 data. The "XXXXXX" is a 3457 placeholder for what would be 6 octets of 8-bit data in an actual 3458 transaction. 3460 The following example demonstrates finding the first unseen message 3461 in the mailbox: 3463 Example: C: A284 SEARCH RETURN (MIN) UNSEEN 3464 S: * ESEARCH (TAG "A284") MIN 4 3465 S: A284 OK SEARCH completed 3467 The following example demonstrates that if the ESEARCH UID indicator 3468 is present, all data in the ESEARCH response is referring to UIDs; 3469 for example, the MIN result specifier will be followed by a UID. 3471 Example: C: A285 UID SEARCH RETURN (MIN MAX) 1:5000 3472 S: * ESEARCH (TAG "A285") UID MIN 7 MAX 3800 3473 S: A285 OK SEARCH completed 3475 The following example demonstrates returning the number of deleted 3476 messages: 3478 Example: C: A286 SEARCH RETURN (COUNT) DELETED 3479 S: * ESEARCH (TAG "A286") COUNT 15 3480 S: A286 OK SEARCH completed 3482 6.4.5. FETCH Command 3484 Arguments: sequence set 3485 message data item names or macro 3487 Responses: untagged responses: FETCH 3489 Result: OK - fetch completed 3490 NO - fetch error: can't fetch that data 3491 BAD - command unknown or arguments invalid 3493 The FETCH command retrieves data associated with a message in the 3494 mailbox. The data items to be fetched can be either a single atom or 3495 a parenthesized list. 3497 Most data items, identified in the formal syntax under the msg-att- 3498 static rule, are static and MUST NOT change for any particular 3499 message. Other data items, identified in the formal syntax under the 3500 msg-att-dynamic rule, MAY change, either as a result of a STORE 3501 command or due to external events. 3503 For example, if a client receives an ENVELOPE for a message when 3504 it already knows the envelope, it can safely ignore the newly 3505 transmitted envelope. 3507 There are three macros which specify commonly-used sets of data 3508 items, and can be used instead of data items. A macro must be used 3509 by itself, and not in conjunction with other macros or data items. 3511 ALL Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE) 3513 FAST Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE) 3515 FULL Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE 3516 BODY) 3518 The currently defined data items that can be fetched are: 3520 BINARY[]<> 3522 Requests that the specified section be transmitted after 3523 performing Content-Transfer-Encoding-related decoding. 3525 The argument, if present, requests that a subset of 3526 the data be returned. The semantics of a partial FETCH BINARY 3527 command are the same as for a partial FETCH BODY command, with 3528 the exception that the arguments refer to the DECODED 3529 section data. 3531 BINARY.PEEK[]<> An alternate form of 3532 BINARY[] that does not implicitly set the \Seen 3533 flag. 3535 BINARY.SIZE[] 3537 Requests the decoded size of the section (i.e., the size to 3538 expect in response to the corresponding FETCH BINARY request). 3540 Note: client authors are cautioned that this might be an 3541 expensive operation for some server implementations. 3542 Needlessly issuing this request could result in degraded 3543 performance due to servers having to calculate the value every 3544 time the request is issued. 3546 BODY Non-extensible form of BODYSTRUCTURE. 3548 BODY[
]<> 3550 The text of a particular body section. The section 3551 specification is a set of zero or more part specifiers 3552 delimited by periods. A part specifier is either a part number 3553 or one of the following: HEADER, HEADER.FIELDS, 3554 HEADER.FIELDS.NOT, MIME, and TEXT. An empty section 3555 specification refers to the entire message, including the 3556 header. 3558 Every message has at least one part number. Non-[MIME-IMB] 3559 messages, and non-multipart [MIME-IMB] messages with no 3560 encapsulated message, only have a part 1. 3562 Multipart messages are assigned consecutive part numbers, as 3563 they occur in the message. If a particular part is of type 3564 message or multipart, its parts MUST be indicated by a period 3565 followed by the part number within that nested multipart part. 3567 A part of type MESSAGE/RFC822 or MESSAGE/GLOBAL also has nested 3568 part numbers, referring to parts of the MESSAGE part's body. 3570 The HEADER, HEADER.FIELDS, HEADER.FIELDS.NOT, and TEXT part 3571 specifiers can be the sole part specifier or can be prefixed by 3572 one or more numeric part specifiers, provided that the numeric 3573 part specifier refers to a part of type MESSAGE/RFC822 or 3574 MESSAGE/GLOBAL. The MIME part specifier MUST be prefixed by 3575 one or more numeric part specifiers. 3577 The HEADER, HEADER.FIELDS, and HEADER.FIELDS.NOT part 3578 specifiers refer to the [RFC-5322] header of the message or of 3579 an encapsulated [MIME-IMT] MESSAGE/RFC822 or MESSAGE/GLOBAL 3580 message. HEADER.FIELDS and HEADER.FIELDS.NOT are followed by a 3581 list of field-name (as defined in [RFC-5322]) names, and return 3582 a subset of the header. The subset returned by HEADER.FIELDS 3583 contains only those header fields with a field-name that 3584 matches one of the names in the list; similarly, the subset 3585 returned by HEADER.FIELDS.NOT contains only the header fields 3586 with a non-matching field-name. The field-matching is ASCII 3587 range case-insensitive but otherwise exact. Subsetting does 3588 not exclude the [RFC-5322] delimiting blank line between the 3589 header and the body; the blank line is included in all header 3590 fetches, except in the case of a message which has no body and 3591 no blank line. 3593 The MIME part specifier refers to the [MIME-IMB] header for 3594 this part. 3596 The TEXT part specifier refers to the text body of the message, 3597 omitting the [RFC-5322] header. 3599 Here is an example of a complex message with some of its 3600 part specifiers: 3602 HEADER ([RFC-5322] header of the message) 3603 TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 3604 1 TEXT/PLAIN 3605 2 APPLICATION/OCTET-STREAM 3606 3 MESSAGE/RFC822 3607 3.HEADER ([RFC-5322] header of the message) 3608 3.TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 3609 3.1 TEXT/PLAIN 3610 3.2 APPLICATION/OCTET-STREAM 3611 4 MULTIPART/MIXED 3612 4.1 IMAGE/GIF 3613 4.1.MIME ([MIME-IMB] header for the IMAGE/GIF) 3614 4.2 MESSAGE/RFC822 3615 4.2.HEADER ([RFC-5322] header of the message) 3616 4.2.TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 3617 4.2.1 TEXT/PLAIN 3618 4.2.2 MULTIPART/ALTERNATIVE 3619 4.2.2.1 TEXT/PLAIN 3620 4.2.2.2 TEXT/RICHTEXT 3622 It is possible to fetch a substring of the designated text. 3623 This is done by appending an open angle bracket ("<"), the 3624 octet position of the first desired octet, a period, the 3625 maximum number of octets desired, and a close angle bracket 3626 (">") to the part specifier. If the starting octet is beyond 3627 the end of the text, an empty string is returned. 3629 Any partial fetch that attempts to read beyond the end of the 3630 text is truncated as appropriate. A partial fetch that starts 3631 at octet 0 is returned as a partial fetch, even if this 3632 truncation happened. 3634 Note: This means that BODY[]<0.2048> of a 1500-octet message 3635 will return BODY[]<0> with a literal of size 1500, not 3636 BODY[]. 3638 Note: A substring fetch of a HEADER.FIELDS or 3639 HEADER.FIELDS.NOT part specifier is calculated after 3640 subsetting the header. 3642 The \Seen flag is implicitly set; if this causes the flags to 3643 change, they SHOULD be included as part of the FETCH responses. 3645 BODY.PEEK[
]<> An alternate form of BODY[
] 3646 that does not implicitly set the \Seen flag. 3648 BODYSTRUCTURE The [MIME-IMB] body structure of the message. This is 3649 computed by the server by parsing the [MIME-IMB] header fields in 3650 the [RFC-5322] header and [MIME-IMB] headers. 3652 ENVELOPE The envelope structure of the message. This is computed by 3653 the server by parsing the [RFC-5322] header into the component 3654 parts, defaulting various fields as necessary. 3656 FLAGS The flags that are set for this message. 3658 INTERNALDATE The internal date of the message. 3660 RFC822.SIZE The [RFC-5322] size of the message. 3662 UID The unique identifier for the message. 3664 Example: C: A654 FETCH 2:4 (FLAGS BODY[HEADER.FIELDS (DATE FROM)]) 3665 S: * 2 FETCH .... 3666 S: * 3 FETCH .... 3667 S: * 4 FETCH .... 3668 S: A654 OK FETCH completed 3670 6.4.6. STORE Command 3672 Arguments: sequence set 3673 message data item name 3674 value for message data item 3676 Responses: untagged responses: FETCH 3678 Result: OK - store completed 3679 NO - store error: can't store that data 3680 BAD - command unknown or arguments invalid 3682 The STORE command alters data associated with a message in the 3683 mailbox. Normally, STORE will return the updated value of the data 3684 with an untagged FETCH response. A suffix of ".SILENT" in the data 3685 item name prevents the untagged FETCH, and the server SHOULD assume 3686 that the client has determined the updated value itself or does not 3687 care about the updated value. 3689 Note: Regardless of whether or not the ".SILENT" suffix was used, 3690 the server SHOULD send an untagged FETCH response if a change to a 3691 message's flags from an external source is observed. The intent 3692 is that the status of the flags is determinate without a race 3693 condition. 3695 The currently defined data items that can be stored are: 3697 FLAGS Replace the flags for the message with the 3698 argument. The new value of the flags is returned as if a FETCH of 3699 those flags was done. 3701 FLAGS.SILENT Equivalent to FLAGS, but without returning 3702 a new value. 3704 +FLAGS Add the argument to the flags for the message. 3705 The new value of the flags is returned as if a FETCH of those 3706 flags was done. 3708 +FLAGS.SILENT Equivalent to +FLAGS, but without 3709 returning a new value. 3711 -FLAGS Remove the argument from the flags for the 3712 message. The new value of the flags is returned as if a FETCH of 3713 those flags was done. 3715 -FLAGS.SILENT Equivalent to -FLAGS, but without 3716 returning a new value. 3718 Example: C: A003 STORE 2:4 +FLAGS (\Deleted) 3719 S: * 2 FETCH (FLAGS (\Deleted \Seen)) 3720 S: * 3 FETCH (FLAGS (\Deleted)) 3721 S: * 4 FETCH (FLAGS (\Deleted \Flagged \Seen)) 3722 S: A003 OK STORE completed 3724 6.4.7. COPY Command 3726 Arguments: sequence set 3727 mailbox name 3729 Responses: no specific responses for this command 3731 Result: OK - copy completed 3732 NO - copy error: can't copy those messages or to that 3733 name 3734 BAD - command unknown or arguments invalid 3736 The COPY command copies the specified message(s) to the end of the 3737 specified destination mailbox. The flags and internal date of the 3738 message(s) SHOULD be preserved in the copy. 3740 If the destination mailbox does not exist, a server SHOULD return an 3741 error. It SHOULD NOT automatically create the mailbox. Unless it is 3742 certain that the destination mailbox can not be created, the server 3743 MUST send the response code "[TRYCREATE]" as the prefix of the text 3744 of the tagged NO response. This gives a hint to the client that it 3745 can attempt a CREATE command and retry the COPY if the CREATE is 3746 successful. 3748 If the COPY command is unsuccessful for any reason, server 3749 implementations MUST restore the destination mailbox to its state 3750 before the COPY attempt. 3752 On successful completion of a COPY, the server SHOULD return a 3753 COPYUID response code. 3755 In the case of a mailbox that has permissions set so that the client 3756 can COPY to the mailbox, but not SELECT or EXAMINE it, the server 3757 SHOULD NOT send an COPYUID response code as it would disclose 3758 information about the mailbox. 3760 In the case of a mailbox that has UIDNOTSTICKY status (see the 3761 UIDNOTSTICKY response code), the server MAY omit the COPYUID response 3762 code as it is not meaningful. 3764 If the server does not return the COPYUID response code, the client 3765 can discover this information by selecting the destination mailbox. 3767 The location of messages placed in the destination mailbox by COPY 3768 can be determined by using FETCH and/or SEARCH commands (e.g., for 3769 Message-ID). 3771 Example: C: A003 COPY 2:4 MEETING 3772 S: A003 OK COPY completed 3774 6.4.8. MOVE Command 3776 Arguments: sequence set 3777 mailbox name 3779 Responses: no specific responses for this command 3781 Result: OK - move completed 3782 NO - move error: can't move those messages or to that 3783 name 3784 BAD - command unknown or arguments invalid 3786 The MOVE command moves the specified message(s) to the end of the 3787 specified destination mailbox. The flags and internal date of the 3788 message(s) SHOULD be preserved. 3790 This means that a new message is created in the target mailbox with a 3791 new UID, the original message is removed from the source mailbox, and 3792 it appears to the client as a single action. This has the same 3793 effect for each message as this sequence: 3795 1. [UID] COPY 3797 2. [UID] STORE +FLAGS.SILENT \DELETED 3799 3. UID EXPUNGE 3801 Although the effect of the MOVE is the same as the preceding steps, 3802 the semantics are not identical: The intermediate states produced by 3803 those steps do not occur, and the response codes are different. In 3804 particular, though the COPY and EXPUNGE response codes will be 3805 returned, response codes for a STORE MUST NOT be generated and the 3806 \Deleted flag MUST NOT be set for any message. 3808 Because a MOVE applies to a set of messages, it might fail partway 3809 through the set. Regardless of whether the command is successful in 3810 moving the entire set, each individual message SHOULD either be moved 3811 or unaffected. The server MUST leave each message in a state where 3812 it is in at least one of the source or target mailboxes (no message 3813 can be lost or orphaned). The server SHOULD NOT leave any message in 3814 both mailboxes (it would be bad for a partial failure to result in a 3815 bunch of duplicate messages). This is true even if the server 3816 returns a tagged NO response to the command. 3818 Because of the similarity of MOVE to COPY, extensions that affect 3819 COPY affect MOVE in the same way. Response codes such as TRYCREATE 3820 (see Section 7.1), as well as those defined by extensions, are sent 3821 as appropriate. 3823 Servers SHOULD send COPYUID in response to a UID MOVE (see 3824 Section 6.4.9) command. For additional information see Section 7.1. 3826 Servers are also advised to send the COPYUID response code in an 3827 untagged OK before sending EXPUNGE or moved responses. (Sending 3828 COPYUID in the tagged OK, as described in the UIDPLUS specification, 3829 means that clients first receive an EXPUNGE for a message and 3830 afterwards COPYUID for the same message. It can be unnecessarily 3831 difficult to process that sequence usefully.) 3833 An example: 3834 C: a UID MOVE 42:69 foo 3835 S: * OK [COPYUID 432432 42:69 1202:1229] 3836 S: * 22 EXPUNGE 3837 S: (more expunges) 3838 S: a OK Done 3840 Note that the server may send unrelated EXPUNGE responses as well, if 3841 any happen to have been expunged at the same time; this is normal 3842 IMAP operation. 3844 Note that moving a message to the currently selected mailbox (that 3845 is, where the source and target mailboxes are the same) is allowed 3846 when copying the message to the currently selected mailbox is 3847 allowed. 3849 The server may send EXPUNGE responses before the tagged response, so 3850 the client cannot safely send more commands with message sequence 3851 number arguments while the server is processing MOVE. 3853 MOVE and UID MOVE can be pipelined with other commands, but care has 3854 to be taken. Both commands modify sequence numbers and also allow 3855 unrelated EXPUNGE responses. The renumbering of other messages in 3856 the source mailbox following any EXPUNGE response can be surprising 3857 and makes it unsafe to pipeline any command that relies on message 3858 sequence numbers after a MOVE or UID MOVE. Similarly, MOVE cannot be 3859 pipelined with a command that might cause message renumbering. See 3860 Section 5.5, for more information about ambiguities as well as 3861 handling requirements for both clients and servers. 3863 6.4.9. UID Command 3865 Arguments: command name 3866 command arguments 3868 Responses: untagged responses: FETCH, ESEARCH, EXPUNGE 3870 Result: OK - UID command completed 3871 NO - UID command error 3872 BAD - command unknown or arguments invalid 3874 The UID command has three forms. In the first form, it takes as its 3875 arguments a COPY, MOVE, FETCH, or STORE command with arguments 3876 appropriate for the associated command. However, the numbers in the 3877 sequence set argument are unique identifiers instead of message 3878 sequence numbers. Sequence set ranges are permitted, but there is no 3879 guarantee that unique identifiers will be contiguous. 3881 A non-existent unique identifier is ignored without any error message 3882 generated. Thus, it is possible for a UID FETCH command to return an 3883 OK without any data or a UID COPY, UID MOVE or UID STORE to return an 3884 OK without performing any operations. 3886 In the second form, the UID command takes an EXPUNGE command with an 3887 extra parameter the specified a sequence set of UIDs to operate on. 3888 The UID EXPUNGE command permanently removes all messages that both 3889 have the \Deleted flag set and have a UID that is included in the 3890 specified sequence set from the currently selected mailbox. If a 3891 message either does not have the \Deleted flag set or has a UID that 3892 is not included in the specified sequence set, it is not affected. 3894 UID EXPUNGE is particularly useful for disconnected use clients. 3895 By using UID EXPUNGE instead of EXPUNGE when resynchronizing with 3896 the server, the client can ensure that it does not inadvertantly 3897 remove any messages that have been marked as \Deleted by other 3898 clients between the time that the client was last connected and 3899 the time the client resynchronizes. 3901 Example: C: A003 UID EXPUNGE 3000:3002 3902 S: * 3 EXPUNGE 3903 S: * 3 EXPUNGE 3904 S: * 3 EXPUNGE 3905 S: A003 OK UID EXPUNGE completed 3907 In the third form, the UID command takes a SEARCH command with SEARCH 3908 command arguments. The interpretation of the arguments is the same 3909 as with SEARCH; however, the numbers returned in a ESEARCH response 3910 for a UID SEARCH command are unique identifiers instead of message 3911 sequence numbers. Also, the corresponding ESEARCH response MUST 3912 include the UID indicator. For example, the command UID SEARCH 1:100 3913 UID 443:557 returns the unique identifiers corresponding to the 3914 intersection of two sequence sets, the message sequence number range 3915 1:100 and the UID range 443:557. 3917 Note: in the above example, the UID range 443:557 appears. The 3918 same comment about a non-existent unique identifier being ignored 3919 without any error message also applies here. Hence, even if 3920 neither UID 443 or 557 exist, this range is valid and would 3921 include an existing UID 495. 3923 Also note that a UID range of 559:* always includes the UID of the 3924 last message in the mailbox, even if 559 is higher than any 3925 assigned UID value. This is because the contents of a range are 3926 independent of the order of the range endpoints. Thus, any UID 3927 range with * as one of the endpoints indicates at least one 3928 message (the message with the highest numbered UID), unless the 3929 mailbox is empty. 3931 The number after the "*" in an untagged FETCH or EXPUNGE response is 3932 always a message sequence number, not a unique identifier, even for a 3933 UID command response. However, server implementations MUST 3934 implicitly include the UID message data item as part of any FETCH 3935 response caused by a UID command, regardless of whether a UID was 3936 specified as a message data item to the FETCH. 3938 Note: The rule about including the UID message data item as part of a 3939 FETCH response primarily applies to the UID FETCH and UID STORE 3940 commands, including a UID FETCH command that does not include UID as 3941 a message data item. Although it is unlikely that the other UID 3942 commands will cause an untagged FETCH, this rule applies to these 3943 commands as well. 3945 Example: C: A999 UID FETCH 4827313:4828442 FLAGS 3946 S: * 23 FETCH (FLAGS (\Seen) UID 4827313) 3947 S: * 24 FETCH (FLAGS (\Seen) UID 4827943) 3948 S: * 25 FETCH (FLAGS (\Seen) UID 4828442) 3949 S: A999 OK UID FETCH completed 3951 6.5. Client Commands - Experimental/Expansion 3953 6.5.1. X Command 3955 Arguments: implementation defined 3957 Responses: implementation defined 3958 Result: OK - command completed 3959 NO - failure 3960 BAD - command unknown or arguments invalid 3962 Any command prefixed with an X is an experimental command. Commands 3963 which are not part of this specification, a standard or standards- 3964 track revision of this specification, or an IESG-approved 3965 experimental protocol, MUST use the X prefix. 3967 Any added untagged responses issued by an experimental command MUST 3968 also be prefixed with an X. Server implementations MUST NOT send any 3969 such untagged responses, unless the client requested it by issuing 3970 the associated experimental command. 3972 Example: C: a441 CAPABILITY 3973 S: * CAPABILITY IMAP4rev2 XPIG-LATIN 3974 S: a441 OK CAPABILITY completed 3975 C: A442 XPIG-LATIN 3976 S: * XPIG-LATIN ow-nay eaking-spay ig-pay atin-lay 3977 S: A442 OK XPIG-LATIN ompleted-cay 3979 7. Server Responses 3981 Server responses are in three forms: status responses, server data, 3982 and command continuation request. The information contained in a 3983 server response, identified by "Contents:" in the response 3984 descriptions below, is described by function, not by syntax. The 3985 precise syntax of server responses is described in the Formal Syntax 3986 section. 3988 The client MUST be prepared to accept any response at all times. 3990 Status responses can be tagged or untagged. Tagged status responses 3991 indicate the completion result (OK, NO, or BAD status) of a client 3992 command, and have a tag matching the command. 3994 Some status responses, and all server data, are untagged. An 3995 untagged response is indicated by the token "*" instead of a tag. 3996 Untagged status responses indicate server greeting, or server status 3997 that does not indicate the completion of a command (for example, an 3998 impending system shutdown alert). For historical reasons, untagged 3999 server data responses are also called "unsolicited data", although 4000 strictly speaking, only unilateral server data is truly 4001 "unsolicited". 4003 Certain server data MUST be recorded by the client when it is 4004 received; this is noted in the description of that data. Such data 4005 conveys critical information which affects the interpretation of all 4006 subsequent commands and responses (e.g., updates reflecting the 4007 creation or destruction of messages). 4009 Other server data SHOULD be recorded for later reference; if the 4010 client does not need to record the data, or if recording the data has 4011 no obvious purpose (e.g., a SEARCH response when no SEARCH command is 4012 in progress), the data SHOULD be ignored. 4014 An example of unilateral untagged server data occurs when the IMAP 4015 connection is in the selected state. In the selected state, the 4016 server checks the mailbox for new messages as part of command 4017 execution. Normally, this is part of the execution of every command; 4018 hence, a NOOP command suffices to check for new messages. If new 4019 messages are found, the server sends untagged EXISTS response 4020 reflecting the new size of the mailbox. Server implementations that 4021 offer multiple simultaneous access to the same mailbox SHOULD also 4022 send appropriate unilateral untagged FETCH and EXPUNGE responses if 4023 another agent changes the state of any message flags or expunges any 4024 messages. 4026 Command continuation request responses use the token "+" instead of a 4027 tag. These responses are sent by the server to indicate acceptance 4028 of an incomplete client command and readiness for the remainder of 4029 the command. 4031 7.1. Server Responses - Status Responses 4033 Status responses are OK, NO, BAD, PREAUTH and BYE. OK, NO, and BAD 4034 can be tagged or untagged. PREAUTH and BYE are always untagged. 4036 Status responses MAY include an OPTIONAL "response code". A response 4037 code consists of data inside square brackets in the form of an atom, 4038 possibly followed by a space and arguments. The response code 4039 contains additional information or status codes for client software 4040 beyond the OK/NO/BAD condition, and are defined when there is a 4041 specific action that a client can take based upon the additional 4042 information. 4044 The currently defined response codes are: 4046 ALERT 4048 The human-readable text contains a special alert that MUST be 4049 presented to the user in a fashion that calls the user's 4050 attention to the message. 4052 ALREADYEXISTS 4053 The operation attempts to create something that already exists, 4054 such as when the CREATE or RENAME directories attempt to create 4055 a mailbox and there is already one of that name. 4057 C: o RENAME this that 4058 S: o NO [ALREADYEXISTS] Mailbox "that" already exists 4060 APPENDUID 4062 Followed by the UIDVALIDITY of the destination mailbox and the 4063 UID assigned to the appended message in the destination 4064 mailbox, indicates that the message has been appended to the 4065 destination mailbox with that UID. 4067 If the server also supports the [MULTIAPPEND] extension, and if 4068 multiple messages were appended in the APPEND command, then the 4069 second value is a UID set containing the UIDs assigned to the 4070 appended messages, in the order they were transmitted in the 4071 APPEND command. This UID set may not contain extraneous UIDs 4072 or the symbol "*". 4074 Note: the UID set form of the APPENDUID response code MUST 4075 NOT be used if only a single message was appended. In 4076 particular, a server MUST NOT send a range such as 123:123. 4077 This is because a client that does not support [MULTIAPPEND] 4078 expects only a single UID and not a UID set. 4080 UIDs are assigned in strictly ascending order in the mailbox 4081 (refer to Section 2.3.1.1); note that a range of 12:10 is 4082 exactly equivalent to 10:12 and refers to the sequence 4083 10,11,12. 4085 This response code is returned in a tagged OK response to the 4086 APPEND command. 4088 AUTHENTICATIONFAILED 4090 Authentication failed for some reason on which the server is 4091 unwilling to elaborate. Typically, this includes "unknown 4092 user" and "bad password". 4094 This is the same as not sending any response code, except that 4095 when a client sees AUTHENTICATIONFAILED, it knows that the 4096 problem wasn't, e.g., UNAVAILABLE, so there's no point in 4097 trying the same login/password again later. 4099 C: b LOGIN "fred" "foo" 4100 S: b NO [AUTHENTICATIONFAILED] Authentication failed 4102 AUTHORIZATIONFAILED 4104 Authentication succeeded in using the authentication identity, 4105 but the server cannot or will not allow the authentication 4106 identity to act as the requested authorization identity. This 4107 is only applicable when the authentication and authorization 4108 identities are different. 4110 C: c1 AUTHENTICATE PLAIN 4111 [...] 4112 S: c1 NO [AUTHORIZATIONFAILED] No such authorization-ID 4114 C: c2 AUTHENTICATE PLAIN 4115 [...] 4116 S: c2 NO [AUTHORIZATIONFAILED] Authenticator is not an admin 4118 BADCHARSET 4120 Optionally followed by a parenthesized list of charsets. A 4121 SEARCH failed because the given charset is not supported by 4122 this implementation. If the optional list of charsets is 4123 given, this lists the charsets that are supported by this 4124 implementation. 4126 CANNOT 4128 The operation violates some invariant of the server and can 4129 never succeed. 4131 C: l create "///////" 4132 S: l NO [CANNOT] Adjacent slashes are not supported 4134 CAPABILITY 4136 Followed by a list of capabilities. This can appear in the 4137 initial OK or PREAUTH response to transmit an initial 4138 capabilities list. It can also appear in tagged responses to 4139 LOGIN or AUTHENTICATE commands. This makes it unnecessary for 4140 a client to send a separate CAPABILITY command if it recognizes 4141 this response. 4143 CLIENTBUG 4144 The server has detected a client bug. This can accompany all 4145 of OK, NO, and BAD, depending on what the client bug is. 4147 C: k1 select "/archive/projects/experiment-iv" 4148 [...] 4149 S: k1 OK [READ-ONLY] Done 4150 C: k2 status "/archive/projects/experiment-iv" (messages) 4151 [...] 4152 S: k2 OK [CLIENTBUG] Done 4154 CLOSED 4156 The CLOSED response code has no parameters. A server return 4157 the CLOSED response code when the currently selected mailbox is 4158 closed implicitly using the SELECT/EXAMINE command on another 4159 mailbox. The CLOSED response code serves as a boundary between 4160 responses for the previously opened mailbox (which was closed) 4161 and the newly selected mailbox; all responses before the CLOSED 4162 response code relate to the mailbox that was closed, and all 4163 subsequent responses relate to the newly opened mailbox. 4165 There is no need to return the CLOSED response code on 4166 completion of the CLOSE or the UNSELECT command (or similar), 4167 whose purpose is to close the currently selected mailbox 4168 without opening a new one. 4170 The server can also return an unsolicited CLOSED response code 4171 when it wants to force the client to return to authenticated 4172 state. For example, the server can do that when the mailbox 4173 requires repairs or is deleted in another session. 4175 CONTACTADMIN 4177 The user should contact the system administrator or support 4178 desk. 4180 C: e login "fred" "foo" 4181 S: e OK [CONTACTADMIN] 4183 COPYUID 4185 Followed by the UIDVALIDITY of the destination mailbox, a UID 4186 set containing the UIDs of the message(s) in the source mailbox 4187 that were copied to the destination mailbox and containing the 4188 UIDs assigned to the copied message(s) in the destination 4189 mailbox, indicates that the message(s) have been copied to the 4190 destination mailbox with the stated UID(s). 4192 The source UID set is in the order the message(s) were copied; 4193 the destination UID set corresponds to the source UID set and 4194 is in the same order. Neither of the UID sets may contain 4195 extraneous UIDs or the symbol "*". 4197 UIDs are assigned in strictly ascending order in the mailbox 4198 (refer to Section 2.3.1.1); note that a range of 12:10 is 4199 exactly equivalent to 10:12 and refers to the sequence 4200 10,11,12. 4202 This response code is returned in a tagged OK response to the 4203 COPY command. 4205 CORRUPTION 4207 The server discovered that some relevant data (e.g., the 4208 mailbox) are corrupt. This response code does not include any 4209 information about what's corrupt, but the server can write that 4210 to its logfiles. 4212 C: i select "/archive/projects/experiment-iv" 4213 S: i NO [CORRUPTION] Cannot open mailbox 4215 EXPIRED 4217 Either authentication succeeded or the server no longer had the 4218 necessary data; either way, access is no longer permitted using 4219 that passphrase. The client or user should get a new 4220 passphrase. 4222 C: d login "fred" "foo" 4223 S: d NO [EXPIRED] That password isn't valid any more 4225 EXPUNGEISSUED 4227 Someone else has issued an EXPUNGE for the same mailbox. The 4228 client may want to issue NOOP soon. [IMAP-MULTIACCESS] 4229 discusses this subject in depth. 4231 C: h search from fred@example.com 4232 S: * ESEARCH (TAG "h") ALL 1:3,5,8,13,21,42 4233 S: h OK [EXPUNGEISSUED] Search completed 4235 INUSE 4237 An operation has not been carried out because it involves 4238 sawing off a branch someone else is sitting on. Someone else 4239 may be holding an exclusive lock needed for this operation, or 4240 the operation may involve deleting a resource someone else is 4241 using, typically a mailbox. 4243 The operation may succeed if the client tries again later. 4245 C: g delete "/archive/projects/experiment-iv" 4246 S: g NO [INUSE] Mailbox in use 4248 LIMIT 4250 The operation ran up against an implementation limit of some 4251 kind, such as the number of flags on a single message or the 4252 number of flags used in a mailbox. 4254 C: m STORE 42 FLAGS f1 f2 f3 f4 f5 ... f250 4255 S: m NO [LIMIT] At most 32 flags in one mailbox supported 4257 NONEXISTENT 4259 The operation attempts to delete something that does not exist. 4260 Similar to ALREADYEXISTS. 4262 C: p RENAME this that 4263 S: p NO [NONEXISTENT] No such mailbox 4265 NOPERM 4267 The access control system (e.g., Access Control List (ACL), see 4268 [RFC4314] does not permit this user to carry out an operation, 4269 such as selecting or creating a mailbox. 4271 C: f select "/archive/projects/experiment-iv" 4272 S: f NO [NOPERM] Access denied 4274 OVERQUOTA 4276 The user would be over quota after the operation. (The user 4277 may or may not be over quota already.) 4279 Note that if the server sends OVERQUOTA but doesn't support the 4280 IMAP QUOTA extension defined by [RFC2087], then there is a 4281 quota, but the client cannot find out what the quota is. 4283 C: n1 uid copy 1:* oldmail 4284 S: n1 NO [OVERQUOTA] Sorry 4286 C: n2 uid copy 1:* oldmail 4287 S: n2 OK [OVERQUOTA] You are now over your soft quota 4289 PARSE 4291 The human-readable text represents an error in parsing the 4292 [RFC-5322] header or [MIME-IMB] headers of a message in the 4293 mailbox. 4295 PERMANENTFLAGS 4297 Followed by a parenthesized list of flags, indicates which of 4298 the known flags the client can change permanently. Any flags 4299 that are in the FLAGS untagged response, but not the 4300 PERMANENTFLAGS list, can not be set permanently. The 4301 PERMANENTFLAGS list can also include the special flag \*, which 4302 indicates that it is possible to create new keywords by 4303 attempting to store those keywords in the mailbox. If the 4304 client attempts to STORE a flag that is not in the 4305 PERMANENTFLAGS list, the server will either ignore the change 4306 or store the state change for the remainder of the current 4307 session only. 4309 There is no need for a server that included the special flag \* 4310 to return a new PERMANENTFLAGS response code when a new keyword 4311 was successfully set on a message upon client request. However 4312 if the server has a limit on the number of different keywords 4313 that can be stored in a mailbox and that limit is reached, the 4314 server MUST send a new PERMANENTFLAGS response code without the 4315 special flag \*. 4317 PRIVACYREQUIRED 4319 The operation is not permitted due to a lack of privacy. If 4320 Transport Layer Security (TLS) is not in use, the client could 4321 try STARTTLS (see Section 6.2.1) and then repeat the operation. 4323 C: d login "fred" "foo" 4324 S: d NO [PRIVACYREQUIRED] Connection offers no privacy 4326 C: d select inbox 4327 S: d NO [PRIVACYREQUIRED] Connection offers no privacy 4329 READ-ONLY 4331 The mailbox is selected read-only, or its access while selected 4332 has changed from read-write to read-only. 4334 READ-WRITE 4336 The mailbox is selected read-write, or its access while 4337 selected has changed from read-only to read-write. 4339 SERVERBUG 4341 The server encountered a bug in itself or violated one of its 4342 own invariants. 4344 C: j select "/archive/projects/experiment-iv" 4345 S: j NO [SERVERBUG] This should not happen 4347 TRYCREATE 4349 An APPEND or COPY attempt is failing because the target mailbox 4350 does not exist (as opposed to some other reason). This is a 4351 hint to the client that the operation can succeed if the 4352 mailbox is first created by the CREATE command. 4354 UIDNEXT 4356 Followed by a decimal number, indicates the next unique 4357 identifier value. Refer to Section 2.3.1.1 for more 4358 information. 4360 UIDNOTSTICKY 4362 The selected mailbox is supported by a mail store that does not 4363 support persistent UIDs; that is, UIDVALIDITY will be different 4364 each time the mailbox is selected. Consequently, APPEND or 4365 COPY to this mailbox will not return an APPENDUID or COPYUID 4366 response code. 4368 This response code is returned in an untagged NO response to 4369 the SELECT command. 4371 Note: servers SHOULD NOT have any UIDNOTSTICKY mail stores. 4372 This facility exists to support legacy mail stores in which 4373 it is technically infeasible to support persistent UIDs. 4374 This should be avoided when designing new mail stores. 4376 UIDVALIDITY 4378 Followed by a decimal number, indicates the unique identifier 4379 validity value. Refer to Section 2.3.1.1 for more information. 4381 UNAVAILABLE 4383 Temporary failure because a subsystem is down. For example, an 4384 IMAP server that uses a Lightweight Directory Access Protocol 4385 (LDAP) or Radius server for authentication might use this 4386 response code when the LDAP/Radius server is down. 4388 C: a LOGIN "fred" "foo" 4389 S: a NO [UNAVAILABLE] User's backend down for maintenance 4391 UNKNOWN-CTE 4393 The server does not know how to decode the section's Content- 4394 Transfer-Encoding. 4396 Additional response codes defined by particular client or server 4397 implementations SHOULD be prefixed with an "X" until they are added 4398 to a revision of this protocol. Client implementations SHOULD ignore 4399 response codes that they do not recognize. 4401 7.1.1. OK Response 4403 Contents: OPTIONAL response code 4404 human-readable text 4406 The OK response indicates an information message from the server. 4407 When tagged, it indicates successful completion of the associated 4408 command. The human-readable text MAY be presented to the user as an 4409 information message. The untagged form indicates an information-only 4410 message; the nature of the information MAY be indicated by a response 4411 code. 4413 The untagged form is also used as one of three possible greetings at 4414 connection startup. It indicates that the connection is not yet 4415 authenticated and that a LOGIN or an AUTHENTICATE command is needed. 4417 Example: S: * OK IMAP4rev2 server ready 4418 C: A001 LOGIN fred blurdybloop 4419 S: * OK [ALERT] System shutdown in 10 minutes 4420 S: A001 OK LOGIN Completed 4422 7.1.2. NO Response 4424 Contents: OPTIONAL response code 4425 human-readable text 4427 The NO response indicates an operational error message from the 4428 server. When tagged, it indicates unsuccessful completion of the 4429 associated command. The untagged form indicates a warning; the 4430 command can still complete successfully. The human-readable text 4431 describes the condition. 4433 Example: C: A222 COPY 1:2 owatagusiam 4434 S: * NO Disk is 98% full, please delete unnecessary data 4435 S: A222 OK COPY completed 4436 C: A223 COPY 3:200 blurdybloop 4437 S: * NO Disk is 98% full, please delete unnecessary data 4438 S: * NO Disk is 99% full, please delete unnecessary data 4439 S: A223 NO COPY failed: disk is full 4441 7.1.3. BAD Response 4443 Contents: OPTIONAL response code 4444 human-readable text 4446 The BAD response indicates an error message from the server. When 4447 tagged, it reports a protocol-level error in the client's command; 4448 the tag indicates the command that caused the error. The untagged 4449 form indicates a protocol-level error for which the associated 4450 command can not be determined; it can also indicate an internal 4451 server failure. The human-readable text describes the condition. 4453 Example: C: ...very long command line... 4454 S: * BAD Command line too long 4455 C: ...empty line... 4456 S: * BAD Empty command line 4457 C: A443 EXPUNGE 4458 S: * BAD Disk crash, attempting salvage to a new disk! 4459 S: * OK Salvage successful, no data lost 4460 S: A443 OK Expunge completed 4462 7.1.4. PREAUTH Response 4464 Contents: OPTIONAL response code 4465 human-readable text 4467 The PREAUTH response is always untagged, and is one of three possible 4468 greetings at connection startup. It indicates that the connection 4469 has already been authenticated by external means; thus no LOGIN/ 4470 AUTHENTICATE command is needed. 4472 Example: S: * PREAUTH IMAP4rev2 server logged in as Smith 4474 7.1.5. BYE Response 4476 Contents: OPTIONAL response code 4477 human-readable text 4479 The BYE response is always untagged, and indicates that the server is 4480 about to close the connection. The human-readable text MAY be 4481 displayed to the user in a status report by the client. The BYE 4482 response is sent under one of four conditions: 4484 1. as part of a normal logout sequence. The server will close the 4485 connection after sending the tagged OK response to the LOGOUT 4486 command. 4488 2. as a panic shutdown announcement. The server closes the 4489 connection immediately. 4491 3. as an announcement of an inactivity autologout. The server 4492 closes the connection immediately. 4494 4. as one of three possible greetings at connection startup, 4495 indicating that the server is not willing to accept a connection 4496 from this client. The server closes the connection immediately. 4498 The difference between a BYE that occurs as part of a normal LOGOUT 4499 sequence (the first case) and a BYE that occurs because of a failure 4500 (the other three cases) is that the connection closes immediately in 4501 the failure case. In all cases the client SHOULD continue to read 4502 response data from the server until the connection is closed; this 4503 will ensure that any pending untagged or completion responses are 4504 read and processed. 4506 Example: S: * BYE Autologout; idle for too long 4508 7.2. Server Responses - Server and Mailbox Status 4510 These responses are always untagged. This is how server and mailbox 4511 status data are transmitted from the server to the client. Many of 4512 these responses typically result from a command with the same name. 4514 7.2.1. The ENABLED Response 4516 Contents: capability listing 4518 The ENABLED response occurs as a result of an ENABLE command. The 4519 capability listing contains a space-separated listing of capability 4520 names that the server supports and that were successfully enabled. 4522 The ENABLED response may contain no capabilities, which means that no 4523 extensions listed by the client were successfully enabled. 4525 7.2.2. CAPABILITY Response 4527 Contents: capability listing 4529 The CAPABILITY response occurs as a result of a CAPABILITY command. 4530 The capability listing contains a space-separated listing of 4531 capability names that the server supports. The capability listing 4532 MUST include the atom "IMAP4rev2". 4534 In addition, client and server implementations MUST implement the 4535 STARTTLS, LOGINDISABLED, and AUTH=PLAIN (described in [PLAIN]) 4536 capabilities. See the Security Considerations section for important 4537 information. 4539 A capability name which begins with "AUTH=" indicates that the server 4540 supports that particular authentication mechanism. 4542 The LOGINDISABLED capability indicates that the LOGIN command is 4543 disabled, and that the server will respond with a tagged NO response 4544 to any attempt to use the LOGIN command even if the user name and 4545 password are valid. An IMAP client MUST NOT issue the LOGIN command 4546 if the server advertises the LOGINDISABLED capability. 4548 Other capability names indicate that the server supports an 4549 extension, revision, or amendment to the IMAP4rev2 protocol. Server 4550 responses MUST conform to this document until the client issues a 4551 command that uses the associated capability. 4553 Capability names MUST either begin with "X" or be standard or 4554 standards-track IMAP4rev2 extensions, revisions, or amendments 4555 registered with IANA. A server MUST NOT offer unregistered or non- 4556 standard capability names, unless such names are prefixed with an 4557 "X". 4559 Client implementations SHOULD NOT require any capability name other 4560 than "IMAP4rev2", and MUST ignore any unknown capability names. 4562 A server MAY send capabilities automatically, by using the CAPABILITY 4563 response code in the initial PREAUTH or OK responses, and by sending 4564 an updated CAPABILITY response code in the tagged OK response as part 4565 of a successful authentication. It is unnecessary for a client to 4566 send a separate CAPABILITY command if it recognizes these automatic 4567 capabilities. 4569 Example: S: * CAPABILITY IMAP4rev2 STARTTLS AUTH=GSSAPI XPIG-LATIN 4571 7.2.3. LIST Response 4573 Contents: name attributes 4574 hierarchy delimiter 4575 name 4577 The LIST response occurs as a result of a LIST command. It returns a 4578 single name that matches the LIST specification. There can be 4579 multiple LIST responses for a single LIST command. 4581 The following base name attributes are defined: 4583 \NonExistent The "\NonExistent" attribute indicates that a mailbox 4584 name does not refer to an existing mailbox. Note that this 4585 attribute is not meaningful by itself, as mailbox names that match 4586 the canonical LIST pattern but don't exist must not be returned 4587 unless one of the two conditions listed below is also satisfied: 4589 1. The mailbox name also satisfies the selection criteria (for 4590 example, it is subscribed and the "SUBSCRIBED" selection 4591 option has been specified). 4593 2. "RECURSIVEMATCH" has been specified, and the mailbox name has 4594 at least one descendant mailbox name that does not match the 4595 LIST pattern and does match the selection criteria. 4597 In practice, this means that the "\NonExistent" attribute is 4598 usually returned with one or more of "\Subscribed", "\Remote", 4599 "\HasChildren", or the CHILDINFO extended data item. 4601 The "\NonExistent" attribute implies "\NoSelect". 4603 \Noinferiors It is not possible for any child levels of hierarchy to 4604 exist under this name; no child levels exist now and none can be 4605 created in the future. 4607 \Noselect It is not possible to use this name as a selectable 4608 mailbox. 4610 \HasChildren The presence of this attribute indicates that the 4611 mailbox has child mailboxes. A server SHOULD NOT set this 4612 attribute if there are child mailboxes and the user does not have 4613 permission to access any of them. In this case, \HasNoChildren 4614 SHOULD be used. In many cases, however, a server may not be able 4615 to efficiently compute whether a user has access to any child 4616 mailbox. Note that even though the \HasChildren attribute for a 4617 mailbox must be correct at the time of processing of the mailbox, 4618 a client must be prepared to deal with a situation when a mailbox 4619 is marked with the \HasChildren attribute, but no child mailbox 4620 appears in the response to the LIST command. This might happen, 4621 for example, due to children mailboxes being deleted or made 4622 inaccessible to the user (using access control) by another client 4623 before the server is able to list them. 4625 \HasNoChildren The presence of this attribute indicates that the 4626 mailbox has NO child mailboxes that are accessible to the 4627 currently authenticated user. 4629 \Marked The mailbox has been marked "interesting" by the server; the 4630 mailbox probably contains messages that have been added since the 4631 last time the mailbox was selected. 4633 \Unmarked The mailbox does not contain any additional messages since 4634 the last time the mailbox was selected. 4636 \Subscribed The mailbox name was subscribed to using the SUBSCRIBE 4637 command. 4639 \Remote The mailbox is a remote mailbox. 4641 It is an error for the server to return both a \HasChildren and a 4642 \HasNoChildren attribute in the same LIST response. 4644 Note: the \HasNoChildren attribute should not be confused with the 4645 \NoInferiors attribute, which indicates that no child mailboxes 4646 exist now and none can be created in the future. 4648 If it is not feasible for the server to determine whether or not the 4649 mailbox is "interesting", the server SHOULD NOT send either \Marked 4650 or \Unmarked. The server MUST NOT send more than one of \Marked, 4651 \Unmarked, and \Noselect for a single mailbox, and MAY send none of 4652 these. 4654 In addition to the base name attributes defined above, an IMAP server 4655 MAY also include any or all of the following attributes that denote 4656 "role" (or "special-use") of a mailbox. These attributes are 4657 included along with base attributes defined above. A given mailbox 4658 may have none, one, or more than one of these attributes. In some 4659 cases, a special use is advice to a client about what to put in that 4660 mailbox. In other cases, it's advice to a client about what to 4661 expect to find there. 4663 \All This mailbox presents all messages in the user's message store. 4664 Implementations MAY omit some messages, such as, perhaps, those in 4665 \Trash and \Junk. When this special use is supported, it is 4666 almost certain to represent a virtual mailbox. 4668 \Archive This mailbox is used to archive messages. The meaning of 4669 an "archival" mailbox is server-dependent; typically, it will be 4670 used to get messages out of the inbox, or otherwise keep them out 4671 of the user's way, while still making them accessible. 4673 \Drafts This mailbox is used to hold draft messages -- typically, 4674 messages that are being composed but have not yet been sent. In 4675 some server implementations, this might be a virtual mailbox, 4676 containing messages from other mailboxes that are marked with the 4677 "\Draft" message flag. Alternatively, this might just be advice 4678 that a client put drafts here. 4680 \Flagged This mailbox presents all messages marked in some way as 4681 "important". When this special use is supported, it is likely to 4682 represent a virtual mailbox collecting messages (from other 4683 mailboxes) that are marked with the "\Flagged" message flag. 4685 \Junk This mailbox is where messages deemed to be junk mail are 4686 held. Some server implementations might put messages here 4687 automatically. Alternatively, this might just be advice to a 4688 client-side spam filter. 4690 \Sent This mailbox is used to hold copies of messages that have been 4691 sent. Some server implementations might put messages here 4692 automatically. Alternatively, this might just be advice that a 4693 client save sent messages here. 4695 \Trash This mailbox is used to hold messages that have been deleted 4696 or marked for deletion. In some server implementations, this 4697 might be a virtual mailbox, containing messages from other 4698 mailboxes that are marked with the "\Deleted" message flag. 4699 Alternatively, this might just be advice that a client that 4700 chooses not to use the IMAP "\Deleted" model should use this as 4701 its trash location. In server implementations that strictly 4702 expect the IMAP "\Deleted" model, this special use is likely not 4703 to be supported. 4705 All of special-use attributes are OPTIONAL, and any given server or 4706 message store may support any combination of the attributes, or none 4707 at all. In most cases, there will likely be at most one mailbox with 4708 a given attribute for a given user, but in some server or message 4709 store implementations it might be possible for multiple mailboxes to 4710 have the same special-use attribute. 4712 Special-use attributes are likely to be user-specific. User Adam 4713 might share his \Sent mailbox with user Barb, but that mailbox is 4714 unlikely to also serve as Barb's \Sent mailbox. 4716 The hierarchy delimiter is a character used to delimit levels of 4717 hierarchy in a mailbox name. A client can use it to create child 4718 mailboxes, and to search higher or lower levels of naming hierarchy. 4719 All children of a top-level hierarchy node MUST use the same 4720 separator character. A NIL hierarchy delimiter means that no 4721 hierarchy exists; the name is a "flat" name. 4723 The name represents an unambiguous left-to-right hierarchy, and MUST 4724 be valid for use as a reference in LIST command. Unless \Noselect or 4725 \NonExistent is indicated, the name MUST also be valid as an argument 4726 for commands, such as SELECT, that accept mailbox names. 4728 Example: S: * LIST (\Noselect) "/" ~/Mail/foo 4730 7.2.4. NAMESPACE Response 4732 Contents: the prefix and hierarchy delimiter to the server's 4733 Personal Namespace(s), Other Users' Namespace(s), and 4734 Shared Namespace(s) 4736 The NAMESPACE response occurs as a result of a NAMESPACE command. It 4737 contains the prefix and hierarchy delimiter to the server's Personal 4738 Namespace(s), Other Users' Namespace(s), and Shared Namespace(s) that 4739 the server wishes to expose. The response will contain a NIL for any 4740 namespace class that is not available. Namespace-Response-Extensions 4741 ABNF non terminal is defined for extensibility and MAY be included in 4742 the response. 4744 Namespace-Response-Extensions which are not on the IETF standards 4745 track, MUST be prefixed with an "X-". 4747 Example: S: * NAMESPACE (("" "/")) (("~" "/")) NIL 4749 7.2.5. STATUS Response 4751 Contents: name 4752 status parenthesized list 4754 The STATUS response occurs as a result of an STATUS command. It 4755 returns the mailbox name that matches the STATUS specification and 4756 the requested mailbox status information. 4758 Example: S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) 4760 7.2.6. ESEARCH Response 4762 Contents: one or more search-return-data pairs 4764 The ESEARCH response occurs as a result of a SEARCH or UID SEARCH 4765 command. 4767 The ESEARCH response starts with an optional search correlator. If 4768 it is missing, then the response was not caused by a particular IMAP 4769 command, whereas if it is present, it contains the tag of the command 4770 that caused the response to be returned. 4772 The search correlator is followed by an optional UID indicator. If 4773 this indicator is present, all data in the ESEARCH response refers to 4774 UIDs, otherwise all returned data refers to message numbers. 4776 The rest of the ESEARCH response contains one or more search data 4777 pairs. Each pair starts with unique return item name, followed by a 4778 space and the corresponding data. Search data pairs may be returned 4779 in any order. Unless specified otherwise by an extension, any return 4780 item name SHOULD appear only once in an ESEARCH response. 4782 [[TBD: describe the most common search data pairs returned.]] 4784 Example: S: * ESEARCH UID COUNT 5 ALL 4:19,21,28 4786 Example: S: * ESEARCH (TAG "a567") UID COUNT 5 ALL 4:19,21,28 4788 Example: S: * ESEARCH COUNT 5 ALL 1:17,21 4790 7.2.7. FLAGS Response 4792 Contents: flag parenthesized list 4794 The FLAGS response occurs as a result of a SELECT or EXAMINE command. 4795 The flag parenthesized list identifies the flags (at a minimum, the 4796 system-defined flags) that are applicable for this mailbox. Flags 4797 other than the system flags can also exist, depending on server 4798 implementation. 4800 The update from the FLAGS response MUST be recorded by the client. 4802 Example: S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 4804 7.3. Server Responses - Mailbox Size 4806 These responses are always untagged. This is how changes in the size 4807 of the mailbox are transmitted from the server to the client. 4808 Immediately following the "*" token is a number that represents a 4809 message count. 4811 7.3.1. EXISTS Response 4813 Contents: none 4815 The EXISTS response reports the number of messages in the mailbox. 4816 This response occurs as a result of a SELECT or EXAMINE command, and 4817 if the size of the mailbox changes (e.g., new messages). 4819 The update from the EXISTS response MUST be recorded by the client. 4821 Example: S: * 23 EXISTS 4823 7.4. Server Responses - Message Status 4825 These responses are always untagged. This is how message data are 4826 transmitted from the server to the client, often as a result of a 4827 command with the same name. Immediately following the "*" token is a 4828 number that represents a message sequence number. 4830 7.4.1. EXPUNGE Response 4832 Contents: none 4834 The EXPUNGE response reports that the specified message sequence 4835 number has been permanently removed from the mailbox. The message 4836 sequence number for each successive message in the mailbox is 4837 immediately decremented by 1, and this decrement is reflected in 4838 message sequence numbers in subsequent responses (including other 4839 untagged EXPUNGE responses). 4841 The EXPUNGE response also decrements the number of messages in the 4842 mailbox; it is not necessary to send an EXISTS response with the new 4843 value. 4845 As a result of the immediate decrement rule, message sequence numbers 4846 that appear in a set of successive EXPUNGE responses depend upon 4847 whether the messages are removed starting from lower numbers to 4848 higher numbers, or from higher numbers to lower numbers. For 4849 example, if the last 5 messages in a 9-message mailbox are expunged, 4850 a "lower to higher" server will send five untagged EXPUNGE responses 4851 for message sequence number 5, whereas a "higher to lower server" 4852 will send successive untagged EXPUNGE responses for message sequence 4853 numbers 9, 8, 7, 6, and 5. 4855 An EXPUNGE response MUST NOT be sent when no command is in progress, 4856 nor while responding to a FETCH, STORE, or SEARCH command. This rule 4857 is necessary to prevent a loss of synchronization of message sequence 4858 numbers between client and server. A command is not "in progress" 4859 until the complete command has been received; in particular, a 4860 command is not "in progress" during the negotiation of command 4861 continuation. 4863 Note: UID FETCH, UID STORE, and UID SEARCH are different commands 4864 from FETCH, STORE, and SEARCH. An EXPUNGE response MAY be sent 4865 during a UID command. 4867 The update from the EXPUNGE response MUST be recorded by the client. 4869 Example: S: * 44 EXPUNGE 4871 7.4.2. FETCH Response 4873 Contents: message data 4875 The FETCH response returns data about a message to the client. The 4876 data are pairs of data item names and their values in parentheses. 4877 This response occurs as the result of a FETCH or STORE command, as 4878 well as by unilateral server decision (e.g., flag updates). 4880 The current data items are: 4882 BINARY[]<> 4884 An or expressing the content of the 4885 specified section after removing any Content-Transfer-Encoding- 4886 related encoding. If is present it refers to the 4887 offset within the DECODED section data. 4889 If the domain of the decoded data is "8bit" and the data does 4890 not contain the NUL octet, the server SHOULD return the data in 4891 a instead of a ; this allows the client to 4892 determine if the "8bit" data contains the NUL octet without 4893 having to explicitly scan the data stream for for NULs. 4895 Messaging clients and servers have been notoriously lax in 4896 their adherence to the Internet CRLF convention for terminating 4897 lines of textual data (text/* media types) in Internet 4898 protocols. When sending data in BINARY[...] FETCH data item, 4899 servers MUST ensure that textual line-oriented sections are 4900 always transmitted using the IMAP4 CRLF line termination 4901 syntax, regardless of the underlying storage representation of 4902 the data on the server. 4904 If the server does not know how to decode the section's 4905 Content-Transfer-Encoding, it MUST fail the request and issue a 4906 "NO" response that contains the "UNKNOWN-CTE" response code. 4908 BINARY.SIZE[] 4910 The size of the section after removing any Content-Transfer- 4911 Encoding-related encoding. The value returned MUST match the 4912 size of the or that will be returned by 4913 the corresponding FETCH BINARY request. 4915 If the server does not know how to decode the section's 4916 Content-Transfer-Encoding, it MUST fail the request and issue a 4917 "NO" response that contains the "UNKNOWN-CTE" response code. 4919 BODY A form of BODYSTRUCTURE without extension data. 4921 BODY[
]<> 4923 A string expressing the body contents of the specified section. 4924 The string SHOULD be interpreted by the client according to the 4925 content transfer encoding, body type, and subtype. 4927 If the origin octet is specified, this string is a substring of 4928 the entire body contents, starting at that origin octet. This 4929 means that BODY[]<0> MAY be truncated, but BODY[] is NEVER 4930 truncated. 4932 Note: The origin octet facility MUST NOT be used by a server 4933 in a FETCH response unless the client specifically requested 4934 it by means of a FETCH of a BODY[
]<> data 4935 item. 4937 8-bit textual data is permitted if a [CHARSET] identifier is 4938 part of the body parameter parenthesized list for this section. 4939 Note that headers (part specifiers HEADER or MIME, or the 4940 header portion of a MESSAGE/RFC822 or MESSAGE/GLOBAL part), MAY 4941 be in UTF-8. Note also that the [RFC-5322] delimiting blank 4942 line between the header and the body is not affected by header 4943 line subsetting; the blank line is always included as part of 4944 header data, except in the case of a message which has no body 4945 and no blank line. 4947 Non-textual data such as binary data MUST be transfer encoded 4948 into a textual form, such as BASE64, prior to being sent to the 4949 client. To derive the original binary data, the client MUST 4950 decode the transfer encoded string. 4952 BODYSTRUCTURE 4954 A parenthesized list that describes the [MIME-IMB] body 4955 structure of a message. This is computed by the server by 4956 parsing the [MIME-IMB] header fields, defaulting various fields 4957 as necessary. 4959 For example, a simple text message of 48 lines and 2279 octets 4960 can have a body structure of: ("TEXT" "PLAIN" ("CHARSET" "US- 4961 ASCII") NIL NIL "7BIT" 2279 48) 4963 Multiple parts are indicated by parenthesis nesting. Instead 4964 of a body type as the first element of the parenthesized list, 4965 there is a sequence of one or more nested body structures. The 4966 second element of the parenthesized list is the multipart 4967 subtype (mixed, digest, parallel, alternative, etc.). 4969 For example, a two part message consisting of a text and a 4970 BASE64-encoded text attachment can have a body structure of: 4971 (("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 1152 4972 23)("TEXT" "PLAIN" ("CHARSET" "US-ASCII" "NAME" "cc.diff") 4973 "<960723163407.20117h@cac.washington.edu>" "Compiler diff" 4974 "BASE64" 4554 73) "MIXED") 4976 Extension data follows the multipart subtype. Extension data 4977 is never returned with the BODY fetch, but can be returned with 4978 a BODYSTRUCTURE fetch. Extension data, if present, MUST be in 4979 the defined order. The extension data of a multipart body part 4980 are in the following order: 4982 body parameter parenthesized list A parenthesized list of 4983 attribute/value pairs [e.g., ("foo" "bar" "baz" "rag") where 4984 "bar" is the value of "foo", and "rag" is the value of 4985 "baz"] as defined in [MIME-IMB]. 4987 body parameter parenthesized list Servers SHOULD decode 4988 parameter value continuations as described in [RFC2231]. 4990 body disposition A parenthesized list, consisting of a 4991 disposition type string, followed by a parenthesized list of 4992 disposition attribute/value pairs as defined in 4993 [DISPOSITION]. Servers SHOULD decode parameter value 4994 continuations as described in [RFC2231]. 4996 body language A string or parenthesized list giving the body 4997 language value as defined in [LANGUAGE-TAGS]. 4999 body location A string giving the body content URI as defined 5000 in [LOCATION]. 5002 Any following extension data are not yet defined in this 5003 version of the protocol. Such extension data can consist of 5004 zero or more NILs, strings, numbers, or potentially nested 5005 parenthesized lists of such data. Client implementations that 5006 do a BODYSTRUCTURE fetch MUST be prepared to accept such 5007 extension data. Server implementations MUST NOT send such 5008 extension data until it has been defined by a revision of this 5009 protocol. 5011 The basic fields of a non-multipart body part are in the 5012 following order: 5014 body type A string giving the content media type name as 5015 defined in [MIME-IMB]. 5017 body subtype A string giving the content subtype name as 5018 defined in [MIME-IMB]. 5020 body parameter parenthesized list A parenthesized list of 5021 attribute/value pairs [e.g., ("foo" "bar" "baz" "rag") where 5022 "bar" is the value of "foo" and "rag" is the value of "baz"] 5023 as defined in [MIME-IMB]. 5025 body id A string giving the Content-ID header field value as 5026 defined in Section 7 of [MIME-IMB]. 5028 body description A string giving the Content-Description 5029 header field value as defined in Section 8 of [MIME-IMB]. 5031 body encoding A string giving the content transfer encoding as 5032 defined in Section 6 of [MIME-IMB]. 5034 body size A number giving the size of the body in octets. 5035 Note that this size is the size in its transfer encoding and 5036 not the resulting size after any decoding. 5038 A body type of type MESSAGE and subtype RFC822 contains, 5039 immediately after the basic fields, the envelope structure, 5040 body structure, and size in text lines of the encapsulated 5041 message. 5043 A body type of type TEXT contains, immediately after the basic 5044 fields, the size of the body in text lines. Note that this 5045 size is the size in its content transfer encoding and not the 5046 resulting size after any decoding. 5048 Extension data follows the basic fields and the type-specific 5049 fields listed above. Extension data is never returned with the 5050 BODY fetch, but can be returned with a BODYSTRUCTURE fetch. 5051 Extension data, if present, MUST be in the defined order. 5053 The extension data of a non-multipart body part are in the 5054 following order: 5056 body MD5 A string giving the body MD5 value as defined in 5057 [MD5]. 5059 body disposition A parenthesized list with the same content 5060 and function as the body disposition for a multipart body 5061 part. 5063 body language A string or parenthesized list giving the body 5064 language value as defined in [LANGUAGE-TAGS]. 5066 body location A string giving the body content URI as defined 5067 in [LOCATION]. 5069 Any following extension data are not yet defined in this 5070 version of the protocol, and would be as described above under 5071 multipart extension data. 5073 ENVELOPE 5075 A parenthesized list that describes the envelope structure of a 5076 message. This is computed by the server by parsing the 5077 [RFC-5322] header into the component parts, defaulting various 5078 fields as necessary. 5080 The fields of the envelope structure are in the following 5081 order: date, subject, from, sender, reply-to, to, cc, bcc, in- 5082 reply-to, and message-id. The date, subject, in-reply-to, and 5083 message-id fields are strings. The from, sender, reply-to, to, 5084 cc, and bcc fields are parenthesized lists of address 5085 structures. 5087 An address structure is a parenthesized list that describes an 5088 electronic mail address. The fields of an address structure 5089 are in the following order: personal name, [SMTP] at-domain- 5090 list (source route), mailbox name, and host name. 5092 [RFC-5322] group syntax is indicated by a special form of 5093 address structure in which the host name field is NIL. If the 5094 mailbox name field is also NIL, this is an end of group marker 5095 (semi-colon in RFC 822 syntax). If the mailbox name field is 5096 non-NIL, this is a start of group marker, and the mailbox name 5097 field holds the group name phrase. 5099 If the Date, Subject, In-Reply-To, and Message-ID header lines 5100 are absent in the [RFC-5322] header, the corresponding member 5101 of the envelope is NIL; if these header lines are present but 5102 empty the corresponding member of the envelope is the empty 5103 string. 5105 Note: some servers may return a NIL envelope member in the 5106 "present but empty" case. Clients SHOULD treat NIL and 5107 empty string as identical. 5109 Note: [RFC-5322] requires that all messages have a valid 5110 Date header. Therefore, the date member in the envelope can 5111 not be NIL or the empty string. 5113 Note: [RFC-5322] requires that the In-Reply-To and Message- 5114 ID headers, if present, have non-empty content. Therefore, 5115 the in-reply-to and message-id members in the envelope can 5116 not be the empty string. 5118 If the From, To, Cc, and Bcc header lines are absent in the 5119 [RFC-5322] header, or are present but empty, the corresponding 5120 member of the envelope is NIL. 5122 If the Sender or Reply-To lines are absent in the [RFC-5322] 5123 header, or are present but empty, the server sets the 5124 corresponding member of the envelope to be the same value as 5125 the from member (the client is not expected to know to do 5126 this). 5128 Note: [RFC-5322] requires that all messages have a valid 5129 From header. Therefore, the from, sender, and reply-to 5130 members in the envelope can not be NIL. 5132 FLAGS A parenthesized list of flags that are set for this message. 5134 INTERNALDATE A string representing the internal date of the message. 5136 RFC822.SIZE A number expressing the [RFC-5322] size of the message. 5138 UID A number expressing the unique identifier of the message. 5140 Example: S: * 23 FETCH (FLAGS (\Seen) RFC822.SIZE 44827) 5142 7.5. Server Responses - Command Continuation Request 5144 The command continuation request response is indicated by a "+" token 5145 instead of a tag. This form of response indicates that the server is 5146 ready to accept the continuation of a command from the client. The 5147 remainder of this response is a line of text. 5149 This response is used in the AUTHENTICATE command to transmit server 5150 data to the client, and request additional client data. This 5151 response is also used if an argument to any command is a 5152 synchronizing literal. 5154 The client is not permitted to send the octets of the synchronizing 5155 literal unless the server indicates that it is expected. This 5156 permits the server to process commands and reject errors on a line- 5157 by-line basis. The remainder of the command, including the CRLF that 5158 terminates a command, follows the octets of the literal. If there 5159 are any additional command arguments, the literal octets are followed 5160 by a space and those arguments. 5162 Example: C: A001 LOGIN {11} 5163 S: + Ready for additional command text 5164 C: FRED FOOBAR {7} 5165 S: + Ready for additional command text 5166 C: fat man 5167 S: A001 OK LOGIN completed 5168 C: A044 BLURDYBLOOP {102856} 5169 S: A044 BAD No such command as "BLURDYBLOOP" 5171 8. Sample IMAP4rev2 connection 5173 The following is a transcript of an IMAP4rev2 connection. A long 5174 line in this sample is broken for editorial clarity. 5176 S: * OK IMAP4rev2 Service Ready 5177 C: a001 login mrc secret 5178 S: a001 OK LOGIN completed 5179 C: a002 select inbox 5180 S: * 18 EXISTS 5181 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 5182 S: * OK [UIDVALIDITY 3857529045] UIDs valid 5183 S: a002 OK [READ-WRITE] SELECT completed 5184 C: a003 fetch 12 full 5185 S: * 12 FETCH (FLAGS (\Seen) INTERNALDATE "17-Jul-1996 02:44:25 -0700" 5186 RFC822.SIZE 4286 ENVELOPE ("Wed, 17 Jul 1996 02:23:25 -0700 (PDT)" 5187 "IMAP4rev2 WG mtg summary and minutes" 5188 (("Terry Gray" NIL "gray" "cac.washington.edu")) 5189 (("Terry Gray" NIL "gray" "cac.washington.edu")) 5190 (("Terry Gray" NIL "gray" "cac.washington.edu")) 5191 ((NIL NIL "imap" "cac.washington.edu")) 5192 ((NIL NIL "minutes" "CNRI.Reston.VA.US") 5193 ("John Klensin" NIL "KLENSIN" "MIT.EDU")) NIL NIL 5194 "") 5195 BODY ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 3028 5196 92)) 5197 S: a003 OK FETCH completed 5198 C: a004 fetch 12 body[header] 5199 S: * 12 FETCH (BODY[HEADER] {342} 5200 S: Date: Wed, 17 Jul 1996 02:23:25 -0700 (PDT) 5201 S: From: Terry Gray 5202 S: Subject: IMAP4rev2 WG mtg summary and minutes 5203 S: To: imap@cac.washington.edu 5204 S: cc: minutes@CNRI.Reston.VA.US, John Klensin 5205 S: Message-Id: 5206 S: MIME-Version: 1.0 5207 S: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 5208 S: 5209 S: ) 5210 S: a004 OK FETCH completed 5211 C: a005 store 12 +flags \deleted 5212 S: * 12 FETCH (FLAGS (\Seen \Deleted)) 5213 S: a005 OK +FLAGS completed 5214 C: a006 logout 5215 S: * BYE IMAP4rev2 server terminating connection 5216 S: a006 OK LOGOUT completed 5218 9. Formal Syntax 5220 The following syntax specification uses the Augmented Backus-Naur 5221 Form (ABNF) notation as specified in [ABNF]. 5223 In the case of alternative or optional rules in which a later rule 5224 overlaps an earlier rule, the rule which is listed earlier MUST take 5225 priority. For example, "\Seen" when parsed as a flag is the \Seen 5226 flag name and not a flag-extension, even though "\Seen" can be parsed 5227 as a flag-extension. Some, but not all, instances of this rule are 5228 noted below. 5230 Note: [ABNF] rules MUST be followed strictly; in particular: 5232 (1) Except as noted otherwise, all alphabetic characters are case- 5233 insensitive. The use of upper or lower case characters to define 5234 token strings is for editorial clarity only. Implementations MUST 5235 accept these strings in a case-insensitive fashion. 5237 (2) In all cases, SP refers to exactly one space. It is NOT 5238 permitted to substitute TAB, insert additional spaces, or 5239 otherwise treat SP as being equivalent to LWSP. 5241 (3) The ASCII NUL character, %x00, MUST NOT be used at any time. 5243 address = "(" addr-name SP addr-adl SP addr-mailbox SP 5244 addr-host ")" 5246 addr-adl = nstring 5247 ; Holds route from [RFC-5322] route-addr if 5248 ; non-NIL 5250 addr-host = nstring 5251 ; NIL indicates [RFC-5322] group syntax. 5252 ; Otherwise, holds [RFC-5322] domain name 5254 addr-mailbox = nstring 5255 ; NIL indicates end of [RFC-5322] group; if 5256 ; non-NIL and addr-host is NIL, holds 5257 ; [RFC-5322] group name. 5258 ; Otherwise, holds [RFC-5322] local-part 5259 ; after removing [RFC-5322] quoting 5261 addr-name = nstring 5262 ; If non-NIL, holds phrase from [RFC-5322] 5263 ; mailbox after removing [RFC-5322] quoting 5265 append = "APPEND" SP mailbox [SP flag-list] [SP date-time] SP 5266 literal 5268 append-uid = uniqueid 5270 astring = 1*ASTRING-CHAR / string 5271 ASTRING-CHAR = ATOM-CHAR / resp-specials 5273 atom = 1*ATOM-CHAR 5275 ATOM-CHAR = 5277 atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards / 5278 quoted-specials / resp-specials 5280 authenticate = "AUTHENTICATE" SP auth-type [SP initial-resp] 5281 *(CRLF base64) 5283 auth-type = atom 5284 ; Defined by [SASL] 5286 base64 = *(4base64-char) [base64-terminal] 5288 base64-char = ALPHA / DIGIT / "+" / "/" 5289 ; Case-sensitive 5291 base64-terminal = (2base64-char "==") / (3base64-char "=") 5293 body = "(" (body-type-1part / body-type-mpart) ")" 5295 body-extension = nstring / number / 5296 "(" body-extension *(SP body-extension) ")" 5297 ; Future expansion. Client implementations 5298 ; MUST accept body-extension fields. Server 5299 ; implementations MUST NOT generate 5300 ; body-extension fields except as defined by 5301 ; future standard or standards-track 5302 ; revisions of this specification. 5304 body-ext-1part = body-fld-md5 [SP body-fld-dsp [SP body-fld-lang 5305 [SP body-fld-loc *(SP body-extension)]]] 5306 ; MUST NOT be returned on non-extensible 5307 ; "BODY" fetch 5309 body-ext-mpart = body-fld-param [SP body-fld-dsp [SP body-fld-lang 5310 [SP body-fld-loc *(SP body-extension)]]] 5311 ; MUST NOT be returned on non-extensible 5312 ; "BODY" fetch 5314 body-fields = body-fld-param SP body-fld-id SP body-fld-desc SP 5315 body-fld-enc SP body-fld-octets 5317 body-fld-desc = nstring 5318 body-fld-dsp = "(" string SP body-fld-param ")" / nil 5320 body-fld-enc = (DQUOTE ("7BIT" / "8BIT" / "BINARY" / "BASE64"/ 5321 "QUOTED-PRINTABLE") DQUOTE) / string 5323 body-fld-id = nstring 5325 body-fld-lang = nstring / "(" string *(SP string) ")" 5327 body-fld-loc = nstring 5329 body-fld-lines = number 5331 body-fld-md5 = nstring 5333 body-fld-octets = number 5335 body-fld-param = "(" string SP string *(SP string SP string) ")" / nil 5337 body-type-1part = (body-type-basic / body-type-msg / body-type-text) 5338 [SP body-ext-1part] 5340 body-type-basic = media-basic SP body-fields 5341 ; MESSAGE subtype MUST NOT be "RFC822" or "GLOBAL" 5343 body-type-mpart = 1*body SP media-subtype 5344 [SP body-ext-mpart] 5345 ; MULTIPART body part 5347 body-type-msg = media-message SP body-fields SP envelope 5348 SP body SP body-fld-lines 5350 body-type-text = media-text SP body-fields SP body-fld-lines 5352 capability = ("AUTH=" auth-type) / atom 5353 ; New capabilities MUST begin with "X" or be 5354 ; registered with IANA as standard or 5355 ; standards-track 5357 capability-data = "CAPABILITY" *(SP capability) SP "IMAP4rev2" 5358 *(SP capability) 5359 ; Servers MUST implement the STARTTLS, AUTH=PLAIN, 5360 ; and LOGINDISABLED capabilities 5361 ; Servers which offer RFC 1730 compatibility MUST 5362 ; list "IMAP4" as the first capability. 5364 CHAR8 = %x01-ff 5365 ; any OCTET except NUL, %x00 5367 charset = atom / quoted 5369 childinfo-extended-item = "CHILDINFO" SP "(" 5370 list-select-base-opt-quoted 5371 *(SP list-select-base-opt-quoted) ")" 5372 ; Extended data item (mbox-list-extended-item) 5373 ; returned when the RECURSIVEMATCH 5374 ; selection option is specified. 5375 ; Note 1: the CHILDINFO tag can be returned 5376 ; with and without surrounding quotes, as per 5377 ; mbox-list-extended-item-tag production. 5378 ; Note 2: The selection options are always returned 5379 ; quoted, unlike their specification in 5380 ; the extended LIST command. 5382 child-mbox-flag = "\HasChildren" / "\HasNoChildren" 5383 ; attributes for CHILDREN return option, at most one 5384 ; possible per LIST response 5386 command = tag SP (command-any / command-auth / command-nonauth / 5387 command-select) CRLF 5388 ; Modal based on state 5390 command-any = "CAPABILITY" / "LOGOUT" / "NOOP" / enable / x-command 5391 ; Valid in all states 5393 command-auth = append / create / delete / examine / list / 5394 Namespace-Command / 5395 rename / select / status / subscribe / unsubscribe / 5396 idle 5397 ; Valid only in Authenticated or Selected state 5399 command-nonauth = login / authenticate / "STARTTLS" 5400 ; Valid only when in Not Authenticated state 5402 command-select = "CLOSE" / "UNSELECT" / "EXPUNGE" / copy / 5403 move / fetch / store / search / uid 5404 ; Valid only when in Selected state 5406 continue-req = "+" SP (resp-text / base64) CRLF 5408 copy = "COPY" SP sequence-set SP mailbox 5410 create = "CREATE" SP mailbox 5411 ; Use of INBOX gives a NO error 5413 date = date-text / DQUOTE date-text DQUOTE 5414 date-day = 1*2DIGIT 5415 ; Day of month 5417 date-day-fixed = (SP DIGIT) / 2DIGIT 5418 ; Fixed-format version of date-day 5420 date-month = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / 5421 "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec" 5423 date-text = date-day "-" date-month "-" date-year 5425 date-year = 4DIGIT 5427 date-time = DQUOTE date-day-fixed "-" date-month "-" date-year 5428 SP time SP zone DQUOTE 5430 delete = "DELETE" SP mailbox 5431 ; Use of INBOX gives a NO error 5433 digit-nz = %x31-39 5434 ; 1-9 5436 eitem-standard-tag = atom 5437 ; a tag for extended list data defined in a Standard 5438 ; Track or Experimental RFC. 5440 eitem-vendor-tag = vendor-token "-" atom 5441 ; a vendor-specific tag for extended list data 5443 enable = "ENABLE" 1*(SP capability) 5445 enable-data = "ENABLED" *(SP capability) 5447 envelope = "(" env-date SP env-subject SP env-from SP 5448 env-sender SP env-reply-to SP env-to SP env-cc SP 5449 env-bcc SP env-in-reply-to SP env-message-id ")" 5451 env-bcc = "(" 1*address ")" / nil 5453 env-cc = "(" 1*address ")" / nil 5455 env-date = nstring 5457 env-from = "(" 1*address ")" / nil 5459 env-in-reply-to = nstring 5461 env-message-id = nstring 5462 env-reply-to = "(" 1*address ")" / nil 5464 env-sender = "(" 1*address ")" / nil 5466 env-subject = nstring 5468 env-to = "(" 1*address ")" / nil 5470 esearch-response = "ESEARCH" [search-correlator] [SP "UID"] 5471 *(SP search-return-data) 5472 ; ESEARCH response replaces SEARCH response 5473 ; from IMAP4rev1. 5475 examine = "EXAMINE" SP mailbox 5477 fetch = "FETCH" SP sequence-set SP ("ALL" / "FULL" / "FAST" / 5478 fetch-att / "(" fetch-att *(SP fetch-att) ")") 5480 fetch-att = "ENVELOPE" / "FLAGS" / "INTERNALDATE" / 5481 "RFC822.SIZE" / 5482 "BODY" ["STRUCTURE"] / "UID" / 5483 "BODY" section [partial] / 5484 "BODY.PEEK" section [partial] / 5485 "BINARY" [".PEEK"] section-binary [partial] / 5486 "BINARY.SIZE" section-binary 5488 flag = "\Answered" / "\Flagged" / "\Deleted" / 5489 "\Seen" / "\Draft" / flag-keyword / flag-extension 5490 ; Does not include "\Recent" 5492 flag-extension = "\" atom 5493 ; Future expansion. Client implementations 5494 ; MUST accept flag-extension flags. Server 5495 ; implementations MUST NOT generate 5496 ; flag-extension flags except as defined by 5497 ; future standard or standards-track 5498 ; revisions of this specification. 5499 ; "\Recent" was defined in RFC 3501 5500 ; and is now deprecated. 5502 flag-fetch = flag 5504 flag-keyword = "$MDNSent" / "$Forwarded" / atom 5506 flag-list = "(" [flag *(SP flag)] ")" 5508 flag-perm = flag / "\*" 5509 greeting = "*" SP (resp-cond-auth / resp-cond-bye) CRLF 5511 header-fld-name = astring 5513 header-list = "(" header-fld-name *(SP header-fld-name) ")" 5515 idle = "IDLE" CRLF "DONE" 5517 initial-resp = (base64 / "=") 5518 ; "initial response" defined in 5519 ; Section 5.1 of [RFC4422] 5521 list = "LIST" [SP list-select-opts] SP mailbox SP mbox-or-pat 5522 [SP list-return-opts] 5524 list-mailbox = 1*list-char / string 5526 list-char = ATOM-CHAR / list-wildcards / resp-specials 5528 list-return-opts = "RETURN" SP 5529 "(" [return-option *(SP return-option)] ")" 5530 ; list return options, e.g., CHILDREN 5532 list-select-base-opt = "SUBSCRIBED" / option-extension 5533 ; options that can be used by themselves 5535 list-select-base-opt-quoted = DQUOTE list-select-base-opt DQUOTE 5537 list-select-independent-opt = "REMOTE" / option-extension 5538 ; options that do not syntactically interact with 5539 ; other options 5541 list-select-mod-opt = "RECURSIVEMATCH" / option-extension 5542 ; options that require a list-select-base-opt 5543 ; to also be present 5545 list-select-opt = list-select-base-opt / list-select-independent-opt 5546 / list-select-mod-opt 5547 ; An option registration template is described in 5548 ; Section 9.3 of this document. 5550 list-select-opts = "(" [ 5551 (*(list-select-opt SP) list-select-base-opt 5552 *(SP list-select-opt)) 5553 / (list-select-independent-opt 5554 *(SP list-select-independent-opt)) 5555 ] ")" 5557 ; Any number of options may be in any order. 5558 ; If a list-select-mod-opt appears, then a 5559 ; list-select-base-opt must also appear. 5560 ; This allows these: 5561 ; () 5562 ; (REMOTE) 5563 ; (SUBSCRIBED) 5564 ; (SUBSCRIBED REMOTE) 5565 ; (SUBSCRIBED RECURSIVEMATCH) 5566 ; (SUBSCRIBED REMOTE RECURSIVEMATCH) 5567 ; But does NOT allow these: 5568 ; (RECURSIVEMATCH) 5569 ; (REMOTE RECURSIVEMATCH) 5571 list-wildcards = "%" / "*" 5573 literal = "{" number ["+"] "}" CRLF *CHAR8 5574 ; represents the number of CHAR8s. 5575 ; A non-synchronizing literal is distinguished from 5576 ; a synchronizing literal by presence of the "+" 5577 ; before the closing "}". 5578 ; Non synchronizing literals are not allowed when 5579 ; sent from server to the client. 5581 literal8 = "~{" number "}" CRLF *OCTET 5582 ; represents the number of OCTETs 5583 ; in the response string. 5585 login = "LOGIN" SP userid SP password 5587 mailbox = "INBOX" / astring 5588 ; INBOX is case-insensitive. All case variants of 5589 ; INBOX (e.g., "iNbOx") MUST be interpreted as INBOX 5590 ; not as an astring. An astring which consists of 5591 ; the case-insensitive sequence "I" "N" "B" "O" "X" 5592 ; is considered to be INBOX and not an astring. 5593 ; Refer to section 5.1 for further 5594 ; semantic details of mailbox names. 5596 mailbox-data = "FLAGS" SP flag-list / "LIST" SP mailbox-list / 5597 esearch-response / 5598 "STATUS" SP mailbox SP "(" [status-att-list] ")" / 5599 number SP "EXISTS" / Namespace-Response 5601 mailbox-list = "(" [mbx-list-flags] ")" SP 5602 (DQUOTE QUOTED-CHAR DQUOTE / nil) SP mailbox 5603 [SP mbox-list-extended] 5604 ; This is the list information pointed to by the ABNF 5605 ; item "mailbox-data", which is defined in [IMAP4] 5607 mbox-list-extended = "(" [mbox-list-extended-item 5608 *(SP mbox-list-extended-item)] ")" 5610 mbox-list-extended-item = mbox-list-extended-item-tag SP 5611 tagged-ext-val 5613 mbox-list-extended-item-tag = astring 5614 ; The content MUST conform to either "eitem-vendor-tag" 5615 ; or "eitem-standard-tag" ABNF productions. 5617 mbox-or-pat = list-mailbox / patterns 5619 mbx-list-flags = *(mbx-list-oflag SP) mbx-list-sflag 5620 *(SP mbx-list-oflag) / 5621 mbx-list-oflag *(SP mbx-list-oflag) 5623 mbx-list-oflag = "\Noinferiors" / child-mbox-flag / 5624 "\Subscribed" / "\Remote" / flag-extension 5625 ; Other flags; multiple possible per LIST response 5627 mbx-list-sflag = "\NonExistent" / "\Noselect" / "\Marked" / "\Unmarked" 5628 ; Selectability flags; only one per LIST response 5630 media-basic = ((DQUOTE ("APPLICATION" / "AUDIO" / "IMAGE" / 5631 "MESSAGE" / "VIDEO" / "FONT") DQUOTE) / string) SP 5632 media-subtype 5633 ; Defined in [MIME-IMT]. 5634 ; FONT defined in RFC YYYY. 5636 media-message = DQUOTE "MESSAGE" DQUOTE SP 5637 DQUOTE ("RFC822" / "GLOBAL") DQUOTE 5638 ; Defined in [MIME-IMT] 5640 media-subtype = string 5641 ; Defined in [MIME-IMT] 5643 media-text = DQUOTE "TEXT" DQUOTE SP media-subtype 5644 ; Defined in [MIME-IMT] 5646 message-data = nz-number SP ("EXPUNGE" / ("FETCH" SP msg-att)) 5648 move = "MOVE" SP sequence-set SP mailbox 5650 msg-att = "(" (msg-att-dynamic / msg-att-static) 5651 *(SP (msg-att-dynamic / msg-att-static)) ")" 5653 msg-att-dynamic = "FLAGS" SP "(" [flag-fetch *(SP flag-fetch)] ")" 5654 ; MAY change for a message 5656 msg-att-static = "ENVELOPE" SP envelope / "INTERNALDATE" SP date-time / 5657 "RFC822.SIZE" SP number / 5658 "BODY" ["STRUCTURE"] SP body / 5659 "BODY" section ["<" number ">"] SP nstring / 5660 "BINARY" section-binary SP (nstring / literal8) / 5661 "BINARY.SIZE" section-binary SP number / 5662 "UID" SP uniqueid 5663 ; MUST NOT change for a message 5665 Namespace = nil / "(" 1*Namespace-Descr ")" 5667 Namespace-Command = "NAMESPACE" 5669 Namespace-Descr = "(" string SP 5670 (DQUOTE QUOTED-CHAR DQUOTE / nil) 5671 [Namespace-Response-Extensions] ")" 5673 Namespace-Response-Extensions = *(Namespace-Response-Extension) 5675 Namespace-Response-Extension = SP string SP 5676 "(" string *(SP string) ")" 5678 Namespace-Response = "NAMESPACE" SP Namespace 5679 SP Namespace SP Namespace 5680 ; The first Namespace is the Personal Namespace(s) 5681 ; The second Namespace is the Other Users' Namespace(s) 5682 ; The third Namespace is the Shared Namespace(s) 5684 nil = "NIL" 5686 nstring = string / nil 5688 number = 1*DIGIT 5689 ; Unsigned 32-bit integer 5690 ; (0 <= n < 4,294,967,296) 5692 number64 = 1*DIGIT 5693 ; Unsigned 63-bit integer 5694 ; (0 <= n <= 9,223,372,036,854,775,807) 5696 nz-number = digit-nz *DIGIT 5697 ; Non-zero unsigned 32-bit integer 5698 ; (0 < n < 4,294,967,296) 5700 option-extension = (option-standard-tag / option-vendor-tag) 5702 [SP option-value] 5704 option-standard-tag = atom 5705 ; an option defined in a Standards Track or 5706 ; Experimental RFC 5708 option-val-comp = astring / 5709 option-val-comp *(SP option-val-comp) / 5710 "(" option-val-comp ")" 5712 option-value = "(" option-val-comp ")" 5714 option-vendor-tag = vendor-token "-" atom 5715 ; a vendor-specific option, non-standard 5717 partial-range = number ["." nz-number] 5718 ; Copied from RFC 5092 (IMAP URL) 5720 partial = "<" number "." nz-number ">" 5721 ; Partial FETCH request. 0-based offset of 5722 ; the first octet, followed by the number of octets 5723 ; in the fragment. 5725 password = astring 5727 patterns = "(" list-mailbox *(SP list-mailbox) ")" 5729 quoted = DQUOTE *QUOTED-CHAR DQUOTE 5731 QUOTED-CHAR = / 5732 "\" quoted-specials / UTF8-2 / UTF8-3 / UTF8-4 5734 quoted-specials = DQUOTE / "\" 5736 rename = "RENAME" SP mailbox SP mailbox 5737 ; Use of INBOX as a destination gives a NO error 5739 response = *(continue-req / response-data) response-done 5741 response-data = "*" SP (resp-cond-state / resp-cond-bye / 5742 mailbox-data / message-data / capability-data / 5743 enable-data) CRLF 5745 response-done = response-tagged / response-fatal 5747 response-fatal = "*" SP resp-cond-bye CRLF 5748 ; Server closes connection immediately 5750 response-tagged = tag SP resp-cond-state CRLF 5752 resp-code-apnd = "APPENDUID" SP nz-number SP append-uid 5754 resp-code-copy = "COPYUID" SP nz-number SP uid-set SP uid-set 5756 resp-cond-auth = ("OK" / "PREAUTH") SP resp-text 5757 ; Authentication condition 5759 resp-cond-bye = "BYE" SP resp-text 5761 resp-cond-state = ("OK" / "NO" / "BAD") SP resp-text 5762 ; Status condition 5764 resp-specials = "]" 5766 ;; ////Can we make "text" optional? Will this have any bad side effects? 5767 resp-text = ["[" resp-text-code "]" SP] text 5769 resp-text-code = "ALERT" / 5770 "BADCHARSET" [SP "(" charset *(SP charset) ")" ] / 5771 capability-data / "PARSE" / 5772 "PERMANENTFLAGS" SP "(" 5773 [flag-perm *(SP flag-perm)] ")" / 5774 "READ-ONLY" / "READ-WRITE" / "TRYCREATE" / 5775 "UIDNEXT" SP nz-number / "UIDVALIDITY" SP nz-number / 5776 resp-code-apnd / resp-code-copy / "UIDNOTSTICKY" / 5777 "UNAVAILABLE" / "AUTHENTICATIONFAILED" / 5778 "AUTHORIZATIONFAILED" / "EXPIRED" / 5779 "PRIVACYREQUIRED" / "CONTACTADMIN" / "NOPERM" / 5780 "INUSE" / "EXPUNGEISSUED" / "CORRUPTION" / 5781 "SERVERBUG" / "CLIENTBUG" / "CANNOT" / 5782 "LIMIT" / "OVERQUOTA" / "ALREADYEXISTS" / 5783 "NONEXISTENT" / 5784 "CLOSED" / 5785 "UNKNOWN-CTE" / 5786 atom [SP 1*] 5788 return-option = "SUBSCRIBED" / "CHILDREN" / option-extension 5790 search = "SEARCH" [search-return-opts] 5791 SP search-program 5793 search-correlator = SP "(" "TAG" SP tag-string ")" 5795 search-key = "ALL" / "ANSWERED" / "BCC" SP astring / 5796 "BEFORE" SP date / "BODY" SP astring / 5797 "CC" SP astring / "DELETED" / "FLAGGED" / 5798 "FROM" SP astring / "KEYWORD" SP flag-keyword / 5799 "ON" SP date / "SEEN" / 5800 "SINCE" SP date / "SUBJECT" SP astring / 5801 "TEXT" SP astring / "TO" SP astring / 5802 "UNANSWERED" / "UNDELETED" / "UNFLAGGED" / 5803 "UNKEYWORD" SP flag-keyword / "UNSEEN" / 5804 ; Above this line were in [IMAP2] 5805 "DRAFT" / "HEADER" SP header-fld-name SP astring / 5806 "LARGER" SP number / "NOT" SP search-key / 5807 "OR" SP search-key SP search-key / 5808 "SENTBEFORE" SP date / "SENTON" SP date / 5809 "SENTSINCE" SP date / "SMALLER" SP number / 5810 "UID" SP sequence-set / "UNDRAFT" / sequence-set / 5811 "(" search-key *(SP search-key) ")" 5813 search-modifier-name = tagged-ext-label 5815 search-mod-params = tagged-ext-val 5816 ; This non-terminal shows recommended syntax 5817 ; for future extensions. 5819 search-program = ["CHARSET" SP charset SP] 5820 search-key *(SP search-key) 5821 ; CHARSET argument to SEARCH MUST be 5822 ; registered with IANA. 5824 search-ret-data-ext = search-modifier-name SP search-return-value 5825 ; Note that not every SEARCH return option 5826 ; is required to have the corresponding 5827 ; ESEARCH return data. 5829 search-return-data = "MIN" SP nz-number / 5830 "MAX" SP nz-number / 5831 "ALL" SP sequence-set / 5832 "COUNT" SP number / 5833 search-ret-data-ext 5834 ; All return data items conform to 5835 ; search-ret-data-ext syntax 5837 search-return-opts = SP "RETURN" SP "(" [search-return-opt 5838 *(SP search-return-opt)] ")" 5840 search-return-opt = "MIN" / "MAX" / "ALL" / "COUNT" / 5841 search-ret-opt-ext 5842 ; conforms to generic search-ret-opt-ext 5843 ; syntax 5845 search-ret-opt-ext = search-modifier-name [SP search-mod-params] 5846 search-return-value = tagged-ext-val 5847 ; Data for the returned search option. 5848 ; A single "nz-number"/"number"/"number64" value 5849 ; can be returned as an atom (i.e., without 5850 ; quoting). A sequence-set can be returned 5851 ; as an atom as well. 5853 section = "[" [section-spec] "]" 5855 section-binary = "[" [section-part] "]" 5857 section-msgtext = "HEADER" / "HEADER.FIELDS" [".NOT"] SP header-list / 5858 "TEXT" 5859 ; top-level or MESSAGE/RFC822 or MESSAGE/GLOBAL part 5861 section-part = nz-number *("." nz-number) 5862 ; body part reference. 5863 ; Allows for accessing nested body parts. 5865 section-spec = section-msgtext / (section-part ["." section-text]) 5867 section-text = section-msgtext / "MIME" 5868 ; text other than actual body part (headers, etc.) 5870 select = "SELECT" SP mailbox 5872 seq-number = nz-number / "*" 5873 ; message sequence number (COPY, FETCH, STORE 5874 ; commands) or unique identifier (UID COPY, 5875 ; UID FETCH, UID STORE commands). 5876 ; * represents the largest number in use. In 5877 ; the case of message sequence numbers, it is 5878 ; the number of messages in a non-empty mailbox. 5879 ; In the case of unique identifiers, it is the 5880 ; unique identifier of the last message in the 5881 ; mailbox or, if the mailbox is empty, the 5882 ; mailbox's current UIDNEXT value. 5883 ; The server should respond with a tagged BAD 5884 ; response to a command that uses a message 5885 ; sequence number greater than the number of 5886 ; messages in the selected mailbox. This 5887 ; includes "*" if the selected mailbox is empty. 5889 seq-range = seq-number ":" seq-number 5890 ; two seq-number values and all values between 5891 ; these two regardless of order. 5892 ; Example: 2:4 and 4:2 are equivalent and indicate 5893 ; values 2, 3, and 4. 5895 ; Example: a unique identifier sequence range of 5896 ; 3291:* includes the UID of the last message in 5897 ; the mailbox, even if that value is less than 3291. 5899 sequence-set = (seq-number / seq-range) ["," sequence-set] 5900 ; set of seq-number values, regardless of order. 5901 ; Servers MAY coalesce overlaps and/or execute the 5902 ; sequence in any order. 5903 ; Example: a message sequence number set of 5904 ; 2,4:7,9,12:* for a mailbox with 15 messages is 5905 ; equivalent to 2,4,5,6,7,9,12,13,14,15 5906 ; Example: a message sequence number set of *:4,5:7 5907 ; for a mailbox with 10 messages is equivalent to 5908 ; 10,9,8,7,6,5,4,5,6,7 and MAY be reordered and 5909 ; overlap coalesced to be 4,5,6,7,8,9,10. 5911 status = "STATUS" SP mailbox SP 5912 "(" status-att *(SP status-att) ")" 5914 status-att = "MESSAGES" / "UIDNEXT" / "UIDVALIDITY" / 5915 "UNSEEN" / "DELETED" / "SIZE" 5917 status-att-val = ("MESSAGES" SP number) / 5918 ("UIDNEXT" SP nz-number) / 5919 ("UIDVALIDITY" SP nz-number) / 5920 ("UNSEEN" SP number) / 5921 ("DELETED" SP number) / 5922 ("SIZE" SP number64) 5923 ; Extensions to the STATUS responses 5924 ; should extend this production. 5925 ; Extensions should use the generic 5926 ; syntax defined by tagged-ext. 5928 status-att-list = status-att-val *(SP status-att-val) 5930 store = "STORE" SP sequence-set SP store-att-flags 5932 store-att-flags = (["+" / "-"] "FLAGS" [".SILENT"]) SP 5933 (flag-list / (flag *(SP flag))) 5935 string = quoted / literal 5937 subscribe = "SUBSCRIBE" SP mailbox 5939 tag = 1* 5941 tagged-ext-label = tagged-label-fchar *tagged-label-char 5942 ;; Is a valid RFC 3501 "atom". 5944 tagged-label-fchar = ALPHA / "-" / "_" / "." 5946 tagged-label-char = tagged-label-fchar / DIGIT / ":" 5948 tagged-ext-comp = astring / 5949 tagged-ext-comp *(SP tagged-ext-comp) / 5950 "(" tagged-ext-comp ")" 5951 ;; Extensions that follow this general 5952 ;; syntax should use nstring instead of 5953 ;; astring when appropriate in the context 5954 ;; of the extension. 5955 ;; Note that a message set or a "number" 5956 ;; can always be represented as an "atom". 5957 ;; An URL should be represented as 5958 ;; a "quoted" string. 5960 tagged-ext-simple = sequence-set / number / number64 5962 tagged-ext-val = tagged-ext-simple / 5963 "(" [tagged-ext-comp] ")" 5965 text = 1*TEXT-CHAR 5967 TEXT-CHAR = 5969 time = 2DIGIT ":" 2DIGIT ":" 2DIGIT 5970 ; Hours minutes seconds 5972 uid = "UID" SP 5973 (copy / move / fetch / search / store / uid-expunge) 5974 ; Unique identifiers used instead of message 5975 ; sequence numbers 5977 uid-expunge = "EXPUNGE" SP sequence-set 5978 ; Unique identifiers used instead of message 5979 ; sequence numbers 5981 uid-set = (uniqueid / uid-range) *("," uid-set) 5983 uid-range = (uniqueid ":" uniqueid) 5984 ; two uniqueid values and all values 5985 ; between these two regards of order. 5986 ; Example: 2:4 and 4:2 are equivalent. 5988 uniqueid = nz-number 5989 ; Strictly ascending 5991 unsubscribe = "UNSUBSCRIBE" SP mailbox 5992 userid = astring 5994 UTF8-2 = 5996 UTF8-3 = 5998 UTF8-4 = 6000 x-command = "X" atom 6002 zone = ("+" / "-") 4DIGIT 6003 ; Signed four-digit value of hhmm representing 6004 ; hours and minutes east of Greenwich (that is, 6005 ; the amount that the given time differs from 6006 ; Universal Time). Subtracting the timezone 6007 ; from the given time will give the UT form. 6008 ; The Universal Time zone is "+0000". 6010 10. Author's Note 6012 This document is a revision or rewrite of earlier documents, and 6013 supercedes the protocol specification in those documents: RFC 2060, 6014 RFC 1730, unpublished IMAP2bis.TXT document, RFC 1176, and RFC 1064. 6016 11. Security Considerations 6018 IMAP4rev2 protocol transactions, including electronic mail data, are 6019 sent in the clear over the network unless protection from snooping is 6020 negotiated. This can be accomplished either by the use of IMAPS 6021 service, STARTTLS command, negotiated privacy protection in the 6022 AUTHENTICATE command, or some other protection mechanism. 6024 11.1. STARTTLS Security Considerations 6026 IMAP client and server implementations MUST comply with relevant TLS 6027 recommendations from [RFC8314]. 6029 Additionally, when using TLS 1.2, IMAP implementations MUST implement 6030 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 cipher suite, and SHOULD 6031 implement the TLS_RSA_WITH_AES_128_CBC_SHA [TLS] cipher suite. This 6032 is important as it assures that any two compliant implementations can 6033 be configured to interoperate. Other TLS cipher suites recommended 6034 in RFC 7525 are RECOMMENDED: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 6035 TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 and 6036 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384. All other cipher suites are 6037 OPTIONAL. Note that this is a change from section 2.1 of [IMAP-TLS]. 6039 During the [TLS] negotiation, the client MUST check its understanding 6040 of the server hostname against the server's identity as presented in 6041 the server Certificate message, in order to prevent man-in-the-middle 6042 attacks. This procedure is described in [RFC7817]. 6044 Both the client and server MUST check the result of the STARTTLS 6045 command and subsequent [TLS] negotiation to see whether acceptable 6046 authentication and/or privacy was achieved. 6048 11.2. COPYUID and APPENDUID response codes 6050 The COPYUID and APPENDUID response codes return information about the 6051 mailbox, which may be considered sensitive if the mailbox has 6052 permissions set that permit the client to COPY or APPEND to the 6053 mailbox, but not SELECT or EXAMINE it. 6055 Consequently, these response codes SHOULD NOT be issued if the client 6056 does not have access to SELECT or EXAMINE the mailbox. 6058 11.3. LIST command and Other Users' namespace 6060 In response to a LIST command containing an argument of the Other 6061 Users' Namespace prefix, a server SHOULD NOT list users that have not 6062 granted list access to their personal mailboxes to the currently 6063 authenticated user. Providing such a list, could compromise security 6064 by potentially disclosing confidential information of who is located 6065 on the server, or providing a starting point of a list of user 6066 accounts to attack. 6068 11.4. Other Security Considerations 6070 A server error message for an AUTHENTICATE command which fails due to 6071 invalid credentials SHOULD NOT detail why the credentials are 6072 invalid. 6074 Use of the LOGIN command sends passwords in the clear. This can be 6075 avoided by using the AUTHENTICATE command with a [SASL] mechanism 6076 that does not use plaintext passwords, by first negotiating 6077 encryption via STARTTLS or some other protection mechanism. 6079 A server implementation MUST implement a configuration that, at the 6080 time of authentication, requires: 6081 (1) The STARTTLS command has been negotiated. 6082 OR 6083 (2) Some other mechanism that protects the session from password 6084 snooping has been provided. 6085 OR 6086 (3) The following measures are in place: 6088 (a) The LOGINDISABLED capability is advertised, and [SASL] mechanisms 6089 (such as PLAIN) using plaintext passwords are NOT advertised in the 6090 CAPABILITY list. 6091 AND 6092 (b) The LOGIN command returns an error even if the password is 6093 correct. 6094 AND 6095 (c) The AUTHENTICATE command returns an error with all [SASL] 6096 mechanisms that use plaintext passwords, even if the password is 6097 correct. 6099 A server error message for a failing LOGIN command SHOULD NOT specify 6100 that the user name, as opposed to the password, is invalid. 6102 A server SHOULD have mechanisms in place to limit or delay failed 6103 AUTHENTICATE/LOGIN attempts. 6105 Additional security considerations are discussed in the section 6106 discussing the AUTHENTICATE and LOGIN commands. 6108 12. IANA Considerations 6110 IANA is requested to update "Service Names and Transport Protocol 6111 Port Numbers" registry as follows: 6113 1. Registration for TCP "imap" port 143 should be updated to point 6114 to this document and RFC 3501. 6116 2. Registration for TCP "imaps" port 993 should be updated to point 6117 to this document, RFC 8314 and RFC 3501. 6119 3. Both UDP port 143 and UDP port 993 should be marked as "Reserved" 6120 in the registry. 6122 Additional IANA actions are specified in subsection of this section. 6124 12.1. Updates to IMAP4 Capabilities registry 6126 IMAP4 capabilities are registered by publishing a standards track or 6127 IESG approved informational or experimental RFC. The registry is 6128 currently located at: http://www.iana.org/assignments/ 6129 imap4-capabilities 6131 As this specification revises the STARTTLS and LOGINDISABLED 6132 extensions previously defined in [IMAP-TLS], IANA is requested to 6133 update registry entries for these 2 extensions to point to this 6134 document. 6136 12.2. GSSAPI/SASL service name 6138 GSSAPI/Kerberos/SASL service names are registered by publishing a 6139 standards track or IESG approved experimental RFC. The registry is 6140 currently located at: http://www.iana.org/assignments/gssapi-service- 6141 names 6143 IANA is requested to update the "imap" service name previously 6144 registered in RFC 3501, to point to this document. 6146 13. References 6148 13.1. Normative References 6150 [ABNF] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 6151 Specifications: ABNF", STD 68, RFC 5234, January 2008, 6152 . 6154 [ANONYMOUS] 6155 Zeilenga, K., "Anonymous Simple Authentication and 6156 Security Layer (SASL) Mechanism", RFC 4505, June 2006, 6157 . 6159 [CHARSET] Freed, N. and J. Postel, "IANA Charset Registration 6160 Procedures", BCP 19, RFC 2978, October 2000, 6161 . 6163 [SCRAM-SHA-256] 6164 Hansen, T., "SCRAM-SHA-256 and SCRAM-SHA-256-PLUS Simple 6165 Authentication and Security Layer (SASL) Mechanisms", 6166 RFC 7677, DOI 10.17487/RFC7677, November 2015, 6167 . 6169 [DISPOSITION] 6170 Troost, R., Dorner, S., and K. Moore, Ed., "Communicating 6171 Presentation Information in Internet Messages: The 6172 Content-Disposition Header Field", RFC 2183, August 1997, 6173 . 6175 [PLAIN] Zeilenga, K., Ed., "The PLAIN Simple Authentication and 6176 Security Layer (SASL) Mechanism", RFC 4616, August 2006, 6177 . 6179 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 6180 Requirement Levels", BCP 14, RFC 2119, 6181 DOI 10.17487/RFC2119, March 1997, 6182 . 6184 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 6185 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 6186 May 2017, . 6188 [LANGUAGE-TAGS] 6189 Alvestrand, H., "Content Language Headers", RFC 3282, May 6190 2002, . 6192 [LOCATION] 6193 Palme, J., Hopmann, A., and N. Shelness, "MIME 6194 Encapsulation of Aggregate Documents, such as HTML 6195 (MHTML)", RFC 2557, March 1999, 6196 . 6198 [MD5] Myers, J. and M. Rose, "The Content-MD5 Header Field", 6199 RFC 1864, October 1995, 6200 . 6202 [MIME-HDRS] 6203 Moore, K., "MIME (Multipurpose Internet Mail Extensions) 6204 Part Three: Message Header Extensions for Non-ASCII Text", 6205 RFC 2047, November 1996, 6206 . 6208 [MIME-IMB] 6209 Freed, N. and N. Borenstein, "Multipurpose Internet Mail 6210 Extensions (MIME) Part One: Format of Internet Message 6211 Bodies", RFC 2045, November 1996, 6212 . 6214 [MIME-IMT] 6215 Freed, N. and N. Borenstein, "Multipurpose Internet Mail 6216 Extensions (MIME) Part Two: Media Types", RFC 2046, 6217 November 1996, . 6219 [RFC2231] Freed, N. and K. Moore, "MIME Parameter Value and Encoded 6220 Word Extensions: Character Sets, Languages, and 6221 Continuations", RFC 2231, DOI 10.17487/RFC2231, November 6222 1997, . 6224 [RFC-5322] 6225 Resnick, P., Ed., "Internet Message Format", RFC 5322, 6226 October 2008, . 6228 [SASL] Melnikov, A., Ed. and K. Zeilenga, Ed., "Simple 6229 Authentication and Security Layer (SASL)", RFC 4422, June 6230 2006, . 6232 [TLS] Dierks, T. and E. Rescorla, "The Transport Layer Security 6233 (TLS) Protocol Version 1.2", RFC 5246, August 2008, 6234 . 6236 [UTF-7] Goldsmith, D. and M. Davis, "UTF-7 A Mail-Safe 6237 Transformation Format of Unicode", RFC 2152, May 1997, 6238 . 6240 [UTF-8] Yergeau, F., "UTF-8, a transformation format of ISO 6241 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 6242 2003, . 6244 [MULTIAPPEND] 6245 Crispin, M., "Internet Message Access Protocol (IMAP) - 6246 MULTIAPPEND Extension", RFC 3502, March 2003, 6247 . 6249 [NET-UNICODE] 6250 Klensin, J. and M. Padlipsky, "Unicode Format for Network 6251 Interchange", RFC 5198, DOI 10.17487/RFC5198, March 2008, 6252 . 6254 [I18N-HDRS] 6255 Yang, A., Steele, S., and N. Freed, "Internationalized 6256 Email Headers", RFC 6532, DOI 10.17487/RFC6532, February 6257 2012, . 6259 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 6260 Encodings", RFC 4648, DOI 10.17487/RFC4648, October 2006, 6261 . 6263 [RFC7817] Melnikov, A., "Updated Transport Layer Security (TLS) 6264 Server Identity Check Procedure for Email-Related 6265 Protocols", RFC 7817, DOI 10.17487/RFC7817, March 2016, 6266 . 6268 [RFC8098] Hansen, T., Ed. and A. Melnikov, Ed., "Message Disposition 6269 Notification", STD 85, RFC 8098, DOI 10.17487/RFC8098, 6270 February 2017, . 6272 [RFC8314] Moore, K. and C. Newman, "Cleartext Considered Obsolete: 6273 Use of Transport Layer Security (TLS) for Email Submission 6274 and Access", RFC 8314, DOI 10.17487/RFC8314, January 2018, 6275 . 6277 [IMAP-IMPLEMENTATION] 6278 Leiba, B., "IMAP4 Implementation Recommendations", 6279 RFC 2683, September 1999, 6280 . 6282 [IMAP-MULTIACCESS] 6283 Gahrns, M., "IMAP4 Multi-Accessed Mailbox Practice", 6284 RFC 2180, July 1997, 6285 . 6287 13.2. Informative References (related protocols) 6289 [RFC5258] Leiba, B. and A. Melnikov, "Internet Message Access 6290 Protocol version 4 - LIST Command Extensions", RFC 5258, 6291 DOI 10.17487/RFC5258, June 2008, 6292 . 6294 [RFC2193] Gahrns, M., "IMAP4 Mailbox Referrals", RFC 2193, 6295 DOI 10.17487/RFC2193, September 1997, 6296 . 6298 [RFC3348] Gahrns, M. and R. Cheng, "The Internet Message Action 6299 Protocol (IMAP4) Child Mailbox Extension", RFC 3348, 6300 DOI 10.17487/RFC3348, July 2002, 6301 . 6303 [RFC7888] Melnikov, A., Ed., "IMAP4 Non-synchronizing Literals", 6304 RFC 7888, DOI 10.17487/RFC7888, May 2016, 6305 . 6307 [IMAP-DISC] 6308 Melnikov, A., Ed., "Synchronization Operations for 6309 Disconnected IMAP4 Clients", RFC 4549, June 2006, 6310 . 6312 [IMAP-I18N] 6313 Newman, C., Gulbrandsen, A., and A. Melnikov, "Internet 6314 Message Access Protocol Internationalization", RFC 5255, 6315 DOI 10.17487/RFC5255, June 2008, 6316 . 6318 [IMAP-MODEL] 6319 Crispin, M., "Distributed Electronic Mail Models in 6320 IMAP4", RFC 1733, December 1994, 6321 . 6323 [IMAP-UTF-8] 6324 Resnick, P., Ed., Newman, C., Ed., and S. Shen, Ed., "IMAP 6325 Support for UTF-8", RFC 6855, DOI 10.17487/RFC6855, March 6326 2013, . 6328 [SMTP] Klensin, J., "Simple Mail Transfer Protocol", RFC 5321, 6329 October 2008, . 6331 [RFC3516] Nerenberg, L., "IMAP4 Binary Content Extension", RFC 3516, 6332 DOI 10.17487/RFC3516, April 2003, 6333 . 6335 [RFC4314] Melnikov, A., "IMAP4 Access Control List (ACL) Extension", 6336 RFC 4314, December 2005, 6337 . 6339 [RFC2087] Myers, J., "IMAP4 QUOTA extension", RFC 2087, January 6340 1997, . 6342 [IMAP-URL] 6343 Melnikov, A., Ed. and C. Newman, "IMAP URL Scheme", 6344 RFC 5092, DOI 10.17487/RFC5092, November 2007, 6345 . 6347 13.3. Informative References (historical aspects of IMAP and related 6348 protocols) 6350 [IMAP-COMPAT] 6351 Crispin, M., "IMAP4 Compatibility with IMAP2bis", 6352 RFC 2061, December 1996, 6353 . 6355 [IMAP-HISTORICAL] 6356 Crispin, M., "IMAP4 Compatibility with IMAP2 and 6357 IMAP2bis", RFC 1732, December 1994, 6358 . 6360 [IMAP-OBSOLETE] 6361 Crispin, M., "Internet Message Access Protocol - Obsolete 6362 Syntax", RFC 2062, December 1996, 6363 . 6365 [IMAP2] Crispin, M., "Interactive Mail Access Protocol: Version 6366 2", RFC 1176, August 1990, 6367 . 6369 [RFC-822] Crocker, D., "STANDARD FOR THE FORMAT OF ARPA INTERNET 6370 TEXT MESSAGES", STD 11, RFC 822, August 1982, 6371 . 6373 [RFC-821] Postel, J., "Simple Mail Transfer Protocol", STD 10, 6374 RFC 821, August 1982, 6375 . 6377 [IMAP-TLS] 6378 Newman, C., "Using TLS with IMAP, POP3 and ACAP", 6379 RFC 2595, June 1999, 6380 . 6382 Appendix A. Backward compatibility with IMAP4rev1 6384 An implementation that wants to remain compatible with IMAP4rev1 can 6385 advertise both IMAP4rev1 and IMAP4rev2 in its CAPABILITY response/ 6386 response code. While some IMAP4rev1 responses were removed in 6387 IMAP4rev2, their presence will not break IMAP4rev2-only clients. 6389 If both IMAP4rev1 and IMAP4rev2 are advertised, an IMAP client that 6390 wants to use IMAP4rev2 MUST issue an "ENABLE IMAP4rev2" command. 6392 Servers advertising both IMAP4rev1 and IMAP4rev2 SHOULD NOT 6394 generate UTF-8 quoted strings unless the client has issued "ENABLE 6395 IMAP4rev2". Consider implementation of mechanisms described or 6396 referenced in [IMAP-UTF-8] to achieve this goal. 6398 Servers advertising both IMAP4rev1 and IMAP4rev2, and clients 6399 intending to be compatible with IMAP4rev1 servers MUST be compatible 6400 with the international mailbox naming convention described in the 6401 following subsection. 6403 A.1. Mailbox International Naming Convention for compatibility with 6404 IMAP4rev1 6406 Support for the Mailbox International Naming Convention described in 6407 this section is not required for IMAP4rev2-only clients and servers. 6409 By convention, international mailbox names in IMAP4rev1 are specified 6410 using a modified version of the UTF-7 encoding described in [UTF-7]. 6411 Modified UTF-7 may also be usable in servers that implement an 6412 earlier version of this protocol. 6414 In modified UTF-7, printable US-ASCII characters, except for "&", 6415 represent themselves; that is, characters with octet values 0x20-0x25 6416 and 0x27-0x7e. The character "&" (0x26) is represented by the two- 6417 octet sequence "&-". 6419 All other characters (octet values 0x00-0x1f and 0x7f-0xff) are 6420 represented in modified BASE64, with a further modification from 6421 [UTF-7] that "," is used instead of "/". Modified BASE64 MUST NOT be 6422 used to represent any printing US-ASCII character which can represent 6423 itself. Only characters inside the modified BASE64 alphabet are 6424 permitted in modified BASE64 text. 6426 "&" is used to shift to modified BASE64 and "-" to shift back to US- 6427 ASCII. There is no implicit shift from BASE64 to US-ASCII, and null 6428 shifts ("-&" while in BASE64; note that "&-" while in US-ASCII means 6429 "&") are not permitted. However, all names start in US-ASCII, and 6430 MUST end in US-ASCII; that is, a name that ends with a non-ASCII 6431 ISO-10646 character MUST end with a "-"). 6433 The purpose of these modifications is to correct the following 6434 problems with UTF-7: 6436 1. UTF-7 uses the "+" character for shifting; this conflicts with 6437 the common use of "+" in mailbox names, in particular USENET 6438 newsgroup names. 6440 2. UTF-7's encoding is BASE64 which uses the "/" character; this 6441 conflicts with the use of "/" as a popular hierarchy delimiter. 6443 3. UTF-7 prohibits the unencoded usage of "\"; this conflicts with 6444 the use of "\" as a popular hierarchy delimiter. 6446 4. UTF-7 prohibits the unencoded usage of "~"; this conflicts with 6447 the use of "~" in some servers as a home directory indicator. 6449 5. UTF-7 permits multiple alternate forms to represent the same 6450 string; in particular, printable US-ASCII characters can be 6451 represented in encoded form. 6453 Although modified UTF-7 is a convention, it establishes certain 6454 requirements on server handling of any mailbox name with an embedded 6455 "&" character. In particular, server implementations MUST preserve 6456 the exact form of the modified BASE64 portion of a modified UTF-7 6457 name and treat that text as case-sensitive, even if names are 6458 otherwise case-insensitive or case-folded. 6460 Server implementations SHOULD verify that any mailbox name with an 6461 embedded "&" character, used as an argument to CREATE, is: in the 6462 correctly modified UTF-7 syntax, has no superfluous shifts, and has 6463 no encoding in modified BASE64 of any printing US-ASCII character 6464 which can represent itself. However, client implementations MUST NOT 6465 depend upon the server doing this, and SHOULD NOT attempt to create a 6466 mailbox name with an embedded "&" character unless it complies with 6467 the modified UTF-7 syntax. 6469 Server implementations which export a mail store that does not follow 6470 the modified UTF-7 convention MUST convert to modified UTF-7 any 6471 mailbox name that contains either non-ASCII characters or the "&" 6472 character. 6474 For example, here is a mailbox name which mixes English, Chinese, 6475 and Japanese text: ~peter/mail/&U,BTFw-/&ZeVnLIqe- 6477 For example, the string "&Jjo!" is not a valid mailbox name 6478 because it does not contain a shift to US-ASCII before the "!". 6479 The correct form is "&Jjo-!". The string "&U,BTFw-&ZeVnLIqe-" is 6480 not permitted because it contains a superfluous shift. The 6481 correct form is "&U,BTF2XlZyyKng-". 6483 Appendix B. Backward compatibility with BINARY extension 6485 IMAP4rev2 is incorporates subset of functionality provided by the 6486 BINARY extension [RFC3516], in particular it includes additional 6487 FETCH items (BINARY, BINARY.PEEK and BINARY.SIZE), but not extensions 6488 to the APPEND command. IMAP4rev2 implementations that supports full 6489 RFC 3516 functionality need to also advertise the BINARY token in the 6490 CAPABILITY response. 6492 Appendix C. Changes from RFC 3501 / IMAP4rev1 6494 The following is the plan for remaining changes. The plan might 6495 change over time. 6497 1. Fold in the following extensions/RFC: RFC 5530 (IMAP Response 6498 Codes, done), UIDPLUS (done), ENABLE (done), ESEARCH (done), 6499 SPECIAL-USE (list of new mailbox attributes is done), LITERAL- 6500 (done), NAMESPACE (done), SASL-IR (done), IDLE (done), MOVE 6501 (done). 6503 2. Add CLOSED response code (from CONDSTORE) - done 6505 3. Add support for $MDNSent and $Forwarded IMAP keywords - done. 6506 Add more examples showing their use? Also add other keywords 6507 like $Phishing, $Junk, $NonJunk? 6509 4. Require all unsolicited FETCH updates to include UID - done. 6511 5. Update recommendations on TLS ciphers to match UTA WG work (as 6512 per RFC 8314, RFC 7525 and RFC 7817) - done. 6514 6. Possibly fold in the following extensions/RFC: Base LIST- 6515 EXTENDED syntax plus deprecate LSUB (replace it with LIST 6516 \Subscribed) minus the requirement to support multiple list 6517 patterns, STATUS-in-LIST, SEARCHRES, BINARY (only the FETCH 6518 changes on leaf body part and make APPEND related ones optional. 6519 See the mailing list discussion) - done. 6521 6. 6523 7. Add STATUS SIZE (total mailbox size) - done. Add STATUS DELETED 6524 (number of messages with \Deleted flag set) - done. 6526 8. Drop UTF-7, all mailboxes are always in UTF-8 - done. 6528 9. Revise IANA registration of IMAP extensions and give advice on 6529 use of "X-" convention. 6531 10. Allow word-based searching (as per Chris Newman)? Need to 6532 discuss header field search, where exact/substring match is 6533 still required for interoperability. 6535 The following changes since RFC 3501 were done so far: 6537 1. Folded in IMAP UNSELECT (RFC 3691), UIDPLUS (RFC 4315), ESEARCH 6538 (RFC 4731), ENABLE (RFC 5161), IDLE (RFC 2177), SASL-IR (RFC 6539 4959) and MOVE (RFC 6851) extensions. Also folded RFC 5530 and 6540 FETCH side of the BINARY extension (RFC 3516). 6542 2. Clarified that server should decode parameter value 6543 continuations as described in [RFC2231]. This requirement was 6544 hidden in RFC 2231 itself. 6546 3. SEARCH command now requires to return ESEARCH response (SEARCH 6547 response is now deprecated). 6549 4. Added CLOSED response code from RFC 7162. 6551 5. Updated to use modern TLS-related recommendations as per RFC 6552 8314, RFC 7817, RFC 7525. 6554 6. For future extensibility extended ABNF for tagged-ext-simple to 6555 allow for bare number64. 6557 7. Added SHOULD level requirement on IMAP servers to support 6558 $MDNSent and $Forwarded keywords. 6560 8. Added STATUS SIZE and STATUS DELETED. 6562 9. Mailbox names and message headers now allow for UTF-8. Support 6563 for Modified UTF-7 in mailbox names is not required, unless 6564 compatibility with IMAP4rev1 is desired. 6566 10. UNSEEN response code on SELECT/EXAMINE is now deprecated. 6568 11. RECENT response on SELECT/EXAMINE, \Recent flag, RECENT STATUS, 6569 SEARCH NEW items are now deprecated. 6571 12. Clarified that the server doesn't need to send a new 6572 PERMANENTFLAGS response code when a new keyword was successfully 6573 added and the server advertised \* earlier for the same mailbox. 6575 13. Removed the CHECK command. Clients should use NOOP instead. 6577 14. RFC822, RFC822.HEADER and RFC822.TEXT FETCH data items were 6578 deprecated. Clients should use the corresponding BODY[] 6579 variants instead. 6581 15. Replaced DIGEST-MD5 SASL mechanism with SCRAM-SHA-256. DIGEST- 6582 MD5 was deprecated. 6584 16. LSUB command was deprecated. Clients should use LIST 6585 (SUBSCRIBED) instead. 6587 Appendix D. Acknowledgement 6589 Earlier versions of this document were edited by Mark Crispin. 6590 Sadly, he is no longer available to help with this work. Editors of 6591 this revisions are hoping that Mark would have approved. 6593 Chris Newman has contributed text on I18N and use of UTF-8 in 6594 messages and mailbox names. 6596 Thank you to Tony Hansen for helping with the index generation. 6597 Thank you to Timo Sirainen, Bron Gondwana and Arnt Gulbrandsen for 6598 extensive feedback. 6600 This document incorporate text from RFC 4315 (by Mark Crispin), RFC 6601 4466 (by Cyrus Daboo), RFC 4731 (by Dave Cridland), RFC 5161 (by Arnt 6602 Gulbrandsen), RFC 5530 (by Arnt Gulbrandsen), RFC 6154 (by Jamie 6603 Nicolson) 6605 so work done by authors/editors of these documents is appreciated. 6607 Index 6609 $ 6610 $Forwarded (predefined flag) 12 6611 $MDNSent (predefined flag) 12 6613 + 6614 +FLAGS 80 6615 +FLAGS.SILENT 80 6617 - 6618 -FLAGS 80 6619 -FLAGS.SILENT 80 6621 A 6622 ALERT (response code) 87 6623 ALL (fetch item) 76 6624 ALL (search key) 72 6625 ALL (search result option) 71 6626 ALREADYEXISTS (response code) 87 6627 ANSWERED (search key) 72 6628 APPEND (command) 63 6629 APPENDUID (response code) 88 6630 AUTHENTICATE (command) 28 6631 AUTHENTICATIONFAILED (response code) 88 6632 AUTHORIZATIONFAILED (response code) 89 6634 B 6635 BAD (response) 96 6636 BADCHARSET (response code) 89 6637 BCC (search key) 73 6638 BEFORE (search key) 73 6639 BINARY.PEEK[]<> (fetch item) 77 6640 BINARY.SIZE[] (fetch item) 77 6641 BINARY.SIZE[] (fetch result) 106 6642 BINARY[]<> (fetch result) 105 6643 BINARY[]<> (fetch item) 76 6644 BODY (fetch item) 77 6645 BODY (fetch result) 106 6646 BODY (search key) 73 6647 BODY.PEEK[
]<> (fetch item) 79 6648 BODYSTRUCTURE (fetch item) 79 6649 BODYSTRUCTURE (fetch result) 107 6650 BODY[
]<> (fetch result) 106 6651 BODY[
]<> (fetch item) 77 6652 BYE (response) 97 6653 Body Structure (message attribute) 13 6655 C 6656 CANNOT (response code) 89 6657 CAPABILITY (command) 24 6658 CAPABILITY (response code) 89 6659 CAPABILITY (response) 98 6660 CC (search key) 73 6661 CLIENTBUG (response code) 89 6662 CLOSE (command) 68 6663 CLOSED (response code) 90 6664 CONTACTADMIN (response code) 90 6665 COPY (command) 81 6666 COPYUID (response code) 90 6667 CORRUPTION (response code) 91 6668 COUNT (search result option) 71 6669 CREATE (command) 36 6671 D 6672 DELETE (command) 37 6673 DELETED (search key) 73 6674 DELETED (status item) 63 6675 DRAFT (search key) 73 6677 E 6678 ENABLE (command) 32 6679 ENVELOPE (fetch item) 79 6680 ENVELOPE (fetch result) 109 6681 ESEARCH (response) 103 6682 EXAMINE (command) 35 6683 EXPIRED (response code) 91 6684 EXPUNGE (command) 69 6685 EXPUNGE (response) 104 6686 EXPUNGEISSUED (response code) 91 6687 Envelope Structure (message attribute) 13 6689 F 6690 FAST (fetch item) 76 6691 FETCH (command) 76 6692 FETCH (response) 105 6693 FLAGGED (search key) 73 6694 FLAGS (fetch item) 79 6695 FLAGS (fetch result) 110 6696 FLAGS (response) 103 6697 FLAGS (store command data item) 80 6698 FLAGS.SILENT (store command data item) 80 6699 FROM (search key) 73 6700 FULL (fetch item) 76 6701 Flags (message attribute) 11 6703 H 6704 HEADER (part specifier) 77 6705 HEADER (search key) 73 6706 HEADER.FIELDS (part specifier) 77 6707 HEADER.FIELDS.NOT (part specifier) 77 6709 I 6710 IDLE (command) 66 6711 INTERNALDATE (fetch item) 79 6712 INTERNALDATE (fetch result) 110 6713 INUSE (response code) 91 6714 Internal Date (message attribute) 12 6716 K 6717 KEYWORD (search key) 73 6718 Keyword (type of flag) 12 6720 L 6721 LARGER (search key) 73 6722 LIMIT (response code) 92 6723 LIST (command) 41 6724 LIST (response) 99 6725 LOGOUT (command) 26 6727 M 6728 MAX (search result option) 71 6729 MAY (specification requirement term) 5 6730 MESSAGES (status item) 63 6731 MIME (part specifier) 78 6732 MIN (search result option) 71 6733 MOVE (command) 82 6734 MUST (specification requirement term) 5 6735 MUST NOT (specification requirement term) 5 6736 Message Sequence Number (message attribute) 11 6738 N 6739 NAMESPACE (command) 57 6740 NAMESPACE (response) 102 6741 NO (response) 95 6742 NONEXISTENT (response code) 92 6743 NOOP (command) 25 6744 NOPERM (response code) 92 6745 NOT (search key) 73 6746 NOT RECOMMENDED (specification requirement term) 5 6748 O 6749 OK (response) 95 6750 ON (search key) 73 6751 OPTIONAL (specification requirement term) 5 6752 OR (search key) 73 6753 OVERQUOTA (response code) 92 6755 P 6756 PARSE (response code) 93 6757 PERMANENTFLAGS (response code) 93 6758 PREAUTH (response) 96 6759 PRIVACYREQUIRED (response code) 93 6760 Permanent Flag (class of flag) 12 6761 Predefined keywords 12 6763 R 6764 READ-ONLY (response code) 93 6765 READ-WRITE (response code) 94 6766 RECOMMENDED (specification requirement term) 5 6767 RENAME (command) 39 6768 REQUIRED (specification requirement term) 5 6769 RFC822.SIZE (fetch item) 79 6770 RFC822.SIZE (fetch result) 110 6772 S 6773 SEARCH (command) 70 6774 SEEN (search key) 74 6775 SELECT (command) 34 6776 SENTBEFORE (search key) 74 6777 SENTON (search key) 74 6778 SENTSINCE (search key) 74 6779 SERVERBUG (response code) 94 6780 SHOULD (specification requirement term) 5 6781 SHOULD NOT (specification requirement term) 5 6782 SINCE (search key) 74 6783 SIZE (status item) 63 6784 SMALLER (search key) 74 6785 STARTTLS (command) 27 6786 STATUS (command) 62 6787 STATUS (response) 102 6788 STORE (command) 80 6789 SUBJECT (search key) 74 6790 SUBSCRIBE (command) 40 6791 Session Flag (class of flag) 12 6792 System Flag (type of flag) 11 6794 T 6795 TEXT (part specifier) 77 6796 TEXT (search key) 74 6797 TO (search key) 74 6798 TRYCREATE (response code) 94 6800 U 6801 UID (command) 84 6802 UID (fetch item) 79 6803 UID (fetch result) 110 6804 UID (search key) 74 6805 UIDNEXT (response code) 94 6806 UIDNEXT (status item) 63 6807 UIDNOTSTICKY (response code) 94 6808 UIDVALIDITY (response code) 94 6809 UIDVALIDITY (status item) 63 6810 UNANSWERED (search key) 74 6811 UNAVAILABLE (response code) 95 6812 UNDELETED (search key) 74 6813 UNDRAFT (search key) 74 6814 UNFLAGGED (search key) 74 6815 UNKEYWORD (search key) 74 6816 UNKNOWN-CTE (response code) 95 6817 UNSEEN (search key) 74 6818 UNSEEN (status item) 63 6819 UNSELECT (command) 69 6820 UNSUBSCRIBE (command) 41 6821 Unique Identifier (UID) (message attribute) 9 6823 X 6824 X (command) 85 6826 [ 6827 [RFC-5322] Size (message attribute) 13 6829 \ 6830 \All (mailbox name attribute) 100 6831 \Answered (system flag) 11 6832 \Archive (mailbox name attribute) 101 6833 \Deleted (system flag) 12 6834 \Draft (system flag) 12 6835 \Drafts (mailbox name attribute) 101 6836 \Flagged (mailbox name attribute) 101 6837 \Flagged (system flag) 11 6838 \HasChildren (mailbox name attribute) 99 6839 \HasNoChildren (mailbox name attribute) 100 6840 \Junk (mailbox name attribute) 101 6841 \Marked (mailbox name attribute) 100 6842 \Noinferiors (mailbox name attribute) 99 6843 \NonExistent (mailbox name attribute) 99 6844 \Noselect (mailbox name attribute) 99 6845 \Recent (system flag) 12 6846 \Remote (mailbox name attribute) 100 6847 \Seen (system flag) 11 6848 \Sent (mailbox name attribute) 101 6849 \Subscribed (mailbox name attribute) 100 6850 \Trash (mailbox name attribute) 101 6851 \Unmarked (mailbox name attribute) 100 6853 Authors' Addresses 6855 Alexey Melnikov (editor) 6856 Isode Ltd 6857 14 Castle Mews 6858 Hampton, Middlesex TW12 2NP 6859 UK 6861 Email: Alexey.Melnikov@isode.com 6863 Barry Leiba (editor) 6864 Huawei Technologies 6866 Phone: +1 646 827 0648 6867 Email: barryleiba@computer.org 6868 URI: http://internetmessagingtechnology.org/