idnits 2.17.1 draft-ietf-extra-imap4rev2-09.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 12 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 24, 2019) is 1615 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 6390, but not defined == Missing Reference: 'IMAP-OBSOLETE' is mentioned on line 6385, but not defined == Missing Reference: 'IMAP-COMPAT' is mentioned on line 6375, but not defined == Missing Reference: 'IMAP-HISTORICAL' is mentioned on line 6380, but not defined == Missing Reference: 'RFC-822' is mentioned on line 6394, but not defined ** Obsolete undefined reference: RFC 822 (Obsoleted by RFC 2822) == Missing Reference: 'HEADER' is mentioned on line 5225, but not defined == Missing Reference: 'IMAP-DISC' is mentioned on line 6332, but not defined == Missing Reference: 'SMTP' is mentioned on line 6353, but not defined == Missing Reference: 'RFC7888' is mentioned on line 6328, but not defined -- Looks like a reference, but probably isn't: '1' on line 842 == Missing Reference: 'IMAP-URL' is mentioned on line 6367, but not defined == Missing Reference: 'UIDVALIDITY 3857529045' is mentioned on line 5208, but not defined == Missing Reference: 'UIDNEXT 4392' is mentioned on line 1649, but not defined == Missing Reference: 'RFC5258' is mentioned on line 6314, but not defined == Missing Reference: 'RFC2193' is mentioned on line 6319, but not defined == Missing Reference: 'RFC3348' is mentioned on line 6323, but not defined ** Obsolete undefined reference: RFC 3348 (Obsoleted by RFC 5258) == Missing Reference: 'UIDNEXT 2' is mentioned on line 3062, but not defined == Missing Reference: 'UIDVALIDITY 1' is mentioned on line 3133, but not defined == Missing Reference: 'IMAP-I18N' is mentioned on line 6337, but not defined == Missing Reference: 'UID' is mentioned on line 3823, but not defined == Missing Reference: 'RFC4314' is mentioned on line 6360, but not defined == Missing Reference: 'RFC2087' is mentioned on line 6364, but not defined ** Obsolete undefined reference: RFC 2087 (Obsoleted by RFC 9208) == Missing Reference: 'READ-WRITE' is mentioned on line 5209, but not defined == Missing Reference: 'RFC4422' is mentioned on line 5545, but not defined == Missing Reference: 'IMAP4' is mentioned on line 5631, but not defined == Missing Reference: 'Namespace-Response-Extensions' is mentioned on line 5697, but not defined == Missing Reference: 'IMAP-TLS' is mentioned on line 6398, but not defined == Missing Reference: 'IMAP-MODEL' is mentioned on line 6343, but not defined == Missing Reference: 'IMAP-UTF-8' is mentioned on line 6417, but not defined == Missing Reference: 'RFC3516' is mentioned on line 6508, but not defined ** Obsolete normative reference: RFC 5246 (ref. 'TLS') (Obsoleted by RFC 8446) ** Downref: Normative reference to an Informational RFC: RFC 2152 (ref. 'UTF-7') ** Downref: Normative reference to an Informational RFC: RFC 2683 (ref. 'IMAP-IMPLEMENTATION') ** Downref: Normative reference to an Informational RFC: RFC 2180 (ref. 'IMAP-MULTIACCESS') Summary: 9 errors (**), 0 flaws (~~), 31 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 27, 2020 November 24, 2019 8 INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev2 9 draft-ietf-extra-imap4rev2-09 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 27, 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 . . . . . . . . . . . . . . . . . . 58 135 6.3.11. STATUS Command . . . . . . . . . . . . . . . . . . . 63 136 6.3.12. APPEND Command . . . . . . . . . . . . . . . . . . . 64 137 6.3.13. IDLE Command . . . . . . . . . . . . . . . . . . . . 67 138 6.4. Client Commands - Selected State . . . . . . . . . . . . 69 139 6.4.1. CLOSE Command . . . . . . . . . . . . . . . . . . . . 69 140 6.4.2. UNSELECT Command . . . . . . . . . . . . . . . . . . 70 141 6.4.3. EXPUNGE Command . . . . . . . . . . . . . . . . . . . 70 142 6.4.4. SEARCH Command . . . . . . . . . . . . . . . . . . . 71 143 6.4.5. FETCH Command . . . . . . . . . . . . . . . . . . . . 77 144 6.4.6. STORE Command . . . . . . . . . . . . . . . . . . . . 81 145 6.4.7. COPY Command . . . . . . . . . . . . . . . . . . . . 82 146 6.4.8. MOVE Command . . . . . . . . . . . . . . . . . . . . 83 147 6.4.9. UID Command . . . . . . . . . . . . . . . . . . . . . 85 148 6.5. Client Commands - Experimental/Expansion . . . . . . . . 86 149 6.5.1. X Command . . . . . . . . . . . . . . . . . . . 86 150 7. Server Responses . . . . . . . . . . . . . . . . . . . . . . 87 151 7.1. Server Responses - Status Responses . . . . . . . . . . . 88 152 7.1.1. OK Response . . . . . . . . . . . . . . . . . . . . . 96 153 7.1.2. NO Response . . . . . . . . . . . . . . . . . . . . . 96 154 7.1.3. BAD Response . . . . . . . . . . . . . . . . . . . . 97 155 7.1.4. PREAUTH Response . . . . . . . . . . . . . . . . . . 97 156 7.1.5. BYE Response . . . . . . . . . . . . . . . . . . . . 98 157 7.2. Server Responses - Server and Mailbox Status . . . . . . 98 158 7.2.1. The ENABLED Response . . . . . . . . . . . . . . . . 98 159 7.2.2. CAPABILITY Response . . . . . . . . . . . . . . . . . 99 160 7.2.3. LIST Response . . . . . . . . . . . . . . . . . . . . 100 161 7.2.4. NAMESPACE Response . . . . . . . . . . . . . . . . . 103 162 7.2.5. STATUS Response . . . . . . . . . . . . . . . . . . . 103 163 7.2.6. ESEARCH Response . . . . . . . . . . . . . . . . . . 104 164 7.2.7. FLAGS Response . . . . . . . . . . . . . . . . . . . 104 165 7.3. Server Responses - Mailbox Size . . . . . . . . . . . . . 105 166 7.3.1. EXISTS Response . . . . . . . . . . . . . . . . . . . 105 167 7.4. Server Responses - Message Status . . . . . . . . . . . . 105 168 7.4.1. EXPUNGE Response . . . . . . . . . . . . . . . . . . 105 169 7.4.2. FETCH Response . . . . . . . . . . . . . . . . . . . 106 170 7.5. Server Responses - Command Continuation Request . . . . . 112 171 8. Sample IMAP4rev2 connection . . . . . . . . . . . . . . . . . 112 172 9. Formal Syntax . . . . . . . . . . . . . . . . . . . . . . . . 113 173 10. Author's Note . . . . . . . . . . . . . . . . . . . . . . . . 130 174 11. Security Considerations . . . . . . . . . . . . . . . . . . . 130 175 11.1. STARTTLS Security Considerations . . . . . . . . . . . . 130 176 11.2. COPYUID and APPENDUID response codes . . . . . . . . . . 131 177 11.3. LIST command and Other Users' namespace . . . . . . . . 131 178 11.4. Other Security Considerations . . . . . . . . . . . . . 131 179 12. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 132 180 12.1. Updates to IMAP4 Capabilities registry . . . . . . . . . 132 181 12.2. GSSAPI/SASL service name . . . . . . . . . . . . . . . . 133 182 13. References . . . . . . . . . . . . . . . . . . . . . . . . . 133 183 13.1. Normative References . . . . . . . . . . . . . . . . . . 133 184 13.2. Informative References (related protocols) . . . . . . . 136 185 13.3. Informative References (historical aspects of IMAP and 186 related protocols) . . . . . . . . . . . . . . . . . . . 137 187 Appendix A. Backward compatibility with IMAP4rev1 . . . . . . . 138 188 A.1. Mailbox International Naming Convention for compatibility 189 with IMAP4rev1 . . . . . . . . . . . . . . . . . . . . . 138 190 Appendix B. Backward compatibility with BINARY extension . . . . 140 191 Appendix C. Changes from RFC 3501 / IMAP4rev1 . . . . . . . . . 140 192 Appendix D. Acknowledgement . . . . . . . . . . . . . . . . . . 142 193 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 194 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 148 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 8-bit UTF-8 (of which 7-bit US-ASCII is a subset) 244 unless otherwise specified. Other character sets are indicated using 245 a "CHARSET", as described in [MIME-IMT] and defined in [CHARSET]. 246 CHARSETs have important additional semantics in addition to defining 247 character set; refer to 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. Obsolete commands, 272 responses, and data formats which an IMAP4rev2 implementation can 273 encounter when used with an earlier implementation are described in 274 Appendix C and [IMAP-OBSOLETE]. 276 Other compatibility issues with IMAP2bis, the most common variant of 277 the earlier protocol, are discussed in [IMAP-COMPAT]. A full 278 discussion of compatibility issues with rare (and presumed extinct) 279 variants of [IMAP2] is in [IMAP-HISTORICAL]; this document is 280 primarily of historical interest. 282 IMAP was originally developed for the older [RFC-822] standard, and 283 as a consequence several fetch items in IMAP incorporate "RFC822" in 284 their name. With the exception of RFC822.SIZE, there are more modern 285 replacements; for example, the modern version of RFC822.HEADER is 286 BODY.PEEK[HEADER]. In all cases, "RFC822" should be interpreted as a 287 reference to the updated [RFC-5322] standard. 289 2. Protocol Overview 291 2.1. Link Level 293 The IMAP4rev2 protocol assumes a reliable data stream such as that 294 provided by TCP. When TCP is used, an IMAP4rev2 server listens on 295 port 143. 297 2.2. Commands and Responses 299 An IMAP4rev2 connection consists of the establishment of a client/ 300 server network connection, an initial greeting from the server, and 301 client/server interactions. These client/server interactions consist 302 of a client command, server data, and a server completion result 303 response. 305 All interactions transmitted by client and server are in the form of 306 lines, that is, strings that end with a CRLF. The protocol receiver 307 of an IMAP4rev2 client or server is either reading a line, or is 308 reading a sequence of octets with a known count followed by a line. 310 2.2.1. Client Protocol Sender and Server Protocol Receiver 312 The client command begins an operation. Each client command is 313 prefixed with an identifier (typically a short alphanumeric string, 314 e.g., A0001, A0002, etc.) called a "tag". A different tag is 315 generated by the client for each command. 317 Clients MUST follow the syntax outlined in this specification 318 strictly. It is a syntax error to send a command with missing or 319 extraneous spaces or arguments. 321 There are two cases in which a line from the client does not 322 represent a complete command. In one case, a command argument is 323 quoted with an octet count (see the description of literal in String 324 under Data Formats); in the other case, the command arguments require 325 server feedback (see the AUTHENTICATE command). In either case, the 326 server sends a command continuation request response if it is ready 327 for the octets (if appropriate) and the remainder of the command. 328 This response is prefixed with the token "+". 330 Note: If instead, the server detected an error in the command, it 331 sends a BAD completion response with a tag matching the command 332 (as described below) to reject the command and prevent the client 333 from sending any more of the command. 335 It is also possible for the server to send a completion response 336 for some other command (if multiple commands are in progress), or 337 untagged data. In either case, the command continuation request 338 is still pending; the client takes the appropriate action for the 339 response, and reads another response from the server. In all 340 cases, the client MUST send a complete command (including 341 receiving all command continuation request responses and command 342 continuations for the command) before initiating a new command. 344 The protocol receiver of an IMAP4rev2 server reads a command line 345 from the client, parses the command and its arguments, and transmits 346 server data and a server command completion result response. 348 2.2.2. Server Protocol Sender and Client Protocol Receiver 350 Data transmitted by the server to the client and status responses 351 that do not indicate command completion are prefixed with the token 352 "*", and are called untagged responses. 354 Server data MAY be sent as a result of a client command, or MAY be 355 sent unilaterally by the server. There is no syntactic difference 356 between server data that resulted from a specific command and server 357 data that were sent unilaterally. 359 The server completion result response indicates the success or 360 failure of the operation. It is tagged with the same tag as the 361 client command which began the operation. Thus, if more than one 362 command is in progress, the tag in a server completion response 363 identifies the command to which the response applies. There are 364 three possible server completion responses: OK (indicating success), 365 NO (indicating failure), or BAD (indicating a protocol error such as 366 unrecognized command or command syntax error). 368 Servers SHOULD enforce the syntax outlined in this specification 369 strictly. Any client command with a protocol syntax error, including 370 (but not limited to) missing or extraneous spaces or arguments, 371 SHOULD be rejected, and the client given a BAD server completion 372 response. 374 The protocol receiver of an IMAP4rev2 client reads a response line 375 from the server. It then takes action on the response based upon the 376 first token of the response, which can be a tag, a "*", or a "+". 378 A client MUST be prepared to accept any server response at all times. 379 This includes server data that was not requested. Server data SHOULD 380 be recorded, so that the client can reference its recorded copy 381 rather than sending a command to the server to request the data. In 382 the case of certain server data, the data MUST be recorded. 384 This topic is discussed in greater detail in the Server Responses 385 section. 387 2.3. Message Attributes 389 In addition to message text, each message has several attributes 390 associated with it. These attributes can be retrieved individually 391 or in conjunction with other attributes or message texts. 393 2.3.1. Message Numbers 395 Messages in IMAP4rev2 are accessed by one of two numbers; the unique 396 identifier or the message sequence number. 398 2.3.1.1. Unique Identifier (UID) Message Attribute 400 An unsigned 32-bit value assigned to each message, which when used 401 with the unique identifier validity value (see below) forms a 64-bit 402 value that MUST NOT refer to any other message in the mailbox or any 403 subsequent mailbox with the same name forever. Unique identifiers 404 are assigned in a strictly ascending fashion in the mailbox; as each 405 message is added to the mailbox it is assigned a higher UID than the 406 message(s) which were added previously. Unlike message sequence 407 numbers, unique identifiers are not necessarily contiguous. 409 The unique identifier of a message MUST NOT change during the 410 session, and SHOULD NOT change between sessions. Any change of 411 unique identifiers between sessions MUST be detectable using the 412 UIDVALIDITY mechanism discussed below. Persistent unique identifiers 413 are required for a client to resynchronize its state from a previous 414 session with the server (e.g., disconnected or offline access 415 clients); this is discussed further in [IMAP-DISC]. 417 Associated with every mailbox are two 32-bit unsigned values which 418 aid in unique identifier handling: the next unique identifier value 419 (UIDNEXT) and the unique identifier validity value (UIDVALIDITY). 421 The next unique identifier value is the predicted value that will be 422 assigned to a new message in the mailbox. Unless the unique 423 identifier validity also changes (see below), the next unique 424 identifier value MUST have the following two characteristics. First, 425 the next unique identifier value MUST NOT change unless new messages 426 are added to the mailbox; and second, the next unique identifier 427 value MUST change whenever new messages are added to the mailbox, 428 even if those new messages are subsequently expunged. 430 Note: The next unique identifier value is intended to provide a 431 means for a client to determine whether any messages have been 432 delivered to the mailbox since the previous time it checked this 433 value. It is not intended to provide any guarantee that any 434 message will have this unique identifier. A client can only 435 assume, at the time that it obtains the next unique identifier 436 value, that messages arriving after that time will have a UID 437 greater than or equal to that value. 439 The unique identifier validity value is sent in a UIDVALIDITY 440 response code in an OK untagged response at mailbox selection time. 441 If unique identifiers from an earlier session fail to persist in this 442 session, the unique identifier validity value MUST be greater than 443 the one used in the earlier session. 445 Note: Ideally, unique identifiers SHOULD persist at all times. 446 Although this specification recognizes that failure to persist can 447 be unavoidable in certain server environments, it STRONGLY 448 ENCOURAGES message store implementation techniques that avoid this 449 problem. For example: 451 1. Unique identifiers MUST be strictly ascending in the mailbox 452 at all times. If the physical message store is re-ordered by 453 a non-IMAP agent, this requires that the unique identifiers in 454 the mailbox be regenerated, since the former unique 455 identifiers are no longer strictly ascending as a result of 456 the re-ordering. 458 2. If the message store has no mechanism to store unique 459 identifiers, it must regenerate unique identifiers at each 460 session, and each session must have a unique UIDVALIDITY 461 value. 463 3. If the mailbox is deleted and a new mailbox with the same name 464 is created at a later date, the server must either keep track 465 of unique identifiers from the previous instance of the 466 mailbox, or it must assign a new UIDVALIDITY value to the new 467 instance of the mailbox. A good UIDVALIDITY value to use in 468 this case is a 32-bit representation of the creation date/time 469 of the mailbox. It is alright to use a constant such as 1, 470 but only if it guaranteed that unique identifiers will never 471 be reused, even in the case of a mailbox being deleted (or 472 renamed) and a new mailbox by the same name created at some 473 future time. 475 4. The combination of mailbox name, UIDVALIDITY, and UID must 476 refer to a single immutable message on that server forever. 477 In particular, the internal date, [RFC-5322] size, envelope, 478 body structure, and message texts (all BODY[...] fetch data 479 items) must never change. This does not include message 480 numbers, nor does it include attributes that can be set by a 481 STORE command (e.g., FLAGS). 483 2.3.1.2. Message Sequence Number Message Attribute 485 A relative position from 1 to the number of messages in the mailbox. 486 This position MUST be ordered by ascending unique identifier. As 487 each new message is added, it is assigned a message sequence number 488 that is 1 higher than the number of messages in the mailbox before 489 that new message was added. 491 Message sequence numbers can be reassigned during the session. For 492 example, when a message is permanently removed (expunged) from the 493 mailbox, the message sequence number for all subsequent messages is 494 decremented. The number of messages in the mailbox is also 495 decremented. Similarly, a new message can be assigned a message 496 sequence number that was once held by some other message prior to an 497 expunge. 499 In addition to accessing messages by relative position in the 500 mailbox, message sequence numbers can be used in mathematical 501 calculations. For example, if an untagged "11 EXISTS" is received, 502 and previously an untagged "8 EXISTS" was received, three new 503 messages have arrived with message sequence numbers of 9, 10, and 11. 504 Another example, if message 287 in a 523 message mailbox has UID 505 12345, there are exactly 286 messages which have lesser UIDs and 236 506 messages which have greater UIDs. 508 2.3.2. Flags Message Attribute 510 A list of zero or more named tokens associated with the message. A 511 flag is set by its addition to this list, and is cleared by its 512 removal. There are two types of flags in IMAP4rev2. A flag of 513 either type can be permanent or session-only. 515 A system flag is a flag name that is pre-defined in this 516 specification and begin with "\". 518 Certain system flags (\Deleted and \Seen) have special semantics 519 described elsewhere in this document. The currently-defined system 520 flags are: 522 \Seen Message has been read 524 \Answered Message has been answered 526 \Flagged Message is "flagged" for urgent/special attention 527 \Deleted Message is "deleted" for removal by later EXPUNGE 529 \Draft Message has not completed composition (marked as a draft). 531 \Recent This flag was in used in IMAP4rev1 and is now deprecated. 533 A keyword is defined by the server implementation. Keywords do not 534 begin with "\". Servers MAY permit the client to define new keywords 535 in the mailbox (see the description of the PERMANENTFLAGS response 536 code for more information). Some keywords that start with "$" are 537 also defined in this specification. 539 This document defines several keywords that were not originally 540 defined in RFC 3501, but which were found to be useful by client 541 implementations. These keywords SHOULD be supported (i.e. allowed in 542 APPEND, COPY, MOVE and SEARCH commands) by server implementations: 544 $Forwarded Message has been forwarded to another email address, 545 embedded within or attached to a new message. An email client 546 sets this keyword when it successfully forwards the message to 547 another email address. Typical usage of this keyword is to show a 548 different (or additional) icon for a message that has been 549 forwarded. Once set, the flag SHOULD NOT be cleared. 551 $Forwarded 553 $Forwarded 555 $MDNSent Message Disposition Notification [RFC8098] was generated 556 and sent for this message. 558 $MDNSent 560 A flag can be permanent or session-only on a per-flag basis. 561 Permanent flags are those which the client can add or remove from the 562 message flags permanently; that is, concurrent and subsequent 563 sessions will see any change in permanent flags. Changes to session 564 flags are valid only in that session. 566 2.3.3. Internal Date Message Attribute 568 The internal date and time of the message on the server. This is not 569 the date and time in the [RFC-5322] header, but rather a date and 570 time which reflects when the message was received. In the case of 571 messages delivered via [SMTP], this SHOULD be the date and time of 572 final delivery of the message as defined by [SMTP]. In the case of 573 messages delivered by the IMAP4rev2 COPY or MOVE command, this SHOULD 574 be the internal date and time of the source message. In the case of 575 messages delivered by the IMAP4rev2 APPEND command, this SHOULD be 576 the date and time as specified in the APPEND command description. 577 All other cases are implementation defined. 579 2.3.4. [RFC-5322] Size Message Attribute 581 The number of octets in the message, as expressed in [RFC-5322] 582 format. 584 2.3.5. Envelope Structure Message Attribute 586 A parsed representation of the [RFC-5322] header of the message. 587 Note that the IMAP Envelope structure is not the same as an [SMTP] 588 envelope. 590 2.3.6. Body Structure Message Attribute 592 A parsed representation of the [MIME-IMB] body structure information 593 of the message. 595 2.4. Message Texts 597 In addition to being able to fetch the full [RFC-5322] text of a 598 message, IMAP4rev2 permits the fetching of portions of the full 599 message text. Specifically, it is possible to fetch the [RFC-5322] 600 message header, [RFC-5322] message body, a [MIME-IMB] body part, or a 601 [MIME-IMB] header. 603 3. State and Flow Diagram 605 Once the connection between client and server is established, an 606 IMAP4rev2 connection is in one of four states. The initial state is 607 identified in the server greeting. Most commands are only valid in 608 certain states. It is a protocol error for the client to attempt a 609 command while the connection is in an inappropriate state, and the 610 server will respond with a BAD or NO (depending upon server 611 implementation) command completion result. 613 3.1. Not Authenticated State 615 In the not authenticated state, the client MUST supply authentication 616 credentials before most commands will be permitted. This state is 617 entered when a connection starts unless the connection has been pre- 618 authenticated. 620 3.2. Authenticated State 622 In the authenticated state, the client is authenticated and MUST 623 select a mailbox to access before commands that affect messages will 624 be permitted. This state is entered when a pre-authenticated 625 connection starts, when acceptable authentication credentials have 626 been provided, after an error in selecting a mailbox, or after a 627 successful CLOSE command. 629 3.3. Selected State 631 In a selected state, a mailbox has been selected to access. This 632 state is entered when a mailbox has been successfully selected. 634 3.4. Logout State 636 In the logout state, the connection is being terminated. This state 637 can be entered as a result of a client request (via the LOGOUT 638 command) or by unilateral action on the part of either the client or 639 server. 641 If the client requests the logout state, the server MUST send an 642 untagged BYE response and a tagged OK response to the LOGOUT command 643 before the server closes the connection; and the client MUST read the 644 tagged OK response to the LOGOUT command before the client closes the 645 connection. 647 A server SHOULD NOT unilaterally close the connection without sending 648 an untagged BYE response that contains the reason for having done so. 649 A client SHOULD NOT unilaterally close the connection, and instead 650 SHOULD issue a LOGOUT command. If the server detects that the client 651 has unilaterally closed the connection, the server MAY omit the 652 untagged BYE response and simply close its connection. 654 +----------------------+ 655 |connection established| 656 +----------------------+ 657 || 658 \/ 659 +--------------------------------------+ 660 | server greeting | 661 +--------------------------------------+ 662 || (1) || (2) || (3) 663 \/ || || 664 +-----------------+ || || 665 |Not Authenticated| || || 666 +-----------------+ || || 667 || (7) || (4) || || 668 || \/ \/ || 669 || +----------------+ || 670 || | Authenticated |<=++ || 671 || +----------------+ || || 672 || || (7) || (5) || (6) || 673 || || \/ || || 674 || || +--------+ || || 675 || || |Selected|==++ || 676 || || +--------+ || 677 || || || (7) || 678 \/ \/ \/ \/ 679 +--------------------------------------+ 680 | Logout | 681 +--------------------------------------+ 682 || 683 \/ 684 +-------------------------------+ 685 |both sides close the connection| 686 +-------------------------------+ 688 (1) connection without pre-authentication (OK greeting) 689 (2) pre-authenticated connection (PREAUTH greeting) 690 (3) rejected connection (BYE greeting) 691 (4) successful LOGIN or AUTHENTICATE command 692 (5) successful SELECT or EXAMINE command 693 (6) CLOSE command, unsolicited CLOSED response code or 694 failed SELECT or EXAMINE command 695 (7) LOGOUT command, server shutdown, or connection closed 697 4. Data Formats 699 IMAP4rev2 uses textual commands and responses. Data in IMAP4rev2 can 700 be in one of several forms: atom, number, string, parenthesized list, 701 or NIL. Note that a particular data item may take more than one 702 form; for example, a data item defined as using "astring" syntax may 703 be either an atom or a string. 705 4.1. Atom 707 An atom consists of one or more non-special characters. 709 4.1.1. Sequence set and UID set 711 A set of messages can be referenced by a sequence set containing 712 either message sequence numbers or unique identifiers. See Section 9 713 for details. Sequence sets can contain ranges (e.g. "5:50"), an 714 enumeration of specific message/UID numbers, a special symbol "*", or 715 a combination of the above. 717 A "UID set" is similar to the sequence set of unique identifiers; 718 however, the "*" value for a sequence number is not permitted. 720 4.2. Number 722 A number consists of one or more digit characters, and represents a 723 numeric value. 725 4.3. String 727 A string is in one of three forms: synchonizing literal, non- 728 synchronizing literal or quoted string. The synchronizing literal 729 form is the general form of string. The non-synchronizing literal 730 form is also the general form, but has length limitation. The quoted 731 string form is an alternative that avoids the overhead of processing 732 a literal at the cost of limitations of characters which may be used. 734 When the distinction between synchronizing and non-synchronizing 735 literals is not important, this document just uses the term 736 "literal". 738 A synchronizing literal is a sequence of zero or more octets 739 (including CR and LF), prefix-quoted with an octet count in the form 740 of an open brace ("{"), the number of octets, close brace ("}"), and 741 CRLF. In the case of synchronizing literals transmitted from server 742 to client, the CRLF is immediately followed by the octet data. In 743 the case of synchronizing literals transmitted from client to server, 744 the client MUST wait to receive a command continuation request 745 (described later in this document) before sending the octet data (and 746 the remainder of the command). 748 The non-synchronizing literal is an alternate form of synchronizing 749 literal, and it may appear in communication from client to server 750 instead of the synchonizing form of literal. The non-synchronizing 751 literal form MUST NOT be sent from server to client. The non- 752 synchronizing literal is distinguished from the synchronizing literal 753 by having a plus ("+") between the octet count and the closing brace 754 ("}"). The server does not generate a command continuation request 755 in response to a non-synchronizing literal, and clients are not 756 required to wait before sending the octets of a non- synchronizing 757 literal. Non-synchronizing literals MUST NOT be larger than 4096 758 octets. Any literal larger than 4096 bytes MUST be sent as a 759 synchronizing literal. (Non-synchronizing literals defined in this 760 document are the same as non-synchronizing literals defined by the 761 LITERAL- extension from [RFC7888]. See that document for details on 762 how to handle invalid non-synchronizing literals longer than 4096 763 octets and for interaction with other IMAP extensions.) 765 A quoted string is a sequence of zero or more Unicode characters, 766 excluding CR and LF, encoded in UTF-8, with double quote (<">) 767 characters at each end. 769 The empty string is represented as "" (a quoted string with zero 770 characters between double quotes), as {0} followed by CRLF (a 771 synchronizing literal with an octet count of 0) or as {0+} followed 772 by CRLF (a non-synchronizing literal with an octet count of 0). 774 Note: Even if the octet count is 0, a client transmitting a 775 synchronizing literal MUST wait to receive a command continuation 776 request. 778 4.3.1. 8-bit and Binary Strings 780 8-bit textual and binary mail is supported through the use of a 781 [MIME-IMB] content transfer encoding. IMAP4rev2 implementations MAY 782 transmit 8-bit or multi-octet characters in literals, but SHOULD do 783 so only when the [CHARSET] is identified. 785 IMAP4rev2 is compatible with [I18N-HDRS]. As a result, the 786 identified charset for header-field values with 8-bit content is 787 UTF-8 [UTF-8]. IMAP4rev2 implementations MUST accept and MAY 788 transmit [UTF-8] text in quoted-strings as long as the string does 789 not contain NUL, CR, or LF. This differs from IMAP4rev1 790 implementations. 792 Although a BINARY content transfer encoding is defined, unencoded 793 binary strings are not permitted, unless returned in a in 794 response to BINARY.PEEK[]<> or 795 BINARY[]<> FETCH data item. A "binary 796 string" is any string with NUL characters. A string with an 797 excessive amount of CTL characters MAY also be considered to be 798 binary. Unless returned in response to BINARY.PEEK[...]/BINARY[...] 799 FETCH, client and server implementations MUST encode binary data into 800 a textual form, such as BASE64, before transmitting the data. 802 4.4. Parenthesized List 804 Data structures are represented as a "parenthesized list"; a sequence 805 of data items, delimited by space, and bounded at each end by 806 parentheses. A parenthesized list can contain other parenthesized 807 lists, using multiple levels of parentheses to indicate nesting. 809 The empty list is represented as () -- a parenthesized list with no 810 members. 812 4.5. NIL 814 The special form "NIL" represents the non-existence of a particular 815 data item that is represented as a string or parenthesized list, as 816 distinct from the empty string "" or the empty parenthesized list (). 818 Note: NIL is never used for any data item which takes the form of 819 an atom. For example, a mailbox name of "NIL" is a mailbox named 820 NIL as opposed to a non-existent mailbox name. This is because 821 mailbox uses "astring" syntax which is an atom or a string. 822 Conversely, an addr-name of NIL is a non-existent personal name, 823 because addr-name uses "nstring" syntax which is NIL or a string, 824 but never an atom. 826 Examples: 828 The following LIST response: 830 * LIST () "/" NIL 832 is equivalent to: 833 * LIST () "/" "NIL" 835 as LIST response ABNF is using astring for mailbox name. 837 However, the following response 839 * FETCH 1 (BODY[1] NIL) 841 is not equivalent to: 842 * FETCH 1 (BODY[1] "NIL") 843 The former means absence of the body part, while the latter 844 means that it contains literal sequence of characters "NIL". 846 5. Operational Considerations 848 The following rules are listed here to ensure that all IMAP4rev2 849 implementations interoperate properly. 851 5.1. Mailbox Naming 853 In IMAP4rev2, Mailbox names are encoded in Net-Unicode [NET-UNICODE] 854 (this differs from IMAP4rev1). Client implementations MAY attempt to 855 create Net-Unicode mailbox names, and MUST interpret any 8-bit 856 mailbox names returned by LIST as [NET-UNICODE]. Server 857 implementations MUST prohibit the creation of 8-bit mailbox names 858 that do not comply with Net-Unicode (however, servers MAY accept a 859 de-normalized UTF-8 mailbox name and convert it to Net-Unicode prior 860 to mailbox creation). 862 The case-insensitive mailbox name INBOX is a special name reserved to 863 mean "the primary mailbox for this user on this server". (Note that 864 this special name may not exist on some servers for some users, for 865 example if the user has no access to personal namespace.) The 866 interpretation of all other names is implementation-dependent. 868 In particular, this specification takes no position on case 869 sensitivity in non-INBOX mailbox names. Some server implementations 870 are fully case-sensitive in ASCII range; others preserve case of a 871 newly-created name but otherwise are case-insensitive; and yet others 872 coerce names to a particular case. Client implementations MUST 873 interact with any of these. 875 There are certain client considerations when creating a new mailbox 876 name: 878 1. Any character which is one of the atom-specials (see the Formal 879 Syntax) will require that the mailbox name be represented as a 880 quoted string or literal. 882 2. CTL and other non-graphic characters are difficult to represent 883 in a user interface and are best avoided. Servers MAY refuse to 884 create mailbox names containing Unicode CTL characters. 886 3. Although the list-wildcard characters ("%" and "*") are valid in 887 a mailbox name, it is difficult to use such mailbox names with 888 the LIST command due to the conflict with wildcard 889 interpretation. 891 4. Usually, a character (determined by the server implementation) is 892 reserved to delimit levels of hierarchy. 894 5. Two characters, "#" and "&", have meanings by convention, and 895 should be avoided except when used in that convention. 897 5.1.1. Mailbox Hierarchy Naming 899 If it is desired to export hierarchical mailbox names, mailbox names 900 MUST be left-to-right hierarchical using a single character to 901 separate levels of hierarchy. The same hierarchy separator character 902 is used for all levels of hierarchy within a single name. 904 5.1.2. Namespaces 906 Personal Namespace: A namespace that the server considers within the 907 personal scope of the authenticated user on a particular connection. 908 Typically, only the authenticated user has access to mailboxes in 909 their Personal Namespace. It is the part of the namespace that 910 belongs to the user that is allocated for mailboxes. If an INBOX 911 exists for a user, it MUST appear within the user's personal 912 namespace. In the typical case, there SHOULD be only one Personal 913 Namespace on a server. 915 Other Users' Namespace: A namespace that consists of mailboxes from 916 the Personal Namespaces of other users. To access mailboxes in the 917 Other Users' Namespace, the currently authenticated user MUST be 918 explicitly granted access rights. For example, it is common for a 919 manager to grant to their secretary access rights to their mailbox. 920 In the typical case, there SHOULD be only one Other Users' Namespace 921 on a server. 923 Shared Namespace: A namespace that consists of mailboxes that are 924 intended to be shared amongst users and do not exist within a user's 925 Personal Namespace. 927 The namespaces a server uses MAY differ on a per-user basis. 929 5.1.2.1. Historic Mailbox Namespace Naming Convention 931 By convention, the first hierarchical element of any mailbox name 932 which begins with "#" identifies the "namespace" of the remainder of 933 the name. This makes it possible to disambiguate between different 934 types of mailbox stores, each of which have their own namespaces. 936 For example, implementations which offer access to USENET 937 newsgroups MAY use the "#news" namespace to partition the USENET 938 newsgroup namespace from that of other mailboxes. Thus, the 939 comp.mail.misc newsgroup would have a mailbox name of 940 "#news.comp.mail.misc", and the name "comp.mail.misc" can refer to 941 a different object (e.g., a user's private mailbox). 943 Namespaces that include the "#" character are not IMAP URL [IMAP-URL] 944 friendly requiring the "#" character to be represented as %23 when 945 within URLs. As such, server implementers MAY instead consider using 946 namespace prefixes that do not contain the "#" character. 948 5.1.2.2. Common namespace models 950 Previous version of this protocol does not define a default server 951 namespace. Two common namespace models have evolved: 953 The "Personal Mailbox" model, in which the default namespace that is 954 presented consists of only the user's personal mailboxes. To access 955 shared mailboxes, the user must use an escape mechanism to reach 956 another namespace. 958 The "Complete Hierarchy" model, in which the default namespace that 959 is presented includes the user's personal mailboxes along with any 960 other mailboxes they have access to. 962 5.2. Mailbox Size and Message Status Updates 964 At any time, a server can send data that the client did not request. 965 Sometimes, such behavior is REQUIRED. For example, agents other than 966 the server MAY add messages to the mailbox (e.g., new message 967 delivery), change the flags of the messages in the mailbox (e.g., 968 simultaneous access to the same mailbox by multiple agents), or even 969 remove messages from the mailbox. A server MUST send mailbox size 970 updates automatically if a mailbox size change is observed during the 971 processing of a command. A server SHOULD send message flag updates 972 automatically, without requiring the client to request such updates 973 explicitly. 975 Special rules exist for server notification of a client about the 976 removal of messages to prevent synchronization errors; see the 977 description of the EXPUNGE response for more detail. In particular, 978 it is NOT permitted to send an EXISTS response that would reduce the 979 number of messages in the mailbox; only the EXPUNGE response can do 980 this. 982 Regardless of what implementation decisions a client makes on 983 remembering data from the server, a client implementation MUST record 984 mailbox size updates. It MUST NOT assume that any command after the 985 initial mailbox selection will return the size of the mailbox. 987 5.3. Response when no Command in Progress 989 Server implementations are permitted to send an untagged response 990 (except for EXPUNGE) while there is no command in progress. Server 991 implementations that send such responses MUST deal with flow control 992 considerations. Specifically, they MUST either (1) verify that the 993 size of the data does not exceed the underlying transport's available 994 window size, or (2) use non-blocking writes. 996 5.4. Autologout Timer 998 If a server has an inactivity autologout timer that applies to 999 sessions after authentication, the duration of that timer MUST be at 1000 least 30 minutes. The receipt of ANY command from the client during 1001 that interval SHOULD suffice to reset the autologout timer. 1003 5.5. Multiple Commands in Progress (Command Pipelining) 1005 The client MAY send another command without waiting for the 1006 completion result response of a command, subject to ambiguity rules 1007 (see below) and flow control constraints on the underlying data 1008 stream. Similarly, a server MAY begin processing another command 1009 before processing the current command to completion, subject to 1010 ambiguity rules. However, any command continuation request responses 1011 and command continuations MUST be negotiated before any subsequent 1012 command is initiated. 1014 The exception is if an ambiguity would result because of a command 1015 that would affect the results of other commands. Clients MUST NOT 1016 send multiple commands without waiting if an ambiguity would result. 1017 If the server detects a possible ambiguity, it MUST execute commands 1018 to completion in the order given by the client. 1020 The most obvious example of ambiguity is when a command would affect 1021 the results of another command, e.g., a FETCH of a message's flags 1022 and a STORE of that same message's flags. 1024 A non-obvious ambiguity occurs with commands that permit an untagged 1025 EXPUNGE response (commands other than FETCH, STORE, and SEARCH), 1026 since an untagged EXPUNGE response can invalidate sequence numbers in 1027 a subsequent command. This is not a problem for FETCH, STORE, or 1028 SEARCH commands because servers are prohibited from sending EXPUNGE 1029 responses while any of those commands are in progress. Therefore, if 1030 the client sends any command other than FETCH, STORE, or SEARCH, it 1031 MUST wait for the completion result response before sending a command 1032 with message sequence numbers. 1034 Note: EXPUNGE responses are permitted while UID FETCH, UID STORE, 1035 and UID SEARCH are in progress. If the client sends a UID 1036 command, it MUST wait for a completion result response before 1037 sending a command which uses message sequence numbers (this may 1038 include UID SEARCH). Any message sequence numbers in an argument 1039 to UID SEARCH are associated with messages prior to the effect of 1040 any untagged EXPUNGE returned by the UID SEARCH. 1042 For example, the following non-waiting command sequences are invalid: 1044 FETCH + NOOP + STORE 1046 STORE + COPY + FETCH 1048 COPY + COPY 1050 The following are examples of valid non-waiting command sequences: 1052 FETCH + STORE + SEARCH + NOOP 1054 STORE + COPY + EXPUNGE 1056 UID SEARCH + UID SEARCH may be valid or invalid as a non-waiting 1057 command sequence, depending upon whether or not the second UID 1058 SEARCH contains message sequence numbers. 1060 6. Client Commands 1062 IMAP4rev2 commands are described in this section. Commands are 1063 organized by the state in which the command is permitted. Commands 1064 which are permitted in multiple states are listed in the minimum 1065 permitted state (for example, commands valid in authenticated and 1066 selected state are listed in the authenticated state commands). 1068 Command arguments, identified by "Arguments:" in the command 1069 descriptions below, are described by function, not by syntax. The 1070 precise syntax of command arguments is described in the Formal Syntax 1071 (Section 9). 1073 Some commands cause specific server responses to be returned; these 1074 are identified by "Responses:" in the command descriptions below. 1075 See the response descriptions in the Responses section for 1076 information on these responses, and the Formal Syntax section for the 1077 precise syntax of these responses. It is possible for server data to 1078 be transmitted as a result of any command. Thus, commands that do 1079 not specifically require server data specify "no specific responses 1080 for this command" instead of "none". 1082 The "Result:" in the command description refers to the possible 1083 tagged status responses to a command, and any special interpretation 1084 of these status responses. 1086 The state of a connection is only changed by successful commands 1087 which are documented as changing state. A rejected command (BAD 1088 response) never changes the state of the connection or of the 1089 selected mailbox. A failed command (NO response) generally does not 1090 change the state of the connection or of the selected mailbox; the 1091 exception being the SELECT and EXAMINE commands. 1093 6.1. Client Commands - Any State 1095 The following commands are valid in any state: CAPABILITY, NOOP, and 1096 LOGOUT. 1098 6.1.1. CAPABILITY Command 1100 Arguments: none 1102 Responses: REQUIRED untagged response: CAPABILITY 1104 Result: OK - capability completed 1105 BAD - command unknown or arguments invalid 1107 The CAPABILITY command requests a listing of capabilities that the 1108 server supports. The server MUST send a single untagged CAPABILITY 1109 response with "IMAP4rev2" as one of the listed capabilities before 1110 the (tagged) OK response. 1112 A capability name which begins with "AUTH=" indicates that the server 1113 supports that particular authentication mechanism. All such names 1114 are, by definition, part of this specification. For example, the 1115 authorization capability for an experimental "blurdybloop" 1116 authenticator would be "AUTH=XBLURDYBLOOP" and not 1117 "XAUTH=BLURDYBLOOP" or "XAUTH=XBLURDYBLOOP". 1119 Other capability names refer to extensions, revisions, or amendments 1120 to this specification. See the documentation of the CAPABILITY 1121 response for additional information. No capabilities, beyond the 1122 base IMAP4rev2 set defined in this specification, are enabled without 1123 explicit client action to invoke the capability. 1125 Client and server implementations MUST implement the STARTTLS, 1126 LOGINDISABLED, and AUTH=PLAIN (described in [PLAIN]) capabilities. 1127 See the Security Considerations section for important information. 1129 See the section entitled "Client Commands - Experimental/Expansion" 1130 for information about the form of site or implementation-specific 1131 capabilities. 1133 Example: C: abcd CAPABILITY 1134 S: * CAPABILITY IMAP4rev2 STARTTLS AUTH=GSSAPI 1135 LOGINDISABLED 1136 S: abcd OK CAPABILITY completed 1137 C: efgh STARTTLS 1138 S: efgh OK STARTLS completed 1139 1140 C: ijkl CAPABILITY 1141 S: * CAPABILITY IMAP4rev2 AUTH=GSSAPI AUTH=PLAIN 1142 S: ijkl OK CAPABILITY completed 1144 6.1.2. NOOP Command 1146 Arguments: none 1148 Responses: no specific responses for this command (but see below) 1150 Result: OK - noop completed 1151 BAD - command unknown or arguments invalid 1153 The NOOP command always succeeds. It does nothing. 1155 Since any command can return a status update as untagged data, the 1156 NOOP command can be used as a periodic poll for new messages or 1157 message status updates during a period of inactivity (the IDLE 1158 command Section 6.3.13 should be used instead of NOOP if real-time 1159 updates to mailbox state are desirable). The NOOP command can also 1160 be used to reset any inactivity autologout timer on the server. 1162 Example: C: a002 NOOP 1163 S: a002 OK NOOP completed 1164 . . . 1165 C: a047 NOOP 1166 S: * 22 EXPUNGE 1167 S: * 23 EXISTS 1168 S: * 14 FETCH (UID 1305 FLAGS (\Seen \Deleted)) 1169 S: a047 OK NOOP completed 1171 6.1.3. LOGOUT Command 1173 Arguments: none 1175 Responses: REQUIRED untagged response: BYE 1177 Result: OK - logout completed 1178 BAD - command unknown or arguments invalid 1180 The LOGOUT command informs the server that the client is done with 1181 the connection. The server MUST send a BYE untagged response before 1182 the (tagged) OK response, and then close the network connection. 1184 Example: C: A023 LOGOUT 1185 S: * BYE IMAP4rev2 Server logging out 1186 S: A023 OK LOGOUT completed 1187 (Server and client then close the connection) 1189 6.2. Client Commands - Not Authenticated State 1191 In the not authenticated state, the AUTHENTICATE or LOGIN command 1192 establishes authentication and enters the authenticated state. The 1193 AUTHENTICATE command provides a general mechanism for a variety of 1194 authentication techniques, privacy protection, and integrity 1195 checking; whereas the LOGIN command uses a traditional user name and 1196 plaintext password pair and has no means of establishing privacy 1197 protection or integrity checking. 1199 The STARTTLS command is an alternate form of establishing session 1200 privacy protection and integrity checking, but does not by itself 1201 establish authentication or enter the authenticated state. 1203 Server implementations MAY allow access to certain mailboxes without 1204 establishing authentication. This can be done by means of the 1205 ANONYMOUS [SASL] authenticator described in [ANONYMOUS]. An older 1206 convention is a LOGIN command using the userid "anonymous"; in this 1207 case, a password is required although the server may choose to accept 1208 any password. The restrictions placed on anonymous users are 1209 implementation-dependent. 1211 Once authenticated (including as anonymous), it is not possible to 1212 re-enter not authenticated state. 1214 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 1215 the following commands are valid in the not authenticated state: 1216 STARTTLS, AUTHENTICATE and LOGIN. See the Security Considerations 1217 section for important information about these commands. 1219 6.2.1. STARTTLS Command 1221 Arguments: none 1223 Responses: no specific response for this command 1225 Result: OK - starttls completed, begin TLS negotiation 1226 BAD - command unknown or arguments invalid 1228 A [TLS] negotiation begins immediately after the CRLF at the end of 1229 the tagged OK response from the server. Once a client issues a 1230 STARTTLS command, it MUST NOT issue further commands until a server 1231 response is seen and the [TLS] negotiation is complete. 1233 The server remains in the non-authenticated state, even if client 1234 credentials are supplied during the [TLS] negotiation. This does not 1235 preclude an authentication mechanism such as EXTERNAL (defined in 1236 [SASL]) from using client identity determined by the [TLS] 1237 negotiation. 1239 Once [TLS] has been started, the client MUST discard cached 1240 information about server capabilities and SHOULD re-issue the 1241 CAPABILITY command. This is necessary to protect against man-in- 1242 the-middle attacks which alter the capabilities list prior to 1243 STARTTLS. The server MAY advertise different capabilities, and in 1244 particular SHOULD NOT advertise the STARTTLS capability, after a 1245 successful STARTTLS command. 1247 Example: C: a001 CAPABILITY 1248 S: * CAPABILITY IMAP4rev2 STARTTLS LOGINDISABLED 1249 S: a001 OK CAPABILITY completed 1250 C: a002 STARTTLS 1251 S: a002 OK Begin TLS negotiation now 1252 1253 C: a003 CAPABILITY 1254 S: * CAPABILITY IMAP4rev2 AUTH=PLAIN 1255 S: a003 OK CAPABILITY completed 1256 C: a004 LOGIN joe password 1257 S: a004 OK LOGIN completed 1259 6.2.2. AUTHENTICATE Command 1261 Arguments: SASL authentication mechanism name 1262 OPTIONAL initial response 1264 Responses: continuation data can be requested 1266 Result: OK - authenticate completed, now in authenticated state 1267 NO - authenticate failure: unsupported authentication 1268 mechanism, credentials rejected 1269 BAD - command unknown or arguments invalid, 1270 authentication exchange cancelled 1272 The AUTHENTICATE command indicates a [SASL] authentication mechanism 1273 to the server. If the server supports the requested authentication 1274 mechanism, it performs an authentication protocol exchange to 1275 authenticate and identify the client. It MAY also negotiate an 1276 OPTIONAL security layer for subsequent protocol interactions. If the 1277 requested authentication mechanism is not supported, the server 1278 SHOULD reject the AUTHENTICATE command by sending a tagged NO 1279 response. 1281 The AUTHENTICATE command supports the optional "initial response" 1282 feature defined in Section 5.1 of [SASL]. The client doesn't need to 1283 use it. If a SASL mechanism supports "initial response", but it is 1284 not specified by the client, the server handles this as specified in 1285 Section 3 of [SASL]. 1287 The service name specified by this protocol's profile of [SASL] is 1288 "imap". 1290 The authentication protocol exchange consists of a series of server 1291 challenges and client responses that are specific to the 1292 authentication mechanism. A server challenge consists of a command 1293 continuation request response with the "+" token followed by a BASE64 1294 encoded (see Section 4 of [RFC4648]) string. The client response 1295 consists of a single line consisting of a BASE64 encoded string. If 1296 the client wishes to cancel an authentication exchange, it issues a 1297 line consisting of a single "*". If the server receives such a 1298 response, or if it receives an invalid BASE64 string (e.g. 1299 characters outside the BASE64 alphabet, or non-terminal "="), it MUST 1300 reject the AUTHENTICATE command by sending a tagged BAD response. 1302 As with any other client response, this initial response MUST be 1303 encoded as BASE64. It also MUST be transmitted outside of a quoted 1304 string or literal. To send a zero-length initial response, the 1305 client MUST send a single pad character ("="). This indicates that 1306 the response is present, but is a zero-length string. 1308 When decoding the BASE64 data in the initial response, decoding 1309 errors MUST be treated as in any normal SASL client response, i.e. 1310 with a tagged BAD response. In particular, the server should check 1311 for any characters not explicitly allowed by the BASE64 alphabet, as 1312 well as any sequence of BASE64 characters that contains the pad 1313 character ('=') anywhere other than the end of the string (e.g., 1314 "=AAA" and "AAA=BBB" are not allowed). 1316 If the client uses an initial response with a SASL mechanism that 1317 does not support an initial response, the server MUST reject the 1318 command with a tagged BAD response. 1320 If a security layer is negotiated through the [SASL] authentication 1321 exchange, it takes effect immediately following the CRLF that 1322 concludes the authentication exchange for the client, and the CRLF of 1323 the tagged OK response for the server. 1325 While client and server implementations MUST implement the 1326 AUTHENTICATE command itself, it is not required to implement any 1327 authentication mechanisms other than the PLAIN mechanism described in 1328 [PLAIN]. Also, an authentication mechanism is not required to 1329 support any security layers. 1331 Note: a server implementation MUST implement a configuration in 1332 which it does NOT permit any plaintext password mechanisms, unless 1333 either the STARTTLS command has been negotiated or some other 1334 mechanism that protects the session from password snooping has 1335 been provided. Server sites SHOULD NOT use any configuration 1336 which permits a plaintext password mechanism without such a 1337 protection mechanism against password snooping. Client and server 1338 implementations SHOULD implement additional [SASL] mechanisms that 1339 do not use plaintext passwords, such the GSSAPI mechanism 1340 described in [SASL] and/or the SCRAM-SHA-256/SCRAM-SHA-256-PLUS 1341 [SCRAM-SHA-256] mechanisms. 1343 Servers and clients can support multiple authentication mechanisms. 1344 The server SHOULD list its supported authentication mechanisms in the 1345 response to the CAPABILITY command so that the client knows which 1346 authentication mechanisms to use. 1348 A server MAY include a CAPABILITY response code in the tagged OK 1349 response of a successful AUTHENTICATE command in order to send 1350 capabilities automatically. It is unnecessary for a client to send a 1351 separate CAPABILITY command if it recognizes these automatic 1352 capabilities. This should only be done if a security layer was not 1353 negotiated by the AUTHENTICATE command, because the tagged OK 1354 response as part of an AUTHENTICATE command is not protected by 1355 encryption/integrity checking. [SASL] requires the client to re- 1356 issue a CAPABILITY command in this case. The server MAY advertise 1357 different capabilities after a successful AUTHENTICATE command. 1359 If an AUTHENTICATE command fails with a NO response, the client MAY 1360 try another authentication mechanism by issuing another AUTHENTICATE 1361 command. It MAY also attempt to authenticate by using the LOGIN 1362 command (see Section 6.2.3 for more detail). In other words, the 1363 client MAY request authentication types in decreasing order of 1364 preference, with the LOGIN command as a last resort. 1366 The authorization identity passed from the client to the server 1367 during the authentication exchange is interpreted by the server as 1368 the user name whose privileges the client is requesting. 1370 Example: S: * OK IMAP4rev2 Server 1371 C: A001 AUTHENTICATE GSSAPI 1372 S: + 1373 C: YIIB+wYJKoZIhvcSAQICAQBuggHqMIIB5qADAgEFoQMCAQ6iBw 1374 MFACAAAACjggEmYYIBIjCCAR6gAwIBBaESGxB1Lndhc2hpbmd0 1375 b24uZWR1oi0wK6ADAgEDoSQwIhsEaW1hcBsac2hpdmFtcy5jYW 1376 Mud2FzaGluZ3Rvbi5lZHWjgdMwgdCgAwIBAaEDAgEDooHDBIHA 1377 cS1GSa5b+fXnPZNmXB9SjL8Ollj2SKyb+3S0iXMljen/jNkpJX 1378 AleKTz6BQPzj8duz8EtoOuNfKgweViyn/9B9bccy1uuAE2HI0y 1379 C/PHXNNU9ZrBziJ8Lm0tTNc98kUpjXnHZhsMcz5Mx2GR6dGknb 1380 I0iaGcRerMUsWOuBmKKKRmVMMdR9T3EZdpqsBd7jZCNMWotjhi 1381 vd5zovQlFqQ2Wjc2+y46vKP/iXxWIuQJuDiisyXF0Y8+5GTpAL 1382 pHDc1/pIGmMIGjoAMCAQGigZsEgZg2on5mSuxoDHEA1w9bcW9n 1383 FdFxDKpdrQhVGVRDIzcCMCTzvUboqb5KjY1NJKJsfjRQiBYBdE 1384 NKfzK+g5DlV8nrw81uOcP8NOQCLR5XkoMHC0Dr/80ziQzbNqhx 1385 O6652Npft0LQwJvenwDI13YxpwOdMXzkWZN/XrEqOWp6GCgXTB 1386 vCyLWLlWnbaUkZdEYbKHBPjd8t/1x5Yg== 1387 S: + YGgGCSqGSIb3EgECAgIAb1kwV6ADAgEFoQMCAQ+iSzBJoAMC 1388 AQGiQgRAtHTEuOP2BXb9sBYFR4SJlDZxmg39IxmRBOhXRKdDA0 1389 uHTCOT9Bq3OsUTXUlk0CsFLoa8j+gvGDlgHuqzWHPSQg== 1390 C: 1391 S: + YDMGCSqGSIb3EgECAgIBAAD/////6jcyG4GE3KkTzBeBiVHe 1392 ceP2CWY0SR0fAQAgAAQEBAQ= 1393 C: YDMGCSqGSIb3EgECAgIBAAD/////3LQBHXTpFfZgrejpLlLImP 1394 wkhbfa2QteAQAgAG1yYwE= 1395 S: A001 OK GSSAPI authentication successful 1397 Note: The line breaks within server challenges and client responses 1398 are for editorial clarity and are not in real authenticators. 1400 6.2.3. LOGIN Command 1402 Arguments: user name 1403 password 1405 Responses: no specific responses for this command 1407 Result: OK - login completed, now in authenticated state 1408 NO - login failure: user name or password rejected 1409 BAD - command unknown or arguments invalid 1411 The LOGIN command identifies the client to the server and carries the 1412 plaintext password authenticating this user. 1414 A server MAY include a CAPABILITY response code in the tagged OK 1415 response to a successful LOGIN command in order to send capabilities 1416 automatically. It is unnecessary for a client to send a separate 1417 CAPABILITY command if it recognizes these automatic capabilities. 1419 Example: C: a001 LOGIN SMITH SESAME 1420 S: a001 OK LOGIN completed 1422 Note: Use of the LOGIN command over an insecure network (such as the 1423 Internet) is a security risk, because anyone monitoring network 1424 traffic can obtain plaintext passwords. The LOGIN command SHOULD NOT 1425 be used except as a last resort, and it is recommended that client 1426 implementations have a means to disable any automatic use of the 1427 LOGIN command. 1429 Unless either the client is accessing IMAP service on IMAPS port 1430 [RFC8314], the STARTTLS command has been negotiated or some other 1431 mechanism that protects the session from password snooping has been 1432 provided, a server implementation MUST implement a configuration in 1433 which it advertises the LOGINDISABLED capability and does NOT permit 1434 the LOGIN command. Server sites SHOULD NOT use any configuration 1435 which permits the LOGIN command without such a protection mechanism 1436 against password snooping. A client implementation MUST NOT send a 1437 LOGIN command if the LOGINDISABLED capability is advertised. 1439 6.3. Client Commands - Authenticated State 1441 In the authenticated state, commands that manipulate mailboxes as 1442 atomic entities are permitted. Of these commands, the SELECT and 1443 EXAMINE commands will select a mailbox for access and enter the 1444 selected state. 1446 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 1447 the following commands are valid in the authenticated state: ENABLE, 1448 SELECT, EXAMINE, NAMESPACE, CREATE, DELETE, RENAME, SUBSCRIBE, 1449 UNSUBSCRIBE, LIST, STATUS, APPEND and IDLE. 1451 6.3.1. ENABLE Command 1453 Arguments: capability names 1455 Responses: no specific responses for this command 1457 Result: OK - Relevant capabilities enabled 1458 BAD - No arguments, or syntax error in an argument 1460 Several IMAP extensions allow the server to return unsolicited 1461 responses specific to these extensions in certain circumstances. 1462 However, servers cannot send those unsolicited responses (with the 1463 exception of response codes (see Section 7.1) included in tagged or 1464 untagged OK/NO/BAD responses, which can always be sent) until they 1465 know that the clients support such extensions and thus won't choke on 1466 the extension response data. 1468 The ENABLE command provides an explicit indication from the client 1469 that it supports particular extensions. It is designed such that the 1470 client can send a simple constant string with the extensions it 1471 supports, and the server will enable the shared subset that both 1472 support. 1474 The ENABLE command takes a list of capability names, and requests the 1475 server to enable the named extensions. Once enabled using ENABLE, 1476 each extension remains active until the IMAP connection is closed. 1477 For each argument, the server does the following: 1479 o If the argument is not an extension known to the server, the 1480 server MUST ignore the argument. 1482 o If the argument is an extension known to the server, and it is not 1483 specifically permitted to be enabled using ENABLE, the server MUST 1484 ignore the argument. (Note that knowing about an extension 1485 doesn't necessarily imply supporting that extension.) 1487 o If the argument is an extension that is supported by the server 1488 and that needs to be enabled, the server MUST enable the extension 1489 for the duration of the connection. Note that once an extension 1490 is enabled, there is no way to disable it. 1492 If the ENABLE command is successful, the server MUST send an untagged 1493 ENABLED response Section 7.2.1. 1495 Clients SHOULD only include extensions that need to be enabled by the 1496 server. For example, a client can enable IMAP4rev2 specific 1497 behaviour when both IMAP4rev1 and IMAP4rev2 are advertised in the 1498 CAPABILITY response. Future RFCs may add to this list. 1500 The ENABLE command is only valid in the authenticated state, before 1501 any mailbox is selected. Clients MUST NOT issue ENABLE once they 1502 SELECT/EXAMINE a mailbox; however, server implementations don't have 1503 to check that no mailbox is selected or was previously selected 1504 during the duration of a connection. 1506 The ENABLE command can be issued multiple times in a session. It is 1507 additive; i.e., "ENABLE a b", followed by "ENABLE c" is the same as a 1508 single command "ENABLE a b c". When multiple ENABLE commands are 1509 issued, each corresponding ENABLED response SHOULD only contain 1510 extensions enabled by the corresponding ENABLE command. 1512 There are no limitations on pipelining ENABLE. For example, it is 1513 possible to send ENABLE and then immediately SELECT, or a LOGIN 1514 immediately followed by ENABLE. 1516 The server MUST NOT change the CAPABILITY list as a result of 1517 executing ENABLE; i.e., a CAPABILITY command issued right after an 1518 ENABLE command MUST list the same capabilities as a CAPABILITY 1519 command issued before the ENABLE command. This is demonstrated in 1520 the following example: 1522 C: t1 CAPABILITY 1523 S: * CAPABILITY IMAP4rev1 ID LITERAL+ ENABLE X-GOOD-IDEA 1524 S: t1 OK foo 1525 C: t2 ENABLE CONDSTORE X-GOOD-IDEA 1526 S: * ENABLED X-GOOD-IDEA 1527 S: t2 OK foo 1528 C: t3 CAPABILITY 1529 S: * CAPABILITY IMAP4rev1 ID LITERAL+ ENABLE X-GOOD-IDEA 1530 S: t3 OK foo again 1532 In the following example, the client enables CONDSTORE: 1534 C: a1 ENABLE CONDSTORE 1535 S: * ENABLED CONDSTORE 1536 S: a1 OK Conditional Store enabled 1538 6.3.1.1. Note to Designers of Extensions That May Use the ENABLE 1539 Command 1541 Designers of IMAP extensions are discouraged from creating extensions 1542 that require ENABLE unless there is no good alternative design. 1543 Specifically, extensions that cause potentially incompatible behavior 1544 changes to deployed server responses (and thus benefit from ENABLE) 1545 have a higher complexity cost than extensions that do not. 1547 6.3.2. SELECT Command 1549 Arguments: mailbox name 1551 Responses: REQUIRED untagged responses: FLAGS, EXISTS 1552 REQUIRED OK untagged responses: PERMANENTFLAGS, 1553 UIDNEXT, UIDVALIDITY 1555 Result: OK - select completed, now in selected state 1556 NO - select failure, now in authenticated state: no 1557 such mailbox, can't access mailbox 1558 BAD - command unknown or arguments invalid 1560 The SELECT command selects a mailbox so that messages in the mailbox 1561 can be accessed. Before returning an OK to the client, the server 1562 MUST send the following untagged data to the client. Note that 1563 earlier versions of this protocol only required the FLAGS and EXISTS 1564 untagged data; consequently, client implementations SHOULD implement 1565 default behavior for missing data as discussed with the individual 1566 item. 1568 FLAGS Defined flags in the mailbox. See the description of the 1569 FLAGS response for more detail. 1571 EXISTS The number of messages in the mailbox. See the 1572 description of the EXISTS response for more detail. 1574 OK [PERMANENTFLAGS ()] A list of message flags that 1575 the client can change permanently. If this is missing, the client 1576 should assume that all flags can be changed permanently. 1578 OK [UIDNEXT ] The next unique identifier value. Refer to 1579 Section 2.3.1.1 for more information. 1581 OK [UIDNEXT ] If this is missing, the client can not make any 1582 assumptions about the next unique identifier value. 1584 OK [UIDVALIDITY ] The unique identifier validity value. Refer to 1585 Section 2.3.1.1 for more information. If this is missing, the 1586 server does not support unique identifiers. 1588 Only one mailbox can be selected at a time in a connection; 1589 simultaneous access to multiple mailboxes requires multiple 1590 connections. The SELECT command automatically deselects any 1591 currently selected mailbox before attempting the new selection. 1592 Consequently, if a mailbox is selected and a SELECT command that 1593 fails is attempted, no mailbox is selected. When deselecting a 1594 selected mailbox, the server MUST return an untagged OK response with 1595 the "[CLOSED]" response code when the currently selected mailbox is 1596 closed (see Paragraph 10). 1598 If the client is permitted to modify the mailbox, the server SHOULD 1599 prefix the text of the tagged OK response with the "[READ-WRITE]" 1600 response code. 1602 If the client is not permitted to modify the mailbox but is permitted 1603 read access, the mailbox is selected as read-only, and the server 1604 MUST prefix the text of the tagged OK response to SELECT with the 1605 "[READ-ONLY]" response code. Read-only access through SELECT differs 1606 from the EXAMINE command in that certain read-only mailboxes MAY 1607 permit the change of permanent state on a per-user (as opposed to 1608 global) basis. Netnews messages marked in a server-based .newsrc 1609 file are an example of such per-user permanent state that can be 1610 modified with read-only mailboxes. 1612 Example: C: A142 SELECT INBOX 1613 S: * 172 EXISTS 1614 S: * OK [UIDVALIDITY 3857529045] UIDs valid 1615 S: * OK [UIDNEXT 4392] Predicted next UID 1616 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1617 S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited 1618 S: A142 OK [READ-WRITE] SELECT completed 1620 Note that IMAP4rev1 compliant servers can also send the untagged 1621 RECENT response which was depractated in IMAP4rev2. E.g. "* 0 1622 RECENT". Pure IMAP4rev2 clients are advised to ignore the untagged 1623 RECENT response. 1625 6.3.3. EXAMINE Command 1627 Arguments: mailbox name 1629 Responses: REQUIRED untagged responses: FLAGS, EXISTS 1630 REQUIRED OK untagged responses: PERMANENTFLAGS, 1631 UIDNEXT, UIDVALIDITY 1633 Result: OK - examine completed, now in selected state 1634 NO - examine failure, now in authenticated state: no 1635 such mailbox, can't access mailbox BAD - command unknown 1636 or arguments invalid 1638 The EXAMINE command is identical to SELECT and returns the same 1639 output; however, the selected mailbox is identified as read-only. No 1640 changes to the permanent state of the mailbox, including per-user 1641 state, are permitted. 1643 The text of the tagged OK response to the EXAMINE command MUST begin 1644 with the "[READ-ONLY]" response code. 1646 Example: C: A932 EXAMINE blurdybloop 1647 S: * 17 EXISTS 1648 S: * OK [UIDVALIDITY 3857529045] UIDs valid 1649 S: * OK [UIDNEXT 4392] Predicted next UID 1650 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1651 S: * OK [PERMANENTFLAGS ()] No permanent flags permitted 1652 S: A932 OK [READ-ONLY] EXAMINE completed 1654 6.3.4. CREATE Command 1656 Arguments: mailbox name 1658 Responses: no specific responses for this command 1660 Result: OK - create completed 1661 NO - create failure: can't create mailbox with that name 1662 BAD - command unknown or arguments invalid 1664 The CREATE command creates a mailbox with the given name. An OK 1665 response is returned only if a new mailbox with that name has been 1666 created. It is an error to attempt to create INBOX or a mailbox with 1667 a name that refers to an extant mailbox. Any error in creation will 1668 return a tagged NO response. If a client attempts to create a UTF-8 1669 mailbox name that is not a valid Net-Unicode name, the server MUST 1670 reject the creation or convert the name to Net-Unicode prior to 1671 creating the mailbox. 1673 If the mailbox name is suffixed with the server's hierarchy separator 1674 character (as returned from the server by a LIST command), this is a 1675 declaration that the client intends to create mailbox names under 1676 this name in the hierarchy. Server implementations that do not 1677 require this declaration MUST ignore the declaration. In any case, 1678 the name created is without the trailing hierarchy delimiter. 1680 If the server's hierarchy separator character appears elsewhere in 1681 the name, the server SHOULD create any superior hierarchical names 1682 that are needed for the CREATE command to be successfully completed. 1683 In other words, an attempt to create "foo/bar/zap" on a server in 1684 which "/" is the hierarchy separator character SHOULD create foo/ and 1685 foo/bar/ if they do not already exist. 1687 If a new mailbox is created with the same name as a mailbox which was 1688 deleted, its unique identifiers MUST be greater than any unique 1689 identifiers used in the previous incarnation of the mailbox UNLESS 1690 the new incarnation has a different unique identifier validity value. 1691 See the description of the UID command for more detail. 1693 Example: C: A003 CREATE owatagusiam/ 1694 S: A003 OK CREATE completed 1695 C: A004 CREATE owatagusiam/blurdybloop 1696 S: A004 OK CREATE completed 1698 Note: The interpretation of this example depends on whether "/" 1699 was returned as the hierarchy separator from LIST. If "/" is the 1700 hierarchy separator, a new level of hierarchy named "owatagusiam" 1701 with a member called "blurdybloop" is created. Otherwise, two 1702 mailboxes at the same hierarchy level are created. 1704 6.3.5. DELETE Command 1706 Arguments: mailbox name 1708 Responses: no specific responses for this command 1710 Result: OK - delete completed 1711 NO - delete failure: can't delete mailbox with that name 1712 BAD - command unknown or arguments invalid 1714 The DELETE command permanently removes the mailbox with the given 1715 name. A tagged OK response is returned only if the mailbox has been 1716 deleted. It is an error to attempt to delete INBOX or a mailbox name 1717 that does not exist. 1719 The DELETE command MUST NOT remove inferior hierarchical names. For 1720 example, if a mailbox "foo" has an inferior "foo.bar" (assuming "." 1721 is the hierarchy delimiter character), removing "foo" MUST NOT remove 1722 "foo.bar". It is an error to attempt to delete a name that has 1723 inferior hierarchical names and also has the \Noselect mailbox name 1724 attribute (see the description of the LIST response for more 1725 details). 1727 It is permitted to delete a name that has inferior hierarchical names 1728 and does not have the \Noselect mailbox name attribute. If the 1729 server implementation does not permit deleting the name while 1730 inferior hierarchical names exists the \Noselect mailbox name 1731 attribute is set for that name. In any case, all messages in that 1732 mailbox are removed by the DELETE command. 1734 The value of the highest-used unique identifier of the deleted 1735 mailbox MUST be preserved so that a new mailbox created with the same 1736 name will not reuse the identifiers of the former incarnation, UNLESS 1737 the new incarnation has a different unique identifier validity value. 1738 See the description of the UID command for more detail. 1740 Examples: C: A682 LIST "" * 1741 S: * LIST () "/" blurdybloop 1742 S: * LIST (\Noselect) "/" foo 1743 S: * LIST () "/" foo/bar 1744 S: A682 OK LIST completed 1745 C: A683 DELETE blurdybloop 1746 S: A683 OK DELETE completed 1747 C: A684 DELETE foo 1748 S: A684 NO Name "foo" has inferior hierarchical names 1749 C: A685 DELETE foo/bar 1750 S: A685 OK DELETE Completed 1751 C: A686 LIST "" * 1752 S: * LIST (\Noselect) "/" foo 1753 S: A686 OK LIST completed 1754 C: A687 DELETE foo 1755 S: A687 OK DELETE Completed 1756 C: A82 LIST "" * 1757 S: * LIST () "." blurdybloop 1758 S: * LIST () "." foo 1759 S: * LIST () "." foo.bar 1760 S: A82 OK LIST completed 1761 C: A83 DELETE blurdybloop 1762 S: A83 OK DELETE completed 1763 C: A84 DELETE foo 1764 S: A84 OK DELETE Completed 1765 C: A85 LIST "" * 1766 S: * LIST () "." foo.bar 1767 S: A85 OK LIST completed 1768 C: A86 LIST "" % 1769 S: * LIST (\Noselect) "." foo 1770 S: A86 OK LIST completed 1772 6.3.6. RENAME Command 1774 Arguments: existing mailbox name 1775 new mailbox name 1777 Responses: no specific responses for this command 1779 Result: OK - rename completed 1780 NO - rename failure: can't rename mailbox with that name, 1781 can't rename to mailbox with that name 1782 BAD - command unknown or arguments invalid 1784 The RENAME command changes the name of a mailbox. A tagged OK 1785 response is returned only if the mailbox has been renamed. It is an 1786 error to attempt to rename from a mailbox name that does not exist or 1787 to a mailbox name that already exists. Any error in renaming will 1788 return a tagged NO response. 1790 If the name has inferior hierarchical names, then the inferior 1791 hierarchical names MUST also be renamed. For example, a rename of 1792 "foo" to "zap" will rename "foo/bar" (assuming "/" is the hierarchy 1793 delimiter character) to "zap/bar". 1795 If the server's hierarchy separator character appears in the name, 1796 the server SHOULD create any superior hierarchical names that are 1797 needed for the RENAME command to complete successfully. In other 1798 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. (Note that 1810 some servers refuse renaming INBOX). It moves all messages in INBOX 1811 to a new mailbox with the given name, leaving INBOX empty. If the 1812 server implementation supports inferior hierarchical names of INBOX, 1813 these are unaffected by a rename of INBOX. 1815 Examples: C: A682 LIST "" * 1816 S: * LIST () "/" blurdybloop 1817 S: * LIST (\Noselect) "/" foo 1818 S: * LIST () "/" foo/bar 1819 S: A682 OK LIST completed 1820 C: A683 RENAME blurdybloop sarasoop 1821 S: A683 OK RENAME completed 1822 C: A684 RENAME foo zowie 1823 S: A684 OK RENAME Completed 1824 C: A685 LIST "" * 1825 S: * LIST () "/" sarasoop 1826 S: * LIST (\Noselect) "/" zowie 1827 S: * LIST () "/" zowie/bar 1828 S: A685 OK LIST completed 1830 C: Z432 LIST "" * 1831 S: * LIST () "." INBOX 1832 S: * LIST () "." INBOX.bar 1833 S: Z432 OK LIST completed 1834 C: Z433 RENAME INBOX old-mail 1835 S: Z433 OK RENAME completed 1836 C: Z434 LIST "" * 1837 S: * LIST () "." INBOX 1838 S: * LIST () "." INBOX.bar 1839 S: * LIST () "." old-mail 1840 S: Z434 OK LIST completed 1842 Note that renaming a mailbox doesn't update subscription information 1843 on the original name. To keep subscription information in sync, the 1844 following sequence of commands can be used: 1846 C: 1001 RENAME X Y 1847 C: 1002 SUBSCRIBE Y 1848 C: 1003 UNSUBSCRIBE X 1850 Note that the above sequence of commands doesn't account for updating 1851 subscription for any children mailboxes of mailbox X. 1853 6.3.7. SUBSCRIBE Command 1855 Arguments: mailbox 1857 Responses: no specific responses for this command 1859 Result: OK - subscribe completed 1860 NO - subscribe failure: can't subscribe to that name 1861 BAD - command unknown or arguments invalid 1863 The SUBSCRIBE command adds the specified mailbox name to the server's 1864 set of "active" or "subscribed" mailboxes as returned by the LIST 1865 (SUBSCRIBED) command. This command returns a tagged OK response only 1866 if the subscription is successful. 1868 A server MAY validate the mailbox argument to SUBSCRIBE to verify 1869 that it exists. However, it MUST NOT unilaterally remove an existing 1870 mailbox name from the subscription list even if a mailbox by that 1871 name no longer exists. 1873 Note: This requirement is because a server site can choose to 1874 routinely remove a mailbox with a well-known name (e.g., "system- 1875 alerts") after its contents expire, with the intention of 1876 recreating it when new contents are appropriate. 1878 Example: C: A002 SUBSCRIBE #news.comp.mail.mime 1879 S: A002 OK SUBSCRIBE completed 1881 6.3.8. UNSUBSCRIBE Command 1883 Arguments: mailbox name 1885 Responses: no specific responses for this command 1887 Result: OK - unsubscribe completed 1888 NO - unsubscribe failure: can't unsubscribe that name 1889 BAD - command unknown or arguments invalid 1891 The UNSUBSCRIBE command removes the specified mailbox name from the 1892 server's set of "active" or "subscribed" mailboxes as returned by the 1893 LIST (SUBSCRIBED) command. This command returns a tagged OK response 1894 only if the unsubscription is successful. 1896 Example: C: A002 UNSUBSCRIBE #news.comp.mail.mime 1897 S: A002 OK UNSUBSCRIBE completed 1899 6.3.9. LIST Command 1901 Arguments (basic): reference name 1902 mailbox name with possible wildcards 1904 Arguments (extended): selection options (OPTIONAL) 1905 reference name 1906 mailbox patterns 1907 return options (OPTIONAL) 1909 Responses: untagged responses: LIST 1910 Result: OK - list completed 1911 NO - list failure: can't list that reference or name 1912 BAD - command unknown or arguments invalid 1914 The LIST command returns a subset of names from the complete set of 1915 all names available to the client. Zero or more untagged LIST 1916 replies are returned, containing the name attributes, hierarchy 1917 delimiter, name, and possible extension information; see the 1918 description of the LIST reply for more detail. 1920 The LIST command SHOULD return its data quickly, without undue delay. 1921 For example, it SHOULD NOT go to excess trouble to calculate the 1922 \Marked or \Unmarked status or perform other processing; if each name 1923 requires 1 second of processing, then a list of 1200 names would take 1924 20 minutes! 1926 The extended LIST command, originally introduced in [RFC5258], 1927 provides capabilities beyond that of the original IMAP LIST command. 1928 The extended syntax is being used if one or more of the following 1929 conditions is true: 1931 1. if the first word after the command name begins with a 1932 parenthesis ("LIST selection options") 1934 2. if the second word after the command name begins with a 1935 parenthesis ("multiple mailbox patterns") 1937 3. if the LIST command has more than 2 parameters ("LIST return 1938 options") 1940 An empty ("" string) reference name argument indicates that the 1941 mailbox name is interpreted as by SELECT. The returned mailbox names 1942 MUST match the supplied mailbox name pattern(s). A non-empty 1943 reference name argument is the name of a mailbox or a level of 1944 mailbox hierarchy, and indicates the context in which the mailbox 1945 name is interpreted. Clients SHOULD use the empty reference 1946 argument. 1948 In the basic syntax only, an empty ("" string) mailbox name argument 1949 is a special request to return the hierarchy delimiter and the root 1950 name of the name given in the reference. The value returned as the 1951 root MAY be the empty string if the reference is non-rooted or is an 1952 empty string. In all cases, a hierarchy delimiter (or NIL if there 1953 is no hierarchy) is returned. This permits a client to get the 1954 hierarchy delimiter (or find out that the mailbox names are flat) 1955 even when no mailboxes by that name currently exist. 1957 In the extended syntax, any mailbox name arguments that are empty 1958 strings are ignored. There is no special meaning for empty mailbox 1959 names when the extended syntax is used. 1961 The reference and mailbox name arguments are interpreted into a 1962 canonical form that represents an unambiguous left-to-right 1963 hierarchy. The returned mailbox names will be in the interpreted 1964 form, 1966 that we call "canonical LIST pattern" later in this document. To 1967 define the term "canonical LIST pattern" formally: it refers to the 1968 canonical pattern constructed internally by the server from the 1969 reference and mailbox name arguments. 1971 Note: The interpretation of the reference argument is 1972 implementation-defined. It depends upon whether the server 1973 implementation has a concept of the "current working directory" 1974 and leading "break out characters", which override the current 1975 working directory. 1977 For example, on a server which exports a UNIX or NT filesystem, 1978 the reference argument contains the current working directory, and 1979 the mailbox name argument would contain the name as interpreted in 1980 the current working directory. 1982 If a server implementation has no concept of break out characters, 1983 the canonical form is normally the reference name appended with 1984 the mailbox name. Note that if the server implements the 1985 namespace convention (Section 5.1.2.1), "#" is a break out 1986 character and must be treated as such. 1988 If the reference argument is not a level of mailbox hierarchy 1989 (that is, it is a \NoInferiors name), and/or the reference 1990 argument does not end with the hierarchy delimiter, it is 1991 implementation-dependent how this is interpreted. For example, a 1992 reference of "foo/bar" and mailbox name of "rag/baz" could be 1993 interpreted as "foo/bar/rag/baz", "foo/barrag/baz", or "foo/rag/ 1994 baz". A client SHOULD NOT use such a reference argument except at 1995 the explicit request of the user. A hierarchical browser MUST NOT 1996 make any assumptions about server interpretation of the reference 1997 unless the reference is a level of mailbox hierarchy AND ends with 1998 the hierarchy delimiter. 2000 Any part of the reference argument that is included in the 2001 interpreted form SHOULD prefix the interpreted form. It SHOULD also 2002 be in the same form as the reference name argument. This rule 2003 permits the client to determine if the returned mailbox name is in 2004 the context of the reference argument, or if something about the 2005 mailbox argument overrode the reference argument. Without this rule, 2006 the client would have to have knowledge of the server's naming 2007 semantics including what characters are "breakouts" that override a 2008 naming context. 2010 For example, here are some examples of how references 2011 and mailbox names might be interpreted on a UNIX-based 2012 server: 2014 Reference Mailbox Name Interpretation 2015 ------------ ------------ -------------- 2016 ~smith/Mail/ foo.* ~smith/Mail/foo.* 2017 archive/ % archive/% 2018 #news. comp.mail.* #news.comp.mail.* 2019 ~smith/Mail/ /usr/doc/foo /usr/doc/foo 2020 archive/ ~fred/Mail/* ~fred/Mail/* 2022 The first three examples demonstrate interpretations in 2023 the context of the reference argument. Note that 2024 "~smith/Mail" SHOULD NOT be transformed into something 2025 like "/u2/users/smith/Mail", or it would be impossible 2026 for the client to determine that the interpretation was 2027 in the context of the reference. 2029 The character "*" is a wildcard, and matches zero or more characters 2030 at this position. The character "%" is similar to "*", but it does 2031 not match a hierarchy delimiter. If the "%" wildcard is the last 2032 character of a mailbox name argument, matching levels of hierarchy 2033 are also returned. If these levels of hierarchy are not also 2034 selectable mailboxes, they are returned with the \Noselect mailbox 2035 name attribute (see the description of the LIST response for more 2036 details). 2038 If multiple mailbox patterns are used (in the extended syntax), a 2039 mailbox matches if it matches at least one mailbox pattern. If a 2040 mailbox matches more than one pattern, it is still only returned 2041 once. Any syntactically valid pattern that is not accepted by a 2042 server for any reason MUST be silently ignored. 2044 Selection options tell the server to limit the mailbox names that are 2045 selected by the LIST operation. If selection options are used, the 2046 mailboxes returned are those that match both the list of canonical 2047 LIST patterns and the selection options. Unless a particular 2048 selection option provides special rules, the selection options are 2049 cumulative: a mailbox that matches the mailbox patterns is selected 2050 only if it also matches all of the selection options. (An example of 2051 a selection option with special rules is the RECURSIVEMATCH option.) 2052 Return options control what information is returned for each matched 2053 mailbox. Return options MUST NOT cause the server to report 2054 information about additional mailbox names other than those that 2055 match the canonical LIST patterns and selection options. If no 2056 return options are specified, the client is only expecting 2057 information about mailbox attributes. The server MAY return other 2058 information about the matched mailboxes, and clients MUST be able to 2059 handle that situation. 2061 Initial selection options and return options are defined in the 2062 following subsections, and new ones will also be defined in 2063 extensions. Initial options defined in this document MUST be 2064 supported. Each non-initial option will be enabled by a capability 2065 string (one capability may enable multiple options), and a client 2066 MUST NOT send an option for which the server has not advertised 2067 support. A server MUST respond to options it does not recognize with 2068 a BAD response. The client SHOULD NOT specify any option more than 2069 once; however, if the client does this, the server MUST act as if it 2070 received the option only once. The order in which options are 2071 specified by the client is not significant. 2073 In general, each selection option except RECURSIVEMATCH will have a 2074 corresponding return option. The REMOTE selection option is an 2075 anomaly in this regard, and does not have a corresponding return 2076 option. That is because it expands, rather than restricts, the set 2077 of mailboxes that are returned. Future extensions to this 2078 specification should keep parallelism in mind and define a pair of 2079 corresponding options. 2081 Server implementations are permitted to "hide" otherwise accessible 2082 mailboxes from the wildcard characters, by preventing certain 2083 characters or names from matching a wildcard in certain situations. 2084 For example, a UNIX-based server might restrict the interpretation of 2085 "*" so that an initial "/" character does not match. 2087 The special name INBOX is included in the output from LIST, if INBOX 2088 is supported by this server for this user and if the uppercase string 2089 "INBOX" matches the interpreted reference and mailbox name arguments 2090 with wildcards as described above. The criteria for omitting INBOX 2091 is whether SELECT INBOX will return failure; it is not relevant 2092 whether the user's real INBOX resides on this or some other server. 2094 6.3.9.1. LIST Selection Options 2096 The selection options defined in this specification are as follows: 2098 SUBSCRIBED - causes the LIST command to list subscribed names, 2099 rather than the existing mailboxes. This will often be a subset 2100 of the actual mailboxes. It's also possible for this list to 2101 contain the names of mailboxes that don't exist. In any case, the 2102 list MUST include exactly those mailbox names that match the 2103 canonical list pattern and are subscribed to. 2105 SUBSCRIBED - 2107 This option defines a mailbox attribute, "\Subscribed", that 2108 indicates that a mailbox name is subscribed to. The "\Subscribed" 2109 attribute MUST be supported and MUST be accurately computed when 2110 the SUBSCRIBED selection option is specified. 2112 Note that the SUBSCRIBED selection option implies the SUBSCRIBED 2113 return option (see below). 2115 REMOTE - causes the LIST command to show remote mailboxes as well as 2116 local ones, as described in [RFC2193]. This option is intended to 2117 replace the RLIST command and, in conjunction with the SUBSCRIBED 2118 selection option, the RLSUB command. Servers that don't support 2119 remote mailboxes just ignore this option. 2121 This option defines a mailbox attribute, "\Remote", that indicates 2122 that a mailbox is a remote mailbox. The "\Remote" attribute MUST 2123 be accurately computed when the REMOTE option is specified. 2125 The REMOTE selection option has no interaction with other options. 2126 Its effect is to tell the server to apply the other options, if 2127 any, to remote mailboxes, in addition to local ones. In 2128 particular, it has no interaction with RECURSIVEMATCH (see below). 2129 A request for (REMOTE RECURSIVEMATCH) is invalid, because a 2130 request for (RECURSIVEMATCH) is also invalid. A request for 2131 (REMOTE RECURSIVEMATCH SUBSCRIBED) is asking for all subscribed 2132 mailboxes, both local and remote. 2134 RECURSIVEMATCH - this option forces the server to return information 2135 about parent mailboxes that don't match other selection options, 2136 but have some submailboxes that do. Information about children is 2137 returned in the CHILDINFO extended data item, as described in 2138 Section 6.3.9.6. 2140 Note 1: In order for a parent mailbox to be returned, it still has 2141 to match the canonical LIST pattern. 2143 Note 2: When returning the CHILDINFO extended data item, it 2144 doesn't matter whether or not the submailbox matches the canonical 2145 LIST pattern. See also example 9 in Section 6.3.9.7. 2147 The RECURSIVEMATCH option MUST NOT occur as the only selection 2148 option (or only with REMOTE), as it only makes sense when other 2149 selection options are also used. The server MUST return BAD 2150 tagged response in such case. 2152 Note that even if the RECURSIVEMATCH option is specified, the 2153 client MUST still be able to handle a case when a CHILDINFO 2154 extended data item is returned and there are no submailboxes that 2155 meet the selection criteria of the subsequent LIST command, as 2156 they can be deleted/renamed after the LIST response was sent, but 2157 before the client had a chance to access them. 2159 6.3.9.2. LIST Return Options 2161 The return options defined in this specification are as follows: 2163 SUBSCRIBED - causes the LIST command to return subscription state 2164 for all matching mailbox names. The "\Subscribed" attribute MUST 2165 be supported and MUST be accurately computed when the SUBSCRIBED 2166 return option is specified. Further, all mailbox flags MUST be 2167 accurately computed (this differs from the behavior of the 2168 obsolete LSUB command from IMAP4rev1). 2170 CHILDREN - requests mailbox child information as originally proposed 2171 in [RFC3348]. See Section 6.3.9.5, below, for details. 2173 CHILDREN - This option MUST be supported by all servers. 2175 6.3.9.3. General Principles for Returning LIST Responses 2177 This section outlines several principles that can be used by server 2178 implementations of this document to decide whether a LIST response 2179 should be returned, as well as how many responses and what kind of 2180 information they may contain. 2182 1. At most one LIST response should be returned for each mailbox 2183 name that matches the canonical LIST pattern. Server 2184 implementors must not assume that clients will be able to 2185 assemble mailbox attributes and other information returned in 2186 multiple LIST responses. 2188 2. There are only two reasons for including a matching mailbox name 2189 in the responses to the LIST command (note that the server is 2190 allowed to return unsolicited responses at any time, and such 2191 responses are not governed by this rule): 2193 A. The mailbox name also satisfies the selection criteria. 2195 B. The mailbox name doesn't satisfy the selection criteria, but 2196 it has at least one descendant mailbox name that satisfies 2197 the selection criteria and that doesn't match the canonical 2198 LIST pattern. 2200 For more information on this case, see the CHILDINFO extended 2201 data item described in Section 6.3.9.6. Note that the 2202 CHILDINFO extended data item can only be returned when the 2203 RECURSIVEMATCH selection option is specified. 2205 3. Attributes returned in the same LIST response must be treated 2206 additively. For example, the following response 2208 S: * LIST (\Subscribed \NonExistent) "/" "Fruit/Peach" 2210 means that the "Fruit/Peach" mailbox doesn't exist, but it is 2211 subscribed. 2213 6.3.9.4. Additional LIST-related Requirements on Clients 2215 All clients MUST treat a LIST attribute with a stronger meaning as 2216 implying any attribute that can be inferred from it. (See 2217 Section 7.2.3 for the list of currently defined attributes). For 2218 example, the client must treat the presence of the \NoInferiors 2219 attribute as if the \HasNoChildren attribute was also sent by the 2220 server. 2222 The following table summarizes inference rules described in 2223 Section 6.3.9. 2225 +--------------------+-------------------+ 2226 | returned attribute | implied attribute | 2227 +--------------------+-------------------+ 2228 | \NoInferiors | \HasNoChildren | 2229 | \NonExistent | \NoSelect | 2230 +--------------------+-------------------+ 2232 6.3.9.5. The CHILDREN Return Option 2234 The CHILDREN return option implements the Child Mailbox Extension, 2235 originally proposed by Mike Gahrns and Raymond Cheng, of Microsoft 2236 Corporation. Most of the information in this section is taken 2237 directly from their original specification [RFC3348]. The CHILDREN 2238 return option is simply an indication that the client wants this 2239 information; a server MAY provide it even if the option is not 2240 specified. 2242 Many IMAP4 clients present to the user a hierarchical view of the 2243 mailboxes that a user has access to. Rather than initially 2244 presenting to the user the entire mailbox hierarchy, it is often 2245 preferable to show to the user a collapsed outline list of the 2246 mailbox hierarchy (particularly if there is a large number of 2247 mailboxes). The user can then expand the collapsed outline hierarchy 2248 as needed. It is common to include within the collapsed hierarchy a 2249 visual clue (such as a ''+'') to indicate that there are child 2250 mailboxes under a particular mailbox. When the visual clue is 2251 clicked, the hierarchy list is expanded to show the child mailboxes. 2252 The CHILDREN return option provides a mechanism for a client to 2253 efficiently determine whether a particular mailbox has children, 2254 without issuing a LIST "" * or a LIST "" % for each mailbox name. 2255 The CHILDREN return option defines two new attributes that MUST be 2256 returned within a LIST response: \HasChildren and \HasNoChildren. 2257 Although these attributes MAY be returned in response to any LIST 2258 command, the CHILDREN return option is provided to indicate that the 2259 client particularly wants this information. If the CHILDREN return 2260 option is present, the server MUST return these attributes even if 2261 their computation is expensive. 2263 \HasChildren 2265 The presence of this attribute indicates that the mailbox has 2266 child mailboxes. A server SHOULD NOT set this attribute if 2267 there are child mailboxes and the user does not have permission 2268 to access any of them. In this case, \HasNoChildren SHOULD be 2269 used. In many cases, however, a server may not be able to 2270 efficiently compute whether a user has access to any child 2271 mailbox. Note that even though the \HasChildren attribute for a 2272 mailbox must be correct at the time of processing of the 2273 mailbox, a client must be prepared to deal with a situation when 2274 a mailbox is marked with the \HasChildren attribute, but no 2275 child mailbox appears in the response to the LIST command. This 2276 might happen, for example, due to children mailboxes being 2277 deleted or made inaccessible to the user (using access control) 2278 by another client before the server is able to list them. 2280 \HasNoChildren 2282 The presence of this attribute indicates that the mailbox has NO 2283 child mailboxes that are accessible to the currently 2284 authenticated user. 2286 It is an error for the server to return both a \HasChildren and a 2287 \HasNoChildren attribute in the same LIST response. 2289 Note: the \HasNoChildren attribute should not be confused with the 2290 the \NoInferiors attribute, which indicates that no child mailboxes 2291 exist now and none can be created in the future. 2293 6.3.9.6. CHILDINFO Extended Data Item 2295 The CHILDINFO extended data item MUST NOT be returned unless the 2296 client has specified the RECURSIVEMATCH selection option. 2298 The CHILDINFO extended data item in a LIST response describes the 2299 selection criteria that has caused it to be returned and indicates 2300 that the mailbox has at least one descendant mailbox that matches the 2301 selection criteria. 2303 Note: Some servers allow for mailboxes to exist without requiring 2304 their parent to exist. For example, a mailbox "Customers/ABC" can 2305 exist while the mailbox "Customers" does not. As CHILDINFO extended 2306 data item is not allowed if the RECURSIVEMATCH selection option is 2307 not specified, such servers SHOULD use the "\NonExistent 2308 \HasChildren" attribute pair to signal to the client that there is a 2309 descendant mailbox that matches the selection criteria. See example 2310 11 in Section 6.3.9.7. 2312 The returned selection criteria allow the client to distinguish a 2313 solicited response from an unsolicited one, as well as to distinguish 2314 among solicited responses caused by multiple pipelined LIST commands 2315 that specify different criteria. 2317 Servers SHOULD ONLY return a non-matching mailbox name along with 2318 CHILDINFO if at least one matching child is not also being returned. 2319 That is, servers SHOULD suppress redundant CHILDINFO responses. 2321 Examples 8 and 10 in Section 6.3.9.7 demonstrate the difference 2322 between present CHILDINFO extended data item and the "\HasChildren" 2323 attribute. 2325 The following table summarizes interaction between the "\NonExistent" 2326 attribute and CHILDINFO (the first column indicates whether the 2327 parent mailbox exists): 2329 +--------+--------------+--------------------+----------------------+ 2330 | exists | meets the | has a child that | returned LIST- | 2331 | | selection | meets the | EXTENDED attributes | 2332 | | criteria | selection criteria | and CHILDINFO | 2333 +--------+--------------+--------------------+----------------------+ 2334 | no | no | no | no LIST response | 2335 | | | | returned | 2336 | yes | no | no | no LIST response | 2337 | | | | returned | 2338 | no | yes | no | (\NonExistent | 2339 | | | | ) | 2340 | yes | yes | no | () | 2341 | no | no | yes | (\NonExistent) + | 2342 | | | | CHILDINFO | 2343 | yes | no | yes | () + CHILDINFO | 2344 | no | yes | yes | (\NonExistent | 2345 | | | | ) + CHILDINFO | 2346 | yes | yes | yes | () + CHILDINFO | 2347 +--------+--------------+--------------------+----------------------+ 2349 where is one or more attributes that correspond to the 2350 selection criteria; for example, for the SUBSCRIBED option the 2351 is \Subscribed. 2353 6.3.9.7. LIST Command Examples 2355 This example shows some uses of the basic LIST command: 2357 Example: C: A101 LIST "" "" 2358 S: * LIST (\Noselect) "/" "" 2359 S: A101 OK LIST Completed 2360 C: A102 LIST #news.comp.mail.misc "" 2361 S: * LIST (\Noselect) "." #news. 2362 S: A102 OK LIST Completed 2363 C: A103 LIST /usr/staff/jones "" 2364 S: * LIST (\Noselect) "/" / 2365 S: A103 OK LIST Completed 2366 C: A202 LIST ~/Mail/ % 2367 S: * LIST (\Noselect) "/" ~/Mail/foo 2368 S: * LIST () "/" ~/Mail/meetings 2369 S: A202 OK LIST completed 2371 Extended examples: 2373 1: The first example shows the complete local hierarchy that will 2374 be used for the other examples. 2376 C: A01 LIST "" "*" 2377 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2378 S: * LIST () "/" "Fruit" 2379 S: * LIST () "/" "Fruit/Apple" 2380 S: * LIST () "/" "Fruit/Banana" 2381 S: * LIST () "/" "Tofu" 2382 S: * LIST () "/" "Vegetable" 2383 S: * LIST () "/" "Vegetable/Broccoli" 2384 S: * LIST () "/" "Vegetable/Corn" 2385 S: A01 OK done 2387 2: In the next example, we will see the subscribed mailboxes. This 2388 is similar to, but not equivalent with, . Note 2389 that the mailbox called "Fruit/Peach" is subscribed to, but does 2390 not actually exist (perhaps it was deleted while still 2391 subscribed). The "Fruit" mailbox is not subscribed to, but it 2392 has two subscribed children. The "Vegetable" mailbox is 2393 subscribed and has two children; one of them is subscribed as 2394 well. 2396 C: A02 LIST (SUBSCRIBED) "" "*" 2397 S: * LIST (\Marked \NoInferiors \Subscribed) "/" "inbox" 2398 S: * LIST (\Subscribed) "/" "Fruit/Banana" 2399 S: * LIST (\Subscribed \NonExistent) "/" "Fruit/Peach" 2400 S: * LIST (\Subscribed) "/" "Vegetable" 2401 S: * LIST (\Subscribed) "/" "Vegetable/Broccoli" 2402 S: A02 OK done 2404 3: The next example shows the use of the CHILDREN option. The 2405 client, without having to list the second level of hierarchy, 2406 now knows which of the top-level mailboxes have submailboxes 2407 (children) and which do not. Note that it's not necessary for 2408 the server to return the \HasNoChildren attribute for the inbox, 2409 because the \NoInferiors attribute already implies that, and has 2410 a stronger meaning. 2412 C: A03 LIST () "" "%" RETURN (CHILDREN) 2413 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2414 S: * LIST (\HasChildren) "/" "Fruit" 2415 S: * LIST (\HasNoChildren) "/" "Tofu" 2416 S: * LIST (\HasChildren) "/" "Vegetable" 2417 S: A03 OK done 2419 4: In this example, we see more mailboxes that reside on another 2420 server. This is similar to the command . 2422 C: A04 LIST (REMOTE) "" "%" RETURN (CHILDREN) 2423 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2424 S: * LIST (\HasChildren) "/" "Fruit" 2425 S: * LIST (\HasNoChildren) "/" "Tofu" 2426 S: * LIST (\HasChildren) "/" "Vegetable" 2427 S: * LIST (\Remote) "/" "Bread" 2428 S: * LIST (\HasChildren \Remote) "/" "Meat" 2429 S: A04 OK done 2431 5: The following example also requests the server to include 2432 mailboxes that reside on another server. The server returns 2433 information about all mailboxes that are subscribed. This is 2434 similar to the command . We also see the use of 2435 two selection options. 2437 C: A05 LIST (REMOTE SUBSCRIBED) "" "*" 2438 S: * LIST (\Marked \NoInferiors \Subscribed) "/" "inbox" 2439 S: * LIST (\Subscribed) "/" "Fruit/Banana" 2440 S: * LIST (\Subscribed \NonExistent) "/" "Fruit/Peach" 2441 S: * LIST (\Subscribed) "/" "Vegetable" 2442 S: * LIST (\Subscribed) "/" "Vegetable/Broccoli" 2443 S: * LIST (\Remote \Subscribed) "/" "Bread" 2444 S: A05 OK done 2446 6: The following example requests the server to include mailboxes 2447 that reside on another server. The server is asked to return 2448 subscription information for all returned mailboxes. This is 2449 different from the example above. 2451 Note that the output of this command is not a superset of the 2452 output in the previous example, as it doesn't include LIST 2453 response for the non-existent "Fruit/Peach". 2455 C: A06 LIST (REMOTE) "" "*" RETURN (SUBSCRIBED) 2456 S: * LIST (\Marked \NoInferiors \Subscribed) "/" "inbox" 2457 S: * LIST () "/" "Fruit" 2458 S: * LIST () "/" "Fruit/Apple" 2459 S: * LIST (\Subscribed) "/" "Fruit/Banana" 2460 S: * LIST () "/" "Tofu" 2461 S: * LIST (\Subscribed) "/" "Vegetable" 2462 S: * LIST (\Subscribed) "/" "Vegetable/Broccoli" 2463 S: * LIST () "/" "Vegetable/Corn" 2464 S: * LIST (\Remote \Subscribed) "/" "Bread" 2465 S: * LIST (\Remote) "/" "Meat" 2466 S: A06 OK done 2468 7: In the following example, the client has specified multiple 2469 mailbox patterns. Note that this example does not use the 2470 mailbox hierarchy used in the previous examples. 2472 C: BBB LIST "" ("INBOX" "Drafts" "Sent/%") 2473 S: * LIST () "/" "INBOX" 2474 S: * LIST (\NoInferiors) "/" "Drafts" 2475 S: * LIST () "/" "Sent/March2004" 2476 S: * LIST (\Marked) "/" "Sent/December2003" 2477 S: * LIST () "/" "Sent/August2004" 2478 S: BBB OK done 2480 8: The following example demonstrates the difference between the 2481 \HasChildren attribute and the CHILDINFO extended data item. 2483 Let's assume there is the following hierarchy: 2485 C: C01 LIST "" "*" 2486 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2487 S: * LIST () "/" "Foo" 2488 S: * LIST () "/" "Foo/Bar" 2489 S: * LIST () "/" "Foo/Baz" 2490 S: * LIST () "/" "Moo" 2491 S: C01 OK done 2493 If the client asks RETURN (CHILDREN), it will get this: 2495 C: CA3 LIST "" "%" RETURN (CHILDREN) 2496 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2497 S: * LIST (\HasChildren) "/" "Foo" 2498 S: * LIST (\HasNoChildren) "/" "Moo" 2499 S: CA3 OK done 2501 A) Let's also assume that the mailbox "Foo/Baz" is the only 2502 subscribed mailbox. Then we get this result: 2504 C: C02 LIST (SUBSCRIBED) "" "*" 2505 S: * LIST (\Subscribed) "/" "Foo/Baz" 2506 S: C02 OK done 2508 Now, if the client issues , the server 2509 will return no mailboxes (as the mailboxes "Moo", "Foo", and 2510 "Inbox" are NOT subscribed). However, if the client issues 2511 this: 2513 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2514 S: * LIST () "/" "Foo" ("CHILDINFO" ("SUBSCRIBED")) 2515 S: C04 OK done 2516 (i.e., the mailbox "Foo" is not subscribed, but it has a child 2517 that is.) 2519 A1) If the mailbox "Foo" had also been subscribed, the last 2520 command would return this: 2522 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2523 S: * LIST (\Subscribed) "/" "Foo" ("CHILDINFO" ("SUBSCRIBED")) 2524 S: C04 OK done 2526 or even this: 2528 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2529 S: * LIST (\Subscribed \HasChildren) "/" "Foo" ("CHILDINFO" 2530 ("SUBSCRIBED")) 2531 S: C04 OK done 2533 A2) If we assume instead that the mailbox "Foo" is not part of 2534 the original hierarchy and is not subscribed, the last command 2535 will give this result: 2537 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2538 S: * LIST (\NonExistent) "/" "Foo" ("CHILDINFO" ("SUBSCRIBED")) 2539 S: C04 OK done 2541 B) Now, let's assume that no mailbox is subscribed. In this 2542 case, the command will 2543 return no responses, as there are no subscribed children (even 2544 though "Foo" has children). 2546 C) And finally, suppose that only the mailboxes "Foo" and "Moo" 2547 are subscribed. In that case, we see this result: 2549 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" RETURN (CHILDREN) 2550 S: * LIST (\HasChildren \Subscribed) "/" "Foo" 2551 S: * LIST (\HasNoChildren \Subscribed) "/" "Moo" 2552 S: C04 OK done 2554 (which means that the mailbox "Foo" has children, but none of 2555 them is subscribed). 2557 9: The following example demonstrates that the CHILDINFO extended 2558 data item is returned whether or not children mailboxes match 2559 the canonical LIST pattern. 2561 Let's assume there is the following hierarchy: 2563 C: D01 LIST "" "*" 2564 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2565 S: * LIST () "/" "foo2" 2566 S: * LIST () "/" "foo2/bar1" 2567 S: * LIST () "/" "foo2/bar2" 2568 S: * LIST () "/" "baz2" 2569 S: * LIST () "/" "baz2/bar2" 2570 S: * LIST () "/" "baz2/bar22" 2571 S: * LIST () "/" "baz2/bar222" 2572 S: * LIST () "/" "eps2" 2573 S: * LIST () "/" "eps2/mamba" 2574 S: * LIST () "/" "qux2/bar2" 2575 S: D01 OK done 2577 And that the following mailboxes are subscribed: 2579 C: D02 LIST (SUBSCRIBED) "" "*" 2580 S: * LIST (\Subscribed) "/" "foo2/bar1" 2581 S: * LIST (\Subscribed) "/" "foo2/bar2" 2582 S: * LIST (\Subscribed) "/" "baz2/bar2" 2583 S: * LIST (\Subscribed) "/" "baz2/bar22" 2584 S: * LIST (\Subscribed) "/" "baz2/bar222" 2585 S: * LIST (\Subscribed) "/" "eps2" 2586 S: * LIST (\Subscribed) "/" "eps2/mamba" 2587 S: * LIST (\Subscribed) "/" "qux2/bar2" 2588 S: D02 OK done 2590 The client issues the following command first: 2592 C: D03 LIST (RECURSIVEMATCH SUBSCRIBED) "" "*2" 2593 S: * LIST () "/" "foo2" ("CHILDINFO" ("SUBSCRIBED")) 2594 S: * LIST (\Subscribed) "/" "foo2/bar2" 2595 S: * LIST (\Subscribed) "/" "baz2/bar2" 2596 S: * LIST (\Subscribed) "/" "baz2/bar22" 2597 S: * LIST (\Subscribed) "/" "baz2/bar222" 2598 S: * LIST (\Subscribed) "/" "eps2" ("CHILDINFO" ("SUBSCRIBED")) 2599 S: * LIST (\Subscribed) "/" "qux2/bar2" 2600 S: D03 OK done 2602 and the server may also include (but this would violate a SHOULD 2603 NOT in Section 3.5, because CHILDINFO is redundant) 2605 S: * LIST () "/" "baz2" ("CHILDINFO" ("SUBSCRIBED")) 2606 S: * LIST (\NonExistent) "/" "qux2" ("CHILDINFO" ("SUBSCRIBED")) 2608 The CHILDINFO extended data item is returned for mailboxes 2609 "foo2", "baz2", and "eps2", because all of them have subscribed 2610 children, even though for the mailbox "foo2" only one of the two 2611 subscribed children matches the pattern, for the mailbox "baz2" 2612 all the subscribed children match the pattern, and for the 2613 mailbox "eps2" none of the subscribed children matches the 2614 pattern. 2616 Note that if the client issues 2618 C: D03 LIST (RECURSIVEMATCH SUBSCRIBED) "" "*" 2619 S: * LIST () "/" "foo2" ("CHILDINFO" ("SUBSCRIBED")) 2620 S: * LIST (\Subscribed) "/" "foo2/bar1" 2621 S: * LIST (\Subscribed) "/" "foo2/bar2" 2622 S: * LIST () "/" "baz2" ("CHILDINFO" ("SUBSCRIBED")) 2623 S: * LIST (\Subscribed) "/" "baz2/bar2" 2624 S: * LIST (\Subscribed) "/" "baz2/bar22" 2625 S: * LIST (\Subscribed) "/" "baz2/bar222" 2626 S: * LIST (\Subscribed) "/" "eps2" ("CHILDINFO" ("SUBSCRIBED")) 2627 S: * LIST (\Subscribed) "/" "eps2/mamba" 2628 S: * LIST (\Subscribed) "/" "qux2/bar2" 2629 S: D03 OK done 2631 The LIST responses for mailboxes "foo2", "baz2", and "eps2" 2632 still have the CHILDINFO extended data item, even though this 2633 information is redundant and the client can determine it by 2634 itself. 2636 10: The following example shows usage of multiple mailbox patterns. 2637 It also demonstrates that the presence of the CHILDINFO extended 2638 data item doesn't necessarily imply \HasChildren. 2640 C: a1 LIST "" ("foo" "foo/*") 2641 S: * LIST () "/" foo 2642 S: a1 OK done 2644 C: a2 LIST (SUBSCRIBED) "" "foo/*" 2645 S: * LIST (\Subscribed \NonExistent) "/" foo/bar 2646 S: a2 OK done 2648 C: a3 LIST (SUBSCRIBED RECURSIVEMATCH) "" foo RETURN (CHILDREN) 2649 S: * LIST (\HasNoChildren) "/" foo ("CHILDINFO" ("SUBSCRIBED")) 2650 S: a3 OK done 2652 11: The following example shows how a server that supports missing 2653 mailbox hierarchy elements can signal to a client that didn't 2654 specify the RECURSIVEMATCH selection option that there is a 2655 child mailbox that matches the selection criteria. 2657 C: a1 LIST (REMOTE) "" * 2658 S: * LIST () "/" music/rock 2659 S: * LIST (\Remote) "/" also/jazz 2660 S: a1 OK done 2662 C: a2 LIST () "" % 2663 S: * LIST (\NonExistent \HasChildren) "/" music 2664 S: a2 OK done 2666 C: a3 LIST (REMOTE) "" % 2667 S: * LIST (\NonExistent \HasChildren) "/" music 2668 S: * LIST (\NonExistent \HasChildren) "/" also 2669 S: a3 OK done 2671 C: a3.1 LIST "" (% music/rock) 2672 S: * LIST () "/" music/rock 2673 S: a3.1 OK done 2675 Because "music/rock" is the only mailbox under "music", there's 2676 no need for the server to also return "music". However clients 2677 must handle both cases. 2679 6.3.10. NAMESPACE Command 2681 Arguments: none 2683 Responses: REQUIRED untagged responses: NAMESPACE 2685 Result: OK - command completed 2686 NO - Can't complete the command 2687 BAD - arguments invalid 2689 The NAMESPACE command causes a single ungagged NAMESPACE response to 2690 be returned. The untagged NAMESPACE response contains the prefix and 2691 hierarchy delimiter to the server's Personal Namespace(s), Other 2692 Users' Namespace(s), and Shared Namespace(s) that the server wishes 2693 to expose. The response will contain a NIL for any namespace class 2694 that is not available. Namespace-Response-Extensions ABNF non 2695 terminal is defined for extensibility and MAY be included in the 2696 response. 2698 Example 1: 2700 In this example a server supports a single personal namespace. No 2701 leading prefix is used on personal mailboxes and "/" is the hierarchy 2702 delimiter. 2704 C: A001 NAMESPACE 2705 S: * NAMESPACE (("" "/")) NIL NIL 2706 S: A001 OK NAMESPACE command completed 2708 Example 2: 2710 A user logged on anonymously to a server. No personal mailboxes are 2711 associated with the anonymous user and the user does not have access 2712 to the Other Users' Namespace. No prefix is required to access 2713 shared mailboxes and the hierarchy delimiter is "." 2715 C: A001 NAMESPACE 2716 S: * NAMESPACE NIL NIL (("" ".")) 2717 S: A001 OK NAMESPACE command completed 2719 Example 3: 2721 A server that contains a Personal Namespace and a single Shared 2722 Namespace. 2724 C: A001 NAMESPACE 2725 S: * NAMESPACE (("" "/")) NIL (("Public Folders/" "/")) 2726 S: A001 OK NAMESPACE command completed 2728 Example 4: 2730 A server that contains a Personal Namespace, Other Users' Namespace 2731 and multiple Shared Namespaces. Note that the hierarchy delimiter 2732 used within each namespace can be different. 2734 C: A001 NAMESPACE 2735 S: * NAMESPACE (("" "/")) (("~" "/")) (("#shared/" "/") 2736 ("#public/" "/")("#ftp/" "/")("#news." ".")) 2737 S: A001 OK NAMESPACE command completed 2739 The prefix string allows a client to do things such as automatically 2740 creating personal mailboxes or LISTing all available mailboxes within 2741 a namespace. 2743 Example 5: 2745 A server that supports only the Personal Namespace, with a leading 2746 prefix of INBOX to personal mailboxes and a hierarchy delimiter of 2747 "." 2748 C: A001 NAMESPACE 2749 S: * NAMESPACE (("INBOX." ".")) NIL NIL 2750 S: A001 OK NAMESPACE command completed 2752 < Automatically create a mailbox to store sent items.> 2754 C: A002 CREATE "INBOX.Sent Mail" 2755 S: A002 OK CREATE command completed 2757 Although typically a server will support only a single Personal 2758 Namespace, and a single Other User's Namespace, circumstances exist 2759 where there MAY be multiples of these, and a client MUST be prepared 2760 for them. If a client is configured such that it is required to 2761 create a certain mailbox, there can be circumstances where it is 2762 unclear which Personal Namespaces it should create the mailbox in. 2763 In these situations a client SHOULD let the user select which 2764 namespaces to create the mailbox in or just use the first personal 2765 namespace. 2767 Example 6: 2769 In this example, a server supports 2 Personal Namespaces. In 2770 addition to the regular Personal Namespace, the user has an 2771 additional personal namespace to allow access to mailboxes in an MH 2772 format mailstore. 2774 The client is configured to save a copy of all mail sent by the user 2775 into a mailbox called 'Sent Mail'. Furthermore, after a message is 2776 deleted from a mailbox, the client is configured to move that message 2777 to a mailbox called 'Deleted Items'. 2779 Note that this example demonstrates how some extension flags can be 2780 passed to further describe the #mh namespace. 2782 C: A001 NAMESPACE 2783 S: * NAMESPACE (("" "/")("#mh/" "/" "X-PARAM" ("FLAG1" "FLAG2"))) 2784 NIL NIL 2785 S: A001 OK NAMESPACE command completed 2787 < It is desired to keep only one copy of sent mail. It is unclear 2788 which Personal Namespace the client should use to create the 'Sent 2789 Mail' mailbox. The user is prompted to select a namespace and 2790 only one 'Sent Mail' mailbox is created. > 2792 C: A002 CREATE "Sent Mail" 2793 S: A002 OK CREATE command completed 2795 < The client is designed so that it keeps two 'Deleted Items' 2796 mailboxes, one for each namespace. > 2798 C: A003 CREATE "Delete Items" 2799 S: A003 OK CREATE command completed 2801 C: A004 CREATE "#mh/Deleted Items" 2802 S: A004 OK CREATE command completed 2804 The next level of hierarchy following the Other Users' Namespace 2805 prefix SHOULD consist of , where is a user name 2806 as per the LOGIN or AUTHENTICATE command. 2808 A client can construct a LIST command by appending a "%" to the Other 2809 Users' Namespace prefix to discover the Personal Namespaces of other 2810 users that are available to the currently authenticated user. 2812 In response to such a LIST command, a server SHOULD NOT return user 2813 names that have not granted access to their personal mailboxes to the 2814 user in question. 2816 A server MAY return a LIST response containing only the names of 2817 users that have explicitly granted access to the user in question. 2819 Alternatively, a server MAY return NO to such a LIST command, 2820 requiring that a user name be included with the Other Users' 2821 Namespace prefix before listing any other user's mailboxes. 2823 Example 7: 2825 A server that supports providing a list of other user's mailboxes 2826 that are accessible to the currently logged on user. 2828 C: A001 NAMESPACE 2829 S: * NAMESPACE (("" "/")) (("Other Users/" "/")) NIL 2830 S: A001 OK NAMESPACE command completed 2832 C: A002 LIST "" "Other Users/%" 2833 S: * LIST () "/" "Other Users/Mike" 2834 S: * LIST () "/" "Other Users/Karen" 2835 S: * LIST () "/" "Other Users/Matthew" 2836 S: * LIST () "/" "Other Users/Tesa" 2837 S: A002 OK LIST command completed 2839 Example 8: 2841 A server that does not support providing a list of other user's 2842 mailboxes that are accessible to the currently logged on user. The 2843 mailboxes are listable if the client includes the name of the other 2844 user with the Other Users' Namespace prefix. 2846 C: A001 NAMESPACE 2847 S: * NAMESPACE (("" "/")) (("#Users/" "/")) NIL 2848 S: A001 OK NAMESPACE command completed 2850 < In this example, the currently logged on user has access to the 2851 Personal Namespace of user Mike, but the server chose to suppress 2852 this information in the LIST response. However, by appending the 2853 user name Mike (received through user input) to the Other Users' 2854 Namespace prefix, the client is able to get a listing of the 2855 personal mailboxes of user Mike. > 2857 C: A002 LIST "" "#Users/%" 2858 S: A002 NO The requested item could not be found. 2860 C: A003 LIST "" "#Users/Mike/%" 2861 S: * LIST () "/" "#Users/Mike/INBOX" 2862 S: * LIST () "/" "#Users/Mike/Foo" 2863 S: A003 OK LIST command completed. 2865 A prefix string might not contain a hierarchy delimiter, because in 2866 some cases it is not needed as part of the prefix. 2868 Example 9: 2870 A server that allows access to the Other Users' Namespace by 2871 prefixing the others' mailboxes with a '~' followed by , 2872 where is a user name as per the LOGIN or AUTHENTICATE 2873 command. 2875 C: A001 NAMESPACE 2876 S: * NAMESPACE (("" "/")) (("~" "/")) NIL 2877 S: A001 OK NAMESPACE command completed 2879 < List the mailboxes for user mark > 2881 C: A002 LIST "" "~mark/%" 2882 S: * LIST () "/" "~mark/INBOX" 2883 S: * LIST () "/" "~mark/foo" 2884 S: A002 OK LIST command completed 2886 6.3.11. STATUS Command 2888 Arguments: mailbox name 2889 status data item names 2891 Responses: REQUIRED untagged responses: STATUS 2893 Result: OK - status completed 2894 NO - status failure: no status for that name 2895 BAD - command unknown or arguments invalid 2897 The STATUS command requests the status of the indicated mailbox. It 2898 does not change the currently selected mailbox, nor does it affect 2899 the state of any messages in the queried mailbox. 2901 The STATUS command provides an alternative to opening a second 2902 IMAP4rev2 connection and doing an EXAMINE command on a mailbox to 2903 query that mailbox's status without deselecting the current mailbox 2904 in the first IMAP4rev2 connection. 2906 Unlike the LIST command, the STATUS command is not guaranteed to be 2907 fast in its response. Under certain circumstances, it can be quite 2908 slow. In some implementations, the server is obliged to open the 2909 mailbox read-only internally to obtain certain status information. 2910 Also unlike the LIST command, the STATUS command does not accept 2911 wildcards. 2913 Note: The STATUS command is intended to access the status of 2914 mailboxes other than the currently selected mailbox. Because the 2915 STATUS command can cause the mailbox to be opened internally, and 2916 because this information is available by other means on the 2917 selected mailbox, the STATUS command SHOULD NOT be used on the 2918 currently selected mailbox. 2920 The STATUS command MUST NOT be used as a "check for new messages 2921 in the selected mailbox" operation (refer to sections Section 7, 2922 Section 7.3.1 for more information about the proper method for new 2923 message checking). 2925 STATUS SIZE (see below) can take a significant amount of time, 2926 depending upon server implementation. Clients should use STATUS 2927 SIZE cautiously. 2929 The currently defined status data items that can be requested are: 2931 MESSAGES The number of messages in the mailbox. 2933 UIDNEXT The next unique identifier value of the mailbox. Refer to 2934 Section 2.3.1.1 for more information. 2936 UIDVALIDITY The unique identifier validity value of the mailbox. 2937 Refer to Section 2.3.1.1 for more information. 2939 UNSEEN The number of messages which do not have the \Seen flag set. 2941 DELETED The number of messages which have the \Deleted flag set. 2943 SIZE The total size of the mailbox in octets. This is not strictly 2944 required to be an exact value, but it MUST be equal to or greater 2945 than the sum of the values of the RFC822.SIZE FETCH message data 2946 items (see Section 6.4.5) of all messages in the mailbox. 2948 SIZE 2950 Example: C: A042 STATUS blurdybloop (UIDNEXT MESSAGES) 2951 S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) 2952 S: A042 OK STATUS completed 2954 6.3.12. APPEND Command 2956 Arguments: mailbox name 2957 OPTIONAL flag parenthesized list 2958 OPTIONAL date/time string 2959 message literal 2961 Responses: no specific responses for this command 2963 Result: OK - append completed 2964 NO - append error: can't append to that mailbox, error 2965 in flags or date/time or message text 2966 BAD - command unknown or arguments invalid 2968 The APPEND command appends the literal argument as a new message to 2969 the end of the specified destination mailbox. This argument SHOULD 2970 be in the format of an [RFC-5322] or [I18N-HDRS] message. 8-bit 2971 characters are permitted in the message. A server implementation 2972 that is unable to preserve 8-bit data properly MUST be able to 2973 reversibly convert 8-bit APPEND data to 7-bit using a [MIME-IMB] 2974 content transfer encoding. 2976 Note: There may be exceptions, e.g., draft messages, in which 2977 required [RFC-5322] header lines are omitted in the message 2978 literal argument to APPEND. The full implications of doing so 2979 must be understood and carefully weighed. 2981 If a flag parenthesized list is specified, the flags SHOULD be set in 2982 the resulting message; otherwise, the flag list of the resulting 2983 message is set to empty by default. 2985 If a date-time is specified, the internal date SHOULD be set in the 2986 resulting message; otherwise, the internal date of the resulting 2987 message is set to the current date and time by default. 2989 If the append is unsuccessful for any reason, the mailbox MUST be 2990 restored to its state before the APPEND attempt (other than possibly 2991 keeping the changed mailbox's UIDNEXT value); no partial appending is 2992 permitted. 2994 If the destination mailbox does not exist, a server MUST return an 2995 error, and MUST NOT automatically create the mailbox. Unless it is 2996 certain that the destination mailbox can not be created, the server 2997 MUST send the response code "[TRYCREATE]" as the prefix of the text 2998 of the tagged NO response. This gives a hint to the client that it 2999 can attempt a CREATE command and retry the APPEND if the CREATE is 3000 successful. 3002 On successful completion of an APPEND, the server SHOULD return an 3003 APPENDUID response code. 3005 In the case of a mailbox that has permissions set so that the client 3006 can APPEND to the mailbox, but not SELECT or EXAMINE it, the server 3007 SHOULD NOT send an APPENDUID response code as it would disclose 3008 information about the mailbox. 3010 In the case of a mailbox that has UIDNOTSTICKY status (see 3011 UIDNOTSTICKY response code definition), the server MAY omit the 3012 APPENDUID response code as it is not meaningful. 3014 If the server does not return the APPENDUID response codes, the 3015 client can discover this information by selecting the destination 3016 mailbox. The location of messages placed in the destination mailbox 3017 by APPEND can be determined by using FETCH and/or SEARCH commands 3018 (e.g., for Message-ID or some unique marker placed in the message in 3019 an APPEND). 3021 If the mailbox is currently selected, the normal new message actions 3022 SHOULD occur. Specifically, the server SHOULD notify the client 3023 immediately via an untagged EXISTS response. If the server does not 3024 do so, the client MAY issue a NOOP command after one or more APPEND 3025 commands. 3027 Example: C: A003 APPEND saved-messages (\Seen) {310} 3028 S: + Ready for literal data 3029 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST) 3030 C: From: Fred Foobar 3031 C: Subject: afternoon meeting 3032 C: To: mooch@owatagu.siam.edu 3033 C: Message-Id: 3034 C: MIME-Version: 1.0 3035 C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 3036 C: 3037 C: Hello Joe, do you think we can meet at 3:30 tomorrow? 3038 C: 3039 S: A003 OK APPEND completed 3041 Example: C: A003 APPEND saved-messages (\Seen) {297} 3042 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST) 3043 C: From: Fred Foobar 3044 C: Subject: afternoon meeting 3045 C: To: mooch@example.com 3046 C: Message-Id: 3047 C: MIME-Version: 1.0 3048 C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 3049 C: 3050 C: Hello Joe, do you think we can meet at 3:30 tomorrow? 3051 C: 3052 S: A003 OK [APPENDUID 38505 3955] APPEND completed 3053 C: A004 COPY 2:4 meeting 3054 S: A004 OK [COPYUID 38505 304,319:320 3956:3958] Done 3055 C: A005 UID COPY 305:310 meeting 3056 S: A005 OK No matching messages, so nothing copied 3057 C: A006 COPY 2 funny 3058 S: A006 OK Done 3059 C: A007 SELECT funny 3060 S: * 1 EXISTS 3061 S: * OK [UIDVALIDITY 3857529045] Validity session-only 3062 S: * OK [UIDNEXT 2] Predicted next UID 3063 S: * NO [UIDNOTSTICKY] Non-persistent UIDs 3064 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 3065 S: * OK [PERMANENTFLAGS (\Deleted \Seen)] Limited 3066 S: A007 OK [READ-WRITE] SELECT completed 3068 In this example, A003 and A004 demonstrate successful appending and 3069 copying to a mailbox that returns the UIDs assigned to the messages. 3070 A005 is an example in which no messages were copied; this is because 3071 in A003, we see that message 2 had UID 304, and message 3 had UID 3072 319; therefore, UIDs 305 through 310 do not exist (refer to 3073 Section 2.3.1.1 for further explanation). A006 is an example of a 3074 message being copied that did not return a COPYUID; and, as expected, 3075 A007 shows that the mail store containing that mailbox does not 3076 support persistent UIDs. 3078 Note: The APPEND command is not used for message delivery, because 3079 it does not provide a mechanism to transfer [SMTP] envelope 3080 information. 3082 6.3.13. IDLE Command 3084 Arguments: none 3086 Responses: continuation data will be requested; the client sends the 3087 continuation data "DONE" to end the command 3089 Result: OK - IDLE completed after client sent "DONE" 3090 NO - failure: the server will not allow the IDLE command 3091 at this time 3092 BAD - command unknown or arguments invalid 3094 Without the IDLE command a client requires to poll the server for 3095 changes to the selected mailbox (new mail, deletions, flag changes). 3096 It's often more desirable to have the server transmit updates to the 3097 client in real time. This allows a user to see new mail immediately. 3098 The IDLE command allows a client to tell the server that it's ready 3099 to accept such real-time updates. 3101 The IDLE command is sent from the client to the server when the 3102 client is ready to accept unsolicited update messages. The server 3103 requests a response to the IDLE command using the continuation ("+") 3104 response. The IDLE command remains active until the client responds 3105 to the continuation, and as long as an IDLE command is active, the 3106 server is now free to send untagged EXISTS, EXPUNGE, FETCH, and other 3107 responses at any time. If the server choose to send unsolicited 3108 FETCH responses, they MUST include UID FETCH item. 3110 The IDLE command is terminated by the receipt of a "DONE" 3111 continuation from the client; such response satisfies the server's 3112 continuation request. At that point, the server MAY send any 3113 remaining queued untagged responses and then MUST immediately send 3114 the tagged response to the IDLE command and prepare to process other 3115 commands. As for other commands, the processing of any new command 3116 may cause the sending of unsolicited untagged responses, subject to 3117 the ambiguity limitations. The client MUST NOT send a command while 3118 the server is waiting for the DONE, since the server will not be able 3119 to distinguish a command from a continuation. 3121 The server MAY consider a client inactive if it has an IDLE command 3122 running, and if such a server has an inactivity timeout it MAY log 3123 the client off implicitly at the end of its timeout period. Because 3124 of that, clients using IDLE are advised to terminate the IDLE and re- 3125 issue it at least every 29 minutes to avoid being logged off. This 3126 still allows a client to receive immediate mailbox updates even 3127 though it need only "poll" at half hour intervals. 3129 Example: C: A001 SELECT INBOX 3130 S: * FLAGS (\Deleted \Seen \Flagged) 3131 S: * OK [PERMANENTFLAGS (\Deleted \Seen \Flagged)] Limited 3132 S: * 3 EXISTS 3133 S: * OK [UIDVALIDITY 1] 3134 S: A001 OK [READ-WRITE] SELECT completed 3135 C: A002 IDLE 3136 S: + idling 3137 ...time passes; new mail arrives... 3138 S: * 4 EXISTS 3139 C: DONE 3140 S: A002 OK IDLE terminated 3141 ...another client expunges message 2 now... 3142 C: A003 FETCH 4 ALL 3143 S: * 4 FETCH (...) 3144 S: A003 OK FETCH completed 3145 C: A004 IDLE 3146 S: * 2 EXPUNGE 3147 S: * 3 EXISTS 3148 S: + idling 3149 ...time passes; another client expunges message 3... 3150 S: * 3 EXPUNGE 3151 S: * 2 EXISTS 3152 ...time passes; new mail arrives... 3153 S: * 3 EXISTS 3154 C: DONE 3155 S: A004 OK IDLE terminated 3156 C: A005 FETCH 3 ALL 3157 S: * 3 FETCH (...) 3158 S: A005 OK FETCH completed 3159 C: A006 IDLE 3161 6.4. Client Commands - Selected State 3163 In the selected state, commands that manipulate messages in a mailbox 3164 are permitted. 3166 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 3167 and the authenticated state commands (SELECT, EXAMINE, NAMESPACE, 3168 CREATE, DELETE, RENAME, SUBSCRIBE, UNSUBSCRIBE, LIST, STATUS, and 3169 APPEND), the following commands are valid in the selected state: 3170 CLOSE, UNSELECT, EXPUNGE, SEARCH, FETCH, STORE, COPY, MOVE, and UID. 3172 6.4.1. CLOSE Command 3174 Arguments: none 3176 Responses: no specific responses for this command 3177 Result: OK - close completed, now in authenticated state 3178 BAD - command unknown or arguments invalid 3180 The CLOSE command permanently removes all messages that have the 3181 \Deleted flag set from the currently selected mailbox, and returns to 3182 the authenticated state from the selected state. No untagged EXPUNGE 3183 responses are sent. 3185 No messages are removed, and no error is given, if the mailbox is 3186 selected by an EXAMINE command or is otherwise selected read-only. 3188 Even if a mailbox is selected, a SELECT, EXAMINE, or LOGOUT command 3189 MAY be issued without previously issuing a CLOSE command. The 3190 SELECT, EXAMINE, and LOGOUT commands implicitly close the currently 3191 selected mailbox without doing an expunge. However, when many 3192 messages are deleted, a CLOSE-LOGOUT or CLOSE-SELECT sequence is 3193 considerably faster than an EXPUNGE-LOGOUT or EXPUNGE-SELECT because 3194 no untagged EXPUNGE responses (which the client would probably 3195 ignore) are sent. 3197 Example: C: A341 CLOSE 3198 S: A341 OK CLOSE completed 3200 6.4.2. UNSELECT Command 3202 Arguments: none 3204 Responses: no specific responses for this command 3206 Result: OK - unselect completed, now in authenticated state 3207 BAD - no mailbox selected, or argument supplied but none 3208 permitted 3210 The UNSELECT command frees server's resources associated with the 3211 selected mailbox and returns the server to the authenticated state. 3212 This command performs the same actions as CLOSE, except that no 3213 messages are permanently removed from the currently selected mailbox. 3215 Example: C: A342 UNSELECT 3216 S: A342 OK Unselect completed 3218 6.4.3. EXPUNGE Command 3220 Arguments: none 3222 Responses: untagged responses: EXPUNGE 3224 Result: OK - expunge completed 3225 NO - expunge failure: can't expunge (e.g., permission 3226 denied) 3227 BAD - command unknown or arguments invalid 3229 The EXPUNGE command permanently removes all messages that have the 3230 \Deleted flag set from the currently selected mailbox. Before 3231 returning an OK to the client, an untagged EXPUNGE response is sent 3232 for each message that is removed. 3234 Example: C: A202 EXPUNGE 3235 S: * 3 EXPUNGE 3236 S: * 3 EXPUNGE 3237 S: * 5 EXPUNGE 3238 S: * 8 EXPUNGE 3239 S: A202 OK EXPUNGE completed 3241 Note: In this example, messages 3, 4, 7, and 11 had the \Deleted flag 3242 set. See the description of the EXPUNGE response for further 3243 explanation. 3245 6.4.4. SEARCH Command 3247 Arguments: OPTIONAL result specifier 3248 OPTIONAL [CHARSET] specification 3249 searching criteria (one or more) 3251 Responses: REQUIRED untagged response: ESEARCH 3253 Result: OK - search completed 3254 NO - search error: can't search that [CHARSET] or 3255 criteria 3256 BAD - command unknown or arguments invalid 3258 The SEARCH command searches the mailbox for messages that match the 3259 given searching criteria. 3261 The SEARCH command may contain result options. Result options 3262 control what kind of information is returned about messages matching 3263 the search criteria in an untagged ESEARCH response. If no result 3264 option is specified or empty list of options is specified "()", ALL 3265 is assumed (see below). 3267 The order of individual options is arbitrary. Individual options may 3268 contain parameters enclosed in parentheses (*). If an option has 3269 parameters, they consist of atoms and/or strings and/or lists in a 3270 specific order. Any options not defined by extensions that the 3271 server supports must be rejected with a BAD response. 3273 (*) - if an option has a mandatory parameter, which can always be 3274 represented as a number or a sequence-set, the option parameter does 3275 not need the enclosing (). See ABNF for more details. 3277 This document specifies the following result options: 3279 MIN 3281 Return the lowest message number/UID that satisfies the SEARCH 3282 criteria. 3284 If the SEARCH results in no matches, the server MUST NOT 3285 include the MIN result option in the ESEARCH response; however, 3286 it still MUST send the ESEARCH response. 3288 MAX 3290 Return the highest message number/UID that satisfies the SEARCH 3291 criteria. 3293 If the SEARCH results in no matches, the server MUST NOT 3294 include the MAX result option in the ESEARCH response; however, 3295 it still MUST send the ESEARCH response. 3297 ALL 3299 Return all message numbers/UIDs that satisfy the SEARCH 3300 criteria using the sequence-set syntax. Note, the client MUST 3301 NOT assume that messages/UIDs will be listed in any particular 3302 order. 3304 If the SEARCH results in no matches, the server MUST NOT 3305 include the ALL result option in the ESEARCH response; however, 3306 it still MUST send the ESEARCH response. 3308 COUNT Return number of the messages that satisfy the SEARCH 3309 criteria. This result option MUST always be included in the 3310 ESEARCH response. 3312 Note: future extensions to this document can allow servers to return 3313 multiple ESEARCH responses for a single extended SEARCH command. 3314 However all options specified above MUST result in a single ESEARCH 3315 response. 3317 These extensions will have to describe how results from multiple 3318 ESEARCH responses are to be amalgamated. 3320 Searching criteria consist of one or more search keys. 3322 When multiple keys are specified, the result is the intersection (AND 3323 function) of all the messages that match those keys. For example, 3324 the criteria DELETED FROM "SMITH" SINCE 1-Feb-1994 refers to all 3325 deleted messages from Smith that were placed in the mailbox since 3326 February 1, 1994. A search key can also be a parenthesized list of 3327 one or more search keys (e.g., for use with the OR and NOT keys). 3329 Server implementations MAY exclude [MIME-IMB] body parts with 3330 terminal content media types other than TEXT and MESSAGE from 3331 consideration in SEARCH matching. 3333 The OPTIONAL [CHARSET] specification consists of the word "CHARSET" 3334 followed by a registered [CHARSET]. It indicates the [CHARSET] of 3335 the strings that appear in the search criteria. [MIME-IMB] content 3336 transfer encodings, and [MIME-HDRS] strings in [RFC-5322]/[MIME-IMB] 3337 headers, MUST be decoded before comparing text. Servers MUST support 3338 US-ASCII and UTF-8 charsets; other [CHARSET]s MAY be supported. 3339 Clients SHOULD use UTF-8. Note that if "CHARSET" is not provided 3340 IMAP4rev2 server MUST assume UTF-8, so selecting CHARSET UTF-8 is 3341 redundant. It is permitted for improved compatibility with existing 3342 IMAP4rev1 clients. 3344 If the server does not support the specified [CHARSET], it MUST 3345 return a tagged NO response (not a BAD). This response SHOULD 3346 contain the BADCHARSET response code, which MAY list the [CHARSET]s 3347 supported by the server. 3349 In all search keys that use strings, a message matches the key if the 3350 string is a substring of the associated text. The matching SHOULD be 3351 case-insensitive for characters within ASCII range. Consider using 3352 [IMAP-I18N] for language-sensitive case-insensitive searching. Note 3353 that the empty string is a substring; this is useful when doing a 3354 HEADER search in order to test for a header field presence in the 3355 message. 3357 The defined search keys are as follows. Refer to the Formal Syntax 3358 section for the precise syntactic definitions of the arguments. 3360 3362 Messages with message sequence numbers corresponding 3363 to the specified message sequence number set. 3365 ALL All messages in the mailbox; the default initial key for ANDing. 3367 ANSWERED Messages with the \Answered flag set. 3369 BCC Messages that contain the specified string in the 3370 envelope structure's BCC field. 3372 BEFORE Messages whose internal date (disregarding time and 3373 timezone) is earlier than the specified date. 3375 BODY Messages that contain the specified string in the body 3376 of the message. Unlike TEXT (see below), this doesn't match any 3377 header fields. 3379 CC Messages that contain the specified string in the 3380 envelope structure's CC field. 3382 DELETED Messages with the \Deleted flag set. 3384 DRAFT Messages with the \Draft flag set. 3386 FLAGGED Messages with the \Flagged flag set. 3388 FROM Messages that contain the specified string in the 3389 envelope structure's FROM field. 3391 HEADER Messages that have a header with the 3392 specified field-name (as defined in [RFC-5322]) and that contains 3393 the specified string in the text of the header (what comes after 3394 the colon). If the string to search is zero-length, this matches 3395 all messages that have a header line with the specified field-name 3396 regardless of the contents. Servers should use substring search 3397 for this SEARCH item, as clients can use it for automatic 3398 processing not initiated by end users. For example this can be 3399 used for searching for Message-ID or Content-Type header field 3400 values that need to be exact, or for searches in header fields 3401 that the IMAP server might not know anything about. 3403 KEYWORD Messages with the specified keyword flag set. 3405 LARGER Messages with an [RFC-5322] size larger than the 3406 specified number of octets. 3408 NOT Messages that do not match the specified search 3409 key. 3411 ON Messages whose internal date (disregarding time and 3412 timezone) is within the specified date. 3414 OR Messages that match either search 3415 key. 3417 SEEN Messages that have the \Seen flag set. 3419 SENTBEFORE Messages whose [RFC-5322] Date: header 3420 (disregarding time and timezone) is earlier than the specified 3421 date. 3423 SENTON Messages whose [RFC-5322] Date: header (disregarding 3424 time and timezone) is within the specified date. 3426 SENTSINCE Messages whose [RFC-5322] Date: header 3427 (disregarding time and timezone) is within or later than the 3428 specified date. 3430 SINCE Messages whose internal date (disregarding time and 3431 timezone) is within or later than the specified date. 3433 SMALLER Messages with an [RFC-5322] size smaller than the 3434 specified number of octets. 3436 SUBJECT Messages that contain the specified string in the 3437 envelope structure's SUBJECT field. 3439 TEXT Messages that contain the specified string in the 3440 header (including MIME header fields) or body of the message. 3442 TO Messages that contain the specified string in the 3443 envelope structure's TO field. 3445 UID Messages with unique identifiers corresponding to 3446 the specified unique identifier set. Sequence set ranges are 3447 permitted. 3449 UNANSWERED Messages that do not have the \Answered flag set. 3451 UNDELETED Messages that do not have the \Deleted flag set. 3453 UNDRAFT Messages that do not have the \Draft flag set. 3455 UNFLAGGED Messages that do not have the \Flagged flag set. 3457 UNKEYWORD Messages that do not have the specified keyword 3458 flag set. 3460 UNSEEN Messages that do not have the \Seen flag set. 3462 Example: C: A282 SEARCH RETURN (MIN COUNT) FLAGGED 3463 SINCE 1-Feb-1994 NOT FROM "Smith" 3464 S: * ESEARCH (TAG "A282") MIN 2 COUNT 3 3465 S: A282 OK SEARCH completed 3467 Example: C: A283 SEARCH RETURN () FLAGGED 3468 SINCE 1-Feb-1994 NOT FROM "Smith" 3469 S: * ESEARCH (TAG "A283") ALL 2,10:11 3470 S: A283 OK SEARCH completed 3472 Example: C: A284 SEARCH TEXT "string not in mailbox" 3473 S: * ESEARCH (TAG "A284") 3474 S: A284 OK SEARCH completed 3475 C: A285 SEARCH CHARSET UTF-8 TEXT {6} 3476 S: + Ready for literal text 3477 C: XXXXXX 3478 S: * ESEARCH (TAG "A285") ALL 43 3479 S: A285 OK SEARCH completed 3481 Note: Since this document is restricted to 7-bit ASCII text, it is 3482 not possible to show actual UTF-8 data. The "XXXXXX" is a 3483 placeholder for what would be 6 octets of 8-bit data in an actual 3484 transaction. 3486 The following example demonstrates finding the first unseen message 3487 in the mailbox: 3489 Example: C: A284 SEARCH RETURN (MIN) UNSEEN 3490 S: * ESEARCH (TAG "A284") MIN 4 3491 S: A284 OK SEARCH completed 3493 The following example demonstrates that if the ESEARCH UID indicator 3494 is present, all data in the ESEARCH response is referring to UIDs; 3495 for example, the MIN result specifier will be followed by a UID. 3497 Example: C: A285 UID SEARCH RETURN (MIN MAX) 1:5000 3498 S: * ESEARCH (TAG "A285") UID MIN 7 MAX 3800 3499 S: A285 OK SEARCH completed 3501 The following example demonstrates returning the number of deleted 3502 messages: 3504 Example: C: A286 SEARCH RETURN (COUNT) DELETED 3505 S: * ESEARCH (TAG "A286") COUNT 15 3506 S: A286 OK SEARCH completed 3508 6.4.5. FETCH Command 3510 Arguments: sequence set 3511 message data item names or macro 3513 Responses: untagged responses: FETCH 3515 Result: OK - fetch completed 3516 NO - fetch error: can't fetch that data 3517 BAD - command unknown or arguments invalid 3519 The FETCH command retrieves data associated with a message in the 3520 mailbox. The data items to be fetched can be either a single atom or 3521 a parenthesized list. 3523 Most data items, identified in the formal syntax under the msg-att- 3524 static rule, are static and MUST NOT change for any particular 3525 message. Other data items, identified in the formal syntax under the 3526 msg-att-dynamic rule, MAY change, either as a result of a STORE 3527 command or due to external events. 3529 For example, if a client receives an ENVELOPE for a message when 3530 it already knows the envelope, it can safely ignore the newly 3531 transmitted envelope. 3533 There are three macros which specify commonly-used sets of data 3534 items, and can be used instead of data items. A macro must be used 3535 by itself, and not in conjunction with other macros or data items. 3537 ALL Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE) 3539 FAST Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE) 3541 FULL Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE 3542 BODY) 3544 The currently defined data items that can be fetched are: 3546 BINARY[]<> 3548 Requests that the specified section be transmitted after 3549 performing Content-Transfer-Encoding-related decoding. 3551 The argument, if present, requests that a subset of 3552 the data be returned. The semantics of a partial FETCH BINARY 3553 command are the same as for a partial FETCH BODY command, with 3554 the exception that the arguments refer to the DECODED 3555 section data. 3557 BINARY.PEEK[]<> An alternate form of 3558 BINARY[] that does not implicitly set the \Seen 3559 flag. 3561 BINARY.SIZE[] 3563 Requests the decoded size of the section (i.e., the size to 3564 expect in response to the corresponding FETCH BINARY request). 3566 Note: client authors are cautioned that this might be an 3567 expensive operation for some server implementations. 3568 Needlessly issuing this request could result in degraded 3569 performance due to servers having to calculate the value every 3570 time the request is issued. 3572 BODY Non-extensible form of BODYSTRUCTURE. 3574 BODY[
]<> 3576 The text of a particular body section. The section 3577 specification is a set of zero or more part specifiers 3578 delimited by periods. A part specifier is either a part number 3579 or one of the following: HEADER, HEADER.FIELDS, 3580 HEADER.FIELDS.NOT, MIME, and TEXT. An empty section 3581 specification refers to the entire message, including the 3582 header. 3584 Every message has at least one part number. Non-[MIME-IMB] 3585 messages, and non-multipart [MIME-IMB] messages with no 3586 encapsulated message, only have a part 1. 3588 Multipart messages are assigned consecutive part numbers, as 3589 they occur in the message. If a particular part is of type 3590 message or multipart, its parts MUST be indicated by a period 3591 followed by the part number within that nested multipart part. 3593 A part of type MESSAGE/RFC822 or MESSAGE/GLOBAL also has nested 3594 part numbers, referring to parts of the MESSAGE part's body. 3596 The HEADER, HEADER.FIELDS, HEADER.FIELDS.NOT, and TEXT part 3597 specifiers can be the sole part specifier or can be prefixed by 3598 one or more numeric part specifiers, provided that the numeric 3599 part specifier refers to a part of type MESSAGE/RFC822 or 3600 MESSAGE/GLOBAL. The MIME part specifier MUST be prefixed by 3601 one or more numeric part specifiers. 3603 The HEADER, HEADER.FIELDS, and HEADER.FIELDS.NOT part 3604 specifiers refer to the [RFC-5322] header of the message or of 3605 an encapsulated [MIME-IMT] MESSAGE/RFC822 or MESSAGE/GLOBAL 3606 message. HEADER.FIELDS and HEADER.FIELDS.NOT are followed by a 3607 list of field-name (as defined in [RFC-5322]) names, and return 3608 a subset of the header. The subset returned by HEADER.FIELDS 3609 contains only those header fields with a field-name that 3610 matches one of the names in the list; similarly, the subset 3611 returned by HEADER.FIELDS.NOT contains only the header fields 3612 with a non-matching field-name. The field-matching is ASCII 3613 range case-insensitive but otherwise exact. Subsetting does 3614 not exclude the [RFC-5322] delimiting blank line between the 3615 header and the body; the blank line is included in all header 3616 fetches, except in the case of a message which has no body and 3617 no blank line. 3619 The MIME part specifier refers to the [MIME-IMB] header for 3620 this part. 3622 The TEXT part specifier refers to the text body of the message, 3623 omitting the [RFC-5322] header. 3625 Here is an example of a complex message with some of its 3626 part specifiers: 3628 HEADER ([RFC-5322] header of the message) 3629 TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 3630 1 TEXT/PLAIN 3631 2 APPLICATION/OCTET-STREAM 3632 3 MESSAGE/RFC822 3633 3.HEADER ([RFC-5322] header of the message) 3634 3.TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 3635 3.1 TEXT/PLAIN 3636 3.2 APPLICATION/OCTET-STREAM 3637 4 MULTIPART/MIXED 3638 4.1 IMAGE/GIF 3639 4.1.MIME ([MIME-IMB] header for the IMAGE/GIF) 3640 4.2 MESSAGE/RFC822 3641 4.2.HEADER ([RFC-5322] header of the message) 3642 4.2.TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 3643 4.2.1 TEXT/PLAIN 3644 4.2.2 MULTIPART/ALTERNATIVE 3645 4.2.2.1 TEXT/PLAIN 3646 4.2.2.2 TEXT/RICHTEXT 3648 It is possible to fetch a substring of the designated text. 3649 This is done by appending an open angle bracket ("<"), the 3650 octet position of the first desired octet, a period, the 3651 maximum number of octets desired, and a close angle bracket 3652 (">") to the part specifier. If the starting octet is beyond 3653 the end of the text, an empty string is returned. 3655 Any partial fetch that attempts to read beyond the end of the 3656 text is truncated as appropriate. A partial fetch that starts 3657 at octet 0 is returned as a partial fetch, even if this 3658 truncation happened. 3660 Note: This means that BODY[]<0.2048> of a 1500-octet message 3661 will return BODY[]<0> with a literal of size 1500, not 3662 BODY[]. 3664 Note: A substring fetch of a HEADER.FIELDS or 3665 HEADER.FIELDS.NOT part specifier is calculated after 3666 subsetting the header. 3668 The \Seen flag is implicitly set; if this causes the flags to 3669 change, they SHOULD be included as part of the FETCH responses. 3671 BODY.PEEK[
]<> An alternate form of BODY[
] 3672 that does not implicitly set the \Seen flag. 3674 BODYSTRUCTURE The [MIME-IMB] body structure of the message. This is 3675 computed by the server by parsing the [MIME-IMB] header fields in 3676 the [RFC-5322] header and [MIME-IMB] headers. 3678 ENVELOPE The envelope structure of the message. This is computed by 3679 the server by parsing the [RFC-5322] header into the component 3680 parts, defaulting various fields as necessary. 3682 FLAGS The flags that are set for this message. 3684 INTERNALDATE The internal date of the message. 3686 RFC822.SIZE The [RFC-5322] size of the message. 3688 UID The unique identifier for the message. 3690 Example: C: A654 FETCH 2:4 (FLAGS BODY[HEADER.FIELDS (DATE FROM)]) 3691 S: * 2 FETCH .... 3692 S: * 3 FETCH .... 3693 S: * 4 FETCH .... 3694 S: A654 OK FETCH completed 3696 6.4.6. STORE Command 3698 Arguments: sequence set 3699 message data item name 3700 value for message data item 3702 Responses: untagged responses: FETCH 3704 Result: OK - store completed 3705 NO - store error: can't store that data 3706 BAD - command unknown or arguments invalid 3708 The STORE command alters data associated with a message in the 3709 mailbox. Normally, STORE will return the updated value of the data 3710 with an untagged FETCH response. A suffix of ".SILENT" in the data 3711 item name prevents the untagged FETCH, and the server SHOULD assume 3712 that the client has determined the updated value itself or does not 3713 care about the updated value. 3715 Note: Regardless of whether or not the ".SILENT" suffix was used, 3716 the server SHOULD send an untagged FETCH response if a change to a 3717 message's flags from an external source is observed. The intent 3718 is that the status of the flags is determinate without a race 3719 condition. 3721 The currently defined data items that can be stored are: 3723 FLAGS Replace the flags for the message with the 3724 argument. The new value of the flags is returned as if a FETCH of 3725 those flags was done. 3727 FLAGS.SILENT Equivalent to FLAGS, but without returning 3728 a new value. 3730 +FLAGS Add the argument to the flags for the message. 3731 The new value of the flags is returned as if a FETCH of those 3732 flags was done. 3734 +FLAGS.SILENT Equivalent to +FLAGS, but without 3735 returning a new value. 3737 -FLAGS Remove the argument from the flags for the 3738 message. The new value of the flags is returned as if a FETCH of 3739 those flags was done. 3741 -FLAGS.SILENT Equivalent to -FLAGS, but without 3742 returning a new value. 3744 Example: C: A003 STORE 2:4 +FLAGS (\Deleted) 3745 S: * 2 FETCH (FLAGS (\Deleted \Seen)) 3746 S: * 3 FETCH (FLAGS (\Deleted)) 3747 S: * 4 FETCH (FLAGS (\Deleted \Flagged \Seen)) 3748 S: A003 OK STORE completed 3750 6.4.7. COPY Command 3752 Arguments: sequence set 3753 mailbox name 3755 Responses: no specific responses for this command 3757 Result: OK - copy completed 3758 NO - copy error: can't copy those messages or to that 3759 name 3760 BAD - command unknown or arguments invalid 3762 The COPY command copies the specified message(s) to the end of the 3763 specified destination mailbox. The flags and internal date of the 3764 message(s) SHOULD be preserved in the copy. 3766 If the destination mailbox does not exist, a server SHOULD return an 3767 error. It SHOULD NOT automatically create the mailbox. Unless it is 3768 certain that the destination mailbox can not be created, the server 3769 MUST send the response code "[TRYCREATE]" as the prefix of the text 3770 of the tagged NO response. This gives a hint to the client that it 3771 can attempt a CREATE command and retry the COPY if the CREATE is 3772 successful. 3774 If the COPY command is unsuccessful for any reason, server 3775 implementations MUST restore the destination mailbox to its state 3776 before the COPY attempt. 3778 On successful completion of a COPY, the server SHOULD return a 3779 COPYUID response code. 3781 In the case of a mailbox that has permissions set so that the client 3782 can COPY to the mailbox, but not SELECT or EXAMINE it, the server 3783 SHOULD NOT send an COPYUID response code as it would disclose 3784 information about the mailbox. 3786 In the case of a mailbox that has UIDNOTSTICKY status (see the 3787 UIDNOTSTICKY response code), the server MAY omit the COPYUID response 3788 code as it is not meaningful. 3790 If the server does not return the COPYUID response code, the client 3791 can discover this information by selecting the destination mailbox. 3793 The location of messages placed in the destination mailbox by COPY 3794 can be determined by using FETCH and/or SEARCH commands (e.g., for 3795 Message-ID). 3797 Example: C: A003 COPY 2:4 MEETING 3798 S: A003 OK COPY completed 3800 6.4.8. MOVE Command 3802 Arguments: sequence set 3803 mailbox name 3805 Responses: no specific responses for this command 3807 Result: OK - move completed 3808 NO - move error: can't move those messages or to that 3809 name 3810 BAD - command unknown or arguments invalid 3812 The MOVE command moves the specified message(s) to the end of the 3813 specified destination mailbox. The flags and internal date of the 3814 message(s) SHOULD be preserved. 3816 This means that a new message is created in the target mailbox with a 3817 new UID, the original message is removed from the source mailbox, and 3818 it appears to the client as a single action. This has the same 3819 effect for each message as this sequence: 3821 1. [UID] COPY 3823 2. [UID] STORE +FLAGS.SILENT \DELETED 3825 3. UID EXPUNGE 3827 Although the effect of the MOVE is the same as the preceding steps, 3828 the semantics are not identical: The intermediate states produced by 3829 those steps do not occur, and the response codes are different. In 3830 particular, though the COPY and EXPUNGE response codes will be 3831 returned, response codes for a STORE MUST NOT be generated and the 3832 \Deleted flag MUST NOT be set for any message. 3834 Because a MOVE applies to a set of messages, it might fail partway 3835 through the set. Regardless of whether the command is successful in 3836 moving the entire set, each individual message SHOULD either be moved 3837 or unaffected. The server MUST leave each message in a state where 3838 it is in at least one of the source or target mailboxes (no message 3839 can be lost or orphaned). The server SHOULD NOT leave any message in 3840 both mailboxes (it would be bad for a partial failure to result in a 3841 bunch of duplicate messages). This is true even if the server 3842 returns a tagged NO response to the command. 3844 Because of the similarity of MOVE to COPY, extensions that affect 3845 COPY affect MOVE in the same way. Response codes such as TRYCREATE 3846 (see Section 7.1), as well as those defined by extensions, are sent 3847 as appropriate. 3849 Servers SHOULD send COPYUID in response to a UID MOVE (see 3850 Section 6.4.9) command. For additional information see Section 7.1. 3852 Servers are also advised to send the COPYUID response code in an 3853 untagged OK before sending EXPUNGE or moved responses. (Sending 3854 COPYUID in the tagged OK, as described in the UIDPLUS specification, 3855 means that clients first receive an EXPUNGE for a message and 3856 afterwards COPYUID for the same message. It can be unnecessarily 3857 difficult to process that sequence usefully.) 3859 An example: 3860 C: a UID MOVE 42:69 foo 3861 S: * OK [COPYUID 432432 42:69 1202:1229] 3862 S: * 22 EXPUNGE 3863 S: (more expunges) 3864 S: a OK Done 3866 Note that the server may send unrelated EXPUNGE responses as well, if 3867 any happen to have been expunged at the same time; this is normal 3868 IMAP operation. 3870 Note that moving a message to the currently selected mailbox (that 3871 is, where the source and target mailboxes are the same) is allowed 3872 when copying the message to the currently selected mailbox is 3873 allowed. 3875 The server may send EXPUNGE responses before the tagged response, so 3876 the client cannot safely send more commands with message sequence 3877 number arguments while the server is processing MOVE. 3879 MOVE and UID MOVE can be pipelined with other commands, but care has 3880 to be taken. Both commands modify sequence numbers and also allow 3881 unrelated EXPUNGE responses. The renumbering of other messages in 3882 the source mailbox following any EXPUNGE response can be surprising 3883 and makes it unsafe to pipeline any command that relies on message 3884 sequence numbers after a MOVE or UID MOVE. Similarly, MOVE cannot be 3885 pipelined with a command that might cause message renumbering. See 3886 Section 5.5, for more information about ambiguities as well as 3887 handling requirements for both clients and servers. 3889 6.4.9. UID Command 3891 Arguments: command name 3892 command arguments 3894 Responses: untagged responses: FETCH, ESEARCH, EXPUNGE 3896 Result: OK - UID command completed 3897 NO - UID command error 3898 BAD - command unknown or arguments invalid 3900 The UID command has three forms. In the first form, it takes as its 3901 arguments a COPY, MOVE, FETCH, or STORE command with arguments 3902 appropriate for the associated command. However, the numbers in the 3903 sequence set argument are unique identifiers instead of message 3904 sequence numbers. Sequence set ranges are permitted, but there is no 3905 guarantee that unique identifiers will be contiguous. 3907 A non-existent unique identifier is ignored without any error message 3908 generated. Thus, it is possible for a UID FETCH command to return an 3909 OK without any data or a UID COPY, UID MOVE or UID STORE to return an 3910 OK without performing any operations. 3912 In the second form, the UID command takes an EXPUNGE command with an 3913 extra parameter the specified a sequence set of UIDs to operate on. 3914 The UID EXPUNGE command permanently removes all messages that both 3915 have the \Deleted flag set and have a UID that is included in the 3916 specified sequence set from the currently selected mailbox. If a 3917 message either does not have the \Deleted flag set or has a UID that 3918 is not included in the specified sequence set, it is not affected. 3920 UID EXPUNGE is particularly useful for disconnected use clients. 3921 By using UID EXPUNGE instead of EXPUNGE when resynchronizing with 3922 the server, the client can ensure that it does not inadvertantly 3923 remove any messages that have been marked as \Deleted by other 3924 clients between the time that the client was last connected and 3925 the time the client resynchronizes. 3927 Example: C: A003 UID EXPUNGE 3000:3002 3928 S: * 3 EXPUNGE 3929 S: * 3 EXPUNGE 3930 S: * 3 EXPUNGE 3931 S: A003 OK UID EXPUNGE completed 3933 In the third form, the UID command takes a SEARCH command with SEARCH 3934 command arguments. The interpretation of the arguments is the same 3935 as with SEARCH; however, the numbers returned in a ESEARCH response 3936 for a UID SEARCH command are unique identifiers instead of message 3937 sequence numbers. Also, the corresponding ESEARCH response MUST 3938 include the UID indicator. For example, the command UID SEARCH 1:100 3939 UID 443:557 returns the unique identifiers corresponding to the 3940 intersection of two sequence sets, the message sequence number range 3941 1:100 and the UID range 443:557. 3943 Note: in the above example, the UID range 443:557 appears. The 3944 same comment about a non-existent unique identifier being ignored 3945 without any error message also applies here. Hence, even if 3946 neither UID 443 or 557 exist, this range is valid and would 3947 include an existing UID 495. 3949 Also note that a UID range of 559:* always includes the UID of the 3950 last message in the mailbox, even if 559 is higher than any 3951 assigned UID value. This is because the contents of a range are 3952 independent of the order of the range endpoints. Thus, any UID 3953 range with * as one of the endpoints indicates at least one 3954 message (the message with the highest numbered UID), unless the 3955 mailbox is empty. 3957 The number after the "*" in an untagged FETCH or EXPUNGE response is 3958 always a message sequence number, not a unique identifier, even for a 3959 UID command response. However, server implementations MUST 3960 implicitly include the UID message data item as part of any FETCH 3961 response caused by a UID command, regardless of whether a UID was 3962 specified as a message data item to the FETCH. 3964 Note: The rule about including the UID message data item as part of a 3965 FETCH response primarily applies to the UID FETCH and UID STORE 3966 commands, including a UID FETCH command that does not include UID as 3967 a message data item. Although it is unlikely that the other UID 3968 commands will cause an untagged FETCH, this rule applies to these 3969 commands as well. 3971 Example: C: A999 UID FETCH 4827313:4828442 FLAGS 3972 S: * 23 FETCH (FLAGS (\Seen) UID 4827313) 3973 S: * 24 FETCH (FLAGS (\Seen) UID 4827943) 3974 S: * 25 FETCH (FLAGS (\Seen) UID 4828442) 3975 S: A999 OK UID FETCH completed 3977 6.5. Client Commands - Experimental/Expansion 3979 6.5.1. X Command 3981 Arguments: implementation defined 3983 Responses: implementation defined 3984 Result: OK - command completed 3985 NO - failure 3986 BAD - command unknown or arguments invalid 3988 Any command prefixed with an X is an experimental command. Commands 3989 which are not part of this specification, a standard or standards- 3990 track revision of this specification, or an IESG-approved 3991 experimental protocol, MUST use the X prefix. 3993 Any added untagged responses issued by an experimental command MUST 3994 also be prefixed with an X. Server implementations MUST NOT send any 3995 such untagged responses, unless the client requested it by issuing 3996 the associated experimental command. 3998 Example: C: a441 CAPABILITY 3999 S: * CAPABILITY IMAP4rev2 XPIG-LATIN 4000 S: a441 OK CAPABILITY completed 4001 C: A442 XPIG-LATIN 4002 S: * XPIG-LATIN ow-nay eaking-spay ig-pay atin-lay 4003 S: A442 OK XPIG-LATIN ompleted-cay 4005 7. Server Responses 4007 Server responses are in three forms: status responses, server data, 4008 and command continuation request. The information contained in a 4009 server response, identified by "Contents:" in the response 4010 descriptions below, is described by function, not by syntax. The 4011 precise syntax of server responses is described in the Formal Syntax 4012 section. 4014 The client MUST be prepared to accept any response at all times. 4016 Status responses can be tagged or untagged. Tagged status responses 4017 indicate the completion result (OK, NO, or BAD status) of a client 4018 command, and have a tag matching the command. 4020 Some status responses, and all server data, are untagged. An 4021 untagged response is indicated by the token "*" instead of a tag. 4022 Untagged status responses indicate server greeting, or server status 4023 that does not indicate the completion of a command (for example, an 4024 impending system shutdown alert). For historical reasons, untagged 4025 server data responses are also called "unsolicited data", although 4026 strictly speaking, only unilateral server data is truly 4027 "unsolicited". 4029 Certain server data MUST be recorded by the client when it is 4030 received; this is noted in the description of that data. Such data 4031 conveys critical information which affects the interpretation of all 4032 subsequent commands and responses (e.g., updates reflecting the 4033 creation or destruction of messages). 4035 Other server data SHOULD be recorded for later reference; if the 4036 client does not need to record the data, or if recording the data has 4037 no obvious purpose (e.g., a SEARCH response when no SEARCH command is 4038 in progress), the data SHOULD be ignored. 4040 An example of unilateral untagged server data occurs when the IMAP 4041 connection is in the selected state. In the selected state, the 4042 server checks the mailbox for new messages as part of command 4043 execution. Normally, this is part of the execution of every command; 4044 hence, a NOOP command suffices to check for new messages. If new 4045 messages are found, the server sends untagged EXISTS response 4046 reflecting the new size of the mailbox. Server implementations that 4047 offer multiple simultaneous access to the same mailbox SHOULD also 4048 send appropriate unilateral untagged FETCH and EXPUNGE responses if 4049 another agent changes the state of any message flags or expunges any 4050 messages. 4052 Command continuation request responses use the token "+" instead of a 4053 tag. These responses are sent by the server to indicate acceptance 4054 of an incomplete client command and readiness for the remainder of 4055 the command. 4057 7.1. Server Responses - Status Responses 4059 Status responses are OK, NO, BAD, PREAUTH and BYE. OK, NO, and BAD 4060 can be tagged or untagged. PREAUTH and BYE are always untagged. 4062 Status responses MAY include an OPTIONAL "response code". A response 4063 code consists of data inside square brackets in the form of an atom, 4064 possibly followed by a space and arguments. The response code 4065 contains additional information or status codes for client software 4066 beyond the OK/NO/BAD condition, and are defined when there is a 4067 specific action that a client can take based upon the additional 4068 information. 4070 The currently defined response codes are: 4072 ALERT 4074 The human-readable text contains a special alert that MUST be 4075 presented to the user in a fashion that calls the user's 4076 attention to the message. 4078 ALREADYEXISTS 4079 The operation attempts to create something that already exists, 4080 such as when the CREATE or RENAME directories attempt to create 4081 a mailbox and there is already one of that name. 4083 C: o RENAME this that 4084 S: o NO [ALREADYEXISTS] Mailbox "that" already exists 4086 APPENDUID 4088 Followed by the UIDVALIDITY of the destination mailbox and the 4089 UID assigned to the appended message in the destination 4090 mailbox, indicates that the message has been appended to the 4091 destination mailbox with that UID. 4093 If the server also supports the [MULTIAPPEND] extension, and if 4094 multiple messages were appended in the APPEND command, then the 4095 second value is a UID set containing the UIDs assigned to the 4096 appended messages, in the order they were transmitted in the 4097 APPEND command. This UID set may not contain extraneous UIDs 4098 or the symbol "*". 4100 Note: the UID set form of the APPENDUID response code MUST 4101 NOT be used if only a single message was appended. In 4102 particular, a server MUST NOT send a range such as 123:123. 4103 This is because a client that does not support [MULTIAPPEND] 4104 expects only a single UID and not a UID set. 4106 UIDs are assigned in strictly ascending order in the mailbox 4107 (refer to Section 2.3.1.1); note that a range of 12:10 is 4108 exactly equivalent to 10:12 and refers to the sequence 4109 10,11,12. 4111 This response code is returned in a tagged OK response to the 4112 APPEND command. 4114 AUTHENTICATIONFAILED 4116 Authentication failed for some reason on which the server is 4117 unwilling to elaborate. Typically, this includes "unknown 4118 user" and "bad password". 4120 This is the same as not sending any response code, except that 4121 when a client sees AUTHENTICATIONFAILED, it knows that the 4122 problem wasn't, e.g., UNAVAILABLE, so there's no point in 4123 trying the same login/password again later. 4125 C: b LOGIN "fred" "foo" 4126 S: b NO [AUTHENTICATIONFAILED] Authentication failed 4128 AUTHORIZATIONFAILED 4130 Authentication succeeded in using the authentication identity, 4131 but the server cannot or will not allow the authentication 4132 identity to act as the requested authorization identity. This 4133 is only applicable when the authentication and authorization 4134 identities are different. 4136 C: c1 AUTHENTICATE PLAIN 4137 [...] 4138 S: c1 NO [AUTHORIZATIONFAILED] No such authorization-ID 4140 C: c2 AUTHENTICATE PLAIN 4141 [...] 4142 S: c2 NO [AUTHORIZATIONFAILED] Authenticator is not an admin 4144 BADCHARSET 4146 Optionally followed by a parenthesized list of charsets. A 4147 SEARCH failed because the given charset is not supported by 4148 this implementation. If the optional list of charsets is 4149 given, this lists the charsets that are supported by this 4150 implementation. 4152 CANNOT 4154 The operation violates some invariant of the server and can 4155 never succeed. 4157 C: l create "///////" 4158 S: l NO [CANNOT] Adjacent slashes are not supported 4160 CAPABILITY 4162 Followed by a list of capabilities. This can appear in the 4163 initial OK or PREAUTH response to transmit an initial 4164 capabilities list. It can also appear in tagged responses to 4165 LOGIN or AUTHENTICATE commands. This makes it unnecessary for 4166 a client to send a separate CAPABILITY command if it recognizes 4167 this response. 4169 CLIENTBUG 4170 The server has detected a client bug. This can accompany all 4171 of OK, NO, and BAD, depending on what the client bug is. 4173 C: k1 select "/archive/projects/experiment-iv" 4174 [...] 4175 S: k1 OK [READ-ONLY] Done 4176 C: k2 status "/archive/projects/experiment-iv" (messages) 4177 [...] 4178 S: k2 OK [CLIENTBUG] Done 4180 CLOSED 4182 The CLOSED response code has no parameters. A server return 4183 the CLOSED response code when the currently selected mailbox is 4184 closed implicitly using the SELECT/EXAMINE command on another 4185 mailbox. The CLOSED response code serves as a boundary between 4186 responses for the previously opened mailbox (which was closed) 4187 and the newly selected mailbox; all responses before the CLOSED 4188 response code relate to the mailbox that was closed, and all 4189 subsequent responses relate to the newly opened mailbox. 4191 There is no need to return the CLOSED response code on 4192 completion of the CLOSE or the UNSELECT command (or similar), 4193 whose purpose is to close the currently selected mailbox 4194 without opening a new one. 4196 The server can also return an unsolicited CLOSED response code 4197 when it wants to force the client to return to authenticated 4198 state. For example, the server can do that when the mailbox 4199 requires repairs or is deleted in another session. 4201 CONTACTADMIN 4203 The user should contact the system administrator or support 4204 desk. 4206 C: e login "fred" "foo" 4207 S: e OK [CONTACTADMIN] 4209 COPYUID 4211 Followed by the UIDVALIDITY of the destination mailbox, a UID 4212 set containing the UIDs of the message(s) in the source mailbox 4213 that were copied to the destination mailbox and containing the 4214 UIDs assigned to the copied message(s) in the destination 4215 mailbox, indicates that the message(s) have been copied to the 4216 destination mailbox with the stated UID(s). 4218 The source UID set is in the order the message(s) were copied; 4219 the destination UID set corresponds to the source UID set and 4220 is in the same order. Neither of the UID sets may contain 4221 extraneous UIDs or the symbol "*". 4223 UIDs are assigned in strictly ascending order in the mailbox 4224 (refer to Section 2.3.1.1); note that a range of 12:10 is 4225 exactly equivalent to 10:12 and refers to the sequence 4226 10,11,12. 4228 This response code is returned in a tagged OK response to the 4229 COPY command. 4231 CORRUPTION 4233 The server discovered that some relevant data (e.g., the 4234 mailbox) are corrupt. This response code does not include any 4235 information about what's corrupt, but the server can write that 4236 to its logfiles. 4238 C: i select "/archive/projects/experiment-iv" 4239 S: i NO [CORRUPTION] Cannot open mailbox 4241 EXPIRED 4243 Either authentication succeeded or the server no longer had the 4244 necessary data; either way, access is no longer permitted using 4245 that passphrase. The client or user should get a new 4246 passphrase. 4248 C: d login "fred" "foo" 4249 S: d NO [EXPIRED] That password isn't valid any more 4251 EXPUNGEISSUED 4253 Someone else has issued an EXPUNGE for the same mailbox. The 4254 client may want to issue NOOP soon. [IMAP-MULTIACCESS] 4255 discusses this subject in depth. 4257 C: h search from fred@example.com 4258 S: * ESEARCH (TAG "h") ALL 1:3,5,8,13,21,42 4259 S: h OK [EXPUNGEISSUED] Search completed 4261 INUSE 4263 An operation has not been carried out because it involves 4264 sawing off a branch someone else is sitting on. Someone else 4265 may be holding an exclusive lock needed for this operation, or 4266 the operation may involve deleting a resource someone else is 4267 using, typically a mailbox. 4269 The operation may succeed if the client tries again later. 4271 C: g delete "/archive/projects/experiment-iv" 4272 S: g NO [INUSE] Mailbox in use 4274 LIMIT 4276 The operation ran up against an implementation limit of some 4277 kind, such as the number of flags on a single message or the 4278 number of flags used in a mailbox. 4280 C: m STORE 42 FLAGS f1 f2 f3 f4 f5 ... f250 4281 S: m NO [LIMIT] At most 32 flags in one mailbox supported 4283 NONEXISTENT 4285 The operation attempts to delete something that does not exist. 4286 Similar to ALREADYEXISTS. 4288 C: p RENAME this that 4289 S: p NO [NONEXISTENT] No such mailbox 4291 NOPERM 4293 The access control system (e.g., Access Control List (ACL), see 4294 [RFC4314] does not permit this user to carry out an operation, 4295 such as selecting or creating a mailbox. 4297 C: f select "/archive/projects/experiment-iv" 4298 S: f NO [NOPERM] Access denied 4300 OVERQUOTA 4302 The user would be over quota after the operation. (The user 4303 may or may not be over quota already.) 4305 Note that if the server sends OVERQUOTA but doesn't support the 4306 IMAP QUOTA extension defined by [RFC2087], then there is a 4307 quota, but the client cannot find out what the quota is. 4309 C: n1 uid copy 1:* oldmail 4310 S: n1 NO [OVERQUOTA] Sorry 4312 C: n2 uid copy 1:* oldmail 4313 S: n2 OK [OVERQUOTA] You are now over your soft quota 4315 PARSE 4317 The human-readable text represents an error in parsing the 4318 [RFC-5322] header or [MIME-IMB] headers of a message in the 4319 mailbox. 4321 PERMANENTFLAGS 4323 Followed by a parenthesized list of flags, indicates which of 4324 the known flags the client can change permanently. Any flags 4325 that are in the FLAGS untagged response, but not the 4326 PERMANENTFLAGS list, can not be set permanently. The 4327 PERMANENTFLAGS list can also include the special flag \*, which 4328 indicates that it is possible to create new keywords by 4329 attempting to store those keywords in the mailbox. If the 4330 client attempts to STORE a flag that is not in the 4331 PERMANENTFLAGS list, the server will either ignore the change 4332 or store the state change for the remainder of the current 4333 session only. 4335 There is no need for a server that included the special flag \* 4336 to return a new PERMANENTFLAGS response code when a new keyword 4337 was successfully set on a message upon client request. However 4338 if the server has a limit on the number of different keywords 4339 that can be stored in a mailbox and that limit is reached, the 4340 server MUST send a new PERMANENTFLAGS response code without the 4341 special flag \*. 4343 PRIVACYREQUIRED 4345 The operation is not permitted due to a lack of privacy. If 4346 Transport Layer Security (TLS) is not in use, the client could 4347 try STARTTLS (see Section 6.2.1) and then repeat the operation. 4349 C: d login "fred" "foo" 4350 S: d NO [PRIVACYREQUIRED] Connection offers no privacy 4352 C: d select inbox 4353 S: d NO [PRIVACYREQUIRED] Connection offers no privacy 4355 READ-ONLY 4357 The mailbox is selected read-only, or its access while selected 4358 has changed from read-write to read-only. 4360 READ-WRITE 4362 The mailbox is selected read-write, or its access while 4363 selected has changed from read-only to read-write. 4365 SERVERBUG 4367 The server encountered a bug in itself or violated one of its 4368 own invariants. 4370 C: j select "/archive/projects/experiment-iv" 4371 S: j NO [SERVERBUG] This should not happen 4373 TRYCREATE 4375 An APPEND or COPY attempt is failing because the target mailbox 4376 does not exist (as opposed to some other reason). This is a 4377 hint to the client that the operation can succeed if the 4378 mailbox is first created by the CREATE command. 4380 UIDNEXT 4382 Followed by a decimal number, indicates the next unique 4383 identifier value. Refer to Section 2.3.1.1 for more 4384 information. 4386 UIDNOTSTICKY 4388 The selected mailbox is supported by a mail store that does not 4389 support persistent UIDs; that is, UIDVALIDITY will be different 4390 each time the mailbox is selected. Consequently, APPEND or 4391 COPY to this mailbox will not return an APPENDUID or COPYUID 4392 response code. 4394 This response code is returned in an untagged NO response to 4395 the SELECT command. 4397 Note: servers SHOULD NOT have any UIDNOTSTICKY mail stores. 4398 This facility exists to support legacy mail stores in which 4399 it is technically infeasible to support persistent UIDs. 4400 This should be avoided when designing new mail stores. 4402 UIDVALIDITY 4404 Followed by a decimal number, indicates the unique identifier 4405 validity value. Refer to Section 2.3.1.1 for more information. 4407 UNAVAILABLE 4409 Temporary failure because a subsystem is down. For example, an 4410 IMAP server that uses a Lightweight Directory Access Protocol 4411 (LDAP) or Radius server for authentication might use this 4412 response code when the LDAP/Radius server is down. 4414 C: a LOGIN "fred" "foo" 4415 S: a NO [UNAVAILABLE] User's backend down for maintenance 4417 UNKNOWN-CTE 4419 The server does not know how to decode the section's Content- 4420 Transfer-Encoding. 4422 Additional response codes defined by particular client or server 4423 implementations SHOULD be prefixed with an "X" until they are added 4424 to a revision of this protocol. Client implementations SHOULD ignore 4425 response codes that they do not recognize. 4427 7.1.1. OK Response 4429 Contents: OPTIONAL response code 4430 human-readable text 4432 The OK response indicates an information message from the server. 4433 When tagged, it indicates successful completion of the associated 4434 command. The human-readable text MAY be presented to the user as an 4435 information message. The untagged form indicates an information-only 4436 message; the nature of the information MAY be indicated by a response 4437 code. 4439 The untagged form is also used as one of three possible greetings at 4440 connection startup. It indicates that the connection is not yet 4441 authenticated and that a LOGIN or an AUTHENTICATE command is needed. 4443 Example: S: * OK IMAP4rev2 server ready 4444 C: A001 LOGIN fred blurdybloop 4445 S: * OK [ALERT] System shutdown in 10 minutes 4446 S: A001 OK LOGIN Completed 4448 7.1.2. NO Response 4450 Contents: OPTIONAL response code 4451 human-readable text 4453 The NO response indicates an operational error message from the 4454 server. When tagged, it indicates unsuccessful completion of the 4455 associated command. The untagged form indicates a warning; the 4456 command can still complete successfully. The human-readable text 4457 describes the condition. 4459 Example: C: A222 COPY 1:2 owatagusiam 4460 S: * NO Disk is 98% full, please delete unnecessary data 4461 S: A222 OK COPY completed 4462 C: A223 COPY 3:200 blurdybloop 4463 S: * NO Disk is 98% full, please delete unnecessary data 4464 S: * NO Disk is 99% full, please delete unnecessary data 4465 S: A223 NO COPY failed: disk is full 4467 7.1.3. BAD Response 4469 Contents: OPTIONAL response code 4470 human-readable text 4472 The BAD response indicates an error message from the server. When 4473 tagged, it reports a protocol-level error in the client's command; 4474 the tag indicates the command that caused the error. The untagged 4475 form indicates a protocol-level error for which the associated 4476 command can not be determined; it can also indicate an internal 4477 server failure. The human-readable text describes the condition. 4479 Example: C: ...very long command line... 4480 S: * BAD Command line too long 4481 C: ...empty line... 4482 S: * BAD Empty command line 4483 C: A443 EXPUNGE 4484 S: * BAD Disk crash, attempting salvage to a new disk! 4485 S: * OK Salvage successful, no data lost 4486 S: A443 OK Expunge completed 4488 7.1.4. PREAUTH Response 4490 Contents: OPTIONAL response code 4491 human-readable text 4493 The PREAUTH response is always untagged, and is one of three possible 4494 greetings at connection startup. It indicates that the connection 4495 has already been authenticated by external means; thus no LOGIN/ 4496 AUTHENTICATE command is needed. 4498 Example: S: * PREAUTH IMAP4rev2 server logged in as Smith 4500 7.1.5. BYE Response 4502 Contents: OPTIONAL response code 4503 human-readable text 4505 The BYE response is always untagged, and indicates that the server is 4506 about to close the connection. The human-readable text MAY be 4507 displayed to the user in a status report by the client. The BYE 4508 response is sent under one of four conditions: 4510 1. as part of a normal logout sequence. The server will close the 4511 connection after sending the tagged OK response to the LOGOUT 4512 command. 4514 2. as a panic shutdown announcement. The server closes the 4515 connection immediately. 4517 3. as an announcement of an inactivity autologout. The server 4518 closes the connection immediately. 4520 4. as one of three possible greetings at connection startup, 4521 indicating that the server is not willing to accept a connection 4522 from this client. The server closes the connection immediately. 4524 The difference between a BYE that occurs as part of a normal LOGOUT 4525 sequence (the first case) and a BYE that occurs because of a failure 4526 (the other three cases) is that the connection closes immediately in 4527 the failure case. In all cases the client SHOULD continue to read 4528 response data from the server until the connection is closed; this 4529 will ensure that any pending untagged or completion responses are 4530 read and processed. 4532 Example: S: * BYE Autologout; idle for too long 4534 7.2. Server Responses - Server and Mailbox Status 4536 These responses are always untagged. This is how server and mailbox 4537 status data are transmitted from the server to the client. Many of 4538 these responses typically result from a command with the same name. 4540 7.2.1. The ENABLED Response 4542 Contents: capability listing 4544 The ENABLED response occurs as a result of an ENABLE command. The 4545 capability listing contains a space-separated listing of capability 4546 names that the server supports and that were successfully enabled. 4548 The ENABLED response may contain no capabilities, which means that no 4549 extensions listed by the client were successfully enabled. 4551 7.2.2. CAPABILITY Response 4553 Contents: capability listing 4555 The CAPABILITY response occurs as a result of a CAPABILITY command. 4556 The capability listing contains a space-separated listing of 4557 capability names that the server supports. The capability listing 4558 MUST include the atom "IMAP4rev2". 4560 In addition, client and server implementations MUST implement the 4561 STARTTLS, LOGINDISABLED, and AUTH=PLAIN (described in [PLAIN]) 4562 capabilities. See the Security Considerations section for important 4563 information. 4565 A capability name which begins with "AUTH=" indicates that the server 4566 supports that particular authentication mechanism. 4568 The LOGINDISABLED capability indicates that the LOGIN command is 4569 disabled, and that the server will respond with a tagged NO response 4570 to any attempt to use the LOGIN command even if the user name and 4571 password are valid. An IMAP client MUST NOT issue the LOGIN command 4572 if the server advertises the LOGINDISABLED capability. 4574 Other capability names indicate that the server supports an 4575 extension, revision, or amendment to the IMAP4rev2 protocol. Server 4576 responses MUST conform to this document until the client issues a 4577 command that uses the associated capability. 4579 Capability names MUST either begin with "X" or be standard or 4580 standards-track IMAP4rev2 extensions, revisions, or amendments 4581 registered with IANA. A server MUST NOT offer unregistered or non- 4582 standard capability names, unless such names are prefixed with an 4583 "X". 4585 Client implementations SHOULD NOT require any capability name other 4586 than "IMAP4rev2", and MUST ignore any unknown capability names. 4588 A server MAY send capabilities automatically, by using the CAPABILITY 4589 response code in the initial PREAUTH or OK responses, and by sending 4590 an updated CAPABILITY response code in the tagged OK response as part 4591 of a successful authentication. It is unnecessary for a client to 4592 send a separate CAPABILITY command if it recognizes these automatic 4593 capabilities. 4595 Example: S: * CAPABILITY IMAP4rev2 STARTTLS AUTH=GSSAPI XPIG-LATIN 4597 7.2.3. LIST Response 4599 Contents: name attributes 4600 hierarchy delimiter 4601 name 4603 The LIST response occurs as a result of a LIST command. It returns a 4604 single name that matches the LIST specification. There can be 4605 multiple LIST responses for a single LIST command. 4607 The following base name attributes are defined: 4609 \NonExistent The "\NonExistent" attribute indicates that a mailbox 4610 name does not refer to an existing mailbox. Note that this 4611 attribute is not meaningful by itself, as mailbox names that match 4612 the canonical LIST pattern but don't exist must not be returned 4613 unless one of the two conditions listed below is also satisfied: 4615 1. The mailbox name also satisfies the selection criteria (for 4616 example, it is subscribed and the "SUBSCRIBED" selection 4617 option has been specified). 4619 2. "RECURSIVEMATCH" has been specified, and the mailbox name has 4620 at least one descendant mailbox name that does not match the 4621 LIST pattern and does match the selection criteria. 4623 In practice, this means that the "\NonExistent" attribute is 4624 usually returned with one or more of "\Subscribed", "\Remote", 4625 "\HasChildren", or the CHILDINFO extended data item. 4627 The "\NonExistent" attribute implies "\NoSelect". 4629 \Noinferiors It is not possible for any child levels of hierarchy to 4630 exist under this name; no child levels exist now and none can be 4631 created in the future. 4633 \Noselect It is not possible to use this name as a selectable 4634 mailbox. 4636 \HasChildren The presence of this attribute indicates that the 4637 mailbox has child mailboxes. A server SHOULD NOT set this 4638 attribute if there are child mailboxes and the user does not have 4639 permission to access any of them. In this case, \HasNoChildren 4640 SHOULD be used. In many cases, however, a server may not be able 4641 to efficiently compute whether a user has access to any child 4642 mailbox. Note that even though the \HasChildren attribute for a 4643 mailbox must be correct at the time of processing of the mailbox, 4644 a client must be prepared to deal with a situation when a mailbox 4645 is marked with the \HasChildren attribute, but no child mailbox 4646 appears in the response to the LIST command. This might happen, 4647 for example, due to children mailboxes being deleted or made 4648 inaccessible to the user (using access control) by another client 4649 before the server is able to list them. 4651 \HasNoChildren The presence of this attribute indicates that the 4652 mailbox has NO child mailboxes that are accessible to the 4653 currently authenticated user. 4655 \Marked The mailbox has been marked "interesting" by the server; the 4656 mailbox probably contains messages that have been added since the 4657 last time the mailbox was selected. 4659 \Unmarked The mailbox does not contain any additional messages since 4660 the last time the mailbox was selected. 4662 \Subscribed The mailbox name was subscribed to using the SUBSCRIBE 4663 command. 4665 \Remote The mailbox is a remote mailbox. 4667 It is an error for the server to return both a \HasChildren and a 4668 \HasNoChildren attribute in the same LIST response. 4670 Note: the \HasNoChildren attribute should not be confused with the 4671 \NoInferiors attribute, which indicates that no child mailboxes 4672 exist now and none can be created in the future. 4674 If it is not feasible for the server to determine whether or not the 4675 mailbox is "interesting", the server SHOULD NOT send either \Marked 4676 or \Unmarked. The server MUST NOT send more than one of \Marked, 4677 \Unmarked, and \Noselect for a single mailbox, and MAY send none of 4678 these. 4680 In addition to the base name attributes defined above, an IMAP server 4681 MAY also include any or all of the following attributes that denote 4682 "role" (or "special-use") of a mailbox. These attributes are 4683 included along with base attributes defined above. A given mailbox 4684 may have none, one, or more than one of these attributes. In some 4685 cases, a special use is advice to a client about what to put in that 4686 mailbox. In other cases, it's advice to a client about what to 4687 expect to find there. 4689 \All This mailbox presents all messages in the user's message store. 4690 Implementations MAY omit some messages, such as, perhaps, those in 4691 \Trash and \Junk. When this special use is supported, it is 4692 almost certain to represent a virtual mailbox. 4694 \Archive This mailbox is used to archive messages. The meaning of 4695 an "archival" mailbox is server-dependent; typically, it will be 4696 used to get messages out of the inbox, or otherwise keep them out 4697 of the user's way, while still making them accessible. 4699 \Drafts This mailbox is used to hold draft messages -- typically, 4700 messages that are being composed but have not yet been sent. In 4701 some server implementations, this might be a virtual mailbox, 4702 containing messages from other mailboxes that are marked with the 4703 "\Draft" message flag. Alternatively, this might just be advice 4704 that a client put drafts here. 4706 \Flagged This mailbox presents all messages marked in some way as 4707 "important". When this special use is supported, it is likely to 4708 represent a virtual mailbox collecting messages (from other 4709 mailboxes) that are marked with the "\Flagged" message flag. 4711 \Junk This mailbox is where messages deemed to be junk mail are 4712 held. Some server implementations might put messages here 4713 automatically. Alternatively, this might just be advice to a 4714 client-side spam filter. 4716 \Sent This mailbox is used to hold copies of messages that have been 4717 sent. Some server implementations might put messages here 4718 automatically. Alternatively, this might just be advice that a 4719 client save sent messages here. 4721 \Trash This mailbox is used to hold messages that have been deleted 4722 or marked for deletion. In some server implementations, this 4723 might be a virtual mailbox, containing messages from other 4724 mailboxes that are marked with the "\Deleted" message flag. 4725 Alternatively, this might just be advice that a client that 4726 chooses not to use the IMAP "\Deleted" model should use this as 4727 its trash location. In server implementations that strictly 4728 expect the IMAP "\Deleted" model, this special use is likely not 4729 to be supported. 4731 All of special-use attributes are OPTIONAL, and any given server or 4732 message store may support any combination of the attributes, or none 4733 at all. In most cases, there will likely be at most one mailbox with 4734 a given attribute for a given user, but in some server or message 4735 store implementations it might be possible for multiple mailboxes to 4736 have the same special-use attribute. 4738 Special-use attributes are likely to be user-specific. User Adam 4739 might share his \Sent mailbox with user Barb, but that mailbox is 4740 unlikely to also serve as Barb's \Sent mailbox. 4742 The hierarchy delimiter is a character used to delimit levels of 4743 hierarchy in a mailbox name. A client can use it to create child 4744 mailboxes, and to search higher or lower levels of naming hierarchy. 4745 All children of a top-level hierarchy node MUST use the same 4746 separator character. A NIL hierarchy delimiter means that no 4747 hierarchy exists; the name is a "flat" name. 4749 The name represents an unambiguous left-to-right hierarchy, and MUST 4750 be valid for use as a reference in LIST command. Unless \Noselect or 4751 \NonExistent is indicated, the name MUST also be valid as an argument 4752 for commands, such as SELECT, that accept mailbox names. 4754 Example: S: * LIST (\Noselect) "/" ~/Mail/foo 4756 7.2.4. NAMESPACE Response 4758 Contents: the prefix and hierarchy delimiter to the server's 4759 Personal Namespace(s), Other Users' Namespace(s), and 4760 Shared Namespace(s) 4762 The NAMESPACE response occurs as a result of a NAMESPACE command. It 4763 contains the prefix and hierarchy delimiter to the server's Personal 4764 Namespace(s), Other Users' Namespace(s), and Shared Namespace(s) that 4765 the server wishes to expose. The response will contain a NIL for any 4766 namespace class that is not available. Namespace-Response-Extensions 4767 ABNF non terminal is defined for extensibility and MAY be included in 4768 the response. 4770 Example: S: * NAMESPACE (("" "/")) (("~" "/")) NIL 4772 7.2.5. STATUS Response 4774 Contents: name 4775 status parenthesized list 4777 The STATUS response occurs as a result of an STATUS command. It 4778 returns the mailbox name that matches the STATUS specification and 4779 the requested mailbox status information. 4781 Example: S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) 4783 7.2.6. ESEARCH Response 4785 Contents: one or more search-return-data pairs 4787 The ESEARCH response occurs as a result of a SEARCH or UID SEARCH 4788 command. 4790 The ESEARCH response starts with an optional search correlator. If 4791 it is missing, then the response was not caused by a particular IMAP 4792 command, whereas if it is present, it contains the tag of the command 4793 that caused the response to be returned. 4795 The search correlator is followed by an optional UID indicator. If 4796 this indicator is present, all data in the ESEARCH response refers to 4797 UIDs, otherwise all returned data refers to message numbers. 4799 The rest of the ESEARCH response contains one or more search data 4800 pairs. Each pair starts with unique return item name, followed by a 4801 space and the corresponding data. Search data pairs may be returned 4802 in any order. Unless specified otherwise by an extension, any return 4803 item name SHOULD appear only once in an ESEARCH response. 4805 [[TBD: describe the most common search data pairs returned.]] 4807 Example: S: * ESEARCH UID COUNT 5 ALL 4:19,21,28 4809 Example: S: * ESEARCH (TAG "a567") UID COUNT 5 ALL 4:19,21,28 4811 Example: S: * ESEARCH COUNT 5 ALL 1:17,21 4813 7.2.7. FLAGS Response 4815 Contents: flag parenthesized list 4817 The FLAGS response occurs as a result of a SELECT or EXAMINE command. 4818 The flag parenthesized list identifies the flags (at a minimum, the 4819 system-defined flags) that are applicable for this mailbox. Flags 4820 other than the system flags can also exist, depending on server 4821 implementation. 4823 The update from the FLAGS response MUST be recorded by the client. 4825 Example: S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 4827 7.3. Server Responses - Mailbox Size 4829 These responses are always untagged. This is how changes in the size 4830 of the mailbox are transmitted from the server to the client. 4831 Immediately following the "*" token is a number that represents a 4832 message count. 4834 7.3.1. EXISTS Response 4836 Contents: none 4838 The EXISTS response reports the number of messages in the mailbox. 4839 This response occurs as a result of a SELECT or EXAMINE command, and 4840 if the size of the mailbox changes (e.g., new messages). 4842 The update from the EXISTS response MUST be recorded by the client. 4844 Example: S: * 23 EXISTS 4846 7.4. Server Responses - Message Status 4848 These responses are always untagged. This is how message data are 4849 transmitted from the server to the client, often as a result of a 4850 command with the same name. Immediately following the "*" token is a 4851 number that represents a message sequence number. 4853 7.4.1. EXPUNGE Response 4855 Contents: none 4857 The EXPUNGE response reports that the specified message sequence 4858 number has been permanently removed from the mailbox. The message 4859 sequence number for each successive message in the mailbox is 4860 immediately decremented by 1, and this decrement is reflected in 4861 message sequence numbers in subsequent responses (including other 4862 untagged EXPUNGE responses). 4864 The EXPUNGE response also decrements the number of messages in the 4865 mailbox; it is not necessary to send an EXISTS response with the new 4866 value. 4868 As a result of the immediate decrement rule, message sequence numbers 4869 that appear in a set of successive EXPUNGE responses depend upon 4870 whether the messages are removed starting from lower numbers to 4871 higher numbers, or from higher numbers to lower numbers. For 4872 example, if the last 5 messages in a 9-message mailbox are expunged, 4873 a "lower to higher" server will send five untagged EXPUNGE responses 4874 for message sequence number 5, whereas a "higher to lower server" 4875 will send successive untagged EXPUNGE responses for message sequence 4876 numbers 9, 8, 7, 6, and 5. 4878 An EXPUNGE response MUST NOT be sent when no command is in progress, 4879 nor while responding to a FETCH, STORE, or SEARCH command. This rule 4880 is necessary to prevent a loss of synchronization of message sequence 4881 numbers between client and server. A command is not "in progress" 4882 until the complete command has been received; in particular, a 4883 command is not "in progress" during the negotiation of command 4884 continuation. 4886 Note: UID FETCH, UID STORE, and UID SEARCH are different commands 4887 from FETCH, STORE, and SEARCH. An EXPUNGE response MAY be sent 4888 during a UID command. 4890 The update from the EXPUNGE response MUST be recorded by the client. 4892 Example: S: * 44 EXPUNGE 4894 7.4.2. FETCH Response 4896 Contents: message data 4898 The FETCH response returns data about a message to the client. The 4899 data are pairs of data item names and their values in parentheses. 4900 This response occurs as the result of a FETCH or STORE command, as 4901 well as by unilateral server decision (e.g., flag updates). 4903 The current data items are: 4905 BINARY[]<> 4907 An or expressing the content of the 4908 specified section after removing any Content-Transfer-Encoding- 4909 related encoding. If is present it refers to the 4910 offset within the DECODED section data. 4912 If the domain of the decoded data is "8bit" and the data does 4913 not contain the NUL octet, the server SHOULD return the data in 4914 a instead of a ; this allows the client to 4915 determine if the "8bit" data contains the NUL octet without 4916 having to explicitly scan the data stream for for NULs. 4918 Messaging clients and servers have been notoriously lax in 4919 their adherence to the Internet CRLF convention for terminating 4920 lines of textual data (text/* media types) in Internet 4921 protocols. When sending data in BINARY[...] FETCH data item, 4922 servers MUST ensure that textual line-oriented sections are 4923 always transmitted using the IMAP4 CRLF line termination 4924 syntax, regardless of the underlying storage representation of 4925 the data on the server. 4927 If the server does not know how to decode the section's 4928 Content-Transfer-Encoding, it MUST fail the request and issue a 4929 "NO" response that contains the "UNKNOWN-CTE" response code. 4931 BINARY.SIZE[] 4933 The size of the section after removing any Content-Transfer- 4934 Encoding-related encoding. The value returned MUST match the 4935 size of the or that will be returned by 4936 the corresponding FETCH BINARY request. 4938 If the server does not know how to decode the section's 4939 Content-Transfer-Encoding, it MUST fail the request and issue a 4940 "NO" response that contains the "UNKNOWN-CTE" response code. 4942 BODY A form of BODYSTRUCTURE without extension data. 4944 BODY[
]<> 4946 A string expressing the body contents of the specified section. 4947 The string SHOULD be interpreted by the client according to the 4948 content transfer encoding, body type, and subtype. 4950 If the origin octet is specified, this string is a substring of 4951 the entire body contents, starting at that origin octet. This 4952 means that BODY[]<0> MAY be truncated, but BODY[] is NEVER 4953 truncated. 4955 Note: The origin octet facility MUST NOT be used by a server 4956 in a FETCH response unless the client specifically requested 4957 it by means of a FETCH of a BODY[
]<> data 4958 item. 4960 8-bit textual data is permitted if a [CHARSET] identifier is 4961 part of the body parameter parenthesized list for this section. 4962 Note that headers (part specifiers HEADER or MIME, or the 4963 header portion of a MESSAGE/RFC822 or MESSAGE/GLOBAL part), MAY 4964 be in UTF-8. Note also that the [RFC-5322] delimiting blank 4965 line between the header and the body is not affected by header 4966 line subsetting; the blank line is always included as part of 4967 header data, except in the case of a message which has no body 4968 and no blank line. 4970 Non-textual data such as binary data MUST be transfer encoded 4971 into a textual form, such as BASE64, prior to being sent to the 4972 client. To derive the original binary data, the client MUST 4973 decode the transfer encoded string. 4975 BODYSTRUCTURE 4977 A parenthesized list that describes the [MIME-IMB] body 4978 structure of a message. This is computed by the server by 4979 parsing the [MIME-IMB] header fields, defaulting various fields 4980 as necessary. 4982 For example, a simple text message of 48 lines and 2279 octets 4983 can have a body structure of: ("TEXT" "PLAIN" ("CHARSET" "US- 4984 ASCII") NIL NIL "7BIT" 2279 48) 4986 Multiple parts are indicated by parenthesis nesting. Instead 4987 of a body type as the first element of the parenthesized list, 4988 there is a sequence of one or more nested body structures. The 4989 second element of the parenthesized list is the multipart 4990 subtype (mixed, digest, parallel, alternative, etc.). 4992 For example, a two part message consisting of a text and a 4993 BASE64-encoded text attachment can have a body structure of: 4994 (("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 1152 4995 23)("TEXT" "PLAIN" ("CHARSET" "US-ASCII" "NAME" "cc.diff") 4996 "<960723163407.20117h@cac.washington.edu>" "Compiler diff" 4997 "BASE64" 4554 73) "MIXED") 4999 Extension data follows the multipart subtype. Extension data 5000 is never returned with the BODY fetch, but can be returned with 5001 a BODYSTRUCTURE fetch. Extension data, if present, MUST be in 5002 the defined order. The extension data of a multipart body part 5003 are in the following order: 5005 body parameter parenthesized list A parenthesized list of 5006 attribute/value pairs [e.g., ("foo" "bar" "baz" "rag") where 5007 "bar" is the value of "foo", and "rag" is the value of 5008 "baz"] as defined in [MIME-IMB]. 5010 body parameter parenthesized list Servers SHOULD decode 5011 parameter value continuations as described in [RFC2231], for 5012 example, if the message contains parameters "foo*0*" and 5013 "foo*1*", the server should RFC2231-decode them, concatenate 5014 and return the resulting value as "foo*". 5016 body disposition A parenthesized list, consisting of a 5017 disposition type string, followed by a parenthesized list of 5018 disposition attribute/value pairs as defined in 5019 [DISPOSITION]. Servers SHOULD decode parameter value 5020 continuations as described in [RFC2231]. 5022 body language A string or parenthesized list giving the body 5023 language value as defined in [LANGUAGE-TAGS]. 5025 body location A string giving the body content URI as defined 5026 in [LOCATION]. 5028 Any following extension data are not yet defined in this 5029 version of the protocol. Such extension data can consist of 5030 zero or more NILs, strings, numbers, or potentially nested 5031 parenthesized lists of such data. Client implementations that 5032 do a BODYSTRUCTURE fetch MUST be prepared to accept such 5033 extension data. Server implementations MUST NOT send such 5034 extension data until it has been defined by a revision of this 5035 protocol. 5037 The basic fields of a non-multipart body part are in the 5038 following order: 5040 body type A string giving the content media type name as 5041 defined in [MIME-IMB]. 5043 body subtype A string giving the content subtype name as 5044 defined in [MIME-IMB]. 5046 body parameter parenthesized list A parenthesized list of 5047 attribute/value pairs [e.g., ("foo" "bar" "baz" "rag") where 5048 "bar" is the value of "foo" and "rag" is the value of "baz"] 5049 as defined in [MIME-IMB]. 5051 body id A string giving the Content-ID header field value as 5052 defined in Section 7 of [MIME-IMB]. 5054 body description A string giving the Content-Description 5055 header field value as defined in Section 8 of [MIME-IMB]. 5057 body encoding A string giving the content transfer encoding as 5058 defined in Section 6 of [MIME-IMB]. 5060 body size A number giving the size of the body in octets. 5061 Note that this size is the size in its transfer encoding and 5062 not the resulting size after any decoding. 5064 A body type of type MESSAGE and subtype RFC822 contains, 5065 immediately after the basic fields, the envelope structure, 5066 body structure, and size in text lines of the encapsulated 5067 message. 5069 A body type of type TEXT contains, immediately after the basic 5070 fields, the size of the body in text lines. Note that this 5071 size is the size in its content transfer encoding and not the 5072 resulting size after any decoding. 5074 Extension data follows the basic fields and the type-specific 5075 fields listed above. Extension data is never returned with the 5076 BODY fetch, but can be returned with a BODYSTRUCTURE fetch. 5077 Extension data, if present, MUST be in the defined order. 5079 The extension data of a non-multipart body part are in the 5080 following order: 5082 body MD5 A string giving the body MD5 value as defined in 5083 [MD5]. 5085 body disposition A parenthesized list with the same content 5086 and function as the body disposition for a multipart body 5087 part. 5089 body language A string or parenthesized list giving the body 5090 language value as defined in [LANGUAGE-TAGS]. 5092 body location A string giving the body content URI as defined 5093 in [LOCATION]. 5095 Any following extension data are not yet defined in this 5096 version of the protocol, and would be as described above under 5097 multipart extension data. 5099 ENVELOPE 5101 A parenthesized list that describes the envelope structure of a 5102 message. This is computed by the server by parsing the 5103 [RFC-5322] header into the component parts, defaulting various 5104 fields as necessary. 5106 The fields of the envelope structure are in the following 5107 order: date, subject, from, sender, reply-to, to, cc, bcc, in- 5108 reply-to, and message-id. The date, subject, in-reply-to, and 5109 message-id fields are strings. The from, sender, reply-to, to, 5110 cc, and bcc fields are parenthesized lists of address 5111 structures. 5113 An address structure is a parenthesized list that describes an 5114 electronic mail address. The fields of an address structure 5115 are in the following order: personal name, [SMTP] at-domain- 5116 list (source route), mailbox name, and host name. 5118 [RFC-5322] group syntax is indicated by a special form of 5119 address structure in which the host name field is NIL. If the 5120 mailbox name field is also NIL, this is an end of group marker 5121 (semi-colon in RFC 822 syntax). If the mailbox name field is 5122 non-NIL, this is a start of group marker, and the mailbox name 5123 field holds the group name phrase. 5125 If the Date, Subject, In-Reply-To, and Message-ID header lines 5126 are absent in the [RFC-5322] header, the corresponding member 5127 of the envelope is NIL; if these header lines are present but 5128 empty the corresponding member of the envelope is the empty 5129 string. 5131 Note: some servers may return a NIL envelope member in the 5132 "present but empty" case. Clients SHOULD treat NIL and 5133 empty string as identical. 5135 Note: [RFC-5322] requires that all messages have a valid 5136 Date header. Therefore, the date member in the envelope can 5137 not be NIL or the empty string. 5139 Note: [RFC-5322] requires that the In-Reply-To and Message- 5140 ID headers, if present, have non-empty content. Therefore, 5141 the in-reply-to and message-id members in the envelope can 5142 not be the empty string. 5144 If the From, To, Cc, and Bcc header lines are absent in the 5145 [RFC-5322] header, or are present but empty, the corresponding 5146 member of the envelope is NIL. 5148 If the Sender or Reply-To lines are absent in the [RFC-5322] 5149 header, or are present but empty, the server sets the 5150 corresponding member of the envelope to be the same value as 5151 the from member (the client is not expected to know to do 5152 this). 5154 Note: [RFC-5322] requires that all messages have a valid 5155 From header. Therefore, the from, sender, and reply-to 5156 members in the envelope can not be NIL. 5158 FLAGS A parenthesized list of flags that are set for this message. 5160 INTERNALDATE A string representing the internal date of the message. 5162 RFC822.SIZE A number expressing the [RFC-5322] size of the message. 5164 UID A number expressing the unique identifier of the message. 5166 Example: S: * 23 FETCH (FLAGS (\Seen) RFC822.SIZE 44827) 5168 7.5. Server Responses - Command Continuation Request 5170 The command continuation request response is indicated by a "+" token 5171 instead of a tag. This form of response indicates that the server is 5172 ready to accept the continuation of a command from the client. The 5173 remainder of this response is a line of text. 5175 This response is used in the AUTHENTICATE command to transmit server 5176 data to the client, and request additional client data. This 5177 response is also used if an argument to any command is a 5178 synchronizing literal. 5180 The client is not permitted to send the octets of the synchronizing 5181 literal unless the server indicates that it is expected. This 5182 permits the server to process commands and reject errors on a line- 5183 by-line basis. The remainder of the command, including the CRLF that 5184 terminates a command, follows the octets of the literal. If there 5185 are any additional command arguments, the literal octets are followed 5186 by a space and those arguments. 5188 Example: C: A001 LOGIN {11} 5189 S: + Ready for additional command text 5190 C: FRED FOOBAR {7} 5191 S: + Ready for additional command text 5192 C: fat man 5193 S: A001 OK LOGIN completed 5194 C: A044 BLURDYBLOOP {102856} 5195 S: A044 BAD No such command as "BLURDYBLOOP" 5197 8. Sample IMAP4rev2 connection 5199 The following is a transcript of an IMAP4rev2 connection. A long 5200 line in this sample is broken for editorial clarity. 5202 S: * OK IMAP4rev2 Service Ready 5203 C: a001 login mrc secret 5204 S: a001 OK LOGIN completed 5205 C: a002 select inbox 5206 S: * 18 EXISTS 5207 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 5208 S: * OK [UIDVALIDITY 3857529045] UIDs valid 5209 S: a002 OK [READ-WRITE] SELECT completed 5210 C: a003 fetch 12 full 5211 S: * 12 FETCH (FLAGS (\Seen) INTERNALDATE "17-Jul-1996 02:44:25 -0700" 5212 RFC822.SIZE 4286 ENVELOPE ("Wed, 17 Jul 1996 02:23:25 -0700 (PDT)" 5213 "IMAP4rev2 WG mtg summary and minutes" 5214 (("Terry Gray" NIL "gray" "cac.washington.edu")) 5215 (("Terry Gray" NIL "gray" "cac.washington.edu")) 5216 (("Terry Gray" NIL "gray" "cac.washington.edu")) 5217 ((NIL NIL "imap" "cac.washington.edu")) 5218 ((NIL NIL "minutes" "CNRI.Reston.VA.US") 5219 ("John Klensin" NIL "KLENSIN" "MIT.EDU")) NIL NIL 5220 "") 5221 BODY ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 3028 5222 92)) 5223 S: a003 OK FETCH completed 5224 C: a004 fetch 12 body[header] 5225 S: * 12 FETCH (BODY[HEADER] {342} 5226 S: Date: Wed, 17 Jul 1996 02:23:25 -0700 (PDT) 5227 S: From: Terry Gray 5228 S: Subject: IMAP4rev2 WG mtg summary and minutes 5229 S: To: imap@cac.washington.edu 5230 S: cc: minutes@CNRI.Reston.VA.US, John Klensin 5231 S: Message-Id: 5232 S: MIME-Version: 1.0 5233 S: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 5234 S: 5235 S: ) 5236 S: a004 OK FETCH completed 5237 C: a005 store 12 +flags \deleted 5238 S: * 12 FETCH (FLAGS (\Seen \Deleted)) 5239 S: a005 OK +FLAGS completed 5240 C: a006 logout 5241 S: * BYE IMAP4rev2 server terminating connection 5242 S: a006 OK LOGOUT completed 5244 9. Formal Syntax 5246 The following syntax specification uses the Augmented Backus-Naur 5247 Form (ABNF) notation as specified in [ABNF]. 5249 In the case of alternative or optional rules in which a later rule 5250 overlaps an earlier rule, the rule which is listed earlier MUST take 5251 priority. For example, "\Seen" when parsed as a flag is the \Seen 5252 flag name and not a flag-extension, even though "\Seen" can be parsed 5253 as a flag-extension. Some, but not all, instances of this rule are 5254 noted below. 5256 Note: [ABNF] rules MUST be followed strictly; in particular: 5258 (1) Except as noted otherwise, all alphabetic characters are case- 5259 insensitive. The use of upper or lower case characters to define 5260 token strings is for editorial clarity only. Implementations MUST 5261 accept these strings in a case-insensitive fashion. 5263 (2) In all cases, SP refers to exactly one space. It is NOT 5264 permitted to substitute TAB, insert additional spaces, or 5265 otherwise treat SP as being equivalent to LWSP. 5267 (3) The ASCII NUL character, %x00, MUST NOT be used at any time. 5269 address = "(" addr-name SP addr-adl SP addr-mailbox SP 5270 addr-host ")" 5272 addr-adl = nstring 5273 ; Holds route from [RFC-5322] route-addr if 5274 ; non-NIL 5276 addr-host = nstring 5277 ; NIL indicates [RFC-5322] group syntax. 5278 ; Otherwise, holds [RFC-5322] domain name 5280 addr-mailbox = nstring 5281 ; NIL indicates end of [RFC-5322] group; if 5282 ; non-NIL and addr-host is NIL, holds 5283 ; [RFC-5322] group name. 5284 ; Otherwise, holds [RFC-5322] local-part 5285 ; after removing [RFC-5322] quoting 5287 addr-name = nstring 5288 ; If non-NIL, holds phrase from [RFC-5322] 5289 ; mailbox after removing [RFC-5322] quoting 5291 append = "APPEND" SP mailbox [SP flag-list] [SP date-time] SP 5292 literal 5294 append-uid = uniqueid 5296 astring = 1*ASTRING-CHAR / string 5297 ASTRING-CHAR = ATOM-CHAR / resp-specials 5299 atom = 1*ATOM-CHAR 5301 ATOM-CHAR = 5303 atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards / 5304 quoted-specials / resp-specials 5306 authenticate = "AUTHENTICATE" SP auth-type [SP initial-resp] 5307 *(CRLF base64) 5309 auth-type = atom 5310 ; Defined by [SASL] 5312 base64 = *(4base64-char) [base64-terminal] 5314 base64-char = ALPHA / DIGIT / "+" / "/" 5315 ; Case-sensitive 5317 base64-terminal = (2base64-char "==") / (3base64-char "=") 5319 body = "(" (body-type-1part / body-type-mpart) ")" 5321 body-extension = nstring / number / 5322 "(" body-extension *(SP body-extension) ")" 5323 ; Future expansion. Client implementations 5324 ; MUST accept body-extension fields. Server 5325 ; implementations MUST NOT generate 5326 ; body-extension fields except as defined by 5327 ; future standard or standards-track 5328 ; revisions of this specification. 5330 body-ext-1part = body-fld-md5 [SP body-fld-dsp [SP body-fld-lang 5331 [SP body-fld-loc *(SP body-extension)]]] 5332 ; MUST NOT be returned on non-extensible 5333 ; "BODY" fetch 5335 body-ext-mpart = body-fld-param [SP body-fld-dsp [SP body-fld-lang 5336 [SP body-fld-loc *(SP body-extension)]]] 5337 ; MUST NOT be returned on non-extensible 5338 ; "BODY" fetch 5340 body-fields = body-fld-param SP body-fld-id SP body-fld-desc SP 5341 body-fld-enc SP body-fld-octets 5343 body-fld-desc = nstring 5344 body-fld-dsp = "(" string SP body-fld-param ")" / nil 5346 body-fld-enc = (DQUOTE ("7BIT" / "8BIT" / "BINARY" / "BASE64"/ 5347 "QUOTED-PRINTABLE") DQUOTE) / string 5349 body-fld-id = nstring 5351 body-fld-lang = nstring / "(" string *(SP string) ")" 5353 body-fld-loc = nstring 5355 body-fld-lines = number 5357 body-fld-md5 = nstring 5359 body-fld-octets = number 5361 body-fld-param = "(" string SP string *(SP string SP string) ")" / nil 5363 body-type-1part = (body-type-basic / body-type-msg / body-type-text) 5364 [SP body-ext-1part] 5366 body-type-basic = media-basic SP body-fields 5367 ; MESSAGE subtype MUST NOT be "RFC822" or "GLOBAL" 5369 body-type-mpart = 1*body SP media-subtype 5370 [SP body-ext-mpart] 5371 ; MULTIPART body part 5373 body-type-msg = media-message SP body-fields SP envelope 5374 SP body SP body-fld-lines 5376 body-type-text = media-text SP body-fields SP body-fld-lines 5378 capability = ("AUTH=" auth-type) / atom 5379 ; New capabilities MUST begin with "X" or be 5380 ; registered with IANA as standard or 5381 ; standards-track 5383 capability-data = "CAPABILITY" *(SP capability) SP "IMAP4rev2" 5384 *(SP capability) 5385 ; Servers MUST implement the STARTTLS, AUTH=PLAIN, 5386 ; and LOGINDISABLED capabilities 5387 ; Servers which offer RFC 1730 compatibility MUST 5388 ; list "IMAP4" as the first capability. 5390 CHAR8 = %x01-ff 5391 ; any OCTET except NUL, %x00 5393 charset = atom / quoted 5395 childinfo-extended-item = "CHILDINFO" SP "(" 5396 list-select-base-opt-quoted 5397 *(SP list-select-base-opt-quoted) ")" 5398 ; Extended data item (mbox-list-extended-item) 5399 ; returned when the RECURSIVEMATCH 5400 ; selection option is specified. 5401 ; Note 1: the CHILDINFO tag can be returned 5402 ; with and without surrounding quotes, as per 5403 ; mbox-list-extended-item-tag production. 5404 ; Note 2: The selection options are always returned 5405 ; quoted, unlike their specification in 5406 ; the extended LIST command. 5408 child-mbox-flag = "\HasChildren" / "\HasNoChildren" 5409 ; attributes for CHILDREN return option, at most one 5410 ; possible per LIST response 5412 command = tag SP (command-any / command-auth / command-nonauth / 5413 command-select) CRLF 5414 ; Modal based on state 5416 command-any = "CAPABILITY" / "LOGOUT" / "NOOP" / enable / x-command 5417 ; Valid in all states 5419 command-auth = append / create / delete / examine / list / 5420 Namespace-Command / 5421 rename / select / status / subscribe / unsubscribe / 5422 idle 5423 ; Valid only in Authenticated or Selected state 5425 command-nonauth = login / authenticate / "STARTTLS" 5426 ; Valid only when in Not Authenticated state 5428 command-select = "CLOSE" / "UNSELECT" / "EXPUNGE" / copy / 5429 move / fetch / store / search / uid 5430 ; Valid only when in Selected state 5432 continue-req = "+" SP (resp-text / base64) CRLF 5434 copy = "COPY" SP sequence-set SP mailbox 5436 create = "CREATE" SP mailbox 5437 ; Use of INBOX gives a NO error 5439 date = date-text / DQUOTE date-text DQUOTE 5440 date-day = 1*2DIGIT 5441 ; Day of month 5443 date-day-fixed = (SP DIGIT) / 2DIGIT 5444 ; Fixed-format version of date-day 5446 date-month = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / 5447 "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec" 5449 date-text = date-day "-" date-month "-" date-year 5451 date-year = 4DIGIT 5453 date-time = DQUOTE date-day-fixed "-" date-month "-" date-year 5454 SP time SP zone DQUOTE 5456 delete = "DELETE" SP mailbox 5457 ; Use of INBOX gives a NO error 5459 digit-nz = %x31-39 5460 ; 1-9 5462 eitem-standard-tag = atom 5463 ; a tag for extended list data defined in a Standard 5464 ; Track or Experimental RFC. 5466 eitem-vendor-tag = vendor-token "-" atom 5467 ; a vendor-specific tag for extended list data 5469 enable = "ENABLE" 1*(SP capability) 5471 enable-data = "ENABLED" *(SP capability) 5473 envelope = "(" env-date SP env-subject SP env-from SP 5474 env-sender SP env-reply-to SP env-to SP env-cc SP 5475 env-bcc SP env-in-reply-to SP env-message-id ")" 5477 env-bcc = "(" 1*address ")" / nil 5479 env-cc = "(" 1*address ")" / nil 5481 env-date = nstring 5483 env-from = "(" 1*address ")" / nil 5485 env-in-reply-to = nstring 5487 env-message-id = nstring 5488 env-reply-to = "(" 1*address ")" / nil 5490 env-sender = "(" 1*address ")" / nil 5492 env-subject = nstring 5494 env-to = "(" 1*address ")" / nil 5496 esearch-response = "ESEARCH" [search-correlator] [SP "UID"] 5497 *(SP search-return-data) 5498 ; ESEARCH response replaces SEARCH response 5499 ; from IMAP4rev1. 5501 examine = "EXAMINE" SP mailbox 5503 fetch = "FETCH" SP sequence-set SP ("ALL" / "FULL" / "FAST" / 5504 fetch-att / "(" fetch-att *(SP fetch-att) ")") 5506 fetch-att = "ENVELOPE" / "FLAGS" / "INTERNALDATE" / 5507 "RFC822.SIZE" / 5508 "BODY" ["STRUCTURE"] / "UID" / 5509 "BODY" section [partial] / 5510 "BODY.PEEK" section [partial] / 5511 "BINARY" [".PEEK"] section-binary [partial] / 5512 "BINARY.SIZE" section-binary 5514 flag = "\Answered" / "\Flagged" / "\Deleted" / 5515 "\Seen" / "\Draft" / flag-keyword / flag-extension 5516 ; Does not include "\Recent" 5518 flag-extension = "\" atom 5519 ; Future expansion. Client implementations 5520 ; MUST accept flag-extension flags. Server 5521 ; implementations MUST NOT generate 5522 ; flag-extension flags except as defined by 5523 ; future standard or standards-track 5524 ; revisions of this specification. 5525 ; "\Recent" was defined in RFC 3501 5526 ; and is now deprecated. 5528 flag-fetch = flag 5530 flag-keyword = "$MDNSent" / "$Forwarded" / atom 5532 flag-list = "(" [flag *(SP flag)] ")" 5534 flag-perm = flag / "\*" 5535 greeting = "*" SP (resp-cond-auth / resp-cond-bye) CRLF 5537 header-fld-name = astring 5539 header-list = "(" header-fld-name *(SP header-fld-name) ")" 5541 idle = "IDLE" CRLF "DONE" 5543 initial-resp = (base64 / "=") 5544 ; "initial response" defined in 5545 ; Section 5.1 of [RFC4422] 5547 list = "LIST" [SP list-select-opts] SP mailbox SP mbox-or-pat 5548 [SP list-return-opts] 5550 list-mailbox = 1*list-char / string 5552 list-char = ATOM-CHAR / list-wildcards / resp-specials 5554 list-return-opts = "RETURN" SP 5555 "(" [return-option *(SP return-option)] ")" 5556 ; list return options, e.g., CHILDREN 5558 list-select-base-opt = "SUBSCRIBED" / option-extension 5559 ; options that can be used by themselves 5561 list-select-base-opt-quoted = DQUOTE list-select-base-opt DQUOTE 5563 list-select-independent-opt = "REMOTE" / option-extension 5564 ; options that do not syntactically interact with 5565 ; other options 5567 list-select-mod-opt = "RECURSIVEMATCH" / option-extension 5568 ; options that require a list-select-base-opt 5569 ; to also be present 5571 list-select-opt = list-select-base-opt / list-select-independent-opt 5572 / list-select-mod-opt 5573 ; An option registration template is described in 5574 ; Section 9.3 of this document. 5576 list-select-opts = "(" [ 5577 (*(list-select-opt SP) list-select-base-opt 5578 *(SP list-select-opt)) 5579 / (list-select-independent-opt 5580 *(SP list-select-independent-opt)) 5581 ] ")" 5583 ; Any number of options may be in any order. 5584 ; If a list-select-mod-opt appears, then a 5585 ; list-select-base-opt must also appear. 5586 ; This allows these: 5587 ; () 5588 ; (REMOTE) 5589 ; (SUBSCRIBED) 5590 ; (SUBSCRIBED REMOTE) 5591 ; (SUBSCRIBED RECURSIVEMATCH) 5592 ; (SUBSCRIBED REMOTE RECURSIVEMATCH) 5593 ; But does NOT allow these: 5594 ; (RECURSIVEMATCH) 5595 ; (REMOTE RECURSIVEMATCH) 5597 list-wildcards = "%" / "*" 5599 literal = "{" number ["+"] "}" CRLF *CHAR8 5600 ; represents the number of CHAR8s. 5601 ; A non-synchronizing literal is distinguished from 5602 ; a synchronizing literal by presence of the "+" 5603 ; before the closing "}". 5604 ; Non synchronizing literals are not allowed when 5605 ; sent from server to the client. 5607 literal8 = "~{" number "}" CRLF *OCTET 5608 ; represents the number of OCTETs 5609 ; in the response string. 5611 login = "LOGIN" SP userid SP password 5613 mailbox = "INBOX" / astring 5614 ; INBOX is case-insensitive. All case variants of 5615 ; INBOX (e.g., "iNbOx") MUST be interpreted as INBOX 5616 ; not as an astring. An astring which consists of 5617 ; the case-insensitive sequence "I" "N" "B" "O" "X" 5618 ; is considered to be INBOX and not an astring. 5619 ; Refer to section 5.1 for further 5620 ; semantic details of mailbox names. 5622 mailbox-data = "FLAGS" SP flag-list / "LIST" SP mailbox-list / 5623 esearch-response / 5624 "STATUS" SP mailbox SP "(" [status-att-list] ")" / 5625 number SP "EXISTS" / Namespace-Response 5627 mailbox-list = "(" [mbx-list-flags] ")" SP 5628 (DQUOTE QUOTED-CHAR DQUOTE / nil) SP mailbox 5629 [SP mbox-list-extended] 5630 ; This is the list information pointed to by the ABNF 5631 ; item "mailbox-data", which is defined in [IMAP4] 5633 mbox-list-extended = "(" [mbox-list-extended-item 5634 *(SP mbox-list-extended-item)] ")" 5636 mbox-list-extended-item = mbox-list-extended-item-tag SP 5637 tagged-ext-val 5639 mbox-list-extended-item-tag = astring 5640 ; The content MUST conform to either "eitem-vendor-tag" 5641 ; or "eitem-standard-tag" ABNF productions. 5643 mbox-or-pat = list-mailbox / patterns 5645 mbx-list-flags = *(mbx-list-oflag SP) mbx-list-sflag 5646 *(SP mbx-list-oflag) / 5647 mbx-list-oflag *(SP mbx-list-oflag) 5649 mbx-list-oflag = "\Noinferiors" / child-mbox-flag / 5650 "\Subscribed" / "\Remote" / flag-extension 5651 ; Other flags; multiple possible per LIST response 5653 mbx-list-sflag = "\NonExistent" / "\Noselect" / "\Marked" / "\Unmarked" 5654 ; Selectability flags; only one per LIST response 5656 media-basic = ((DQUOTE ("APPLICATION" / "AUDIO" / "IMAGE" / 5657 "MESSAGE" / "VIDEO" / "FONT") DQUOTE) / string) SP 5658 media-subtype 5659 ; Defined in [MIME-IMT]. 5660 ; FONT defined in RFC YYYY. 5662 media-message = DQUOTE "MESSAGE" DQUOTE SP 5663 DQUOTE ("RFC822" / "GLOBAL") DQUOTE 5664 ; Defined in [MIME-IMT] 5666 media-subtype = string 5667 ; Defined in [MIME-IMT] 5669 media-text = DQUOTE "TEXT" DQUOTE SP media-subtype 5670 ; Defined in [MIME-IMT] 5672 message-data = nz-number SP ("EXPUNGE" / ("FETCH" SP msg-att)) 5674 move = "MOVE" SP sequence-set SP mailbox 5676 msg-att = "(" (msg-att-dynamic / msg-att-static) 5677 *(SP (msg-att-dynamic / msg-att-static)) ")" 5679 msg-att-dynamic = "FLAGS" SP "(" [flag-fetch *(SP flag-fetch)] ")" 5680 ; MAY change for a message 5682 msg-att-static = "ENVELOPE" SP envelope / "INTERNALDATE" SP date-time / 5683 "RFC822.SIZE" SP number / 5684 "BODY" ["STRUCTURE"] SP body / 5685 "BODY" section ["<" number ">"] SP nstring / 5686 "BINARY" section-binary SP (nstring / literal8) / 5687 "BINARY.SIZE" section-binary SP number / 5688 "UID" SP uniqueid 5689 ; MUST NOT change for a message 5691 Namespace = nil / "(" 1*Namespace-Descr ")" 5693 Namespace-Command = "NAMESPACE" 5695 Namespace-Descr = "(" string SP 5696 (DQUOTE QUOTED-CHAR DQUOTE / nil) 5697 [Namespace-Response-Extensions] ")" 5699 Namespace-Response-Extensions = *(Namespace-Response-Extension) 5701 Namespace-Response-Extension = SP string SP 5702 "(" string *(SP string) ")" 5704 Namespace-Response = "NAMESPACE" SP Namespace 5705 SP Namespace SP Namespace 5706 ; The first Namespace is the Personal Namespace(s) 5707 ; The second Namespace is the Other Users' Namespace(s) 5708 ; The third Namespace is the Shared Namespace(s) 5710 nil = "NIL" 5712 nstring = string / nil 5714 number = 1*DIGIT 5715 ; Unsigned 32-bit integer 5716 ; (0 <= n < 4,294,967,296) 5718 number64 = 1*DIGIT 5719 ; Unsigned 63-bit integer 5720 ; (0 <= n <= 9,223,372,036,854,775,807) 5722 nz-number = digit-nz *DIGIT 5723 ; Non-zero unsigned 32-bit integer 5724 ; (0 < n < 4,294,967,296) 5726 option-extension = (option-standard-tag / option-vendor-tag) 5728 [SP option-value] 5730 option-standard-tag = atom 5731 ; an option defined in a Standards Track or 5732 ; Experimental RFC 5734 option-val-comp = astring / 5735 option-val-comp *(SP option-val-comp) / 5736 "(" option-val-comp ")" 5738 option-value = "(" option-val-comp ")" 5740 option-vendor-tag = vendor-token "-" atom 5741 ; a vendor-specific option, non-standard 5743 partial-range = number ["." nz-number] 5744 ; Copied from RFC 5092 (IMAP URL) 5746 partial = "<" number "." nz-number ">" 5747 ; Partial FETCH request. 0-based offset of 5748 ; the first octet, followed by the number of octets 5749 ; in the fragment. 5751 password = astring 5753 patterns = "(" list-mailbox *(SP list-mailbox) ")" 5755 quoted = DQUOTE *QUOTED-CHAR DQUOTE 5757 QUOTED-CHAR = / 5758 "\" quoted-specials / UTF8-2 / UTF8-3 / UTF8-4 5760 quoted-specials = DQUOTE / "\" 5762 rename = "RENAME" SP mailbox SP mailbox 5763 ; Use of INBOX as a destination gives a NO error 5765 response = *(continue-req / response-data) response-done 5767 response-data = "*" SP (resp-cond-state / resp-cond-bye / 5768 mailbox-data / message-data / capability-data / 5769 enable-data) CRLF 5771 response-done = response-tagged / response-fatal 5773 response-fatal = "*" SP resp-cond-bye CRLF 5774 ; Server closes connection immediately 5776 response-tagged = tag SP resp-cond-state CRLF 5778 resp-code-apnd = "APPENDUID" SP nz-number SP append-uid 5780 resp-code-copy = "COPYUID" SP nz-number SP uid-set SP uid-set 5782 resp-cond-auth = ("OK" / "PREAUTH") SP resp-text 5783 ; Authentication condition 5785 resp-cond-bye = "BYE" SP resp-text 5787 resp-cond-state = ("OK" / "NO" / "BAD") SP resp-text 5788 ; Status condition 5790 resp-specials = "]" 5792 resp-text = ["[" resp-text-code "]" SP] [text] 5794 resp-text-code = "ALERT" / 5795 "BADCHARSET" [SP "(" charset *(SP charset) ")" ] / 5796 capability-data / "PARSE" / 5797 "PERMANENTFLAGS" SP "(" 5798 [flag-perm *(SP flag-perm)] ")" / 5799 "READ-ONLY" / "READ-WRITE" / "TRYCREATE" / 5800 "UIDNEXT" SP nz-number / "UIDVALIDITY" SP nz-number / 5801 resp-code-apnd / resp-code-copy / "UIDNOTSTICKY" / 5802 "UNAVAILABLE" / "AUTHENTICATIONFAILED" / 5803 "AUTHORIZATIONFAILED" / "EXPIRED" / 5804 "PRIVACYREQUIRED" / "CONTACTADMIN" / "NOPERM" / 5805 "INUSE" / "EXPUNGEISSUED" / "CORRUPTION" / 5806 "SERVERBUG" / "CLIENTBUG" / "CANNOT" / 5807 "LIMIT" / "OVERQUOTA" / "ALREADYEXISTS" / 5808 "NONEXISTENT" / 5809 "CLOSED" / 5810 "UNKNOWN-CTE" / 5811 atom [SP 1*] 5813 return-option = "SUBSCRIBED" / "CHILDREN" / option-extension 5815 search = "SEARCH" [search-return-opts] 5816 SP search-program 5818 search-correlator = SP "(" "TAG" SP tag-string ")" 5820 search-key = "ALL" / "ANSWERED" / "BCC" SP astring / 5821 "BEFORE" SP date / "BODY" SP astring / 5822 "CC" SP astring / "DELETED" / "FLAGGED" / 5823 "FROM" SP astring / "KEYWORD" SP flag-keyword / 5824 "ON" SP date / "SEEN" / 5825 "SINCE" SP date / "SUBJECT" SP astring / 5826 "TEXT" SP astring / "TO" SP astring / 5827 "UNANSWERED" / "UNDELETED" / "UNFLAGGED" / 5828 "UNKEYWORD" SP flag-keyword / "UNSEEN" / 5829 ; Above this line were in [IMAP2] 5830 "DRAFT" / "HEADER" SP header-fld-name SP astring / 5831 "LARGER" SP number / "NOT" SP search-key / 5832 "OR" SP search-key SP search-key / 5833 "SENTBEFORE" SP date / "SENTON" SP date / 5834 "SENTSINCE" SP date / "SMALLER" SP number / 5835 "UID" SP sequence-set / "UNDRAFT" / sequence-set / 5836 "(" search-key *(SP search-key) ")" 5838 search-modifier-name = tagged-ext-label 5840 search-mod-params = tagged-ext-val 5841 ; This non-terminal shows recommended syntax 5842 ; for future extensions. 5844 search-program = ["CHARSET" SP charset SP] 5845 search-key *(SP search-key) 5846 ; CHARSET argument to SEARCH MUST be 5847 ; registered with IANA. 5849 search-ret-data-ext = search-modifier-name SP search-return-value 5850 ; Note that not every SEARCH return option 5851 ; is required to have the corresponding 5852 ; ESEARCH return data. 5854 search-return-data = "MIN" SP nz-number / 5855 "MAX" SP nz-number / 5856 "ALL" SP sequence-set / 5857 "COUNT" SP number / 5858 search-ret-data-ext 5859 ; All return data items conform to 5860 ; search-ret-data-ext syntax 5862 search-return-opts = SP "RETURN" SP "(" [search-return-opt 5863 *(SP search-return-opt)] ")" 5865 search-return-opt = "MIN" / "MAX" / "ALL" / "COUNT" / 5866 search-ret-opt-ext 5867 ; conforms to generic search-ret-opt-ext 5868 ; syntax 5870 search-ret-opt-ext = search-modifier-name [SP search-mod-params] 5871 search-return-value = tagged-ext-val 5872 ; Data for the returned search option. 5873 ; A single "nz-number"/"number"/"number64" value 5874 ; can be returned as an atom (i.e., without 5875 ; quoting). A sequence-set can be returned 5876 ; as an atom as well. 5878 section = "[" [section-spec] "]" 5880 section-binary = "[" [section-part] "]" 5882 section-msgtext = "HEADER" / "HEADER.FIELDS" [".NOT"] SP header-list / 5883 "TEXT" 5884 ; top-level or MESSAGE/RFC822 or MESSAGE/GLOBAL part 5886 section-part = nz-number *("." nz-number) 5887 ; body part reference. 5888 ; Allows for accessing nested body parts. 5890 section-spec = section-msgtext / (section-part ["." section-text]) 5892 section-text = section-msgtext / "MIME" 5893 ; text other than actual body part (headers, etc.) 5895 select = "SELECT" SP mailbox 5897 seq-number = nz-number / "*" 5898 ; message sequence number (COPY, FETCH, STORE 5899 ; commands) or unique identifier (UID COPY, 5900 ; UID FETCH, UID STORE commands). 5901 ; * represents the largest number in use. In 5902 ; the case of message sequence numbers, it is 5903 ; the number of messages in a non-empty mailbox. 5904 ; In the case of unique identifiers, it is the 5905 ; unique identifier of the last message in the 5906 ; mailbox or, if the mailbox is empty, the 5907 ; mailbox's current UIDNEXT value. 5908 ; The server should respond with a tagged BAD 5909 ; response to a command that uses a message 5910 ; sequence number greater than the number of 5911 ; messages in the selected mailbox. This 5912 ; includes "*" if the selected mailbox is empty. 5914 seq-range = seq-number ":" seq-number 5915 ; two seq-number values and all values between 5916 ; these two regardless of order. 5917 ; Example: 2:4 and 4:2 are equivalent and indicate 5918 ; values 2, 3, and 4. 5920 ; Example: a unique identifier sequence range of 5921 ; 3291:* includes the UID of the last message in 5922 ; the mailbox, even if that value is less than 3291. 5924 sequence-set = (seq-number / seq-range) ["," sequence-set] 5925 ; set of seq-number values, regardless of order. 5926 ; Servers MAY coalesce overlaps and/or execute the 5927 ; sequence in any order. 5928 ; Example: a message sequence number set of 5929 ; 2,4:7,9,12:* for a mailbox with 15 messages is 5930 ; equivalent to 2,4,5,6,7,9,12,13,14,15 5931 ; Example: a message sequence number set of *:4,5:7 5932 ; for a mailbox with 10 messages is equivalent to 5933 ; 10,9,8,7,6,5,4,5,6,7 and MAY be reordered and 5934 ; overlap coalesced to be 4,5,6,7,8,9,10. 5936 status = "STATUS" SP mailbox SP 5937 "(" status-att *(SP status-att) ")" 5939 status-att = "MESSAGES" / "UIDNEXT" / "UIDVALIDITY" / 5940 "UNSEEN" / "DELETED" / "SIZE" 5942 status-att-val = ("MESSAGES" SP number) / 5943 ("UIDNEXT" SP nz-number) / 5944 ("UIDVALIDITY" SP nz-number) / 5945 ("UNSEEN" SP number) / 5946 ("DELETED" SP number) / 5947 ("SIZE" SP number64) 5948 ; Extensions to the STATUS responses 5949 ; should extend this production. 5950 ; Extensions should use the generic 5951 ; syntax defined by tagged-ext. 5953 status-att-list = status-att-val *(SP status-att-val) 5955 store = "STORE" SP sequence-set SP store-att-flags 5957 store-att-flags = (["+" / "-"] "FLAGS" [".SILENT"]) SP 5958 (flag-list / (flag *(SP flag))) 5960 string = quoted / literal 5962 subscribe = "SUBSCRIBE" SP mailbox 5964 tag = 1* 5966 tagged-ext-label = tagged-label-fchar *tagged-label-char 5967 ;; Is a valid RFC 3501 "atom". 5969 tagged-label-fchar = ALPHA / "-" / "_" / "." 5971 tagged-label-char = tagged-label-fchar / DIGIT / ":" 5973 tagged-ext-comp = astring / 5974 tagged-ext-comp *(SP tagged-ext-comp) / 5975 "(" tagged-ext-comp ")" 5976 ;; Extensions that follow this general 5977 ;; syntax should use nstring instead of 5978 ;; astring when appropriate in the context 5979 ;; of the extension. 5980 ;; Note that a message set or a "number" 5981 ;; can always be represented as an "atom". 5982 ;; An URL should be represented as 5983 ;; a "quoted" string. 5985 tagged-ext-simple = sequence-set / number / number64 5987 tagged-ext-val = tagged-ext-simple / 5988 "(" [tagged-ext-comp] ")" 5990 text = 1*TEXT-CHAR 5992 TEXT-CHAR = 5994 time = 2DIGIT ":" 2DIGIT ":" 2DIGIT 5995 ; Hours minutes seconds 5997 uid = "UID" SP 5998 (copy / move / fetch / search / store / uid-expunge) 5999 ; Unique identifiers used instead of message 6000 ; sequence numbers 6002 uid-expunge = "EXPUNGE" SP sequence-set 6003 ; Unique identifiers used instead of message 6004 ; sequence numbers 6006 uid-set = (uniqueid / uid-range) *("," uid-set) 6008 uid-range = (uniqueid ":" uniqueid) 6009 ; two uniqueid values and all values 6010 ; between these two regards of order. 6011 ; Example: 2:4 and 4:2 are equivalent. 6013 uniqueid = nz-number 6014 ; Strictly ascending 6016 unsubscribe = "UNSUBSCRIBE" SP mailbox 6017 userid = astring 6019 UTF8-2 = 6021 UTF8-3 = 6023 UTF8-4 = 6025 x-command = "X" atom 6027 zone = ("+" / "-") 4DIGIT 6028 ; Signed four-digit value of hhmm representing 6029 ; hours and minutes east of Greenwich (that is, 6030 ; the amount that the given time differs from 6031 ; Universal Time). Subtracting the timezone 6032 ; from the given time will give the UT form. 6033 ; The Universal Time zone is "+0000". 6035 10. Author's Note 6037 This document is a revision or rewrite of earlier documents, and 6038 supercedes the protocol specification in those documents: RFC 2060, 6039 RFC 1730, unpublished IMAP2bis.TXT document, RFC 1176, and RFC 1064. 6041 11. Security Considerations 6043 IMAP4rev2 protocol transactions, including electronic mail data, are 6044 sent in the clear over the network unless protection from snooping is 6045 negotiated. This can be accomplished either by the use of IMAPS 6046 service, STARTTLS command, negotiated privacy protection in the 6047 AUTHENTICATE command, or some other protection mechanism. 6049 11.1. STARTTLS Security Considerations 6051 IMAP client and server implementations MUST comply with relevant TLS 6052 recommendations from [RFC8314]. 6054 Additionally, when using TLS 1.2, IMAP implementations MUST implement 6055 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 cipher suite, and SHOULD 6056 implement the TLS_RSA_WITH_AES_128_CBC_SHA [TLS] cipher suite. This 6057 is important as it assures that any two compliant implementations can 6058 be configured to interoperate. Other TLS cipher suites recommended 6059 in RFC 7525 are RECOMMENDED: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 6060 TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 and 6061 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384. All other cipher suites are 6062 OPTIONAL. Note that this is a change from section 2.1 of [IMAP-TLS]. 6064 During the [TLS] negotiation, the client MUST check its understanding 6065 of the server hostname against the server's identity as presented in 6066 the server Certificate message, in order to prevent man-in-the-middle 6067 attacks. This procedure is described in [RFC7817]. 6069 Both the client and server MUST check the result of the STARTTLS 6070 command and subsequent [TLS] negotiation to see whether acceptable 6071 authentication and/or privacy was achieved. 6073 11.2. COPYUID and APPENDUID response codes 6075 The COPYUID and APPENDUID response codes return information about the 6076 mailbox, which may be considered sensitive if the mailbox has 6077 permissions set that permit the client to COPY or APPEND to the 6078 mailbox, but not SELECT or EXAMINE it. 6080 Consequently, these response codes SHOULD NOT be issued if the client 6081 does not have access to SELECT or EXAMINE the mailbox. 6083 11.3. LIST command and Other Users' namespace 6085 In response to a LIST command containing an argument of the Other 6086 Users' Namespace prefix, a server SHOULD NOT list users that have not 6087 granted list access to their personal mailboxes to the currently 6088 authenticated user. Providing such a list, could compromise security 6089 by potentially disclosing confidential information of who is located 6090 on the server, or providing a starting point of a list of user 6091 accounts to attack. 6093 11.4. Other Security Considerations 6095 A server error message for an AUTHENTICATE command which fails due to 6096 invalid credentials SHOULD NOT detail why the credentials are 6097 invalid. 6099 Use of the LOGIN command sends passwords in the clear. This can be 6100 avoided by using the AUTHENTICATE command with a [SASL] mechanism 6101 that does not use plaintext passwords, by first negotiating 6102 encryption via STARTTLS or some other protection mechanism. 6104 A server implementation MUST implement a configuration that, at the 6105 time of authentication, requires: 6106 (1) The STARTTLS command has been negotiated. 6107 OR 6108 (2) Some other mechanism that protects the session from password 6109 snooping has been provided. 6110 OR 6111 (3) The following measures are in place: 6113 (a) The LOGINDISABLED capability is advertised, and [SASL] mechanisms 6114 (such as PLAIN) using plaintext passwords are NOT advertised in the 6115 CAPABILITY list. 6116 AND 6117 (b) The LOGIN command returns an error even if the password is 6118 correct. 6119 AND 6120 (c) The AUTHENTICATE command returns an error with all [SASL] 6121 mechanisms that use plaintext passwords, even if the password is 6122 correct. 6124 A server error message for a failing LOGIN command SHOULD NOT specify 6125 that the user name, as opposed to the password, is invalid. 6127 A server SHOULD have mechanisms in place to limit or delay failed 6128 AUTHENTICATE/LOGIN attempts. 6130 Additional security considerations are discussed in the section 6131 discussing the AUTHENTICATE and LOGIN commands. 6133 12. IANA Considerations 6135 IANA is requested to update "Service Names and Transport Protocol 6136 Port Numbers" registry as follows: 6138 1. Registration for TCP "imap" port 143 should be updated to point 6139 to this document and RFC 3501. 6141 2. Registration for TCP "imaps" port 993 should be updated to point 6142 to this document, RFC 8314 and RFC 3501. 6144 3. Both UDP port 143 and UDP port 993 should be marked as "Reserved" 6145 in the registry. 6147 Additional IANA actions are specified in subsection of this section. 6149 12.1. Updates to IMAP4 Capabilities registry 6151 IMAP4 capabilities are registered by publishing a standards track or 6152 IESG approved informational or experimental RFC. The registry is 6153 currently located at: http://www.iana.org/assignments/ 6154 imap4-capabilities 6156 As this specification revises the STARTTLS and LOGINDISABLED 6157 extensions previously defined in [IMAP-TLS], IANA is requested to 6158 update registry entries for these 2 extensions to point to this 6159 document. 6161 12.2. GSSAPI/SASL service name 6163 GSSAPI/Kerberos/SASL service names are registered by publishing a 6164 standards track or IESG approved experimental RFC. The registry is 6165 currently located at: http://www.iana.org/assignments/gssapi-service- 6166 names 6168 IANA is requested to update the "imap" service name previously 6169 registered in RFC 3501, to point to this document. 6171 13. References 6173 13.1. Normative References 6175 [ABNF] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 6176 Specifications: ABNF", STD 68, RFC 5234, January 2008, 6177 . 6179 [ANONYMOUS] 6180 Zeilenga, K., "Anonymous Simple Authentication and 6181 Security Layer (SASL) Mechanism", RFC 4505, June 2006, 6182 . 6184 [CHARSET] Freed, N. and J. Postel, "IANA Charset Registration 6185 Procedures", BCP 19, RFC 2978, October 2000, 6186 . 6188 [SCRAM-SHA-256] 6189 Hansen, T., "SCRAM-SHA-256 and SCRAM-SHA-256-PLUS Simple 6190 Authentication and Security Layer (SASL) Mechanisms", 6191 RFC 7677, DOI 10.17487/RFC7677, November 2015, 6192 . 6194 [DISPOSITION] 6195 Troost, R., Dorner, S., and K. Moore, Ed., "Communicating 6196 Presentation Information in Internet Messages: The 6197 Content-Disposition Header Field", RFC 2183, August 1997, 6198 . 6200 [PLAIN] Zeilenga, K., Ed., "The PLAIN Simple Authentication and 6201 Security Layer (SASL) Mechanism", RFC 4616, August 2006, 6202 . 6204 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 6205 Requirement Levels", BCP 14, RFC 2119, 6206 DOI 10.17487/RFC2119, March 1997, 6207 . 6209 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 6210 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 6211 May 2017, . 6213 [LANGUAGE-TAGS] 6214 Alvestrand, H., "Content Language Headers", RFC 3282, May 6215 2002, . 6217 [LOCATION] 6218 Palme, J., Hopmann, A., and N. Shelness, "MIME 6219 Encapsulation of Aggregate Documents, such as HTML 6220 (MHTML)", RFC 2557, March 1999, 6221 . 6223 [MD5] Myers, J. and M. Rose, "The Content-MD5 Header Field", 6224 RFC 1864, October 1995, 6225 . 6227 [MIME-HDRS] 6228 Moore, K., "MIME (Multipurpose Internet Mail Extensions) 6229 Part Three: Message Header Extensions for Non-ASCII Text", 6230 RFC 2047, November 1996, 6231 . 6233 [MIME-IMB] 6234 Freed, N. and N. Borenstein, "Multipurpose Internet Mail 6235 Extensions (MIME) Part One: Format of Internet Message 6236 Bodies", RFC 2045, November 1996, 6237 . 6239 [MIME-IMT] 6240 Freed, N. and N. Borenstein, "Multipurpose Internet Mail 6241 Extensions (MIME) Part Two: Media Types", RFC 2046, 6242 November 1996, . 6244 [RFC2231] Freed, N. and K. Moore, "MIME Parameter Value and Encoded 6245 Word Extensions: Character Sets, Languages, and 6246 Continuations", RFC 2231, DOI 10.17487/RFC2231, November 6247 1997, . 6249 [RFC-5322] 6250 Resnick, P., Ed., "Internet Message Format", RFC 5322, 6251 October 2008, . 6253 [SASL] Melnikov, A., Ed. and K. Zeilenga, Ed., "Simple 6254 Authentication and Security Layer (SASL)", RFC 4422, June 6255 2006, . 6257 [TLS] Dierks, T. and E. Rescorla, "The Transport Layer Security 6258 (TLS) Protocol Version 1.2", RFC 5246, August 2008, 6259 . 6261 [UTF-7] Goldsmith, D. and M. Davis, "UTF-7 A Mail-Safe 6262 Transformation Format of Unicode", RFC 2152, May 1997, 6263 . 6265 [UTF-8] Yergeau, F., "UTF-8, a transformation format of ISO 6266 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 6267 2003, . 6269 [MULTIAPPEND] 6270 Crispin, M., "Internet Message Access Protocol (IMAP) - 6271 MULTIAPPEND Extension", RFC 3502, March 2003, 6272 . 6274 [NET-UNICODE] 6275 Klensin, J. and M. Padlipsky, "Unicode Format for Network 6276 Interchange", RFC 5198, DOI 10.17487/RFC5198, March 2008, 6277 . 6279 [I18N-HDRS] 6280 Yang, A., Steele, S., and N. Freed, "Internationalized 6281 Email Headers", RFC 6532, DOI 10.17487/RFC6532, February 6282 2012, . 6284 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 6285 Encodings", RFC 4648, DOI 10.17487/RFC4648, October 2006, 6286 . 6288 [RFC7817] Melnikov, A., "Updated Transport Layer Security (TLS) 6289 Server Identity Check Procedure for Email-Related 6290 Protocols", RFC 7817, DOI 10.17487/RFC7817, March 2016, 6291 . 6293 [RFC8098] Hansen, T., Ed. and A. Melnikov, Ed., "Message Disposition 6294 Notification", STD 85, RFC 8098, DOI 10.17487/RFC8098, 6295 February 2017, . 6297 [RFC8314] Moore, K. and C. Newman, "Cleartext Considered Obsolete: 6298 Use of Transport Layer Security (TLS) for Email Submission 6299 and Access", RFC 8314, DOI 10.17487/RFC8314, January 2018, 6300 . 6302 [IMAP-IMPLEMENTATION] 6303 Leiba, B., "IMAP4 Implementation Recommendations", 6304 RFC 2683, September 1999, 6305 . 6307 [IMAP-MULTIACCESS] 6308 Gahrns, M., "IMAP4 Multi-Accessed Mailbox Practice", 6309 RFC 2180, July 1997, 6310 . 6312 13.2. Informative References (related protocols) 6314 [RFC5258] Leiba, B. and A. Melnikov, "Internet Message Access 6315 Protocol version 4 - LIST Command Extensions", RFC 5258, 6316 DOI 10.17487/RFC5258, June 2008, 6317 . 6319 [RFC2193] Gahrns, M., "IMAP4 Mailbox Referrals", RFC 2193, 6320 DOI 10.17487/RFC2193, September 1997, 6321 . 6323 [RFC3348] Gahrns, M. and R. Cheng, "The Internet Message Action 6324 Protocol (IMAP4) Child Mailbox Extension", RFC 3348, 6325 DOI 10.17487/RFC3348, July 2002, 6326 . 6328 [RFC7888] Melnikov, A., Ed., "IMAP4 Non-synchronizing Literals", 6329 RFC 7888, DOI 10.17487/RFC7888, May 2016, 6330 . 6332 [IMAP-DISC] 6333 Melnikov, A., Ed., "Synchronization Operations for 6334 Disconnected IMAP4 Clients", RFC 4549, June 2006, 6335 . 6337 [IMAP-I18N] 6338 Newman, C., Gulbrandsen, A., and A. Melnikov, "Internet 6339 Message Access Protocol Internationalization", RFC 5255, 6340 DOI 10.17487/RFC5255, June 2008, 6341 . 6343 [IMAP-MODEL] 6344 Crispin, M., "Distributed Electronic Mail Models in 6345 IMAP4", RFC 1733, December 1994, 6346 . 6348 [IMAP-UTF-8] 6349 Resnick, P., Ed., Newman, C., Ed., and S. Shen, Ed., "IMAP 6350 Support for UTF-8", RFC 6855, DOI 10.17487/RFC6855, March 6351 2013, . 6353 [SMTP] Klensin, J., "Simple Mail Transfer Protocol", RFC 5321, 6354 October 2008, . 6356 [RFC3516] Nerenberg, L., "IMAP4 Binary Content Extension", RFC 3516, 6357 DOI 10.17487/RFC3516, April 2003, 6358 . 6360 [RFC4314] Melnikov, A., "IMAP4 Access Control List (ACL) Extension", 6361 RFC 4314, December 2005, 6362 . 6364 [RFC2087] Myers, J., "IMAP4 QUOTA extension", RFC 2087, January 6365 1997, . 6367 [IMAP-URL] 6368 Melnikov, A., Ed. and C. Newman, "IMAP URL Scheme", 6369 RFC 5092, DOI 10.17487/RFC5092, November 2007, 6370 . 6372 13.3. Informative References (historical aspects of IMAP and related 6373 protocols) 6375 [IMAP-COMPAT] 6376 Crispin, M., "IMAP4 Compatibility with IMAP2bis", 6377 RFC 2061, December 1996, 6378 . 6380 [IMAP-HISTORICAL] 6381 Crispin, M., "IMAP4 Compatibility with IMAP2 and 6382 IMAP2bis", RFC 1732, December 1994, 6383 . 6385 [IMAP-OBSOLETE] 6386 Crispin, M., "Internet Message Access Protocol - Obsolete 6387 Syntax", RFC 2062, December 1996, 6388 . 6390 [IMAP2] Crispin, M., "Interactive Mail Access Protocol: Version 6391 2", RFC 1176, August 1990, 6392 . 6394 [RFC-822] Crocker, D., "STANDARD FOR THE FORMAT OF ARPA INTERNET 6395 TEXT MESSAGES", STD 11, RFC 822, August 1982, 6396 . 6398 [IMAP-TLS] 6399 Newman, C., "Using TLS with IMAP, POP3 and ACAP", 6400 RFC 2595, June 1999, 6401 . 6403 Appendix A. Backward compatibility with IMAP4rev1 6405 An implementation that wants to remain compatible with IMAP4rev1 can 6406 advertise both IMAP4rev1 and IMAP4rev2 in its CAPABILITY response/ 6407 response code. While some IMAP4rev1 responses were removed in 6408 IMAP4rev2, their presence will not break IMAP4rev2-only clients. 6410 If both IMAP4rev1 and IMAP4rev2 are advertised, an IMAP client that 6411 wants to use IMAP4rev2 MUST issue an "ENABLE IMAP4rev2" command. 6413 Servers advertising both IMAP4rev1 and IMAP4rev2 SHOULD NOT 6415 generate UTF-8 quoted strings unless the client has issued "ENABLE 6416 IMAP4rev2". Consider implementation of mechanisms described or 6417 referenced in [IMAP-UTF-8] to achieve this goal. 6419 Servers advertising both IMAP4rev1 and IMAP4rev2, and clients 6420 intending to be compatible with IMAP4rev1 servers MUST be compatible 6421 with the international mailbox naming convention described in the 6422 following subsection. 6424 A.1. Mailbox International Naming Convention for compatibility with 6425 IMAP4rev1 6427 Support for the Mailbox International Naming Convention described in 6428 this section is not required for IMAP4rev2-only clients and servers. 6430 By convention, international mailbox names in IMAP4rev1 are specified 6431 using a modified version of the UTF-7 encoding described in [UTF-7]. 6432 Modified UTF-7 may also be usable in servers that implement an 6433 earlier version of this protocol. 6435 In modified UTF-7, printable US-ASCII characters, except for "&", 6436 represent themselves; that is, characters with octet values 0x20-0x25 6437 and 0x27-0x7e. The character "&" (0x26) is represented by the two- 6438 octet sequence "&-". 6440 All other characters (octet values 0x00-0x1f and 0x7f-0xff) are 6441 represented in modified BASE64, with a further modification from 6443 [UTF-7] that "," is used instead of "/". Modified BASE64 MUST NOT be 6444 used to represent any printing US-ASCII character which can represent 6445 itself. Only characters inside the modified BASE64 alphabet are 6446 permitted in modified BASE64 text. 6448 "&" is used to shift to modified BASE64 and "-" to shift back to US- 6449 ASCII. There is no implicit shift from BASE64 to US-ASCII, and null 6450 shifts ("-&" while in BASE64; note that "&-" while in US-ASCII means 6451 "&") are not permitted. However, all names start in US-ASCII, and 6452 MUST end in US-ASCII; that is, a name that ends with a non-ASCII 6453 ISO-10646 character MUST end with a "-"). 6455 The purpose of these modifications is to correct the following 6456 problems with UTF-7: 6458 1. UTF-7 uses the "+" character for shifting; this conflicts with 6459 the common use of "+" in mailbox names, in particular USENET 6460 newsgroup names. 6462 2. UTF-7's encoding is BASE64 which uses the "/" character; this 6463 conflicts with the use of "/" as a popular hierarchy delimiter. 6465 3. UTF-7 prohibits the unencoded usage of "\"; this conflicts with 6466 the use of "\" as a popular hierarchy delimiter. 6468 4. UTF-7 prohibits the unencoded usage of "~"; this conflicts with 6469 the use of "~" in some servers as a home directory indicator. 6471 5. UTF-7 permits multiple alternate forms to represent the same 6472 string; in particular, printable US-ASCII characters can be 6473 represented in encoded form. 6475 Although modified UTF-7 is a convention, it establishes certain 6476 requirements on server handling of any mailbox name with an embedded 6477 "&" character. In particular, server implementations MUST preserve 6478 the exact form of the modified BASE64 portion of a modified UTF-7 6479 name and treat that text as case-sensitive, even if names are 6480 otherwise case-insensitive or case-folded. 6482 Server implementations SHOULD verify that any mailbox name with an 6483 embedded "&" character, used as an argument to CREATE, is: in the 6484 correctly modified UTF-7 syntax, has no superfluous shifts, and has 6485 no encoding in modified BASE64 of any printing US-ASCII character 6486 which can represent itself. However, client implementations MUST NOT 6487 depend upon the server doing this, and SHOULD NOT attempt to create a 6488 mailbox name with an embedded "&" character unless it complies with 6489 the modified UTF-7 syntax. 6491 Server implementations which export a mail store that does not follow 6492 the modified UTF-7 convention MUST convert to modified UTF-7 any 6493 mailbox name that contains either non-ASCII characters or the "&" 6494 character. 6496 For example, here is a mailbox name which mixes English, Chinese, 6497 and Japanese text: ~peter/mail/&U,BTFw-/&ZeVnLIqe- 6499 For example, the string "&Jjo!" is not a valid mailbox name 6500 because it does not contain a shift to US-ASCII before the "!". 6501 The correct form is "&Jjo-!". The string "&U,BTFw-&ZeVnLIqe-" is 6502 not permitted because it contains a superfluous shift. The 6503 correct form is "&U,BTF2XlZyyKng-". 6505 Appendix B. Backward compatibility with BINARY extension 6507 IMAP4rev2 is incorporates subset of functionality provided by the 6508 BINARY extension [RFC3516], in particular it includes additional 6509 FETCH items (BINARY, BINARY.PEEK and BINARY.SIZE), but not extensions 6510 to the APPEND command. IMAP4rev2 implementations that supports full 6511 RFC 3516 functionality need to also advertise the BINARY token in the 6512 CAPABILITY response. 6514 Appendix C. Changes from RFC 3501 / IMAP4rev1 6516 The following is the plan for remaining changes. The plan might 6517 change over time. 6519 1. Fold in the following extensions/RFC: RFC 5530 (IMAP Response 6520 Codes, done), UIDPLUS (done), ENABLE (done), ESEARCH (done), 6521 SPECIAL-USE (list of new mailbox attributes is done), LITERAL- 6522 (done), NAMESPACE (done), SASL-IR (done), IDLE (done), MOVE 6523 (done). 6525 2. Add CLOSED response code (from CONDSTORE) - done 6527 3. Add support for $MDNSent and $Forwarded IMAP keywords - done. 6528 Add more examples showing their use? Also add other keywords 6529 like $Phishing, $Junk, $NonJunk? 6531 4. Require all unsolicited FETCH updates to include UID - done. 6533 5. Update recommendations on TLS ciphers to match UTA WG work (as 6534 per RFC 8314, RFC 7525 and RFC 7817) - done. 6536 6. Possibly fold in the following extensions/RFC: Base LIST- 6537 EXTENDED syntax plus deprecate LSUB (replace it with LIST 6538 \Subscribed) minus the requirement to support multiple list 6539 patterns, STATUS-in-LIST, SEARCHRES, BINARY (only the FETCH 6540 changes on leaf body part and make APPEND related ones optional. 6541 See the mailing list discussion) - done. 6543 6. 6545 7. Add STATUS SIZE (total mailbox size) - done. Add STATUS DELETED 6546 (number of messages with \Deleted flag set) - done. 6548 8. Drop UTF-7, all mailboxes are always in UTF-8 - done. 6550 9. Revise IANA registration of IMAP extensions and give advice on 6551 use of "X-" convention. 6553 10. Allow word-based searching (as per Chris Newman)? Need to 6554 discuss header field search, where exact/substring match is 6555 still required for interoperability. 6557 The following changes since RFC 3501 were done so far: 6559 1. Folded in IMAP UNSELECT (RFC 3691), UIDPLUS (RFC 4315), ESEARCH 6560 (RFC 4731), ENABLE (RFC 5161), IDLE (RFC 2177), SASL-IR (RFC 6561 4959) and MOVE (RFC 6851) extensions. Also folded RFC 5530 and 6562 FETCH side of the BINARY extension (RFC 3516). 6564 2. Clarified that server should decode parameter value 6565 continuations as described in [RFC2231]. This requirement was 6566 hidden in RFC 2231 itself. 6568 3. SEARCH command now requires to return ESEARCH response (SEARCH 6569 response is now deprecated). 6571 4. Added CLOSED response code from RFC 7162. 6573 5. Updated to use modern TLS-related recommendations as per RFC 6574 8314, RFC 7817, RFC 7525. 6576 6. For future extensibility extended ABNF for tagged-ext-simple to 6577 allow for bare number64. 6579 7. Added SHOULD level requirement on IMAP servers to support 6580 $MDNSent and $Forwarded keywords. 6582 8. Added STATUS SIZE and STATUS DELETED. 6584 9. Mailbox names and message headers now allow for UTF-8. Support 6585 for Modified UTF-7 in mailbox names is not required, unless 6586 compatibility with IMAP4rev1 is desired. 6588 10. UNSEEN response code on SELECT/EXAMINE is now deprecated. 6590 11. RECENT response on SELECT/EXAMINE, \Recent flag, RECENT STATUS, 6591 SEARCH NEW items are now deprecated. 6593 12. Clarified that the server doesn't need to send a new 6594 PERMANENTFLAGS response code when a new keyword was successfully 6595 added and the server advertised \* earlier for the same mailbox. 6597 13. Removed the CHECK command. Clients should use NOOP instead. 6599 14. RFC822, RFC822.HEADER and RFC822.TEXT FETCH data items were 6600 deprecated. Clients should use the corresponding BODY[] 6601 variants instead. 6603 15. Replaced DIGEST-MD5 SASL mechanism with SCRAM-SHA-256. DIGEST- 6604 MD5 was deprecated. 6606 16. LSUB command was deprecated. Clients should use LIST 6607 (SUBSCRIBED) instead. 6609 17. resp-text ABNF non terminal was updated to allow for empty text. 6611 18. IDLE command can now return no mailbox related updates. 6613 Appendix D. Acknowledgement 6615 Earlier versions of this document were edited by Mark Crispin. 6616 Sadly, he is no longer available to help with this work. Editors of 6617 this revisions are hoping that Mark would have approved. 6619 Chris Newman has contributed text on I18N and use of UTF-8 in 6620 messages and mailbox names. 6622 Thank you to Tony Hansen for helping with the index generation. 6623 Thank you to Timo Sirainen, Bron Gondwana and Arnt Gulbrandsen for 6624 extensive feedback. 6626 This document incorporate text from RFC 4315 (by Mark Crispin), RFC 6627 4466 (by Cyrus Daboo), RFC 4731 (by Dave Cridland), RFC 5161 (by Arnt 6628 Gulbrandsen), RFC 5530 (by Arnt Gulbrandsen), RFC 6154 (by Jamie 6629 Nicolson) 6631 so work done by authors/editors of these documents is appreciated. 6633 Index 6635 $ 6636 $Forwarded (predefined flag) 12 6637 $MDNSent (predefined flag) 12 6639 + 6640 +FLAGS 81 6641 +FLAGS.SILENT 81 6643 - 6644 -FLAGS 81 6645 -FLAGS.SILENT 81 6647 A 6648 ALERT (response code) 88 6649 ALL (fetch item) 77 6650 ALL (search key) 73 6651 ALL (search result option) 72 6652 ALREADYEXISTS (response code) 88 6653 ANSWERED (search key) 73 6654 APPEND (command) 64 6655 APPENDUID (response code) 89 6656 AUTHENTICATE (command) 28 6657 AUTHENTICATIONFAILED (response code) 89 6658 AUTHORIZATIONFAILED (response code) 90 6660 B 6661 BAD (response) 97 6662 BADCHARSET (response code) 90 6663 BCC (search key) 74 6664 BEFORE (search key) 74 6665 BINARY.PEEK[]<> (fetch item) 78 6666 BINARY.SIZE[] (fetch item) 78 6667 BINARY.SIZE[] (fetch result) 107 6668 BINARY[]<> (fetch result) 106 6669 BINARY[]<> (fetch item) 77 6670 BODY (fetch item) 78 6671 BODY (fetch result) 107 6672 BODY (search key) 74 6673 BODY.PEEK[
]<> (fetch item) 80 6674 BODYSTRUCTURE (fetch item) 80 6675 BODYSTRUCTURE (fetch result) 108 6676 BODY[
]<> (fetch result) 107 6677 BODY[
]<> (fetch item) 78 6678 BYE (response) 98 6679 Body Structure (message attribute) 13 6681 C 6682 CANNOT (response code) 90 6683 CAPABILITY (command) 24 6684 CAPABILITY (response code) 90 6685 CAPABILITY (response) 99 6686 CC (search key) 74 6687 CLIENTBUG (response code) 90 6688 CLOSE (command) 69 6689 CLOSED (response code) 91 6690 CONTACTADMIN (response code) 91 6691 COPY (command) 82 6692 COPYUID (response code) 91 6693 CORRUPTION (response code) 92 6694 COUNT (search result option) 72 6695 CREATE (command) 36 6697 D 6698 DELETE (command) 37 6699 DELETED (search key) 74 6700 DELETED (status item) 64 6701 DRAFT (search key) 74 6703 E 6704 ENABLE (command) 32 6705 ENVELOPE (fetch item) 80 6706 ENVELOPE (fetch result) 110 6707 ESEARCH (response) 104 6708 EXAMINE (command) 35 6709 EXPIRED (response code) 92 6710 EXPUNGE (command) 70 6711 EXPUNGE (response) 105 6712 EXPUNGEISSUED (response code) 92 6713 Envelope Structure (message attribute) 13 6715 F 6716 FAST (fetch item) 77 6717 FETCH (command) 77 6718 FETCH (response) 106 6719 FLAGGED (search key) 74 6720 FLAGS (fetch item) 80 6721 FLAGS (fetch result) 111 6722 FLAGS (response) 104 6723 FLAGS (store command data item) 81 6724 FLAGS.SILENT (store command data item) 81 6725 FROM (search key) 74 6726 FULL (fetch item) 77 6727 Flags (message attribute) 11 6729 H 6730 HEADER (part specifier) 78 6731 HEADER (search key) 74 6732 HEADER.FIELDS (part specifier) 78 6733 HEADER.FIELDS.NOT (part specifier) 78 6735 I 6736 IDLE (command) 67 6737 INTERNALDATE (fetch item) 80 6738 INTERNALDATE (fetch result) 111 6739 INUSE (response code) 92 6740 Internal Date (message attribute) 12 6742 K 6743 KEYWORD (search key) 74 6744 Keyword (type of flag) 12 6746 L 6747 LARGER (search key) 74 6748 LIMIT (response code) 93 6749 LIST (command) 41 6750 LIST (response) 100 6751 LOGOUT (command) 26 6753 M 6754 MAX (search result option) 72 6755 MAY (specification requirement term) 5 6756 MESSAGES (status item) 64 6757 MIME (part specifier) 79 6758 MIN (search result option) 72 6759 MOVE (command) 83 6760 MUST (specification requirement term) 5 6761 MUST NOT (specification requirement term) 5 6762 Message Sequence Number (message attribute) 11 6764 N 6765 NAMESPACE (command) 58 6766 NAMESPACE (response) 103 6767 NO (response) 96 6768 NONEXISTENT (response code) 93 6769 NOOP (command) 25 6770 NOPERM (response code) 93 6771 NOT (search key) 74 6772 NOT RECOMMENDED (specification requirement term) 5 6774 O 6775 OK (response) 96 6776 ON (search key) 74 6777 OPTIONAL (specification requirement term) 5 6778 OR (search key) 74 6779 OVERQUOTA (response code) 93 6781 P 6782 PARSE (response code) 94 6783 PERMANENTFLAGS (response code) 94 6784 PREAUTH (response) 97 6785 PRIVACYREQUIRED (response code) 94 6786 Permanent Flag (class of flag) 12 6787 Predefined keywords 12 6789 R 6790 READ-ONLY (response code) 94 6791 READ-WRITE (response code) 95 6792 RECOMMENDED (specification requirement term) 5 6793 RENAME (command) 39 6794 REQUIRED (specification requirement term) 5 6795 RFC822.SIZE (fetch item) 80 6796 RFC822.SIZE (fetch result) 112 6798 S 6799 SEARCH (command) 71 6800 SEEN (search key) 75 6801 SELECT (command) 34 6802 SENTBEFORE (search key) 75 6803 SENTON (search key) 75 6804 SENTSINCE (search key) 75 6805 SERVERBUG (response code) 95 6806 SHOULD (specification requirement term) 5 6807 SHOULD NOT (specification requirement term) 5 6808 SINCE (search key) 75 6809 SIZE (status item) 64 6810 SMALLER (search key) 75 6811 STARTTLS (command) 27 6812 STATUS (command) 63 6813 STATUS (response) 103 6814 STORE (command) 81 6815 SUBJECT (search key) 75 6816 SUBSCRIBE (command) 40 6817 Session Flag (class of flag) 12 6818 System Flag (type of flag) 11 6820 T 6821 TEXT (part specifier) 78 6822 TEXT (search key) 75 6823 TO (search key) 75 6824 TRYCREATE (response code) 95 6826 U 6827 UID (command) 85 6828 UID (fetch item) 80 6829 UID (fetch result) 112 6830 UID (search key) 75 6831 UIDNEXT (response code) 95 6832 UIDNEXT (status item) 64 6833 UIDNOTSTICKY (response code) 95 6834 UIDVALIDITY (response code) 95 6835 UIDVALIDITY (status item) 64 6836 UNANSWERED (search key) 75 6837 UNAVAILABLE (response code) 96 6838 UNDELETED (search key) 75 6839 UNDRAFT (search key) 75 6840 UNFLAGGED (search key) 75 6841 UNKEYWORD (search key) 75 6842 UNKNOWN-CTE (response code) 96 6843 UNSEEN (search key) 75 6844 UNSEEN (status item) 64 6845 UNSELECT (command) 70 6846 UNSUBSCRIBE (command) 41 6847 Unique Identifier (UID) (message attribute) 9 6849 X 6850 X (command) 86 6852 [ 6853 [RFC-5322] Size (message attribute) 13 6855 \ 6856 \All (mailbox name attribute) 101 6857 \Answered (system flag) 11 6858 \Archive (mailbox name attribute) 102 6859 \Deleted (system flag) 12 6860 \Draft (system flag) 12 6861 \Drafts (mailbox name attribute) 102 6862 \Flagged (mailbox name attribute) 102 6863 \Flagged (system flag) 11 6864 \HasChildren (mailbox name attribute) 100 6865 \HasNoChildren (mailbox name attribute) 101 6866 \Junk (mailbox name attribute) 102 6867 \Marked (mailbox name attribute) 101 6868 \Noinferiors (mailbox name attribute) 100 6869 \NonExistent (mailbox name attribute) 100 6870 \Noselect (mailbox name attribute) 100 6871 \Recent (system flag) 12 6872 \Remote (mailbox name attribute) 101 6873 \Seen (system flag) 11 6874 \Sent (mailbox name attribute) 102 6875 \Subscribed (mailbox name attribute) 101 6876 \Trash (mailbox name attribute) 102 6877 \Unmarked (mailbox name attribute) 101 6879 Authors' Addresses 6881 Alexey Melnikov (editor) 6882 Isode Ltd 6883 14 Castle Mews 6884 Hampton, Middlesex TW12 2NP 6885 UK 6887 Email: Alexey.Melnikov@isode.com 6889 Barry Leiba (editor) 6890 Huawei Technologies 6892 Phone: +1 646 827 0648 6893 Email: barryleiba@computer.org 6894 URI: http://internetmessagingtechnology.org/