idnits 2.17.1 draft-ietf-extra-imap4rev2-10.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The document seems to lack an Introduction section. ** There is 1 instance of too long lines in the document, the longest one being 1 character 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 26, 2019) is 1613 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 6458, but not defined == Missing Reference: 'IMAP-OBSOLETE' is mentioned on line 6453, but not defined == Missing Reference: 'IMAP-COMPAT' is mentioned on line 6443, but not defined == Missing Reference: 'IMAP-HISTORICAL' is mentioned on line 6448, but not defined == Missing Reference: 'RFC-822' is mentioned on line 6462, but not defined ** Obsolete undefined reference: RFC 822 (Obsoleted by RFC 2822) == Missing Reference: 'HEADER' is mentioned on line 5290, but not defined == Missing Reference: 'IMAP-DISC' is mentioned on line 6400, but not defined == Missing Reference: 'SMTP' is mentioned on line 6421, but not defined == Missing Reference: 'RFC7888' is mentioned on line 6396, but not defined -- Looks like a reference, but probably isn't: '1' on line 842 == Missing Reference: 'IMAP-URL' is mentioned on line 6435, but not defined == Missing Reference: 'UIDVALIDITY 3857529045' is mentioned on line 5273, but not defined == Missing Reference: 'UIDNEXT 4392' is mentioned on line 1667, but not defined == Missing Reference: 'RFC5258' is mentioned on line 6382, but not defined == Missing Reference: 'RFC2193' is mentioned on line 6387, but not defined == Missing Reference: 'RFC3348' is mentioned on line 6391, but not defined ** Obsolete undefined reference: RFC 3348 (Obsoleted by RFC 5258) == Missing Reference: 'RFC4314' is mentioned on line 6428, but not defined == Missing Reference: 'UIDNEXT 2' is mentioned on line 3127, but not defined == Missing Reference: 'UIDVALIDITY 1' is mentioned on line 3198, but not defined == Missing Reference: 'IMAP-I18N' is mentioned on line 6405, but not defined == Missing Reference: 'UID' is mentioned on line 3888, but not defined == Missing Reference: 'RFC2087' is mentioned on line 6432, but not defined ** Obsolete undefined reference: RFC 2087 (Obsoleted by RFC 9208) == Missing Reference: 'READ-WRITE' is mentioned on line 5274, but not defined == Missing Reference: 'RFC4422' is mentioned on line 5610, but not defined == Missing Reference: 'IMAP4' is mentioned on line 5696, but not defined == Missing Reference: 'Namespace-Response-Extensions' is mentioned on line 5762, but not defined == Missing Reference: 'IMAP-TLS' is mentioned on line 6466, but not defined == Missing Reference: 'IMAP-MODEL' is mentioned on line 6411, but not defined == Missing Reference: 'IMAP-UTF-8' is mentioned on line 6485, but not defined == Missing Reference: 'RFC3516' is mentioned on line 6576, 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 29, 2020 November 26, 2019 8 INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev2 9 draft-ietf-extra-imap4rev2-10 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 29, 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 . . . . . . . . . . . . . . . . . . . 36 128 6.3.4. CREATE Command . . . . . . . . . . . . . . . . . . . 37 129 6.3.5. DELETE Command . . . . . . . . . . . . . . . . . . . 38 130 6.3.6. RENAME Command . . . . . . . . . . . . . . . . . . . 39 131 6.3.7. SUBSCRIBE Command . . . . . . . . . . . . . . . . . . 41 132 6.3.8. UNSUBSCRIBE Command . . . . . . . . . . . . . . . . . 42 133 6.3.9. LIST Command . . . . . . . . . . . . . . . . . . . . 42 134 6.3.10. NAMESPACE Command . . . . . . . . . . . . . . . . . . 60 135 6.3.11. STATUS Command . . . . . . . . . . . . . . . . . . . 65 136 6.3.12. APPEND Command . . . . . . . . . . . . . . . . . . . 66 137 6.3.13. IDLE Command . . . . . . . . . . . . . . . . . . . . 69 138 6.4. Client Commands - Selected State . . . . . . . . . . . . 71 139 6.4.1. CLOSE Command . . . . . . . . . . . . . . . . . . . . 71 140 6.4.2. UNSELECT Command . . . . . . . . . . . . . . . . . . 72 141 6.4.3. EXPUNGE Command . . . . . . . . . . . . . . . . . . . 72 142 6.4.4. SEARCH Command . . . . . . . . . . . . . . . . . . . 73 143 6.4.5. FETCH Command . . . . . . . . . . . . . . . . . . . . 79 144 6.4.6. STORE Command . . . . . . . . . . . . . . . . . . . . 83 145 6.4.7. COPY Command . . . . . . . . . . . . . . . . . . . . 84 146 6.4.8. MOVE Command . . . . . . . . . . . . . . . . . . . . 85 147 6.4.9. UID Command . . . . . . . . . . . . . . . . . . . . . 87 148 6.5. Client Commands - Experimental/Expansion . . . . . . . . 88 149 6.5.1. X Command . . . . . . . . . . . . . . . . . . . 88 150 7. Server Responses . . . . . . . . . . . . . . . . . . . . . . 89 151 7.1. Server Responses - Status Responses . . . . . . . . . . . 90 152 7.1.1. OK Response . . . . . . . . . . . . . . . . . . . . . 98 153 7.1.2. NO Response . . . . . . . . . . . . . . . . . . . . . 98 154 7.1.3. BAD Response . . . . . . . . . . . . . . . . . . . . 99 155 7.1.4. PREAUTH Response . . . . . . . . . . . . . . . . . . 99 156 7.1.5. BYE Response . . . . . . . . . . . . . . . . . . . . 100 157 7.2. Server Responses - Server and Mailbox Status . . . . . . 100 158 7.2.1. The ENABLED Response . . . . . . . . . . . . . . . . 100 159 7.2.2. CAPABILITY Response . . . . . . . . . . . . . . . . . 101 160 7.2.3. LIST Response . . . . . . . . . . . . . . . . . . . . 102 161 7.2.4. NAMESPACE Response . . . . . . . . . . . . . . . . . 105 162 7.2.5. STATUS Response . . . . . . . . . . . . . . . . . . . 105 163 7.2.6. ESEARCH Response . . . . . . . . . . . . . . . . . . 106 164 7.2.7. FLAGS Response . . . . . . . . . . . . . . . . . . . 106 165 7.3. Server Responses - Mailbox Size . . . . . . . . . . . . . 107 166 7.3.1. EXISTS Response . . . . . . . . . . . . . . . . . . . 107 167 7.4. Server Responses - Message Status . . . . . . . . . . . . 107 168 7.4.1. EXPUNGE Response . . . . . . . . . . . . . . . . . . 107 169 7.4.2. FETCH Response . . . . . . . . . . . . . . . . . . . 108 170 7.5. Server Responses - Command Continuation Request . . . . . 114 171 8. Sample IMAP4rev2 connection . . . . . . . . . . . . . . . . . 114 172 9. Formal Syntax . . . . . . . . . . . . . . . . . . . . . . . . 115 173 10. Author's Note . . . . . . . . . . . . . . . . . . . . . . . . 132 174 11. Security Considerations . . . . . . . . . . . . . . . . . . . 132 175 11.1. STARTTLS Security Considerations . . . . . . . . . . . . 132 176 11.2. COPYUID and APPENDUID response codes . . . . . . . . . . 133 177 11.3. LIST command and Other Users' namespace . . . . . . . . 133 178 11.4. Other Security Considerations . . . . . . . . . . . . . 133 179 12. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 134 180 12.1. Updates to IMAP4 Capabilities registry . . . . . . . . . 134 181 12.2. GSSAPI/SASL service name . . . . . . . . . . . . . . . . 135 182 13. References . . . . . . . . . . . . . . . . . . . . . . . . . 135 183 13.1. Normative References . . . . . . . . . . . . . . . . . . 135 184 13.2. Informative References (related protocols) . . . . . . . 138 185 13.3. Informative References (historical aspects of IMAP and 186 related protocols) . . . . . . . . . . . . . . . . . . . 139 187 Appendix A. Backward compatibility with IMAP4rev1 . . . . . . . 140 188 A.1. Mailbox International Naming Convention for compatibility 189 with IMAP4rev1 . . . . . . . . . . . . . . . . . . . . . 140 190 Appendix B. Backward compatibility with BINARY extension . . . . 142 191 Appendix C. Changes from RFC 3501 / IMAP4rev1 . . . . . . . . . 142 192 Appendix D. Acknowledgement . . . . . . . . . . . . . . . . . . 144 193 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 194 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 150 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 Example: C: A142 SELECT INBOX 1621 S: * 172 EXISTS 1622 S: * OK [UIDVALIDITY 3857529045] UIDs valid 1623 S: * OK [UIDNEXT 4392] Predicted next UID 1624 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1625 S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited 1626 S: A142 OK [READ-WRITE] SELECT completed 1627 [...some time later...] 1628 C: A143 SELECT Drafts 1629 S: * OK [CLOSED] Previous mailbox is now closed 1630 S: * 5 EXISTS 1631 S: * OK [UIDVALIDITY 9877410381] UIDs valid 1632 S: * OK [UIDNEXT 102] Predicted next UID 1633 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1634 S: * OK [PERMANENTFLAGS (\Deleted \Seen \Answered 1635 \Flagged \Draft \*)] System flags and keywords allowed 1636 S: A143 OK [READ-WRITE] SELECT completed 1638 Note that IMAP4rev1 compliant servers can also send the untagged 1639 RECENT response which was depractated in IMAP4rev2. E.g. "* 0 1640 RECENT". Pure IMAP4rev2 clients are advised to ignore the untagged 1641 RECENT response. 1643 6.3.3. EXAMINE Command 1645 Arguments: mailbox name 1647 Responses: REQUIRED untagged responses: FLAGS, EXISTS 1648 REQUIRED OK untagged responses: PERMANENTFLAGS, 1649 UIDNEXT, UIDVALIDITY 1651 Result: OK - examine completed, now in selected state 1652 NO - examine failure, now in authenticated state: no 1653 such mailbox, can't access mailbox BAD - command unknown 1654 or arguments invalid 1656 The EXAMINE command is identical to SELECT and returns the same 1657 output; however, the selected mailbox is identified as read-only. No 1658 changes to the permanent state of the mailbox, including per-user 1659 state, are permitted. 1661 The text of the tagged OK response to the EXAMINE command MUST begin 1662 with the "[READ-ONLY]" response code. 1664 Example: C: A932 EXAMINE blurdybloop 1665 S: * 17 EXISTS 1666 S: * OK [UIDVALIDITY 3857529045] UIDs valid 1667 S: * OK [UIDNEXT 4392] Predicted next UID 1668 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1669 S: * OK [PERMANENTFLAGS ()] No permanent flags permitted 1670 S: A932 OK [READ-ONLY] EXAMINE completed 1672 6.3.4. CREATE Command 1674 Arguments: mailbox name 1676 Responses: no specific responses for this command 1678 Result: OK - create completed 1679 NO - create failure: can't create mailbox with that name 1680 BAD - command unknown or arguments invalid 1682 The CREATE command creates a mailbox with the given name. An OK 1683 response is returned only if a new mailbox with that name has been 1684 created. It is an error to attempt to create INBOX or a mailbox with 1685 a name that refers to an extant mailbox. Any error in creation will 1686 return a tagged NO response. If a client attempts to create a UTF-8 1687 mailbox name that is not a valid Net-Unicode name, the server MUST 1688 reject the creation or convert the name to Net-Unicode prior to 1689 creating the mailbox. 1691 If the mailbox name is suffixed with the server's hierarchy separator 1692 character (as returned from the server by a LIST command), this is a 1693 declaration that the client intends to create mailbox names under 1694 this name in the hierarchy. Server implementations that do not 1695 require this declaration MUST ignore the declaration. In any case, 1696 the name created is without the trailing hierarchy delimiter. 1698 If the server's hierarchy separator character appears elsewhere in 1699 the name, the server SHOULD create any superior hierarchical names 1700 that are needed for the CREATE command to be successfully completed. 1701 In other words, an attempt to create "foo/bar/zap" on a server in 1702 which "/" is the hierarchy separator character SHOULD create foo/ and 1703 foo/bar/ if they do not already exist. 1705 If a new mailbox is created with the same name as a mailbox which was 1706 deleted, its unique identifiers MUST be greater than any unique 1707 identifiers used in the previous incarnation of the mailbox UNLESS 1708 the new incarnation has a different unique identifier validity value. 1709 See the description of the UID command for more detail. 1711 Example: C: A003 CREATE owatagusiam/ 1712 S: A003 OK CREATE completed 1713 C: A004 CREATE owatagusiam/blurdybloop 1714 S: A004 OK CREATE completed 1716 Note: The interpretation of this example depends on whether "/" 1717 was returned as the hierarchy separator from LIST. If "/" is the 1718 hierarchy separator, a new level of hierarchy named "owatagusiam" 1719 with a member called "blurdybloop" is created. Otherwise, two 1720 mailboxes at the same hierarchy level are created. 1722 6.3.5. DELETE Command 1724 Arguments: mailbox name 1726 Responses: no specific responses for this command 1728 Result: OK - delete completed 1729 NO - delete failure: can't delete mailbox with that name 1730 BAD - command unknown or arguments invalid 1732 The DELETE command permanently removes the mailbox with the given 1733 name. A tagged OK response is returned only if the mailbox has been 1734 deleted. It is an error to attempt to delete INBOX or a mailbox name 1735 that does not exist. 1737 The DELETE command MUST NOT remove inferior hierarchical names. For 1738 example, if a mailbox "foo" has an inferior "foo.bar" (assuming "." 1739 is the hierarchy delimiter character), removing "foo" MUST NOT remove 1740 "foo.bar". It is an error to attempt to delete a name that has 1741 inferior hierarchical names and also has the \Noselect mailbox name 1742 attribute (see the description of the LIST response for more 1743 details). 1745 It is permitted to delete a name that has inferior hierarchical names 1746 and does not have the \Noselect mailbox name attribute. If the 1747 server implementation does not permit deleting the name while 1748 inferior hierarchical names exists the \Noselect mailbox name 1749 attribute is set for that name. In any case, all messages in that 1750 mailbox are removed by the DELETE command. 1752 The value of the highest-used unique identifier of the deleted 1753 mailbox MUST be preserved so that a new mailbox created with the same 1754 name will not reuse the identifiers of the former incarnation, UNLESS 1755 the new incarnation has a different unique identifier validity value. 1756 See the description of the UID command for more detail. 1758 Examples: C: A682 LIST "" * 1759 S: * LIST () "/" blurdybloop 1760 S: * LIST (\Noselect) "/" foo 1761 S: * LIST () "/" foo/bar 1762 S: A682 OK LIST completed 1763 C: A683 DELETE blurdybloop 1764 S: A683 OK DELETE completed 1765 C: A684 DELETE foo 1766 S: A684 NO Name "foo" has inferior hierarchical names 1767 C: A685 DELETE foo/bar 1768 S: A685 OK DELETE Completed 1769 C: A686 LIST "" * 1770 S: * LIST (\Noselect) "/" foo 1771 S: A686 OK LIST completed 1772 C: A687 DELETE foo 1773 S: A687 OK DELETE Completed 1774 C: A82 LIST "" * 1775 S: * LIST () "." blurdybloop 1776 S: * LIST () "." foo 1777 S: * LIST () "." foo.bar 1778 S: A82 OK LIST completed 1779 C: A83 DELETE blurdybloop 1780 S: A83 OK DELETE completed 1781 C: A84 DELETE foo 1782 S: A84 OK DELETE Completed 1783 C: A85 LIST "" * 1784 S: * LIST () "." foo.bar 1785 S: A85 OK LIST completed 1786 C: A86 LIST "" % 1787 S: * LIST (\Noselect) "." foo 1788 S: A86 OK LIST completed 1790 6.3.6. RENAME Command 1792 Arguments: existing mailbox name 1793 new mailbox name 1795 Responses: no specific responses for this command 1797 Result: OK - rename completed 1798 NO - rename failure: can't rename mailbox with that name, 1799 can't rename to mailbox with that name 1800 BAD - command unknown or arguments invalid 1802 The RENAME command changes the name of a mailbox. A tagged OK 1803 response is returned only if the mailbox has been renamed. It is an 1804 error to attempt to rename from a mailbox name that does not exist or 1805 to a mailbox name that already exists. Any error in renaming will 1806 return a tagged NO response. 1808 If the name has inferior hierarchical names, then the inferior 1809 hierarchical names MUST also be renamed. For example, a rename of 1810 "foo" to "zap" will rename "foo/bar" (assuming "/" is the hierarchy 1811 delimiter character) to "zap/bar". 1813 If the server's hierarchy separator character appears in the name, 1814 the server SHOULD create any superior hierarchical names that are 1815 needed for the RENAME command to complete successfully. In other 1816 words, an attempt to rename "foo/bar/zap" to baz/rag/zowie on a 1818 server in which "/" is the hierarchy separator character SHOULD 1819 create baz/ and baz/rag/ if they do not already exist. 1821 The value of the highest-used unique identifier of the old mailbox 1822 name MUST be preserved so that a new mailbox created with the same 1823 name will not reuse the identifiers of the former incarnation, UNLESS 1824 the new incarnation has a different unique identifier validity value. 1825 See the description of the UID command for more detail. 1827 Renaming INBOX is permitted, and has special behavior. (Note that 1828 some servers refuse renaming INBOX). It moves all messages in INBOX 1829 to a new mailbox with the given name, leaving INBOX empty. If the 1830 server implementation supports inferior hierarchical names of INBOX, 1831 these are unaffected by a rename of INBOX. 1833 Examples: C: A682 LIST "" * 1834 S: * LIST () "/" blurdybloop 1835 S: * LIST (\Noselect) "/" foo 1836 S: * LIST () "/" foo/bar 1837 S: A682 OK LIST completed 1838 C: A683 RENAME blurdybloop sarasoop 1839 S: A683 OK RENAME completed 1840 C: A684 RENAME foo zowie 1841 S: A684 OK RENAME Completed 1842 C: A685 LIST "" * 1843 S: * LIST () "/" sarasoop 1844 S: * LIST (\Noselect) "/" zowie 1845 S: * LIST () "/" zowie/bar 1846 S: A685 OK LIST completed 1848 C: Z432 LIST "" * 1849 S: * LIST () "." INBOX 1850 S: * LIST () "." INBOX.bar 1851 S: Z432 OK LIST completed 1852 C: Z433 RENAME INBOX old-mail 1853 S: Z433 OK RENAME completed 1854 C: Z434 LIST "" * 1855 S: * LIST () "." INBOX 1856 S: * LIST () "." INBOX.bar 1857 S: * LIST () "." old-mail 1858 S: Z434 OK LIST completed 1860 Note that renaming a mailbox doesn't update subscription information 1861 on the original name. To keep subscription information in sync, the 1862 following sequence of commands can be used: 1864 C: 1001 RENAME X Y 1865 C: 1002 SUBSCRIBE Y 1866 C: 1003 UNSUBSCRIBE X 1868 Note that the above sequence of commands doesn't account for updating 1869 subscription for any children mailboxes of mailbox X. 1871 6.3.7. SUBSCRIBE Command 1873 Arguments: mailbox 1875 Responses: no specific responses for this command 1877 Result: OK - subscribe completed 1878 NO - subscribe failure: can't subscribe to that name 1879 BAD - command unknown or arguments invalid 1881 The SUBSCRIBE command adds the specified mailbox name to the server's 1882 set of "active" or "subscribed" mailboxes as returned by the LIST 1883 (SUBSCRIBED) command. This command returns a tagged OK response only 1884 if the subscription is successful. 1886 A server MAY validate the mailbox argument to SUBSCRIBE to verify 1887 that it exists. However, it MUST NOT unilaterally remove an existing 1888 mailbox name from the subscription list even if a mailbox by that 1889 name no longer exists. 1891 Note: This requirement is because a server site can choose to 1892 routinely remove a mailbox with a well-known name (e.g., "system- 1893 alerts") after its contents expire, with the intention of 1894 recreating it when new contents are appropriate. 1896 Example: C: A002 SUBSCRIBE #news.comp.mail.mime 1897 S: A002 OK SUBSCRIBE completed 1899 6.3.8. UNSUBSCRIBE Command 1901 Arguments: mailbox name 1903 Responses: no specific responses for this command 1905 Result: OK - unsubscribe completed 1906 NO - unsubscribe failure: can't unsubscribe that name 1907 BAD - command unknown or arguments invalid 1909 The UNSUBSCRIBE command removes the specified mailbox name from the 1910 server's set of "active" or "subscribed" mailboxes as returned by the 1911 LIST (SUBSCRIBED) command. This command returns a tagged OK response 1912 only if the unsubscription is successful. 1914 Example: C: A002 UNSUBSCRIBE #news.comp.mail.mime 1915 S: A002 OK UNSUBSCRIBE completed 1917 6.3.9. LIST Command 1919 Arguments (basic): reference name 1920 mailbox name with possible wildcards 1922 Arguments (extended): selection options (OPTIONAL) 1923 reference name 1924 mailbox patterns 1925 return options (OPTIONAL) 1927 Responses: untagged responses: LIST 1928 Result: OK - list completed 1929 NO - list failure: can't list that reference or name 1930 BAD - command unknown or arguments invalid 1932 The LIST command returns a subset of names from the complete set of 1933 all names available to the client. Zero or more untagged LIST 1934 replies are returned, containing the name attributes, hierarchy 1935 delimiter, name, and possible extension information; see the 1936 description of the LIST reply for more detail. 1938 The LIST command SHOULD return its data quickly, without undue delay. 1939 For example, it SHOULD NOT go to excess trouble to calculate the 1940 \Marked or \Unmarked status or perform other processing; if each name 1941 requires 1 second of processing, then a list of 1200 names would take 1942 20 minutes! 1944 The extended LIST command, originally introduced in [RFC5258], 1945 provides capabilities beyond that of the original IMAP LIST command. 1946 The extended syntax is being used if one or more of the following 1947 conditions is true: 1949 1. if the first word after the command name begins with a 1950 parenthesis ("LIST selection options") 1952 2. if the second word after the command name begins with a 1953 parenthesis ("multiple mailbox patterns") 1955 3. if the LIST command has more than 2 parameters ("LIST return 1956 options") 1958 An empty ("" string) reference name argument indicates that the 1959 mailbox name is interpreted as by SELECT. The returned mailbox names 1960 MUST match the supplied mailbox name pattern(s). A non-empty 1961 reference name argument is the name of a mailbox or a level of 1962 mailbox hierarchy, and indicates the context in which the mailbox 1963 name is interpreted. Clients SHOULD use the empty reference 1964 argument. 1966 In the basic syntax only, an empty ("" string) mailbox name argument 1967 is a special request to return the hierarchy delimiter and the root 1968 name of the name given in the reference. The value returned as the 1969 root MAY be the empty string if the reference is non-rooted or is an 1970 empty string. In all cases, a hierarchy delimiter (or NIL if there 1971 is no hierarchy) is returned. This permits a client to get the 1972 hierarchy delimiter (or find out that the mailbox names are flat) 1973 even when no mailboxes by that name currently exist. 1975 In the extended syntax, any mailbox name arguments that are empty 1976 strings are ignored. There is no special meaning for empty mailbox 1977 names when the extended syntax is used. 1979 The reference and mailbox name arguments are interpreted into a 1980 canonical form that represents an unambiguous left-to-right 1981 hierarchy. The returned mailbox names will be in the interpreted 1982 form, 1984 that we call "canonical LIST pattern" later in this document. To 1985 define the term "canonical LIST pattern" formally: it refers to the 1986 canonical pattern constructed internally by the server from the 1987 reference and mailbox name arguments. 1989 Note: The interpretation of the reference argument is 1990 implementation-defined. It depends upon whether the server 1991 implementation has a concept of the "current working directory" 1992 and leading "break out characters", which override the current 1993 working directory. 1995 For example, on a server which exports a UNIX or NT filesystem, 1996 the reference argument contains the current working directory, and 1997 the mailbox name argument would contain the name as interpreted in 1998 the current working directory. 2000 If a server implementation has no concept of break out characters, 2001 the canonical form is normally the reference name appended with 2002 the mailbox name. Note that if the server implements the 2003 namespace convention (Section 5.1.2.1), "#" is a break out 2004 character and must be treated as such. 2006 If the reference argument is not a level of mailbox hierarchy 2007 (that is, it is a \NoInferiors name), and/or the reference 2008 argument does not end with the hierarchy delimiter, it is 2009 implementation-dependent how this is interpreted. For example, a 2010 reference of "foo/bar" and mailbox name of "rag/baz" could be 2011 interpreted as "foo/bar/rag/baz", "foo/barrag/baz", or "foo/rag/ 2012 baz". A client SHOULD NOT use such a reference argument except at 2013 the explicit request of the user. A hierarchical browser MUST NOT 2014 make any assumptions about server interpretation of the reference 2015 unless the reference is a level of mailbox hierarchy AND ends with 2016 the hierarchy delimiter. 2018 Any part of the reference argument that is included in the 2019 interpreted form SHOULD prefix the interpreted form. It SHOULD also 2020 be in the same form as the reference name argument. This rule 2021 permits the client to determine if the returned mailbox name is in 2022 the context of the reference argument, or if something about the 2023 mailbox argument overrode the reference argument. Without this rule, 2024 the client would have to have knowledge of the server's naming 2025 semantics including what characters are "breakouts" that override a 2026 naming context. 2028 For example, here are some examples of how references 2029 and mailbox names might be interpreted on a UNIX-based 2030 server: 2032 Reference Mailbox Name Interpretation 2033 ------------ ------------ -------------- 2034 ~smith/Mail/ foo.* ~smith/Mail/foo.* 2035 archive/ % archive/% 2036 #news. comp.mail.* #news.comp.mail.* 2037 ~smith/Mail/ /usr/doc/foo /usr/doc/foo 2038 archive/ ~fred/Mail/* ~fred/Mail/* 2040 The first three examples demonstrate interpretations in 2041 the context of the reference argument. Note that 2042 "~smith/Mail" SHOULD NOT be transformed into something 2043 like "/u2/users/smith/Mail", or it would be impossible 2044 for the client to determine that the interpretation was 2045 in the context of the reference. 2047 The character "*" is a wildcard, and matches zero or more characters 2048 at this position. The character "%" is similar to "*", but it does 2049 not match a hierarchy delimiter. If the "%" wildcard is the last 2050 character of a mailbox name argument, matching levels of hierarchy 2051 are also returned. If these levels of hierarchy are not also 2052 selectable mailboxes, they are returned with the \Noselect mailbox 2053 name attribute (see the description of the LIST response for more 2054 details). 2056 If multiple mailbox patterns are used (in the extended syntax), a 2057 mailbox matches if it matches at least one mailbox pattern. If a 2058 mailbox matches more than one pattern, it is still only returned 2059 once. Any syntactically valid pattern that is not accepted by a 2060 server for any reason MUST be silently ignored. 2062 Selection options tell the server to limit the mailbox names that are 2063 selected by the LIST operation. If selection options are used, the 2064 mailboxes returned are those that match both the list of canonical 2065 LIST patterns and the selection options. Unless a particular 2066 selection option provides special rules, the selection options are 2067 cumulative: a mailbox that matches the mailbox patterns is selected 2068 only if it also matches all of the selection options. (An example of 2069 a selection option with special rules is the RECURSIVEMATCH option.) 2070 Return options control what information is returned for each matched 2071 mailbox. Return options MUST NOT cause the server to report 2072 information about additional mailbox names other than those that 2073 match the canonical LIST patterns and selection options. If no 2074 return options are specified, the client is only expecting 2075 information about mailbox attributes. The server MAY return other 2076 information about the matched mailboxes, and clients MUST be able to 2077 handle that situation. 2079 Initial selection options and return options are defined in the 2080 following subsections, and new ones will also be defined in 2081 extensions. Initial options defined in this document MUST be 2082 supported. Each non-initial option will be enabled by a capability 2083 string (one capability may enable multiple options), and a client 2084 MUST NOT send an option for which the server has not advertised 2085 support. A server MUST respond to options it does not recognize with 2086 a BAD response. The client SHOULD NOT specify any option more than 2087 once; however, if the client does this, the server MUST act as if it 2088 received the option only once. The order in which options are 2089 specified by the client is not significant. 2091 In general, each selection option except RECURSIVEMATCH will have a 2092 corresponding return option. The REMOTE selection option is an 2093 anomaly in this regard, and does not have a corresponding return 2094 option. That is because it expands, rather than restricts, the set 2095 of mailboxes that are returned. Future extensions to this 2096 specification should keep parallelism in mind and define a pair of 2097 corresponding options. 2099 Server implementations are permitted to "hide" otherwise accessible 2100 mailboxes from the wildcard characters, by preventing certain 2101 characters or names from matching a wildcard in certain situations. 2102 For example, a UNIX-based server might restrict the interpretation of 2103 "*" so that an initial "/" character does not match. 2105 The special name INBOX is included in the output from LIST, if INBOX 2106 is supported by this server for this user and if the uppercase string 2107 "INBOX" matches the interpreted reference and mailbox name arguments 2108 with wildcards as described above. The criteria for omitting INBOX 2109 is whether SELECT INBOX will return failure; it is not relevant 2110 whether the user's real INBOX resides on this or some other server. 2112 6.3.9.1. LIST Selection Options 2114 The selection options defined in this specification are as follows: 2116 SUBSCRIBED - causes the LIST command to list subscribed names, 2117 rather than the existing mailboxes. This will often be a subset 2118 of the actual mailboxes. It's also possible for this list to 2119 contain the names of mailboxes that don't exist. In any case, the 2120 list MUST include exactly those mailbox names that match the 2121 canonical list pattern and are subscribed to. 2123 SUBSCRIBED - 2125 This option defines a mailbox attribute, "\Subscribed", that 2126 indicates that a mailbox name is subscribed to. The "\Subscribed" 2127 attribute MUST be supported and MUST be accurately computed when 2128 the SUBSCRIBED selection option is specified. 2130 Note that the SUBSCRIBED selection option implies the SUBSCRIBED 2131 return option (see below). 2133 REMOTE - causes the LIST command to show remote mailboxes as well as 2134 local ones, as described in [RFC2193]. This option is intended to 2135 replace the RLIST command and, in conjunction with the SUBSCRIBED 2136 selection option, the RLSUB command. Servers that don't support 2137 remote mailboxes just ignore this option. 2139 This option defines a mailbox attribute, "\Remote", that indicates 2140 that a mailbox is a remote mailbox. The "\Remote" attribute MUST 2141 be accurately computed when the REMOTE option is specified. 2143 The REMOTE selection option has no interaction with other options. 2144 Its effect is to tell the server to apply the other options, if 2145 any, to remote mailboxes, in addition to local ones. In 2146 particular, it has no interaction with RECURSIVEMATCH (see below). 2147 A request for (REMOTE RECURSIVEMATCH) is invalid, because a 2148 request for (RECURSIVEMATCH) is also invalid. A request for 2149 (REMOTE RECURSIVEMATCH SUBSCRIBED) is asking for all subscribed 2150 mailboxes, both local and remote. 2152 RECURSIVEMATCH - this option forces the server to return information 2153 about parent mailboxes that don't match other selection options, 2154 but have some submailboxes that do. Information about children is 2155 returned in the CHILDINFO extended data item, as described in 2156 Section 6.3.9.6. 2158 Note 1: In order for a parent mailbox to be returned, it still has 2159 to match the canonical LIST pattern. 2161 Note 2: When returning the CHILDINFO extended data item, it 2162 doesn't matter whether or not the submailbox matches the canonical 2163 LIST pattern. See also example 9 in Section 6.3.9.7. 2165 The RECURSIVEMATCH option MUST NOT occur as the only selection 2166 option (or only with REMOTE), as it only makes sense when other 2167 selection options are also used. The server MUST return BAD 2168 tagged response in such case. 2170 Note that even if the RECURSIVEMATCH option is specified, the 2171 client MUST still be able to handle a case when a CHILDINFO 2172 extended data item is returned and there are no submailboxes that 2173 meet the selection criteria of the subsequent LIST command, as 2174 they can be deleted/renamed after the LIST response was sent, but 2175 before the client had a chance to access them. 2177 6.3.9.2. LIST Return Options 2179 The return options defined in this specification are as follows: 2181 SUBSCRIBED - causes the LIST command to return subscription state 2182 for all matching mailbox names. The "\Subscribed" attribute MUST 2183 be supported and MUST be accurately computed when the SUBSCRIBED 2184 return option is specified. Further, all mailbox flags MUST be 2185 accurately computed (this differs from the behavior of the 2186 obsolete LSUB command from IMAP4rev1). 2188 CHILDREN - requests mailbox child information as originally proposed 2189 in [RFC3348]. See Section 6.3.9.5, below, for details. 2191 CHILDREN - This option MUST be supported by all servers. 2193 STATUS - requests STATUS response for each matching mailbox. 2195 This option takes STATUS data items as parameters. For each 2196 selectable mailbox matching the list pattern and selection 2197 options, the server MUST return an untagged LIST response 2198 followed by an untagged STATUS response containing the 2199 information requested in the STATUS return option. 2201 If an attempted STATUS for a listed mailbox fails because the 2202 mailbox can't be selected (e.g., if the "l" ACL right [RFC4314] 2203 is granted to the mailbox and the "r" right is not granted, or 2204 due to a race condition between LIST and STATUS changing the 2205 mailbox to \NoSelect), the STATUS response MUST NOT be returned 2206 and the LIST response MUST include the \NoSelect attribute. 2207 This means the server may have to buffer the LIST reply until 2208 it has successfully looked up the necessary STATUS information. 2210 If the server runs into unexpected problems while trying to 2211 look up the STATUS information, it MAY drop the corresponding 2212 STATUS reply. In such a situation, the LIST command would 2213 still return a tagged OK reply. 2215 6.3.9.3. General Principles for Returning LIST Responses 2217 This section outlines several principles that can be used by server 2218 implementations of this document to decide whether a LIST response 2219 should be returned, as well as how many responses and what kind of 2220 information they may contain. 2222 1. At most one LIST response should be returned for each mailbox 2223 name that matches the canonical LIST pattern. Server 2224 implementors must not assume that clients will be able to 2225 assemble mailbox attributes and other information returned in 2226 multiple LIST responses. 2228 2. There are only two reasons for including a matching mailbox name 2229 in the responses to the LIST command (note that the server is 2230 allowed to return unsolicited responses at any time, and such 2231 responses are not governed by this rule): 2233 A. The mailbox name also satisfies the selection criteria. 2235 B. The mailbox name doesn't satisfy the selection criteria, but 2236 it has at least one descendant mailbox name that satisfies 2237 the selection criteria and that doesn't match the canonical 2238 LIST pattern. 2240 For more information on this case, see the CHILDINFO extended 2241 data item described in Section 6.3.9.6. Note that the 2242 CHILDINFO extended data item can only be returned when the 2243 RECURSIVEMATCH selection option is specified. 2245 3. Attributes returned in the same LIST response must be treated 2246 additively. For example, the following response 2248 S: * LIST (\Subscribed \NonExistent) "/" "Fruit/Peach" 2250 means that the "Fruit/Peach" mailbox doesn't exist, but it is 2251 subscribed. 2253 6.3.9.4. Additional LIST-related Requirements on Clients 2255 All clients MUST treat a LIST attribute with a stronger meaning as 2256 implying any attribute that can be inferred from it. (See 2257 Section 7.2.3 for the list of currently defined attributes). For 2258 example, the client must treat the presence of the \NoInferiors 2259 attribute as if the \HasNoChildren attribute was also sent by the 2260 server. 2262 The following table summarizes inference rules. 2264 +--------------------+-------------------+ 2265 | returned attribute | implied attribute | 2266 +--------------------+-------------------+ 2267 | \NoInferiors | \HasNoChildren | 2268 | \NonExistent | \NoSelect | 2269 +--------------------+-------------------+ 2271 6.3.9.5. The CHILDREN Return Option 2273 The CHILDREN return option implements the Child Mailbox Extension, 2274 originally proposed by Mike Gahrns and Raymond Cheng, of Microsoft 2275 Corporation. Most of the information in this section is taken 2276 directly from their original specification [RFC3348]. The CHILDREN 2277 return option is simply an indication that the client wants this 2278 information; a server MAY provide it even if the option is not 2279 specified. 2281 Many IMAP4 clients present to the user a hierarchical view of the 2282 mailboxes that a user has access to. Rather than initially 2283 presenting to the user the entire mailbox hierarchy, it is often 2284 preferable to show to the user a collapsed outline list of the 2285 mailbox hierarchy (particularly if there is a large number of 2286 mailboxes). The user can then expand the collapsed outline hierarchy 2287 as needed. It is common to include within the collapsed hierarchy a 2288 visual clue (such as a ''+'') to indicate that there are child 2289 mailboxes under a particular mailbox. When the visual clue is 2290 clicked, the hierarchy list is expanded to show the child mailboxes. 2291 The CHILDREN return option provides a mechanism for a client to 2292 efficiently determine whether a particular mailbox has children, 2293 without issuing a LIST "" * or a LIST "" % for each mailbox name. 2294 The CHILDREN return option defines two new attributes that MUST be 2295 returned within a LIST response: \HasChildren and \HasNoChildren. 2296 Although these attributes MAY be returned in response to any LIST 2297 command, the CHILDREN return option is provided to indicate that the 2298 client particularly wants this information. If the CHILDREN return 2299 option is present, the server MUST return these attributes even if 2300 their computation is expensive. 2302 \HasChildren 2304 The presence of this attribute indicates that the mailbox has 2305 child mailboxes. A server SHOULD NOT set this attribute if 2306 there are child mailboxes and the user does not have permission 2307 to access any of them. In this case, \HasNoChildren SHOULD be 2308 used. In many cases, however, a server may not be able to 2309 efficiently compute whether a user has access to any child 2310 mailbox. Note that even though the \HasChildren attribute for a 2311 mailbox must be correct at the time of processing of the 2312 mailbox, a client must be prepared to deal with a situation when 2313 a mailbox is marked with the \HasChildren attribute, but no 2314 child mailbox appears in the response to the LIST command. This 2315 might happen, for example, due to children mailboxes being 2316 deleted or made inaccessible to the user (using access control) 2317 by another client before the server is able to list them. 2319 \HasNoChildren 2321 The presence of this attribute indicates that the mailbox has NO 2322 child mailboxes that are accessible to the currently 2323 authenticated user. 2325 It is an error for the server to return both a \HasChildren and a 2326 \HasNoChildren attribute in the same LIST response. 2328 Note: the \HasNoChildren attribute should not be confused with the 2329 the \NoInferiors attribute, which indicates that no child mailboxes 2330 exist now and none can be created in the future. 2332 6.3.9.6. CHILDINFO Extended Data Item 2334 The CHILDINFO extended data item MUST NOT be returned unless the 2335 client has specified the RECURSIVEMATCH selection option. 2337 The CHILDINFO extended data item in a LIST response describes the 2338 selection criteria that has caused it to be returned and indicates 2339 that the mailbox has at least one descendant mailbox that matches the 2340 selection criteria. 2342 Note: Some servers allow for mailboxes to exist without requiring 2343 their parent to exist. For example, a mailbox "Customers/ABC" can 2344 exist while the mailbox "Customers" does not. As CHILDINFO extended 2345 data item is not allowed if the RECURSIVEMATCH selection option is 2346 not specified, such servers SHOULD use the "\NonExistent 2347 \HasChildren" attribute pair to signal to the client that there is a 2348 descendant mailbox that matches the selection criteria. See example 2349 11 in Section 6.3.9.7. 2351 The returned selection criteria allow the client to distinguish a 2352 solicited response from an unsolicited one, as well as to distinguish 2353 among solicited responses caused by multiple pipelined LIST commands 2354 that specify different criteria. 2356 Servers SHOULD ONLY return a non-matching mailbox name along with 2357 CHILDINFO if at least one matching child is not also being returned. 2358 That is, servers SHOULD suppress redundant CHILDINFO responses. 2360 Examples 8 and 10 in Section 6.3.9.7 demonstrate the difference 2361 between present CHILDINFO extended data item and the "\HasChildren" 2362 attribute. 2364 The following table summarizes interaction between the "\NonExistent" 2365 attribute and CHILDINFO (the first column indicates whether the 2366 parent mailbox exists): 2368 +--------+--------------+--------------------+----------------------+ 2369 | exists | meets the | has a child that | returned LIST- | 2370 | | selection | meets the | EXTENDED attributes | 2371 | | criteria | selection criteria | and CHILDINFO | 2372 +--------+--------------+--------------------+----------------------+ 2373 | no | no | no | no LIST response | 2374 | | | | returned | 2375 | yes | no | no | no LIST response | 2376 | | | | returned | 2377 | no | yes | no | (\NonExistent | 2378 | | | | ) | 2379 | yes | yes | no | () | 2380 | no | no | yes | (\NonExistent) + | 2381 | | | | CHILDINFO | 2382 | yes | no | yes | () + CHILDINFO | 2383 | no | yes | yes | (\NonExistent | 2384 | | | | ) + CHILDINFO | 2385 | yes | yes | yes | () + CHILDINFO | 2386 +--------+--------------+--------------------+----------------------+ 2388 where is one or more attributes that correspond to the 2389 selection criteria; for example, for the SUBSCRIBED option the 2390 is \Subscribed. 2392 6.3.9.7. LIST Command Examples 2394 This example shows some uses of the basic LIST command: 2396 Example: C: A101 LIST "" "" 2397 S: * LIST (\Noselect) "/" "" 2398 S: A101 OK LIST Completed 2399 C: A102 LIST #news.comp.mail.misc "" 2400 S: * LIST (\Noselect) "." #news. 2401 S: A102 OK LIST Completed 2402 C: A103 LIST /usr/staff/jones "" 2403 S: * LIST (\Noselect) "/" / 2404 S: A103 OK LIST Completed 2405 C: A202 LIST ~/Mail/ % 2406 S: * LIST (\Noselect) "/" ~/Mail/foo 2407 S: * LIST () "/" ~/Mail/meetings 2408 S: A202 OK LIST completed 2410 Extended examples: 2412 1: The first example shows the complete local hierarchy that will 2413 be used for the other examples. 2415 C: A01 LIST "" "*" 2416 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2417 S: * LIST () "/" "Fruit" 2418 S: * LIST () "/" "Fruit/Apple" 2419 S: * LIST () "/" "Fruit/Banana" 2420 S: * LIST () "/" "Tofu" 2421 S: * LIST () "/" "Vegetable" 2422 S: * LIST () "/" "Vegetable/Broccoli" 2423 S: * LIST () "/" "Vegetable/Corn" 2424 S: A01 OK done 2426 2: In the next example, we will see the subscribed mailboxes. This 2427 is similar to, but not equivalent with, . Note 2428 that the mailbox called "Fruit/Peach" is subscribed to, but does 2429 not actually exist (perhaps it was deleted while still 2430 subscribed). The "Fruit" mailbox is not subscribed to, but it 2431 has two subscribed children. The "Vegetable" mailbox is 2432 subscribed and has two children; one of them is subscribed as 2433 well. 2435 C: A02 LIST (SUBSCRIBED) "" "*" 2436 S: * LIST (\Marked \NoInferiors \Subscribed) "/" "inbox" 2437 S: * LIST (\Subscribed) "/" "Fruit/Banana" 2438 S: * LIST (\Subscribed \NonExistent) "/" "Fruit/Peach" 2439 S: * LIST (\Subscribed) "/" "Vegetable" 2440 S: * LIST (\Subscribed) "/" "Vegetable/Broccoli" 2441 S: A02 OK done 2443 3: The next example shows the use of the CHILDREN option. The 2444 client, without having to list the second level of hierarchy, 2445 now knows which of the top-level mailboxes have submailboxes 2446 (children) and which do not. Note that it's not necessary for 2447 the server to return the \HasNoChildren attribute for the inbox, 2448 because the \NoInferiors attribute already implies that, and has 2449 a stronger meaning. 2451 C: A03 LIST () "" "%" RETURN (CHILDREN) 2452 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2453 S: * LIST (\HasChildren) "/" "Fruit" 2454 S: * LIST (\HasNoChildren) "/" "Tofu" 2455 S: * LIST (\HasChildren) "/" "Vegetable" 2456 S: A03 OK done 2458 4: In this example, we see more mailboxes that reside on another 2459 server. This is similar to the command . 2461 C: A04 LIST (REMOTE) "" "%" RETURN (CHILDREN) 2462 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2463 S: * LIST (\HasChildren) "/" "Fruit" 2464 S: * LIST (\HasNoChildren) "/" "Tofu" 2465 S: * LIST (\HasChildren) "/" "Vegetable" 2466 S: * LIST (\Remote) "/" "Bread" 2467 S: * LIST (\HasChildren \Remote) "/" "Meat" 2468 S: A04 OK done 2470 5: The following example also requests the server to include 2471 mailboxes that reside on another server. The server returns 2472 information about all mailboxes that are subscribed. This is 2473 similar to the command . We also see the use of 2474 two selection options. 2476 C: A05 LIST (REMOTE SUBSCRIBED) "" "*" 2477 S: * LIST (\Marked \NoInferiors \Subscribed) "/" "inbox" 2478 S: * LIST (\Subscribed) "/" "Fruit/Banana" 2479 S: * LIST (\Subscribed \NonExistent) "/" "Fruit/Peach" 2480 S: * LIST (\Subscribed) "/" "Vegetable" 2481 S: * LIST (\Subscribed) "/" "Vegetable/Broccoli" 2482 S: * LIST (\Remote \Subscribed) "/" "Bread" 2483 S: A05 OK done 2485 6: The following example requests the server to include mailboxes 2486 that reside on another server. The server is asked to return 2487 subscription information for all returned mailboxes. This is 2488 different from the example above. 2490 Note that the output of this command is not a superset of the 2491 output in the previous example, as it doesn't include LIST 2492 response for the non-existent "Fruit/Peach". 2494 C: A06 LIST (REMOTE) "" "*" RETURN (SUBSCRIBED) 2495 S: * LIST (\Marked \NoInferiors \Subscribed) "/" "inbox" 2496 S: * LIST () "/" "Fruit" 2497 S: * LIST () "/" "Fruit/Apple" 2498 S: * LIST (\Subscribed) "/" "Fruit/Banana" 2499 S: * LIST () "/" "Tofu" 2500 S: * LIST (\Subscribed) "/" "Vegetable" 2501 S: * LIST (\Subscribed) "/" "Vegetable/Broccoli" 2502 S: * LIST () "/" "Vegetable/Corn" 2503 S: * LIST (\Remote \Subscribed) "/" "Bread" 2504 S: * LIST (\Remote) "/" "Meat" 2505 S: A06 OK done 2507 7: In the following example, the client has specified multiple 2508 mailbox patterns. Note that this example does not use the 2509 mailbox hierarchy used in the previous examples. 2511 C: BBB LIST "" ("INBOX" "Drafts" "Sent/%") 2512 S: * LIST () "/" "INBOX" 2513 S: * LIST (\NoInferiors) "/" "Drafts" 2514 S: * LIST () "/" "Sent/March2004" 2515 S: * LIST (\Marked) "/" "Sent/December2003" 2516 S: * LIST () "/" "Sent/August2004" 2517 S: BBB OK done 2519 8: The following example demonstrates the difference between the 2520 \HasChildren attribute and the CHILDINFO extended data item. 2522 Let's assume there is the following hierarchy: 2524 C: C01 LIST "" "*" 2525 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2526 S: * LIST () "/" "Foo" 2527 S: * LIST () "/" "Foo/Bar" 2528 S: * LIST () "/" "Foo/Baz" 2529 S: * LIST () "/" "Moo" 2530 S: C01 OK done 2532 If the client asks RETURN (CHILDREN), it will get this: 2534 C: CA3 LIST "" "%" RETURN (CHILDREN) 2535 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2536 S: * LIST (\HasChildren) "/" "Foo" 2537 S: * LIST (\HasNoChildren) "/" "Moo" 2538 S: CA3 OK done 2540 A) Let's also assume that the mailbox "Foo/Baz" is the only 2541 subscribed mailbox. Then we get this result: 2543 C: C02 LIST (SUBSCRIBED) "" "*" 2544 S: * LIST (\Subscribed) "/" "Foo/Baz" 2545 S: C02 OK done 2547 Now, if the client issues , the server 2548 will return no mailboxes (as the mailboxes "Moo", "Foo", and 2549 "Inbox" are NOT subscribed). However, if the client issues 2550 this: 2552 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2553 S: * LIST () "/" "Foo" ("CHILDINFO" ("SUBSCRIBED")) 2554 S: C04 OK done 2556 (i.e., the mailbox "Foo" is not subscribed, but it has a child 2557 that is.) 2559 A1) If the mailbox "Foo" had also been subscribed, the last 2560 command would return this: 2562 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2563 S: * LIST (\Subscribed) "/" "Foo" ("CHILDINFO" ("SUBSCRIBED")) 2564 S: C04 OK done 2566 or even this: 2568 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2569 S: * LIST (\Subscribed \HasChildren) "/" "Foo" ("CHILDINFO" 2570 ("SUBSCRIBED")) 2571 S: C04 OK done 2573 A2) If we assume instead that the mailbox "Foo" is not part of 2574 the original hierarchy and is not subscribed, the last command 2575 will give this result: 2577 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2578 S: * LIST (\NonExistent) "/" "Foo" ("CHILDINFO" ("SUBSCRIBED")) 2579 S: C04 OK done 2580 B) Now, let's assume that no mailbox is subscribed. In this 2581 case, the command will 2582 return no responses, as there are no subscribed children (even 2583 though "Foo" has children). 2585 C) And finally, suppose that only the mailboxes "Foo" and "Moo" 2586 are subscribed. In that case, we see this result: 2588 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" RETURN (CHILDREN) 2589 S: * LIST (\HasChildren \Subscribed) "/" "Foo" 2590 S: * LIST (\HasNoChildren \Subscribed) "/" "Moo" 2591 S: C04 OK done 2593 (which means that the mailbox "Foo" has children, but none of 2594 them is subscribed). 2596 9: The following example demonstrates that the CHILDINFO extended 2597 data item is returned whether or not children mailboxes match 2598 the canonical LIST pattern. 2600 Let's assume there is the following hierarchy: 2602 C: D01 LIST "" "*" 2603 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2604 S: * LIST () "/" "foo2" 2605 S: * LIST () "/" "foo2/bar1" 2606 S: * LIST () "/" "foo2/bar2" 2607 S: * LIST () "/" "baz2" 2608 S: * LIST () "/" "baz2/bar2" 2609 S: * LIST () "/" "baz2/bar22" 2610 S: * LIST () "/" "baz2/bar222" 2611 S: * LIST () "/" "eps2" 2612 S: * LIST () "/" "eps2/mamba" 2613 S: * LIST () "/" "qux2/bar2" 2614 S: D01 OK done 2616 And that the following mailboxes are subscribed: 2618 C: D02 LIST (SUBSCRIBED) "" "*" 2619 S: * LIST (\Subscribed) "/" "foo2/bar1" 2620 S: * LIST (\Subscribed) "/" "foo2/bar2" 2621 S: * LIST (\Subscribed) "/" "baz2/bar2" 2622 S: * LIST (\Subscribed) "/" "baz2/bar22" 2623 S: * LIST (\Subscribed) "/" "baz2/bar222" 2624 S: * LIST (\Subscribed) "/" "eps2" 2625 S: * LIST (\Subscribed) "/" "eps2/mamba" 2626 S: * LIST (\Subscribed) "/" "qux2/bar2" 2627 S: D02 OK done 2628 The client issues the following command first: 2630 C: D03 LIST (RECURSIVEMATCH SUBSCRIBED) "" "*2" 2631 S: * LIST () "/" "foo2" ("CHILDINFO" ("SUBSCRIBED")) 2632 S: * LIST (\Subscribed) "/" "foo2/bar2" 2633 S: * LIST (\Subscribed) "/" "baz2/bar2" 2634 S: * LIST (\Subscribed) "/" "baz2/bar22" 2635 S: * LIST (\Subscribed) "/" "baz2/bar222" 2636 S: * LIST (\Subscribed) "/" "eps2" ("CHILDINFO" ("SUBSCRIBED")) 2637 S: * LIST (\Subscribed) "/" "qux2/bar2" 2638 S: D03 OK done 2640 and the server may also include (but this would violate a SHOULD 2641 NOT in Section 3.5, because CHILDINFO is redundant) 2643 S: * LIST () "/" "baz2" ("CHILDINFO" ("SUBSCRIBED")) 2644 S: * LIST (\NonExistent) "/" "qux2" ("CHILDINFO" ("SUBSCRIBED")) 2646 The CHILDINFO extended data item is returned for mailboxes 2647 "foo2", "baz2", and "eps2", because all of them have subscribed 2648 children, even though for the mailbox "foo2" only one of the two 2649 subscribed children matches the pattern, for the mailbox "baz2" 2650 all the subscribed children match the pattern, and for the 2651 mailbox "eps2" none of the subscribed children matches the 2652 pattern. 2654 Note that if the client issues 2656 C: D03 LIST (RECURSIVEMATCH SUBSCRIBED) "" "*" 2657 S: * LIST () "/" "foo2" ("CHILDINFO" ("SUBSCRIBED")) 2658 S: * LIST (\Subscribed) "/" "foo2/bar1" 2659 S: * LIST (\Subscribed) "/" "foo2/bar2" 2660 S: * LIST () "/" "baz2" ("CHILDINFO" ("SUBSCRIBED")) 2661 S: * LIST (\Subscribed) "/" "baz2/bar2" 2662 S: * LIST (\Subscribed) "/" "baz2/bar22" 2663 S: * LIST (\Subscribed) "/" "baz2/bar222" 2664 S: * LIST (\Subscribed) "/" "eps2" ("CHILDINFO" ("SUBSCRIBED")) 2665 S: * LIST (\Subscribed) "/" "eps2/mamba" 2666 S: * LIST (\Subscribed) "/" "qux2/bar2" 2667 S: D03 OK done 2669 The LIST responses for mailboxes "foo2", "baz2", and "eps2" 2670 still have the CHILDINFO extended data item, even though this 2671 information is redundant and the client can determine it by 2672 itself. 2674 10: 2676 10: The following example shows usage of extended syntax for mailbox 2677 pattern. It also demonstrates that the presence of the 2678 CHILDINFO extended data item doesn't necessarily imply 2679 \HasChildren. 2681 C: a1 LIST "" ("foo") 2682 S: * LIST () "/" foo 2683 S: a1 OK done 2685 C: a2 LIST (SUBSCRIBED) "" "foo/*" 2686 S: * LIST (\Subscribed \NonExistent) "/" foo/bar 2687 S: a2 OK done 2689 C: a3 LIST (SUBSCRIBED RECURSIVEMATCH) "" foo RETURN (CHILDREN) 2690 S: * LIST (\HasNoChildren) "/" foo ("CHILDINFO" ("SUBSCRIBED")) 2691 S: a3 OK done 2693 11: The following example shows how a server that supports missing 2694 mailbox hierarchy elements can signal to a client that didn't 2695 specify the RECURSIVEMATCH selection option that there is a 2696 child mailbox that matches the selection criteria. 2698 C: a1 LIST (REMOTE) "" * 2699 S: * LIST () "/" music/rock 2700 S: * LIST (\Remote) "/" also/jazz 2701 S: a1 OK done 2703 C: a2 LIST () "" % 2704 S: * LIST (\NonExistent \HasChildren) "/" music 2705 S: a2 OK done 2707 C: a3 LIST (REMOTE) "" % 2708 S: * LIST (\NonExistent \HasChildren) "/" music 2709 S: * LIST (\NonExistent \HasChildren) "/" also 2710 S: a3 OK done 2712 C: a3.1 LIST "" (% music/rock) 2713 S: * LIST () "/" music/rock 2714 S: a3.1 OK done 2716 Because "music/rock" is the only mailbox under "music", there's 2717 no need for the server to also return "music". However clients 2718 must handle both cases. 2720 12: The following examples show use of STATUS return option. 2722 C: A01 LIST "" % RETURN (STATUS (MESSAGES UNSEEN)) 2723 S: * LIST () "." "INBOX" 2724 S: * STATUS "INBOX" (MESSAGES 17 UNSEEN 16) 2725 S: * LIST () "." "foo" 2726 S: * STATUS "foo" (MESSAGES 30 UNSEEN 29) 2727 S: * LIST (\NoSelect) "." "bar" 2728 S: A01 OK List completed. 2730 The "bar" mailbox isn't selectable, so it has no STATUS reply. 2732 C: A02 LIST (SUBSCRIBED RECURSIVEMATCH) "" % RETURN (STATUS 2733 (MESSAGES)) 2734 S: * LIST (\Subscribed) "." "INBOX" 2735 S: * STATUS "INBOX" (MESSAGES 17) 2736 S: * LIST () "." "foo" (CHILDINFO ("SUBSCRIBED")) 2737 S: A02 OK List completed. 2739 The LIST reply for "foo" is returned because it has matching 2740 children, but no STATUS reply is returned because "foo" itself 2741 doesn't match the selection criteria. 2743 6.3.10. NAMESPACE Command 2745 Arguments: none 2747 Responses: REQUIRED untagged responses: NAMESPACE 2749 Result: OK - command completed 2750 NO - Can't complete the command 2751 BAD - arguments invalid 2753 The NAMESPACE command causes a single ungagged NAMESPACE response to 2754 be returned. The untagged NAMESPACE response contains the prefix and 2755 hierarchy delimiter to the server's Personal Namespace(s), Other 2756 Users' Namespace(s), and Shared Namespace(s) that the server wishes 2757 to expose. The response will contain a NIL for any namespace class 2758 that is not available. Namespace-Response-Extensions ABNF non 2759 terminal is defined for extensibility and MAY be included in the 2760 response. 2762 Example 1: 2764 In this example a server supports a single personal namespace. No 2765 leading prefix is used on personal mailboxes and "/" is the hierarchy 2766 delimiter. 2768 C: A001 NAMESPACE 2769 S: * NAMESPACE (("" "/")) NIL NIL 2770 S: A001 OK NAMESPACE command completed 2772 Example 2: 2774 A user logged on anonymously to a server. No personal mailboxes are 2775 associated with the anonymous user and the user does not have access 2776 to the Other Users' Namespace. No prefix is required to access 2777 shared mailboxes and the hierarchy delimiter is "." 2779 C: A001 NAMESPACE 2780 S: * NAMESPACE NIL NIL (("" ".")) 2781 S: A001 OK NAMESPACE command completed 2783 Example 3: 2785 A server that contains a Personal Namespace and a single Shared 2786 Namespace. 2788 C: A001 NAMESPACE 2789 S: * NAMESPACE (("" "/")) NIL (("Public Folders/" "/")) 2790 S: A001 OK NAMESPACE command completed 2792 Example 4: 2794 A server that contains a Personal Namespace, Other Users' Namespace 2795 and multiple Shared Namespaces. Note that the hierarchy delimiter 2796 used within each namespace can be different. 2798 C: A001 NAMESPACE 2799 S: * NAMESPACE (("" "/")) (("~" "/")) (("#shared/" "/") 2800 ("#public/" "/")("#ftp/" "/")("#news." ".")) 2801 S: A001 OK NAMESPACE command completed 2803 The prefix string allows a client to do things such as automatically 2804 creating personal mailboxes or LISTing all available mailboxes within 2805 a namespace. 2807 Example 5: 2809 A server that supports only the Personal Namespace, with a leading 2810 prefix of INBOX to personal mailboxes and a hierarchy delimiter of 2811 "." 2812 C: A001 NAMESPACE 2813 S: * NAMESPACE (("INBOX." ".")) NIL NIL 2814 S: A001 OK NAMESPACE command completed 2816 < Automatically create a mailbox to store sent items.> 2818 C: A002 CREATE "INBOX.Sent Mail" 2819 S: A002 OK CREATE command completed 2821 Although typically a server will support only a single Personal 2822 Namespace, and a single Other User's Namespace, circumstances exist 2823 where there MAY be multiples of these, and a client MUST be prepared 2824 for them. If a client is configured such that it is required to 2825 create a certain mailbox, there can be circumstances where it is 2826 unclear which Personal Namespaces it should create the mailbox in. 2827 In these situations a client SHOULD let the user select which 2828 namespaces to create the mailbox in or just use the first personal 2829 namespace. 2831 Example 6: 2833 In this example, a server supports 2 Personal Namespaces. In 2834 addition to the regular Personal Namespace, the user has an 2835 additional personal namespace to allow access to mailboxes in an MH 2836 format mailstore. 2838 The client is configured to save a copy of all mail sent by the user 2839 into a mailbox called 'Sent Mail'. Furthermore, after a message is 2840 deleted from a mailbox, the client is configured to move that message 2841 to a mailbox called 'Deleted Items'. 2843 Note that this example demonstrates how some extension flags can be 2844 passed to further describe the #mh namespace. 2846 C: A001 NAMESPACE 2847 S: * NAMESPACE (("" "/")("#mh/" "/" "X-PARAM" 2848 ("FLAG1" "FLAG2"))) NIL NIL 2849 S: A001 OK NAMESPACE command completed 2851 < It is desired to keep only one copy of sent mail. 2852 It is unclear which Personal Namespace the client 2853 should use to create the 'Sent Mail' mailbox. 2854 The user is prompted to select a namespace and only 2855 one 'Sent Mail' mailbox is created. > 2857 C: A002 CREATE "Sent Mail" 2858 S: A002 OK CREATE command completed 2860 < The client is designed so that it keeps two 2861 'Deleted Items' mailboxes, one for each namespace. > 2863 C: A003 CREATE "Delete Items" 2864 S: A003 OK CREATE command completed 2866 C: A004 CREATE "#mh/Deleted Items" 2867 S: A004 OK CREATE command completed 2869 The next level of hierarchy following the Other Users' Namespace 2870 prefix SHOULD consist of , where is a user name 2871 as per the LOGIN or AUTHENTICATE command. 2873 A client can construct a LIST command by appending a "%" to the Other 2874 Users' Namespace prefix to discover the Personal Namespaces of other 2875 users that are available to the currently authenticated user. 2877 In response to such a LIST command, a server SHOULD NOT return user 2878 names that have not granted access to their personal mailboxes to the 2879 user in question. 2881 A server MAY return a LIST response containing only the names of 2882 users that have explicitly granted access to the user in question. 2884 Alternatively, a server MAY return NO to such a LIST command, 2885 requiring that a user name be included with the Other Users' 2886 Namespace prefix before listing any other user's mailboxes. 2888 Example 7: 2890 A server that supports providing a list of other user's mailboxes 2891 that are accessible to the currently logged on user. 2893 C: A001 NAMESPACE 2894 S: * NAMESPACE (("" "/")) (("Other Users/" "/")) NIL 2895 S: A001 OK NAMESPACE command completed 2897 C: A002 LIST "" "Other Users/%" 2898 S: * LIST () "/" "Other Users/Mike" 2899 S: * LIST () "/" "Other Users/Karen" 2900 S: * LIST () "/" "Other Users/Matthew" 2901 S: * LIST () "/" "Other Users/Tesa" 2902 S: A002 OK LIST command completed 2904 Example 8: 2906 A server that does not support providing a list of other user's 2907 mailboxes that are accessible to the currently logged on user. The 2908 mailboxes are listable if the client includes the name of the other 2909 user with the Other Users' Namespace prefix. 2911 C: A001 NAMESPACE 2912 S: * NAMESPACE (("" "/")) (("#Users/" "/")) NIL 2913 S: A001 OK NAMESPACE command completed 2915 < In this example, the currently logged on user has access to 2916 the Personal Namespace of user Mike, but the server chose to 2917 suppress this information in the LIST response. However, 2918 by appending the user name Mike (received through user input) 2919 to the Other Users' Namespace prefix, the client is able 2920 to get a listing of the personal mailboxes of user Mike. > 2922 C: A002 LIST "" "#Users/%" 2923 S: A002 NO The requested item could not be found. 2925 C: A003 LIST "" "#Users/Mike/%" 2926 S: * LIST () "/" "#Users/Mike/INBOX" 2927 S: * LIST () "/" "#Users/Mike/Foo" 2928 S: A003 OK LIST command completed. 2930 A prefix string might not contain a hierarchy delimiter, because in 2931 some cases it is not needed as part of the prefix. 2933 Example 9: 2935 A server that allows access to the Other Users' Namespace by 2936 prefixing the others' mailboxes with a '~' followed by , 2937 where is a user name as per the LOGIN or AUTHENTICATE 2938 command. 2940 C: A001 NAMESPACE 2941 S: * NAMESPACE (("" "/")) (("~" "/")) NIL 2942 S: A001 OK NAMESPACE command completed 2944 < List the mailboxes for user mark > 2946 C: A002 LIST "" "~mark/%" 2947 S: * LIST () "/" "~mark/INBOX" 2948 S: * LIST () "/" "~mark/foo" 2949 S: A002 OK LIST command completed 2951 6.3.11. STATUS Command 2953 Arguments: mailbox name 2954 status data item names 2956 Responses: REQUIRED untagged responses: STATUS 2958 Result: OK - status completed 2959 NO - status failure: no status for that name 2960 BAD - command unknown or arguments invalid 2962 The STATUS command requests the status of the indicated mailbox. It 2963 does not change the currently selected mailbox, nor does it affect 2964 the state of any messages in the queried mailbox. 2966 The STATUS command provides an alternative to opening a second 2967 IMAP4rev2 connection and doing an EXAMINE command on a mailbox to 2968 query that mailbox's status without deselecting the current mailbox 2969 in the first IMAP4rev2 connection. 2971 Unlike the LIST command, the STATUS command is not guaranteed to be 2972 fast in its response. Under certain circumstances, it can be quite 2973 slow. In some implementations, the server is obliged to open the 2974 mailbox read-only internally to obtain certain status information. 2975 Also unlike the LIST command, the STATUS command does not accept 2976 wildcards. 2978 Note: The STATUS command is intended to access the status of 2979 mailboxes other than the currently selected mailbox. Because the 2980 STATUS command can cause the mailbox to be opened internally, and 2981 because this information is available by other means on the 2982 selected mailbox, the STATUS command SHOULD NOT be used on the 2983 currently selected mailbox. 2985 The STATUS command MUST NOT be used as a "check for new messages 2986 in the selected mailbox" operation (refer to sections Section 7, 2987 Section 7.3.1 for more information about the proper method for new 2988 message checking). 2990 STATUS SIZE (see below) can take a significant amount of time, 2991 depending upon server implementation. Clients should use STATUS 2992 SIZE cautiously. 2994 The currently defined status data items that can be requested are: 2996 MESSAGES The number of messages in the mailbox. 2998 UIDNEXT The next unique identifier value of the mailbox. Refer to 2999 Section 2.3.1.1 for more information. 3001 UIDVALIDITY The unique identifier validity value of the mailbox. 3002 Refer to Section 2.3.1.1 for more information. 3004 UNSEEN The number of messages which do not have the \Seen flag set. 3006 DELETED The number of messages which have the \Deleted flag set. 3008 SIZE The total size of the mailbox in octets. This is not strictly 3009 required to be an exact value, but it MUST be equal to or greater 3010 than the sum of the values of the RFC822.SIZE FETCH message data 3011 items (see Section 6.4.5) of all messages in the mailbox. 3013 SIZE 3015 Example: C: A042 STATUS blurdybloop (UIDNEXT MESSAGES) 3016 S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) 3017 S: A042 OK STATUS completed 3019 6.3.12. APPEND Command 3021 Arguments: mailbox name 3022 OPTIONAL flag parenthesized list 3023 OPTIONAL date/time string 3024 message literal 3026 Responses: no specific responses for this command 3028 Result: OK - append completed 3029 NO - append error: can't append to that mailbox, error 3030 in flags or date/time or message text 3031 BAD - command unknown or arguments invalid 3033 The APPEND command appends the literal argument as a new message to 3034 the end of the specified destination mailbox. This argument SHOULD 3035 be in the format of an [RFC-5322] or [I18N-HDRS] message. 8-bit 3036 characters are permitted in the message. A server implementation 3037 that is unable to preserve 8-bit data properly MUST be able to 3038 reversibly convert 8-bit APPEND data to 7-bit using a [MIME-IMB] 3039 content transfer encoding. 3041 Note: There may be exceptions, e.g., draft messages, in which 3042 required [RFC-5322] header lines are omitted in the message 3043 literal argument to APPEND. The full implications of doing so 3044 must be understood and carefully weighed. 3046 If a flag parenthesized list is specified, the flags SHOULD be set in 3047 the resulting message; otherwise, the flag list of the resulting 3048 message is set to empty by default. 3050 If a date-time is specified, the internal date SHOULD be set in the 3051 resulting message; otherwise, the internal date of the resulting 3052 message is set to the current date and time by default. 3054 If the append is unsuccessful for any reason, the mailbox MUST be 3055 restored to its state before the APPEND attempt (other than possibly 3056 keeping the changed mailbox's UIDNEXT value); no partial appending is 3057 permitted. 3059 If the destination mailbox does not exist, a server MUST return an 3060 error, and MUST NOT automatically create the mailbox. Unless it is 3061 certain that the destination mailbox can not be created, the server 3062 MUST send the response code "[TRYCREATE]" as the prefix of the text 3063 of the tagged NO response. This gives a hint to the client that it 3064 can attempt a CREATE command and retry the APPEND if the CREATE is 3065 successful. 3067 On successful completion of an APPEND, the server SHOULD return an 3068 APPENDUID response code. 3070 In the case of a mailbox that has permissions set so that the client 3071 can APPEND to the mailbox, but not SELECT or EXAMINE it, the server 3072 SHOULD NOT send an APPENDUID response code as it would disclose 3073 information about the mailbox. 3075 In the case of a mailbox that has UIDNOTSTICKY status (see 3076 UIDNOTSTICKY response code definition), the server MAY omit the 3077 APPENDUID response code as it is not meaningful. 3079 If the server does not return the APPENDUID response codes, the 3080 client can discover this information by selecting the destination 3081 mailbox. The location of messages placed in the destination mailbox 3082 by APPEND can be determined by using FETCH and/or SEARCH commands 3083 (e.g., for Message-ID or some unique marker placed in the message in 3084 an APPEND). 3086 If the mailbox is currently selected, the normal new message actions 3087 SHOULD occur. Specifically, the server SHOULD notify the client 3088 immediately via an untagged EXISTS response. If the server does not 3089 do so, the client MAY issue a NOOP command after one or more APPEND 3090 commands. 3092 Example: C: A003 APPEND saved-messages (\Seen) {310} 3093 S: + Ready for literal data 3094 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST) 3095 C: From: Fred Foobar 3096 C: Subject: afternoon meeting 3097 C: To: mooch@owatagu.siam.edu 3098 C: Message-Id: 3099 C: MIME-Version: 1.0 3100 C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 3101 C: 3102 C: Hello Joe, do you think we can meet at 3:30 tomorrow? 3103 C: 3104 S: A003 OK APPEND completed 3106 Example: C: A003 APPEND saved-messages (\Seen) {297} 3107 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST) 3108 C: From: Fred Foobar 3109 C: Subject: afternoon meeting 3110 C: To: mooch@example.com 3111 C: Message-Id: 3112 C: MIME-Version: 1.0 3113 C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 3114 C: 3115 C: Hello Joe, do you think we can meet at 3:30 tomorrow? 3116 C: 3117 S: A003 OK [APPENDUID 38505 3955] APPEND completed 3118 C: A004 COPY 2:4 meeting 3119 S: A004 OK [COPYUID 38505 304,319:320 3956:3958] Done 3120 C: A005 UID COPY 305:310 meeting 3121 S: A005 OK No matching messages, so nothing copied 3122 C: A006 COPY 2 funny 3123 S: A006 OK Done 3124 C: A007 SELECT funny 3125 S: * 1 EXISTS 3126 S: * OK [UIDVALIDITY 3857529045] Validity session-only 3127 S: * OK [UIDNEXT 2] Predicted next UID 3128 S: * NO [UIDNOTSTICKY] Non-persistent UIDs 3129 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 3130 S: * OK [PERMANENTFLAGS (\Deleted \Seen)] Limited 3131 S: A007 OK [READ-WRITE] SELECT completed 3133 In this example, A003 and A004 demonstrate successful appending and 3134 copying to a mailbox that returns the UIDs assigned to the messages. 3135 A005 is an example in which no messages were copied; this is because 3136 in A003, we see that message 2 had UID 304, and message 3 had UID 3137 319; therefore, UIDs 305 through 310 do not exist (refer to 3138 Section 2.3.1.1 for further explanation). A006 is an example of a 3139 message being copied that did not return a COPYUID; and, as expected, 3140 A007 shows that the mail store containing that mailbox does not 3141 support persistent UIDs. 3143 Note: The APPEND command is not used for message delivery, because 3144 it does not provide a mechanism to transfer [SMTP] envelope 3145 information. 3147 6.3.13. IDLE Command 3149 Arguments: none 3151 Responses: continuation data will be requested; the client sends the 3152 continuation data "DONE" to end the command 3154 Result: OK - IDLE completed after client sent "DONE" 3155 NO - failure: the server will not allow the IDLE command 3156 at this time 3157 BAD - command unknown or arguments invalid 3159 Without the IDLE command a client requires to poll the server for 3160 changes to the selected mailbox (new mail, deletions, flag changes). 3161 It's often more desirable to have the server transmit updates to the 3162 client in real time. This allows a user to see new mail immediately. 3163 The IDLE command allows a client to tell the server that it's ready 3164 to accept such real-time updates. 3166 The IDLE command is sent from the client to the server when the 3167 client is ready to accept unsolicited update messages. The server 3168 requests a response to the IDLE command using the continuation ("+") 3169 response. The IDLE command remains active until the client responds 3170 to the continuation, and as long as an IDLE command is active, the 3171 server is now free to send untagged EXISTS, EXPUNGE, FETCH, and other 3172 responses at any time. If the server choose to send unsolicited 3173 FETCH responses, they MUST include UID FETCH item. 3175 The IDLE command is terminated by the receipt of a "DONE" 3176 continuation from the client; such response satisfies the server's 3177 continuation request. At that point, the server MAY send any 3178 remaining queued untagged responses and then MUST immediately send 3179 the tagged response to the IDLE command and prepare to process other 3180 commands. As for other commands, the processing of any new command 3181 may cause the sending of unsolicited untagged responses, subject to 3182 the ambiguity limitations. The client MUST NOT send a command while 3183 the server is waiting for the DONE, since the server will not be able 3184 to distinguish a command from a continuation. 3186 The server MAY consider a client inactive if it has an IDLE command 3187 running, and if such a server has an inactivity timeout it MAY log 3188 the client off implicitly at the end of its timeout period. Because 3189 of that, clients using IDLE are advised to terminate the IDLE and re- 3190 issue it at least every 29 minutes to avoid being logged off. This 3191 still allows a client to receive immediate mailbox updates even 3192 though it need only "poll" at half hour intervals. 3194 Example: C: A001 SELECT INBOX 3195 S: * FLAGS (\Deleted \Seen \Flagged) 3196 S: * OK [PERMANENTFLAGS (\Deleted \Seen \Flagged)] Limited 3197 S: * 3 EXISTS 3198 S: * OK [UIDVALIDITY 1] 3199 S: A001 OK [READ-WRITE] SELECT completed 3200 C: A002 IDLE 3201 S: + idling 3202 ...time passes; new mail arrives... 3203 S: * 4 EXISTS 3204 C: DONE 3205 S: A002 OK IDLE terminated 3206 ...another client expunges message 2 now... 3207 C: A003 FETCH 4 ALL 3208 S: * 4 FETCH (...) 3209 S: A003 OK FETCH completed 3210 C: A004 IDLE 3211 S: * 2 EXPUNGE 3212 S: * 3 EXISTS 3213 S: + idling 3214 ...time passes; another client expunges message 3... 3215 S: * 3 EXPUNGE 3216 S: * 2 EXISTS 3217 ...time passes; new mail arrives... 3218 S: * 3 EXISTS 3219 C: DONE 3220 S: A004 OK IDLE terminated 3221 C: A005 FETCH 3 ALL 3222 S: * 3 FETCH (...) 3223 S: A005 OK FETCH completed 3224 C: A006 IDLE 3226 6.4. Client Commands - Selected State 3228 In the selected state, commands that manipulate messages in a mailbox 3229 are permitted. 3231 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 3232 and the authenticated state commands (SELECT, EXAMINE, NAMESPACE, 3233 CREATE, DELETE, RENAME, SUBSCRIBE, UNSUBSCRIBE, LIST, STATUS, and 3234 APPEND), the following commands are valid in the selected state: 3235 CLOSE, UNSELECT, EXPUNGE, SEARCH, FETCH, STORE, COPY, MOVE, and UID. 3237 6.4.1. CLOSE Command 3239 Arguments: none 3241 Responses: no specific responses for this command 3242 Result: OK - close completed, now in authenticated state 3243 BAD - command unknown or arguments invalid 3245 The CLOSE command permanently removes all messages that have the 3246 \Deleted flag set from the currently selected mailbox, and returns to 3247 the authenticated state from the selected state. No untagged EXPUNGE 3248 responses are sent. 3250 No messages are removed, and no error is given, if the mailbox is 3251 selected by an EXAMINE command or is otherwise selected read-only. 3253 Even if a mailbox is selected, a SELECT, EXAMINE, or LOGOUT command 3254 MAY be issued without previously issuing a CLOSE command. The 3255 SELECT, EXAMINE, and LOGOUT commands implicitly close the currently 3256 selected mailbox without doing an expunge. However, when many 3257 messages are deleted, a CLOSE-LOGOUT or CLOSE-SELECT sequence is 3258 considerably faster than an EXPUNGE-LOGOUT or EXPUNGE-SELECT because 3259 no untagged EXPUNGE responses (which the client would probably 3260 ignore) are sent. 3262 Example: C: A341 CLOSE 3263 S: A341 OK CLOSE completed 3265 6.4.2. UNSELECT Command 3267 Arguments: none 3269 Responses: no specific responses for this command 3271 Result: OK - unselect completed, now in authenticated state 3272 BAD - no mailbox selected, or argument supplied but none 3273 permitted 3275 The UNSELECT command frees server's resources associated with the 3276 selected mailbox and returns the server to the authenticated state. 3277 This command performs the same actions as CLOSE, except that no 3278 messages are permanently removed from the currently selected mailbox. 3280 Example: C: A342 UNSELECT 3281 S: A342 OK Unselect completed 3283 6.4.3. EXPUNGE Command 3285 Arguments: none 3287 Responses: untagged responses: EXPUNGE 3289 Result: OK - expunge completed 3290 NO - expunge failure: can't expunge (e.g., permission 3291 denied) 3292 BAD - command unknown or arguments invalid 3294 The EXPUNGE command permanently removes all messages that have the 3295 \Deleted flag set from the currently selected mailbox. Before 3296 returning an OK to the client, an untagged EXPUNGE response is sent 3297 for each message that is removed. 3299 Example: C: A202 EXPUNGE 3300 S: * 3 EXPUNGE 3301 S: * 3 EXPUNGE 3302 S: * 5 EXPUNGE 3303 S: * 8 EXPUNGE 3304 S: A202 OK EXPUNGE completed 3306 Note: In this example, messages 3, 4, 7, and 11 had the \Deleted flag 3307 set. See the description of the EXPUNGE response for further 3308 explanation. 3310 6.4.4. SEARCH Command 3312 Arguments: OPTIONAL result specifier 3313 OPTIONAL [CHARSET] specification 3314 searching criteria (one or more) 3316 Responses: REQUIRED untagged response: ESEARCH 3318 Result: OK - search completed 3319 NO - search error: can't search that [CHARSET] or 3320 criteria 3321 BAD - command unknown or arguments invalid 3323 The SEARCH command searches the mailbox for messages that match the 3324 given searching criteria. 3326 The SEARCH command may contain result options. Result options 3327 control what kind of information is returned about messages matching 3328 the search criteria in an untagged ESEARCH response. If no result 3329 option is specified or empty list of options is specified "()", ALL 3330 is assumed (see below). 3332 The order of individual options is arbitrary. Individual options may 3333 contain parameters enclosed in parentheses (*). If an option has 3334 parameters, they consist of atoms and/or strings and/or lists in a 3335 specific order. Any options not defined by extensions that the 3336 server supports must be rejected with a BAD response. 3338 (*) - if an option has a mandatory parameter, which can always be 3339 represented as a number or a sequence-set, the option parameter does 3340 not need the enclosing (). See ABNF for more details. 3342 This document specifies the following result options: 3344 MIN 3346 Return the lowest message number/UID that satisfies the SEARCH 3347 criteria. 3349 If the SEARCH results in no matches, the server MUST NOT 3350 include the MIN result option in the ESEARCH response; however, 3351 it still MUST send the ESEARCH response. 3353 MAX 3355 Return the highest message number/UID that satisfies the SEARCH 3356 criteria. 3358 If the SEARCH results in no matches, the server MUST NOT 3359 include the MAX result option in the ESEARCH response; however, 3360 it still MUST send the ESEARCH response. 3362 ALL 3364 Return all message numbers/UIDs that satisfy the SEARCH 3365 criteria using the sequence-set syntax. Note, the client MUST 3366 NOT assume that messages/UIDs will be listed in any particular 3367 order. 3369 If the SEARCH results in no matches, the server MUST NOT 3370 include the ALL result option in the ESEARCH response; however, 3371 it still MUST send the ESEARCH response. 3373 COUNT Return number of the messages that satisfy the SEARCH 3374 criteria. This result option MUST always be included in the 3375 ESEARCH response. 3377 Note: future extensions to this document can allow servers to return 3378 multiple ESEARCH responses for a single extended SEARCH command. 3379 However all options specified above MUST result in a single ESEARCH 3380 response. 3382 These extensions will have to describe how results from multiple 3383 ESEARCH responses are to be amalgamated. 3385 Searching criteria consist of one or more search keys. 3387 When multiple keys are specified, the result is the intersection (AND 3388 function) of all the messages that match those keys. For example, 3389 the criteria DELETED FROM "SMITH" SINCE 1-Feb-1994 refers to all 3390 deleted messages from Smith that were placed in the mailbox since 3391 February 1, 1994. A search key can also be a parenthesized list of 3392 one or more search keys (e.g., for use with the OR and NOT keys). 3394 Server implementations MAY exclude [MIME-IMB] body parts with 3395 terminal content media types other than TEXT and MESSAGE from 3396 consideration in SEARCH matching. 3398 The OPTIONAL [CHARSET] specification consists of the word "CHARSET" 3399 followed by a registered [CHARSET]. It indicates the [CHARSET] of 3400 the strings that appear in the search criteria. [MIME-IMB] content 3401 transfer encodings, and [MIME-HDRS] strings in [RFC-5322]/[MIME-IMB] 3402 headers, MUST be decoded before comparing text. Servers MUST support 3403 US-ASCII and UTF-8 charsets; other [CHARSET]s MAY be supported. 3404 Clients SHOULD use UTF-8. Note that if "CHARSET" is not provided 3405 IMAP4rev2 server MUST assume UTF-8, so selecting CHARSET UTF-8 is 3406 redundant. It is permitted for improved compatibility with existing 3407 IMAP4rev1 clients. 3409 If the server does not support the specified [CHARSET], it MUST 3410 return a tagged NO response (not a BAD). This response SHOULD 3411 contain the BADCHARSET response code, which MAY list the [CHARSET]s 3412 supported by the server. 3414 In all search keys that use strings, a message matches the key if the 3415 string is a substring of the associated text. The matching SHOULD be 3416 case-insensitive for characters within ASCII range. Consider using 3417 [IMAP-I18N] for language-sensitive case-insensitive searching. Note 3418 that the empty string is a substring; this is useful when doing a 3419 HEADER search in order to test for a header field presence in the 3420 message. 3422 The defined search keys are as follows. Refer to the Formal Syntax 3423 section for the precise syntactic definitions of the arguments. 3425 3427 Messages with message sequence numbers corresponding 3428 to the specified message sequence number set. 3430 ALL All messages in the mailbox; the default initial key for ANDing. 3432 ANSWERED Messages with the \Answered flag set. 3434 BCC Messages that contain the specified string in the 3435 envelope structure's BCC field. 3437 BEFORE Messages whose internal date (disregarding time and 3438 timezone) is earlier than the specified date. 3440 BODY Messages that contain the specified string in the body 3441 of the message. Unlike TEXT (see below), this doesn't match any 3442 header fields. 3444 CC Messages that contain the specified string in the 3445 envelope structure's CC field. 3447 DELETED Messages with the \Deleted flag set. 3449 DRAFT Messages with the \Draft flag set. 3451 FLAGGED Messages with the \Flagged flag set. 3453 FROM Messages that contain the specified string in the 3454 envelope structure's FROM field. 3456 HEADER Messages that have a header with the 3457 specified field-name (as defined in [RFC-5322]) and that contains 3458 the specified string in the text of the header (what comes after 3459 the colon). If the string to search is zero-length, this matches 3460 all messages that have a header line with the specified field-name 3461 regardless of the contents. Servers should use substring search 3462 for this SEARCH item, as clients can use it for automatic 3463 processing not initiated by end users. For example this can be 3464 used for searching for Message-ID or Content-Type header field 3465 values that need to be exact, or for searches in header fields 3466 that the IMAP server might not know anything about. 3468 KEYWORD Messages with the specified keyword flag set. 3470 LARGER Messages with an [RFC-5322] size larger than the 3471 specified number of octets. 3473 NOT Messages that do not match the specified search 3474 key. 3476 ON Messages whose internal date (disregarding time and 3477 timezone) is within the specified date. 3479 OR Messages that match either search 3480 key. 3482 SEEN Messages that have the \Seen flag set. 3484 SENTBEFORE Messages whose [RFC-5322] Date: header 3485 (disregarding time and timezone) is earlier than the specified 3486 date. 3488 SENTON Messages whose [RFC-5322] Date: header (disregarding 3489 time and timezone) is within the specified date. 3491 SENTSINCE Messages whose [RFC-5322] Date: header 3492 (disregarding time and timezone) is within or later than the 3493 specified date. 3495 SINCE Messages whose internal date (disregarding time and 3496 timezone) is within or later than the specified date. 3498 SMALLER Messages with an [RFC-5322] size smaller than the 3499 specified number of octets. 3501 SUBJECT Messages that contain the specified string in the 3502 envelope structure's SUBJECT field. 3504 TEXT Messages that contain the specified string in the 3505 header (including MIME header fields) or body of the message. 3507 TO Messages that contain the specified string in the 3508 envelope structure's TO field. 3510 UID Messages with unique identifiers corresponding to 3511 the specified unique identifier set. Sequence set ranges are 3512 permitted. 3514 UNANSWERED Messages that do not have the \Answered flag set. 3516 UNDELETED Messages that do not have the \Deleted flag set. 3518 UNDRAFT Messages that do not have the \Draft flag set. 3520 UNFLAGGED Messages that do not have the \Flagged flag set. 3522 UNKEYWORD Messages that do not have the specified keyword 3523 flag set. 3525 UNSEEN Messages that do not have the \Seen flag set. 3527 Example: C: A282 SEARCH RETURN (MIN COUNT) FLAGGED 3528 SINCE 1-Feb-1994 NOT FROM "Smith" 3529 S: * ESEARCH (TAG "A282") MIN 2 COUNT 3 3530 S: A282 OK SEARCH completed 3532 Example: C: A283 SEARCH RETURN () FLAGGED 3533 SINCE 1-Feb-1994 NOT FROM "Smith" 3534 S: * ESEARCH (TAG "A283") ALL 2,10:11 3535 S: A283 OK SEARCH completed 3537 Example: C: A284 SEARCH TEXT "string not in mailbox" 3538 S: * ESEARCH (TAG "A284") 3539 S: A284 OK SEARCH completed 3540 C: A285 SEARCH CHARSET UTF-8 TEXT {6} 3541 S: + Ready for literal text 3542 C: XXXXXX 3543 S: * ESEARCH (TAG "A285") ALL 43 3544 S: A285 OK SEARCH completed 3546 Note: Since this document is restricted to 7-bit ASCII text, it is 3547 not possible to show actual UTF-8 data. The "XXXXXX" is a 3548 placeholder for what would be 6 octets of 8-bit data in an actual 3549 transaction. 3551 The following example demonstrates finding the first unseen message 3552 in the mailbox: 3554 Example: C: A284 SEARCH RETURN (MIN) UNSEEN 3555 S: * ESEARCH (TAG "A284") MIN 4 3556 S: A284 OK SEARCH completed 3558 The following example demonstrates that if the ESEARCH UID indicator 3559 is present, all data in the ESEARCH response is referring to UIDs; 3560 for example, the MIN result specifier will be followed by a UID. 3562 Example: C: A285 UID SEARCH RETURN (MIN MAX) 1:5000 3563 S: * ESEARCH (TAG "A285") UID MIN 7 MAX 3800 3564 S: A285 OK SEARCH completed 3566 The following example demonstrates returning the number of deleted 3567 messages: 3569 Example: C: A286 SEARCH RETURN (COUNT) DELETED 3570 S: * ESEARCH (TAG "A286") COUNT 15 3571 S: A286 OK SEARCH completed 3573 6.4.5. FETCH Command 3575 Arguments: sequence set 3576 message data item names or macro 3578 Responses: untagged responses: FETCH 3580 Result: OK - fetch completed 3581 NO - fetch error: can't fetch that data 3582 BAD - command unknown or arguments invalid 3584 The FETCH command retrieves data associated with a message in the 3585 mailbox. The data items to be fetched can be either a single atom or 3586 a parenthesized list. 3588 Most data items, identified in the formal syntax under the msg-att- 3589 static rule, are static and MUST NOT change for any particular 3590 message. Other data items, identified in the formal syntax under the 3591 msg-att-dynamic rule, MAY change, either as a result of a STORE 3592 command or due to external events. 3594 For example, if a client receives an ENVELOPE for a message when 3595 it already knows the envelope, it can safely ignore the newly 3596 transmitted envelope. 3598 There are three macros which specify commonly-used sets of data 3599 items, and can be used instead of data items. A macro must be used 3600 by itself, and not in conjunction with other macros or data items. 3602 ALL Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE) 3604 FAST Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE) 3606 FULL Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE 3607 BODY) 3609 The currently defined data items that can be fetched are: 3611 BINARY[]<> 3613 Requests that the specified section be transmitted after 3614 performing Content-Transfer-Encoding-related decoding. 3616 The argument, if present, requests that a subset of 3617 the data be returned. The semantics of a partial FETCH BINARY 3618 command are the same as for a partial FETCH BODY command, with 3619 the exception that the arguments refer to the DECODED 3620 section data. 3622 BINARY.PEEK[]<> An alternate form of 3623 BINARY[] that does not implicitly set the \Seen 3624 flag. 3626 BINARY.SIZE[] 3628 Requests the decoded size of the section (i.e., the size to 3629 expect in response to the corresponding FETCH BINARY request). 3631 Note: client authors are cautioned that this might be an 3632 expensive operation for some server implementations. 3633 Needlessly issuing this request could result in degraded 3634 performance due to servers having to calculate the value every 3635 time the request is issued. 3637 BODY Non-extensible form of BODYSTRUCTURE. 3639 BODY[
]<> 3641 The text of a particular body section. The section 3642 specification is a set of zero or more part specifiers 3643 delimited by periods. A part specifier is either a part number 3644 or one of the following: HEADER, HEADER.FIELDS, 3645 HEADER.FIELDS.NOT, MIME, and TEXT. An empty section 3646 specification refers to the entire message, including the 3647 header. 3649 Every message has at least one part number. Non-[MIME-IMB] 3650 messages, and non-multipart [MIME-IMB] messages with no 3651 encapsulated message, only have a part 1. 3653 Multipart messages are assigned consecutive part numbers, as 3654 they occur in the message. If a particular part is of type 3655 message or multipart, its parts MUST be indicated by a period 3656 followed by the part number within that nested multipart part. 3658 A part of type MESSAGE/RFC822 or MESSAGE/GLOBAL also has nested 3659 part numbers, referring to parts of the MESSAGE part's body. 3661 The HEADER, HEADER.FIELDS, HEADER.FIELDS.NOT, and TEXT part 3662 specifiers can be the sole part specifier or can be prefixed by 3663 one or more numeric part specifiers, provided that the numeric 3664 part specifier refers to a part of type MESSAGE/RFC822 or 3665 MESSAGE/GLOBAL. The MIME part specifier MUST be prefixed by 3666 one or more numeric part specifiers. 3668 The HEADER, HEADER.FIELDS, and HEADER.FIELDS.NOT part 3669 specifiers refer to the [RFC-5322] header of the message or of 3670 an encapsulated [MIME-IMT] MESSAGE/RFC822 or MESSAGE/GLOBAL 3671 message. HEADER.FIELDS and HEADER.FIELDS.NOT are followed by a 3672 list of field-name (as defined in [RFC-5322]) names, and return 3673 a subset of the header. The subset returned by HEADER.FIELDS 3674 contains only those header fields with a field-name that 3675 matches one of the names in the list; similarly, the subset 3676 returned by HEADER.FIELDS.NOT contains only the header fields 3677 with a non-matching field-name. The field-matching is ASCII 3678 range case-insensitive but otherwise exact. Subsetting does 3679 not exclude the [RFC-5322] delimiting blank line between the 3680 header and the body; the blank line is included in all header 3681 fetches, except in the case of a message which has no body and 3682 no blank line. 3684 The MIME part specifier refers to the [MIME-IMB] header for 3685 this part. 3687 The TEXT part specifier refers to the text body of the message, 3688 omitting the [RFC-5322] header. 3690 Here is an example of a complex message with some of its 3691 part specifiers: 3693 HEADER ([RFC-5322] header of the message) 3694 TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 3695 1 TEXT/PLAIN 3696 2 APPLICATION/OCTET-STREAM 3697 3 MESSAGE/RFC822 3698 3.HEADER ([RFC-5322] header of the message) 3699 3.TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 3700 3.1 TEXT/PLAIN 3701 3.2 APPLICATION/OCTET-STREAM 3702 4 MULTIPART/MIXED 3703 4.1 IMAGE/GIF 3704 4.1.MIME ([MIME-IMB] header for the IMAGE/GIF) 3705 4.2 MESSAGE/RFC822 3706 4.2.HEADER ([RFC-5322] header of the message) 3707 4.2.TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 3708 4.2.1 TEXT/PLAIN 3709 4.2.2 MULTIPART/ALTERNATIVE 3710 4.2.2.1 TEXT/PLAIN 3711 4.2.2.2 TEXT/RICHTEXT 3713 It is possible to fetch a substring of the designated text. 3714 This is done by appending an open angle bracket ("<"), the 3715 octet position of the first desired octet, a period, the 3716 maximum number of octets desired, and a close angle bracket 3717 (">") to the part specifier. If the starting octet is beyond 3718 the end of the text, an empty string is returned. 3720 Any partial fetch that attempts to read beyond the end of the 3721 text is truncated as appropriate. A partial fetch that starts 3722 at octet 0 is returned as a partial fetch, even if this 3723 truncation happened. 3725 Note: This means that BODY[]<0.2048> of a 1500-octet message 3726 will return BODY[]<0> with a literal of size 1500, not 3727 BODY[]. 3729 Note: A substring fetch of a HEADER.FIELDS or 3730 HEADER.FIELDS.NOT part specifier is calculated after 3731 subsetting the header. 3733 The \Seen flag is implicitly set; if this causes the flags to 3734 change, they SHOULD be included as part of the FETCH responses. 3736 BODY.PEEK[
]<> An alternate form of BODY[
] 3737 that does not implicitly set the \Seen flag. 3739 BODYSTRUCTURE The [MIME-IMB] body structure of the message. This is 3740 computed by the server by parsing the [MIME-IMB] header fields in 3741 the [RFC-5322] header and [MIME-IMB] headers. 3743 ENVELOPE The envelope structure of the message. This is computed by 3744 the server by parsing the [RFC-5322] header into the component 3745 parts, defaulting various fields as necessary. 3747 FLAGS The flags that are set for this message. 3749 INTERNALDATE The internal date of the message. 3751 RFC822.SIZE The [RFC-5322] size of the message. 3753 UID The unique identifier for the message. 3755 Example: C: A654 FETCH 2:4 (FLAGS BODY[HEADER.FIELDS (DATE FROM)]) 3756 S: * 2 FETCH .... 3757 S: * 3 FETCH .... 3758 S: * 4 FETCH .... 3759 S: A654 OK FETCH completed 3761 6.4.6. STORE Command 3763 Arguments: sequence set 3764 message data item name 3765 value for message data item 3767 Responses: untagged responses: FETCH 3769 Result: OK - store completed 3770 NO - store error: can't store that data 3771 BAD - command unknown or arguments invalid 3773 The STORE command alters data associated with a message in the 3774 mailbox. Normally, STORE will return the updated value of the data 3775 with an untagged FETCH response. A suffix of ".SILENT" in the data 3776 item name prevents the untagged FETCH, and the server SHOULD assume 3777 that the client has determined the updated value itself or does not 3778 care about the updated value. 3780 Note: Regardless of whether or not the ".SILENT" suffix was used, 3781 the server SHOULD send an untagged FETCH response if a change to a 3782 message's flags from an external source is observed. The intent 3783 is that the status of the flags is determinate without a race 3784 condition. 3786 The currently defined data items that can be stored are: 3788 FLAGS Replace the flags for the message with the 3789 argument. The new value of the flags is returned as if a FETCH of 3790 those flags was done. 3792 FLAGS.SILENT Equivalent to FLAGS, but without returning 3793 a new value. 3795 +FLAGS Add the argument to the flags for the message. 3796 The new value of the flags is returned as if a FETCH of those 3797 flags was done. 3799 +FLAGS.SILENT Equivalent to +FLAGS, but without 3800 returning a new value. 3802 -FLAGS Remove the argument from the flags for the 3803 message. The new value of the flags is returned as if a FETCH of 3804 those flags was done. 3806 -FLAGS.SILENT Equivalent to -FLAGS, but without 3807 returning a new value. 3809 Example: C: A003 STORE 2:4 +FLAGS (\Deleted) 3810 S: * 2 FETCH (FLAGS (\Deleted \Seen)) 3811 S: * 3 FETCH (FLAGS (\Deleted)) 3812 S: * 4 FETCH (FLAGS (\Deleted \Flagged \Seen)) 3813 S: A003 OK STORE completed 3815 6.4.7. COPY Command 3817 Arguments: sequence set 3818 mailbox name 3820 Responses: no specific responses for this command 3822 Result: OK - copy completed 3823 NO - copy error: can't copy those messages or to that 3824 name 3825 BAD - command unknown or arguments invalid 3827 The COPY command copies the specified message(s) to the end of the 3828 specified destination mailbox. The flags and internal date of the 3829 message(s) SHOULD be preserved in the copy. 3831 If the destination mailbox does not exist, a server SHOULD return an 3832 error. It SHOULD NOT automatically create the mailbox. Unless it is 3833 certain that the destination mailbox can not be created, the server 3834 MUST send the response code "[TRYCREATE]" as the prefix of the text 3835 of the tagged NO response. This gives a hint to the client that it 3836 can attempt a CREATE command and retry the COPY if the CREATE is 3837 successful. 3839 If the COPY command is unsuccessful for any reason, server 3840 implementations MUST restore the destination mailbox to its state 3841 before the COPY attempt. 3843 On successful completion of a COPY, the server SHOULD return a 3844 COPYUID response code. 3846 In the case of a mailbox that has permissions set so that the client 3847 can COPY to the mailbox, but not SELECT or EXAMINE it, the server 3848 SHOULD NOT send an COPYUID response code as it would disclose 3849 information about the mailbox. 3851 In the case of a mailbox that has UIDNOTSTICKY status (see the 3852 UIDNOTSTICKY response code), the server MAY omit the COPYUID response 3853 code as it is not meaningful. 3855 If the server does not return the COPYUID response code, the client 3856 can discover this information by selecting the destination mailbox. 3858 The location of messages placed in the destination mailbox by COPY 3859 can be determined by using FETCH and/or SEARCH commands (e.g., for 3860 Message-ID). 3862 Example: C: A003 COPY 2:4 MEETING 3863 S: A003 OK COPY completed 3865 6.4.8. MOVE Command 3867 Arguments: sequence set 3868 mailbox name 3870 Responses: no specific responses for this command 3872 Result: OK - move completed 3873 NO - move error: can't move those messages or to that 3874 name 3875 BAD - command unknown or arguments invalid 3877 The MOVE command moves the specified message(s) to the end of the 3878 specified destination mailbox. The flags and internal date of the 3879 message(s) SHOULD be preserved. 3881 This means that a new message is created in the target mailbox with a 3882 new UID, the original message is removed from the source mailbox, and 3883 it appears to the client as a single action. This has the same 3884 effect for each message as this sequence: 3886 1. [UID] COPY 3888 2. [UID] STORE +FLAGS.SILENT \DELETED 3890 3. UID EXPUNGE 3892 Although the effect of the MOVE is the same as the preceding steps, 3893 the semantics are not identical: The intermediate states produced by 3894 those steps do not occur, and the response codes are different. In 3895 particular, though the COPY and EXPUNGE response codes will be 3896 returned, response codes for a STORE MUST NOT be generated and the 3897 \Deleted flag MUST NOT be set for any message. 3899 Because a MOVE applies to a set of messages, it might fail partway 3900 through the set. Regardless of whether the command is successful in 3901 moving the entire set, each individual message SHOULD either be moved 3902 or unaffected. The server MUST leave each message in a state where 3903 it is in at least one of the source or target mailboxes (no message 3904 can be lost or orphaned). The server SHOULD NOT leave any message in 3905 both mailboxes (it would be bad for a partial failure to result in a 3906 bunch of duplicate messages). This is true even if the server 3907 returns a tagged NO response to the command. 3909 Because of the similarity of MOVE to COPY, extensions that affect 3910 COPY affect MOVE in the same way. Response codes such as TRYCREATE 3911 (see Section 7.1), as well as those defined by extensions, are sent 3912 as appropriate. 3914 Servers SHOULD send COPYUID in response to a UID MOVE (see 3915 Section 6.4.9) command. For additional information see Section 7.1. 3917 Servers are also advised to send the COPYUID response code in an 3918 untagged OK before sending EXPUNGE or moved responses. (Sending 3919 COPYUID in the tagged OK, as described in the UIDPLUS specification, 3920 means that clients first receive an EXPUNGE for a message and 3921 afterwards COPYUID for the same message. It can be unnecessarily 3922 difficult to process that sequence usefully.) 3924 An example: 3925 C: a UID MOVE 42:69 foo 3926 S: * OK [COPYUID 432432 42:69 1202:1229] 3927 S: * 22 EXPUNGE 3928 S: (more expunges) 3929 S: a OK Done 3931 Note that the server may send unrelated EXPUNGE responses as well, if 3932 any happen to have been expunged at the same time; this is normal 3933 IMAP operation. 3935 Note that moving a message to the currently selected mailbox (that 3936 is, where the source and target mailboxes are the same) is allowed 3937 when copying the message to the currently selected mailbox is 3938 allowed. 3940 The server may send EXPUNGE responses before the tagged response, so 3941 the client cannot safely send more commands with message sequence 3942 number arguments while the server is processing MOVE. 3944 MOVE and UID MOVE can be pipelined with other commands, but care has 3945 to be taken. Both commands modify sequence numbers and also allow 3946 unrelated EXPUNGE responses. The renumbering of other messages in 3947 the source mailbox following any EXPUNGE response can be surprising 3948 and makes it unsafe to pipeline any command that relies on message 3949 sequence numbers after a MOVE or UID MOVE. Similarly, MOVE cannot be 3950 pipelined with a command that might cause message renumbering. See 3951 Section 5.5, for more information about ambiguities as well as 3952 handling requirements for both clients and servers. 3954 6.4.9. UID Command 3956 Arguments: command name 3957 command arguments 3959 Responses: untagged responses: FETCH, ESEARCH, EXPUNGE 3961 Result: OK - UID command completed 3962 NO - UID command error 3963 BAD - command unknown or arguments invalid 3965 The UID command has three forms. In the first form, it takes as its 3966 arguments a COPY, MOVE, FETCH, or STORE command with arguments 3967 appropriate for the associated command. However, the numbers in the 3968 sequence set argument are unique identifiers instead of message 3969 sequence numbers. Sequence set ranges are permitted, but there is no 3970 guarantee that unique identifiers will be contiguous. 3972 A non-existent unique identifier is ignored without any error message 3973 generated. Thus, it is possible for a UID FETCH command to return an 3974 OK without any data or a UID COPY, UID MOVE or UID STORE to return an 3975 OK without performing any operations. 3977 In the second form, the UID command takes an EXPUNGE command with an 3978 extra parameter the specified a sequence set of UIDs to operate on. 3979 The UID EXPUNGE command permanently removes all messages that both 3980 have the \Deleted flag set and have a UID that is included in the 3981 specified sequence set from the currently selected mailbox. If a 3982 message either does not have the \Deleted flag set or has a UID that 3983 is not included in the specified sequence set, it is not affected. 3985 UID EXPUNGE is particularly useful for disconnected use clients. 3986 By using UID EXPUNGE instead of EXPUNGE when resynchronizing with 3987 the server, the client can ensure that it does not inadvertantly 3988 remove any messages that have been marked as \Deleted by other 3989 clients between the time that the client was last connected and 3990 the time the client resynchronizes. 3992 Example: C: A003 UID EXPUNGE 3000:3002 3993 S: * 3 EXPUNGE 3994 S: * 3 EXPUNGE 3995 S: * 3 EXPUNGE 3996 S: A003 OK UID EXPUNGE completed 3998 In the third form, the UID command takes a SEARCH command with SEARCH 3999 command arguments. The interpretation of the arguments is the same 4000 as with SEARCH; however, the numbers returned in a ESEARCH response 4001 for a UID SEARCH command are unique identifiers instead of message 4002 sequence numbers. Also, the corresponding ESEARCH response MUST 4003 include the UID indicator. For example, the command UID SEARCH 1:100 4004 UID 443:557 returns the unique identifiers corresponding to the 4005 intersection of two sequence sets, the message sequence number range 4006 1:100 and the UID range 443:557. 4008 Note: in the above example, the UID range 443:557 appears. The 4009 same comment about a non-existent unique identifier being ignored 4010 without any error message also applies here. Hence, even if 4011 neither UID 443 or 557 exist, this range is valid and would 4012 include an existing UID 495. 4014 Also note that a UID range of 559:* always includes the UID of the 4015 last message in the mailbox, even if 559 is higher than any 4016 assigned UID value. This is because the contents of a range are 4017 independent of the order of the range endpoints. Thus, any UID 4018 range with * as one of the endpoints indicates at least one 4019 message (the message with the highest numbered UID), unless the 4020 mailbox is empty. 4022 The number after the "*" in an untagged FETCH or EXPUNGE response is 4023 always a message sequence number, not a unique identifier, even for a 4024 UID command response. However, server implementations MUST 4025 implicitly include the UID message data item as part of any FETCH 4026 response caused by a UID command, regardless of whether a UID was 4027 specified as a message data item to the FETCH. 4029 Note: The rule about including the UID message data item as part of a 4030 FETCH response primarily applies to the UID FETCH and UID STORE 4031 commands, including a UID FETCH command that does not include UID as 4032 a message data item. Although it is unlikely that the other UID 4033 commands will cause an untagged FETCH, this rule applies to these 4034 commands as well. 4036 Example: C: A999 UID FETCH 4827313:4828442 FLAGS 4037 S: * 23 FETCH (FLAGS (\Seen) UID 4827313) 4038 S: * 24 FETCH (FLAGS (\Seen) UID 4827943) 4039 S: * 25 FETCH (FLAGS (\Seen) UID 4828442) 4040 S: A999 OK UID FETCH completed 4042 6.5. Client Commands - Experimental/Expansion 4044 6.5.1. X Command 4046 Arguments: implementation defined 4048 Responses: implementation defined 4049 Result: OK - command completed 4050 NO - failure 4051 BAD - command unknown or arguments invalid 4053 Any command prefixed with an X is an experimental command. Commands 4054 which are not part of this specification, a standard or standards- 4055 track revision of this specification, or an IESG-approved 4056 experimental protocol, MUST use the X prefix. 4058 Any added untagged responses issued by an experimental command MUST 4059 also be prefixed with an X. Server implementations MUST NOT send any 4060 such untagged responses, unless the client requested it by issuing 4061 the associated experimental command. 4063 Example: C: a441 CAPABILITY 4064 S: * CAPABILITY IMAP4rev2 XPIG-LATIN 4065 S: a441 OK CAPABILITY completed 4066 C: A442 XPIG-LATIN 4067 S: * XPIG-LATIN ow-nay eaking-spay ig-pay atin-lay 4068 S: A442 OK XPIG-LATIN ompleted-cay 4070 7. Server Responses 4072 Server responses are in three forms: status responses, server data, 4073 and command continuation request. The information contained in a 4074 server response, identified by "Contents:" in the response 4075 descriptions below, is described by function, not by syntax. The 4076 precise syntax of server responses is described in the Formal Syntax 4077 section. 4079 The client MUST be prepared to accept any response at all times. 4081 Status responses can be tagged or untagged. Tagged status responses 4082 indicate the completion result (OK, NO, or BAD status) of a client 4083 command, and have a tag matching the command. 4085 Some status responses, and all server data, are untagged. An 4086 untagged response is indicated by the token "*" instead of a tag. 4087 Untagged status responses indicate server greeting, or server status 4088 that does not indicate the completion of a command (for example, an 4089 impending system shutdown alert). For historical reasons, untagged 4090 server data responses are also called "unsolicited data", although 4091 strictly speaking, only unilateral server data is truly 4092 "unsolicited". 4094 Certain server data MUST be recorded by the client when it is 4095 received; this is noted in the description of that data. Such data 4096 conveys critical information which affects the interpretation of all 4097 subsequent commands and responses (e.g., updates reflecting the 4098 creation or destruction of messages). 4100 Other server data SHOULD be recorded for later reference; if the 4101 client does not need to record the data, or if recording the data has 4102 no obvious purpose (e.g., a SEARCH response when no SEARCH command is 4103 in progress), the data SHOULD be ignored. 4105 An example of unilateral untagged server data occurs when the IMAP 4106 connection is in the selected state. In the selected state, the 4107 server checks the mailbox for new messages as part of command 4108 execution. Normally, this is part of the execution of every command; 4109 hence, a NOOP command suffices to check for new messages. If new 4110 messages are found, the server sends untagged EXISTS response 4111 reflecting the new size of the mailbox. Server implementations that 4112 offer multiple simultaneous access to the same mailbox SHOULD also 4113 send appropriate unilateral untagged FETCH and EXPUNGE responses if 4114 another agent changes the state of any message flags or expunges any 4115 messages. 4117 Command continuation request responses use the token "+" instead of a 4118 tag. These responses are sent by the server to indicate acceptance 4119 of an incomplete client command and readiness for the remainder of 4120 the command. 4122 7.1. Server Responses - Status Responses 4124 Status responses are OK, NO, BAD, PREAUTH and BYE. OK, NO, and BAD 4125 can be tagged or untagged. PREAUTH and BYE are always untagged. 4127 Status responses MAY include an OPTIONAL "response code". A response 4128 code consists of data inside square brackets in the form of an atom, 4129 possibly followed by a space and arguments. The response code 4130 contains additional information or status codes for client software 4131 beyond the OK/NO/BAD condition, and are defined when there is a 4132 specific action that a client can take based upon the additional 4133 information. 4135 The currently defined response codes are: 4137 ALERT 4139 The human-readable text contains a special alert that MUST be 4140 presented to the user in a fashion that calls the user's 4141 attention to the message. 4143 ALREADYEXISTS 4144 The operation attempts to create something that already exists, 4145 such as when the CREATE or RENAME directories attempt to create 4146 a mailbox and there is already one of that name. 4148 C: o RENAME this that 4149 S: o NO [ALREADYEXISTS] Mailbox "that" already exists 4151 APPENDUID 4153 Followed by the UIDVALIDITY of the destination mailbox and the 4154 UID assigned to the appended message in the destination 4155 mailbox, indicates that the message has been appended to the 4156 destination mailbox with that UID. 4158 If the server also supports the [MULTIAPPEND] extension, and if 4159 multiple messages were appended in the APPEND command, then the 4160 second value is a UID set containing the UIDs assigned to the 4161 appended messages, in the order they were transmitted in the 4162 APPEND command. This UID set may not contain extraneous UIDs 4163 or the symbol "*". 4165 Note: the UID set form of the APPENDUID response code MUST 4166 NOT be used if only a single message was appended. In 4167 particular, a server MUST NOT send a range such as 123:123. 4168 This is because a client that does not support [MULTIAPPEND] 4169 expects only a single UID and not a UID set. 4171 UIDs are assigned in strictly ascending order in the mailbox 4172 (refer to Section 2.3.1.1); note that a range of 12:10 is 4173 exactly equivalent to 10:12 and refers to the sequence 4174 10,11,12. 4176 This response code is returned in a tagged OK response to the 4177 APPEND command. 4179 AUTHENTICATIONFAILED 4181 Authentication failed for some reason on which the server is 4182 unwilling to elaborate. Typically, this includes "unknown 4183 user" and "bad password". 4185 This is the same as not sending any response code, except that 4186 when a client sees AUTHENTICATIONFAILED, it knows that the 4187 problem wasn't, e.g., UNAVAILABLE, so there's no point in 4188 trying the same login/password again later. 4190 C: b LOGIN "fred" "foo" 4191 S: b NO [AUTHENTICATIONFAILED] Authentication failed 4193 AUTHORIZATIONFAILED 4195 Authentication succeeded in using the authentication identity, 4196 but the server cannot or will not allow the authentication 4197 identity to act as the requested authorization identity. This 4198 is only applicable when the authentication and authorization 4199 identities are different. 4201 C: c1 AUTHENTICATE PLAIN 4202 [...] 4203 S: c1 NO [AUTHORIZATIONFAILED] No such authorization-ID 4205 C: c2 AUTHENTICATE PLAIN 4206 [...] 4207 S: c2 NO [AUTHORIZATIONFAILED] Authenticator is not an admin 4209 BADCHARSET 4211 Optionally followed by a parenthesized list of charsets. A 4212 SEARCH failed because the given charset is not supported by 4213 this implementation. If the optional list of charsets is 4214 given, this lists the charsets that are supported by this 4215 implementation. 4217 CANNOT 4219 The operation violates some invariant of the server and can 4220 never succeed. 4222 C: l create "///////" 4223 S: l NO [CANNOT] Adjacent slashes are not supported 4225 CAPABILITY 4227 Followed by a list of capabilities. This can appear in the 4228 initial OK or PREAUTH response to transmit an initial 4229 capabilities list. It can also appear in tagged responses to 4230 LOGIN or AUTHENTICATE commands. This makes it unnecessary for 4231 a client to send a separate CAPABILITY command if it recognizes 4232 this response. 4234 CLIENTBUG 4235 The server has detected a client bug. This can accompany all 4236 of OK, NO, and BAD, depending on what the client bug is. 4238 C: k1 select "/archive/projects/experiment-iv" 4239 [...] 4240 S: k1 OK [READ-ONLY] Done 4241 C: k2 status "/archive/projects/experiment-iv" (messages) 4242 [...] 4243 S: k2 OK [CLIENTBUG] Done 4245 CLOSED 4247 The CLOSED response code has no parameters. A server return 4248 the CLOSED response code when the currently selected mailbox is 4249 closed implicitly using the SELECT/EXAMINE command on another 4250 mailbox. The CLOSED response code serves as a boundary between 4251 responses for the previously opened mailbox (which was closed) 4252 and the newly selected mailbox; all responses before the CLOSED 4253 response code relate to the mailbox that was closed, and all 4254 subsequent responses relate to the newly opened mailbox. 4256 There is no need to return the CLOSED response code on 4257 completion of the CLOSE or the UNSELECT command (or similar), 4258 whose purpose is to close the currently selected mailbox 4259 without opening a new one. 4261 The server MAY also return an unsolicited CLOSED response code 4262 when it wants to force the client to return to authenticated 4263 state. For example, the server can do that when the mailbox 4264 requires repairs or is deleted in another session. 4266 CONTACTADMIN 4268 The user should contact the system administrator or support 4269 desk. 4271 C: e login "fred" "foo" 4272 S: e OK [CONTACTADMIN] 4274 COPYUID 4276 Followed by the UIDVALIDITY of the destination mailbox, a UID 4277 set containing the UIDs of the message(s) in the source mailbox 4278 that were copied to the destination mailbox and containing the 4279 UIDs assigned to the copied message(s) in the destination 4280 mailbox, indicates that the message(s) have been copied to the 4281 destination mailbox with the stated UID(s). 4283 The source UID set is in the order the message(s) were copied; 4284 the destination UID set corresponds to the source UID set and 4285 is in the same order. Neither of the UID sets may contain 4286 extraneous UIDs or the symbol "*". 4288 UIDs are assigned in strictly ascending order in the mailbox 4289 (refer to Section 2.3.1.1); note that a range of 12:10 is 4290 exactly equivalent to 10:12 and refers to the sequence 4291 10,11,12. 4293 This response code is returned in a tagged OK response to the 4294 COPY command. 4296 CORRUPTION 4298 The server discovered that some relevant data (e.g., the 4299 mailbox) are corrupt. This response code does not include any 4300 information about what's corrupt, but the server can write that 4301 to its logfiles. 4303 C: i select "/archive/projects/experiment-iv" 4304 S: i NO [CORRUPTION] Cannot open mailbox 4306 EXPIRED 4308 Either authentication succeeded or the server no longer had the 4309 necessary data; either way, access is no longer permitted using 4310 that passphrase. The client or user should get a new 4311 passphrase. 4313 C: d login "fred" "foo" 4314 S: d NO [EXPIRED] That password isn't valid any more 4316 EXPUNGEISSUED 4318 Someone else has issued an EXPUNGE for the same mailbox. The 4319 client may want to issue NOOP soon. [IMAP-MULTIACCESS] 4320 discusses this subject in depth. 4322 C: h search from fred@example.com 4323 S: * ESEARCH (TAG "h") ALL 1:3,5,8,13,21,42 4324 S: h OK [EXPUNGEISSUED] Search completed 4326 INUSE 4328 An operation has not been carried out because it involves 4329 sawing off a branch someone else is sitting on. Someone else 4330 may be holding an exclusive lock needed for this operation, or 4331 the operation may involve deleting a resource someone else is 4332 using, typically a mailbox. 4334 The operation may succeed if the client tries again later. 4336 C: g delete "/archive/projects/experiment-iv" 4337 S: g NO [INUSE] Mailbox in use 4339 LIMIT 4341 The operation ran up against an implementation limit of some 4342 kind, such as the number of flags on a single message or the 4343 number of flags used in a mailbox. 4345 C: m STORE 42 FLAGS f1 f2 f3 f4 f5 ... f250 4346 S: m NO [LIMIT] At most 32 flags in one mailbox supported 4348 NONEXISTENT 4350 The operation attempts to delete something that does not exist. 4351 Similar to ALREADYEXISTS. 4353 C: p RENAME this that 4354 S: p NO [NONEXISTENT] No such mailbox 4356 NOPERM 4358 The access control system (e.g., Access Control List (ACL), see 4359 [RFC4314] does not permit this user to carry out an operation, 4360 such as selecting or creating a mailbox. 4362 C: f select "/archive/projects/experiment-iv" 4363 S: f NO [NOPERM] Access denied 4365 OVERQUOTA 4367 The user would be over quota after the operation. (The user 4368 may or may not be over quota already.) 4370 Note that if the server sends OVERQUOTA but doesn't support the 4371 IMAP QUOTA extension defined by [RFC2087], then there is a 4372 quota, but the client cannot find out what the quota is. 4374 C: n1 uid copy 1:* oldmail 4375 S: n1 NO [OVERQUOTA] Sorry 4377 C: n2 uid copy 1:* oldmail 4378 S: n2 OK [OVERQUOTA] You are now over your soft quota 4380 PARSE 4382 The human-readable text represents an error in parsing the 4383 [RFC-5322] header or [MIME-IMB] headers of a message in the 4384 mailbox. 4386 PERMANENTFLAGS 4388 Followed by a parenthesized list of flags, indicates which of 4389 the known flags the client can change permanently. Any flags 4390 that are in the FLAGS untagged response, but not the 4391 PERMANENTFLAGS list, can not be set permanently. The 4392 PERMANENTFLAGS list can also include the special flag \*, which 4393 indicates that it is possible to create new keywords by 4394 attempting to store those keywords in the mailbox. If the 4395 client attempts to STORE a flag that is not in the 4396 PERMANENTFLAGS list, the server will either ignore the change 4397 or store the state change for the remainder of the current 4398 session only. 4400 There is no need for a server that included the special flag \* 4401 to return a new PERMANENTFLAGS response code when a new keyword 4402 was successfully set on a message upon client request. However 4403 if the server has a limit on the number of different keywords 4404 that can be stored in a mailbox and that limit is reached, the 4405 server MUST send a new PERMANENTFLAGS response code without the 4406 special flag \*. 4408 PRIVACYREQUIRED 4410 The operation is not permitted due to a lack of privacy. If 4411 Transport Layer Security (TLS) is not in use, the client could 4412 try STARTTLS (see Section 6.2.1) and then repeat the operation. 4414 C: d login "fred" "foo" 4415 S: d NO [PRIVACYREQUIRED] Connection offers no privacy 4417 C: d select inbox 4418 S: d NO [PRIVACYREQUIRED] Connection offers no privacy 4420 READ-ONLY 4422 The mailbox is selected read-only, or its access while selected 4423 has changed from read-write to read-only. 4425 READ-WRITE 4427 The mailbox is selected read-write, or its access while 4428 selected has changed from read-only to read-write. 4430 SERVERBUG 4432 The server encountered a bug in itself or violated one of its 4433 own invariants. 4435 C: j select "/archive/projects/experiment-iv" 4436 S: j NO [SERVERBUG] This should not happen 4438 TRYCREATE 4440 An APPEND or COPY attempt is failing because the target mailbox 4441 does not exist (as opposed to some other reason). This is a 4442 hint to the client that the operation can succeed if the 4443 mailbox is first created by the CREATE command. 4445 UIDNEXT 4447 Followed by a decimal number, indicates the next unique 4448 identifier value. Refer to Section 2.3.1.1 for more 4449 information. 4451 UIDNOTSTICKY 4453 The selected mailbox is supported by a mail store that does not 4454 support persistent UIDs; that is, UIDVALIDITY will be different 4455 each time the mailbox is selected. Consequently, APPEND or 4456 COPY to this mailbox will not return an APPENDUID or COPYUID 4457 response code. 4459 This response code is returned in an untagged NO response to 4460 the SELECT command. 4462 Note: servers SHOULD NOT have any UIDNOTSTICKY mail stores. 4463 This facility exists to support legacy mail stores in which 4464 it is technically infeasible to support persistent UIDs. 4465 This should be avoided when designing new mail stores. 4467 UIDVALIDITY 4469 Followed by a decimal number, indicates the unique identifier 4470 validity value. Refer to Section 2.3.1.1 for more information. 4472 UNAVAILABLE 4474 Temporary failure because a subsystem is down. For example, an 4475 IMAP server that uses a Lightweight Directory Access Protocol 4476 (LDAP) or Radius server for authentication might use this 4477 response code when the LDAP/Radius server is down. 4479 C: a LOGIN "fred" "foo" 4480 S: a NO [UNAVAILABLE] User's backend down for maintenance 4482 UNKNOWN-CTE 4484 The server does not know how to decode the section's Content- 4485 Transfer-Encoding. 4487 Additional response codes defined by particular client or server 4488 implementations SHOULD be prefixed with an "X" until they are added 4489 to a revision of this protocol. Client implementations SHOULD ignore 4490 response codes that they do not recognize. 4492 7.1.1. OK Response 4494 Contents: OPTIONAL response code 4495 human-readable text 4497 The OK response indicates an information message from the server. 4498 When tagged, it indicates successful completion of the associated 4499 command. The human-readable text MAY be presented to the user as an 4500 information message. The untagged form indicates an information-only 4501 message; the nature of the information MAY be indicated by a response 4502 code. 4504 The untagged form is also used as one of three possible greetings at 4505 connection startup. It indicates that the connection is not yet 4506 authenticated and that a LOGIN or an AUTHENTICATE command is needed. 4508 Example: S: * OK IMAP4rev2 server ready 4509 C: A001 LOGIN fred blurdybloop 4510 S: * OK [ALERT] System shutdown in 10 minutes 4511 S: A001 OK LOGIN Completed 4513 7.1.2. NO Response 4515 Contents: OPTIONAL response code 4516 human-readable text 4518 The NO response indicates an operational error message from the 4519 server. When tagged, it indicates unsuccessful completion of the 4520 associated command. The untagged form indicates a warning; the 4521 command can still complete successfully. The human-readable text 4522 describes the condition. 4524 Example: C: A222 COPY 1:2 owatagusiam 4525 S: * NO Disk is 98% full, please delete unnecessary data 4526 S: A222 OK COPY completed 4527 C: A223 COPY 3:200 blurdybloop 4528 S: * NO Disk is 98% full, please delete unnecessary data 4529 S: * NO Disk is 99% full, please delete unnecessary data 4530 S: A223 NO COPY failed: disk is full 4532 7.1.3. BAD Response 4534 Contents: OPTIONAL response code 4535 human-readable text 4537 The BAD response indicates an error message from the server. When 4538 tagged, it reports a protocol-level error in the client's command; 4539 the tag indicates the command that caused the error. The untagged 4540 form indicates a protocol-level error for which the associated 4541 command can not be determined; it can also indicate an internal 4542 server failure. The human-readable text describes the condition. 4544 Example: C: ...very long command line... 4545 S: * BAD Command line too long 4546 C: ...empty line... 4547 S: * BAD Empty command line 4548 C: A443 EXPUNGE 4549 S: * BAD Disk crash, attempting salvage to a new disk! 4550 S: * OK Salvage successful, no data lost 4551 S: A443 OK Expunge completed 4553 7.1.4. PREAUTH Response 4555 Contents: OPTIONAL response code 4556 human-readable text 4558 The PREAUTH response is always untagged, and is one of three possible 4559 greetings at connection startup. It indicates that the connection 4560 has already been authenticated by external means; thus no LOGIN/ 4561 AUTHENTICATE command is needed. 4563 Example: S: * PREAUTH IMAP4rev2 server logged in as Smith 4565 7.1.5. BYE Response 4567 Contents: OPTIONAL response code 4568 human-readable text 4570 The BYE response is always untagged, and indicates that the server is 4571 about to close the connection. The human-readable text MAY be 4572 displayed to the user in a status report by the client. The BYE 4573 response is sent under one of four conditions: 4575 1. as part of a normal logout sequence. The server will close the 4576 connection after sending the tagged OK response to the LOGOUT 4577 command. 4579 2. as a panic shutdown announcement. The server closes the 4580 connection immediately. 4582 3. as an announcement of an inactivity autologout. The server 4583 closes the connection immediately. 4585 4. as one of three possible greetings at connection startup, 4586 indicating that the server is not willing to accept a connection 4587 from this client. The server closes the connection immediately. 4589 The difference between a BYE that occurs as part of a normal LOGOUT 4590 sequence (the first case) and a BYE that occurs because of a failure 4591 (the other three cases) is that the connection closes immediately in 4592 the failure case. In all cases the client SHOULD continue to read 4593 response data from the server until the connection is closed; this 4594 will ensure that any pending untagged or completion responses are 4595 read and processed. 4597 Example: S: * BYE Autologout; idle for too long 4599 7.2. Server Responses - Server and Mailbox Status 4601 These responses are always untagged. This is how server and mailbox 4602 status data are transmitted from the server to the client. Many of 4603 these responses typically result from a command with the same name. 4605 7.2.1. The ENABLED Response 4607 Contents: capability listing 4609 The ENABLED response occurs as a result of an ENABLE command. The 4610 capability listing contains a space-separated listing of capability 4611 names that the server supports and that were successfully enabled. 4613 The ENABLED response may contain no capabilities, which means that no 4614 extensions listed by the client were successfully enabled. 4616 7.2.2. CAPABILITY Response 4618 Contents: capability listing 4620 The CAPABILITY response occurs as a result of a CAPABILITY command. 4621 The capability listing contains a space-separated listing of 4622 capability names that the server supports. The capability listing 4623 MUST include the atom "IMAP4rev2". 4625 In addition, client and server implementations MUST implement the 4626 STARTTLS, LOGINDISABLED, and AUTH=PLAIN (described in [PLAIN]) 4627 capabilities. See the Security Considerations section for important 4628 information. 4630 A capability name which begins with "AUTH=" indicates that the server 4631 supports that particular authentication mechanism. 4633 The LOGINDISABLED capability indicates that the LOGIN command is 4634 disabled, and that the server will respond with a tagged NO response 4635 to any attempt to use the LOGIN command even if the user name and 4636 password are valid. An IMAP client MUST NOT issue the LOGIN command 4637 if the server advertises the LOGINDISABLED capability. 4639 Other capability names indicate that the server supports an 4640 extension, revision, or amendment to the IMAP4rev2 protocol. Server 4641 responses MUST conform to this document until the client issues a 4642 command that uses the associated capability. 4644 Capability names MUST either begin with "X" or be standard or 4645 standards-track IMAP4rev2 extensions, revisions, or amendments 4646 registered with IANA. A server MUST NOT offer unregistered or non- 4647 standard capability names, unless such names are prefixed with an 4648 "X". 4650 Client implementations SHOULD NOT require any capability name other 4651 than "IMAP4rev2", and MUST ignore any unknown capability names. 4653 A server MAY send capabilities automatically, by using the CAPABILITY 4654 response code in the initial PREAUTH or OK responses, and by sending 4655 an updated CAPABILITY response code in the tagged OK response as part 4656 of a successful authentication. It is unnecessary for a client to 4657 send a separate CAPABILITY command if it recognizes these automatic 4658 capabilities. 4660 Example: S: * CAPABILITY IMAP4rev2 STARTTLS AUTH=GSSAPI XPIG-LATIN 4662 7.2.3. LIST Response 4664 Contents: name attributes 4665 hierarchy delimiter 4666 name 4668 The LIST response occurs as a result of a LIST command. It returns a 4669 single name that matches the LIST specification. There can be 4670 multiple LIST responses for a single LIST command. 4672 The following base name attributes are defined: 4674 \NonExistent The "\NonExistent" attribute indicates that a mailbox 4675 name does not refer to an existing mailbox. Note that this 4676 attribute is not meaningful by itself, as mailbox names that match 4677 the canonical LIST pattern but don't exist must not be returned 4678 unless one of the two conditions listed below is also satisfied: 4680 1. The mailbox name also satisfies the selection criteria (for 4681 example, it is subscribed and the "SUBSCRIBED" selection 4682 option has been specified). 4684 2. "RECURSIVEMATCH" has been specified, and the mailbox name has 4685 at least one descendant mailbox name that does not match the 4686 LIST pattern and does match the selection criteria. 4688 In practice, this means that the "\NonExistent" attribute is 4689 usually returned with one or more of "\Subscribed", "\Remote", 4690 "\HasChildren", or the CHILDINFO extended data item. 4692 The "\NonExistent" attribute implies "\NoSelect". 4694 \Noinferiors It is not possible for any child levels of hierarchy to 4695 exist under this name; no child levels exist now and none can be 4696 created in the future. 4698 \Noselect It is not possible to use this name as a selectable 4699 mailbox. 4701 \HasChildren The presence of this attribute indicates that the 4702 mailbox has child mailboxes. A server SHOULD NOT set this 4703 attribute if there are child mailboxes and the user does not have 4704 permission to access any of them. In this case, \HasNoChildren 4705 SHOULD be used. In many cases, however, a server may not be able 4706 to efficiently compute whether a user has access to any child 4707 mailbox. Note that even though the \HasChildren attribute for a 4708 mailbox must be correct at the time of processing of the mailbox, 4709 a client must be prepared to deal with a situation when a mailbox 4710 is marked with the \HasChildren attribute, but no child mailbox 4711 appears in the response to the LIST command. This might happen, 4712 for example, due to children mailboxes being deleted or made 4713 inaccessible to the user (using access control) by another client 4714 before the server is able to list them. 4716 \HasNoChildren The presence of this attribute indicates that the 4717 mailbox has NO child mailboxes that are accessible to the 4718 currently authenticated user. 4720 \Marked The mailbox has been marked "interesting" by the server; the 4721 mailbox probably contains messages that have been added since the 4722 last time the mailbox was selected. 4724 \Unmarked The mailbox does not contain any additional messages since 4725 the last time the mailbox was selected. 4727 \Subscribed The mailbox name was subscribed to using the SUBSCRIBE 4728 command. 4730 \Remote The mailbox is a remote mailbox. 4732 It is an error for the server to return both a \HasChildren and a 4733 \HasNoChildren attribute in the same LIST response. 4735 Note: the \HasNoChildren attribute should not be confused with the 4736 \NoInferiors attribute, which indicates that no child mailboxes 4737 exist now and none can be created in the future. 4739 If it is not feasible for the server to determine whether or not the 4740 mailbox is "interesting", the server SHOULD NOT send either \Marked 4741 or \Unmarked. The server MUST NOT send more than one of \Marked, 4742 \Unmarked, and \Noselect for a single mailbox, and MAY send none of 4743 these. 4745 In addition to the base name attributes defined above, an IMAP server 4746 MAY also include any or all of the following attributes that denote 4747 "role" (or "special-use") of a mailbox. These attributes are 4748 included along with base attributes defined above. A given mailbox 4749 may have none, one, or more than one of these attributes. In some 4750 cases, a special use is advice to a client about what to put in that 4751 mailbox. In other cases, it's advice to a client about what to 4752 expect to find there. 4754 \All This mailbox presents all messages in the user's message store. 4755 Implementations MAY omit some messages, such as, perhaps, those in 4756 \Trash and \Junk. When this special use is supported, it is 4757 almost certain to represent a virtual mailbox. 4759 \Archive This mailbox is used to archive messages. The meaning of 4760 an "archival" mailbox is server-dependent; typically, it will be 4761 used to get messages out of the inbox, or otherwise keep them out 4762 of the user's way, while still making them accessible. 4764 \Drafts This mailbox is used to hold draft messages -- typically, 4765 messages that are being composed but have not yet been sent. In 4766 some server implementations, this might be a virtual mailbox, 4767 containing messages from other mailboxes that are marked with the 4768 "\Draft" message flag. Alternatively, this might just be advice 4769 that a client put drafts here. 4771 \Flagged This mailbox presents all messages marked in some way as 4772 "important". When this special use is supported, it is likely to 4773 represent a virtual mailbox collecting messages (from other 4774 mailboxes) that are marked with the "\Flagged" message flag. 4776 \Junk This mailbox is where messages deemed to be junk mail are 4777 held. Some server implementations might put messages here 4778 automatically. Alternatively, this might just be advice to a 4779 client-side spam filter. 4781 \Sent This mailbox is used to hold copies of messages that have been 4782 sent. Some server implementations might put messages here 4783 automatically. Alternatively, this might just be advice that a 4784 client save sent messages here. 4786 \Trash This mailbox is used to hold messages that have been deleted 4787 or marked for deletion. In some server implementations, this 4788 might be a virtual mailbox, containing messages from other 4789 mailboxes that are marked with the "\Deleted" message flag. 4790 Alternatively, this might just be advice that a client that 4791 chooses not to use the IMAP "\Deleted" model should use this as 4792 its trash location. In server implementations that strictly 4793 expect the IMAP "\Deleted" model, this special use is likely not 4794 to be supported. 4796 All of special-use attributes are OPTIONAL, and any given server or 4797 message store may support any combination of the attributes, or none 4798 at all. In most cases, there will likely be at most one mailbox with 4799 a given attribute for a given user, but in some server or message 4800 store implementations it might be possible for multiple mailboxes to 4801 have the same special-use attribute. 4803 Special-use attributes are likely to be user-specific. User Adam 4804 might share his \Sent mailbox with user Barb, but that mailbox is 4805 unlikely to also serve as Barb's \Sent mailbox. 4807 The hierarchy delimiter is a character used to delimit levels of 4808 hierarchy in a mailbox name. A client can use it to create child 4809 mailboxes, and to search higher or lower levels of naming hierarchy. 4810 All children of a top-level hierarchy node MUST use the same 4811 separator character. A NIL hierarchy delimiter means that no 4812 hierarchy exists; the name is a "flat" name. 4814 The name represents an unambiguous left-to-right hierarchy, and MUST 4815 be valid for use as a reference in LIST command. Unless \Noselect or 4816 \NonExistent is indicated, the name MUST also be valid as an argument 4817 for commands, such as SELECT, that accept mailbox names. 4819 Example: S: * LIST (\Noselect) "/" ~/Mail/foo 4821 7.2.4. NAMESPACE Response 4823 Contents: the prefix and hierarchy delimiter to the server's 4824 Personal Namespace(s), Other Users' Namespace(s), and 4825 Shared Namespace(s) 4827 The NAMESPACE response occurs as a result of a NAMESPACE command. It 4828 contains the prefix and hierarchy delimiter to the server's Personal 4829 Namespace(s), Other Users' Namespace(s), and Shared Namespace(s) that 4830 the server wishes to expose. The response will contain a NIL for any 4831 namespace class that is not available. Namespace-Response-Extensions 4832 ABNF non terminal is defined for extensibility and MAY be included in 4833 the response. 4835 Example: S: * NAMESPACE (("" "/")) (("~" "/")) NIL 4837 7.2.5. STATUS Response 4839 Contents: name 4840 status parenthesized list 4842 The STATUS response occurs as a result of an STATUS command. It 4843 returns the mailbox name that matches the STATUS specification and 4844 the requested mailbox status information. 4846 Example: S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) 4848 7.2.6. ESEARCH Response 4850 Contents: one or more search-return-data pairs 4852 The ESEARCH response occurs as a result of a SEARCH or UID SEARCH 4853 command. 4855 The ESEARCH response starts with an optional search correlator. If 4856 it is missing, then the response was not caused by a particular IMAP 4857 command, whereas if it is present, it contains the tag of the command 4858 that caused the response to be returned. 4860 The search correlator is followed by an optional UID indicator. If 4861 this indicator is present, all data in the ESEARCH response refers to 4862 UIDs, otherwise all returned data refers to message numbers. 4864 The rest of the ESEARCH response contains one or more search data 4865 pairs. Each pair starts with unique return item name, followed by a 4866 space and the corresponding data. Search data pairs may be returned 4867 in any order. Unless specified otherwise by an extension, any return 4868 item name SHOULD appear only once in an ESEARCH response. 4870 [[TBD: describe the most common search data pairs returned.]] 4872 Example: S: * ESEARCH UID COUNT 5 ALL 4:19,21,28 4874 Example: S: * ESEARCH (TAG "a567") UID COUNT 5 ALL 4:19,21,28 4876 Example: S: * ESEARCH COUNT 5 ALL 1:17,21 4878 7.2.7. FLAGS Response 4880 Contents: flag parenthesized list 4882 The FLAGS response occurs as a result of a SELECT or EXAMINE command. 4883 The flag parenthesized list identifies the flags (at a minimum, the 4884 system-defined flags) that are applicable for this mailbox. Flags 4885 other than the system flags can also exist, depending on server 4886 implementation. 4888 The update from the FLAGS response MUST be recorded by the client. 4890 Example: S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 4892 7.3. Server Responses - Mailbox Size 4894 These responses are always untagged. This is how changes in the size 4895 of the mailbox are transmitted from the server to the client. 4896 Immediately following the "*" token is a number that represents a 4897 message count. 4899 7.3.1. EXISTS Response 4901 Contents: none 4903 The EXISTS response reports the number of messages in the mailbox. 4904 This response occurs as a result of a SELECT or EXAMINE command, and 4905 if the size of the mailbox changes (e.g., new messages). 4907 The update from the EXISTS response MUST be recorded by the client. 4909 Example: S: * 23 EXISTS 4911 7.4. Server Responses - Message Status 4913 These responses are always untagged. This is how message data are 4914 transmitted from the server to the client, often as a result of a 4915 command with the same name. Immediately following the "*" token is a 4916 number that represents a message sequence number. 4918 7.4.1. EXPUNGE Response 4920 Contents: none 4922 The EXPUNGE response reports that the specified message sequence 4923 number has been permanently removed from the mailbox. The message 4924 sequence number for each successive message in the mailbox is 4925 immediately decremented by 1, and this decrement is reflected in 4926 message sequence numbers in subsequent responses (including other 4927 untagged EXPUNGE responses). 4929 The EXPUNGE response also decrements the number of messages in the 4930 mailbox; it is not necessary to send an EXISTS response with the new 4931 value. 4933 As a result of the immediate decrement rule, message sequence numbers 4934 that appear in a set of successive EXPUNGE responses depend upon 4935 whether the messages are removed starting from lower numbers to 4936 higher numbers, or from higher numbers to lower numbers. For 4937 example, if the last 5 messages in a 9-message mailbox are expunged, 4938 a "lower to higher" server will send five untagged EXPUNGE responses 4939 for message sequence number 5, whereas a "higher to lower server" 4940 will send successive untagged EXPUNGE responses for message sequence 4941 numbers 9, 8, 7, 6, and 5. 4943 An EXPUNGE response MUST NOT be sent when no command is in progress, 4944 nor while responding to a FETCH, STORE, or SEARCH command. This rule 4945 is necessary to prevent a loss of synchronization of message sequence 4946 numbers between client and server. A command is not "in progress" 4947 until the complete command has been received; in particular, a 4948 command is not "in progress" during the negotiation of command 4949 continuation. 4951 Note: UID FETCH, UID STORE, and UID SEARCH are different commands 4952 from FETCH, STORE, and SEARCH. An EXPUNGE response MAY be sent 4953 during a UID command. 4955 The update from the EXPUNGE response MUST be recorded by the client. 4957 Example: S: * 44 EXPUNGE 4959 7.4.2. FETCH Response 4961 Contents: message data 4963 The FETCH response returns data about a message to the client. The 4964 data are pairs of data item names and their values in parentheses. 4965 This response occurs as the result of a FETCH or STORE command, as 4966 well as by unilateral server decision (e.g., flag updates). 4968 The current data items are: 4970 BINARY[]<> 4972 An or expressing the content of the 4973 specified section after removing any Content-Transfer-Encoding- 4974 related encoding. If is present it refers to the 4975 offset within the DECODED section data. 4977 If the domain of the decoded data is "8bit" and the data does 4978 not contain the NUL octet, the server SHOULD return the data in 4979 a instead of a ; this allows the client to 4980 determine if the "8bit" data contains the NUL octet without 4981 having to explicitly scan the data stream for for NULs. 4983 Messaging clients and servers have been notoriously lax in 4984 their adherence to the Internet CRLF convention for terminating 4985 lines of textual data (text/* media types) in Internet 4986 protocols. When sending data in BINARY[...] FETCH data item, 4987 servers MUST ensure that textual line-oriented sections are 4988 always transmitted using the IMAP4 CRLF line termination 4989 syntax, regardless of the underlying storage representation of 4990 the data on the server. 4992 If the server does not know how to decode the section's 4993 Content-Transfer-Encoding, it MUST fail the request and issue a 4994 "NO" response that contains the "UNKNOWN-CTE" response code. 4996 BINARY.SIZE[] 4998 The size of the section after removing any Content-Transfer- 4999 Encoding-related encoding. The value returned MUST match the 5000 size of the or that will be returned by 5001 the corresponding FETCH BINARY request. 5003 If the server does not know how to decode the section's 5004 Content-Transfer-Encoding, it MUST fail the request and issue a 5005 "NO" response that contains the "UNKNOWN-CTE" response code. 5007 BODY A form of BODYSTRUCTURE without extension data. 5009 BODY[
]<> 5011 A string expressing the body contents of the specified section. 5012 The string SHOULD be interpreted by the client according to the 5013 content transfer encoding, body type, and subtype. 5015 If the origin octet is specified, this string is a substring of 5016 the entire body contents, starting at that origin octet. This 5017 means that BODY[]<0> MAY be truncated, but BODY[] is NEVER 5018 truncated. 5020 Note: The origin octet facility MUST NOT be used by a server 5021 in a FETCH response unless the client specifically requested 5022 it by means of a FETCH of a BODY[
]<> data 5023 item. 5025 8-bit textual data is permitted if a [CHARSET] identifier is 5026 part of the body parameter parenthesized list for this section. 5027 Note that headers (part specifiers HEADER or MIME, or the 5028 header portion of a MESSAGE/RFC822 or MESSAGE/GLOBAL part), MAY 5029 be in UTF-8. Note also that the [RFC-5322] delimiting blank 5030 line between the header and the body is not affected by header 5031 line subsetting; the blank line is always included as part of 5032 header data, except in the case of a message which has no body 5033 and no blank line. 5035 Non-textual data such as binary data MUST be transfer encoded 5036 into a textual form, such as BASE64, prior to being sent to the 5037 client. To derive the original binary data, the client MUST 5038 decode the transfer encoded string. 5040 BODYSTRUCTURE 5042 A parenthesized list that describes the [MIME-IMB] body 5043 structure of a message. This is computed by the server by 5044 parsing the [MIME-IMB] header fields, defaulting various fields 5045 as necessary. 5047 For example, a simple text message of 48 lines and 2279 octets 5048 can have a body structure of: ("TEXT" "PLAIN" ("CHARSET" "US- 5049 ASCII") NIL NIL "7BIT" 2279 48) 5051 Multiple parts are indicated by parenthesis nesting. Instead 5052 of a body type as the first element of the parenthesized list, 5053 there is a sequence of one or more nested body structures. The 5054 second element of the parenthesized list is the multipart 5055 subtype (mixed, digest, parallel, alternative, etc.). 5057 For example, a two part message consisting of a text and a 5058 BASE64-encoded text attachment can have a body structure of: 5059 (("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 1152 5060 23)("TEXT" "PLAIN" ("CHARSET" "US-ASCII" "NAME" "cc.diff") 5061 "<960723163407.20117h@cac.washington.edu>" "Compiler diff" 5062 "BASE64" 4554 73) "MIXED") 5064 Extension data follows the multipart subtype. Extension data 5065 is never returned with the BODY fetch, but can be returned with 5066 a BODYSTRUCTURE fetch. Extension data, if present, MUST be in 5067 the defined order. The extension data of a multipart body part 5068 are in the following order: 5070 body parameter parenthesized list A parenthesized list of 5071 attribute/value pairs [e.g., ("foo" "bar" "baz" "rag") where 5072 "bar" is the value of "foo", and "rag" is the value of 5073 "baz"] as defined in [MIME-IMB]. 5075 body parameter parenthesized list Servers SHOULD decode 5076 parameter value continuations as described in [RFC2231], for 5077 example, if the message contains parameters "foo*0*" and 5078 "foo*1*", the server should RFC2231-decode them, concatenate 5079 and return the resulting value as "foo*". 5081 body disposition A parenthesized list, consisting of a 5082 disposition type string, followed by a parenthesized list of 5083 disposition attribute/value pairs as defined in 5084 [DISPOSITION]. Servers SHOULD decode parameter value 5085 continuations as described in [RFC2231]. 5087 body language A string or parenthesized list giving the body 5088 language value as defined in [LANGUAGE-TAGS]. 5090 body location A string giving the body content URI as defined 5091 in [LOCATION]. 5093 Any following extension data are not yet defined in this 5094 version of the protocol. Such extension data can consist of 5095 zero or more NILs, strings, numbers, or potentially nested 5096 parenthesized lists of such data. Client implementations that 5097 do a BODYSTRUCTURE fetch MUST be prepared to accept such 5098 extension data. Server implementations MUST NOT send such 5099 extension data until it has been defined by a revision of this 5100 protocol. 5102 The basic fields of a non-multipart body part are in the 5103 following order: 5105 body type A string giving the content media type name as 5106 defined in [MIME-IMB]. 5108 body subtype A string giving the content subtype name as 5109 defined in [MIME-IMB]. 5111 body parameter parenthesized list A parenthesized list of 5112 attribute/value pairs [e.g., ("foo" "bar" "baz" "rag") where 5113 "bar" is the value of "foo" and "rag" is the value of "baz"] 5114 as defined in [MIME-IMB]. 5116 body id A string giving the Content-ID header field value as 5117 defined in Section 7 of [MIME-IMB]. 5119 body description A string giving the Content-Description 5120 header field value as defined in Section 8 of [MIME-IMB]. 5122 body encoding A string giving the content transfer encoding as 5123 defined in Section 6 of [MIME-IMB]. 5125 body size A number giving the size of the body in octets. 5126 Note that this size is the size in its transfer encoding and 5127 not the resulting size after any decoding. 5129 A body type of type MESSAGE and subtype RFC822 contains, 5130 immediately after the basic fields, the envelope structure, 5131 body structure, and size in text lines of the encapsulated 5132 message. 5134 A body type of type TEXT contains, immediately after the basic 5135 fields, the size of the body in text lines. Note that this 5136 size is the size in its content transfer encoding and not the 5137 resulting size after any decoding. 5139 Extension data follows the basic fields and the type-specific 5140 fields listed above. Extension data is never returned with the 5141 BODY fetch, but can be returned with a BODYSTRUCTURE fetch. 5142 Extension data, if present, MUST be in the defined order. 5144 The extension data of a non-multipart body part are in the 5145 following order: 5147 body MD5 A string giving the body MD5 value as defined in 5148 [MD5]. 5150 body disposition A parenthesized list with the same content 5151 and function as the body disposition for a multipart body 5152 part. 5154 body language A string or parenthesized list giving the body 5155 language value as defined in [LANGUAGE-TAGS]. 5157 body location A string giving the body content URI as defined 5158 in [LOCATION]. 5160 Any following extension data are not yet defined in this 5161 version of the protocol, and would be as described above under 5162 multipart extension data. 5164 ENVELOPE 5166 A parenthesized list that describes the envelope structure of a 5167 message. This is computed by the server by parsing the 5168 [RFC-5322] header into the component parts, defaulting various 5169 fields as necessary. 5171 The fields of the envelope structure are in the following 5172 order: date, subject, from, sender, reply-to, to, cc, bcc, in- 5173 reply-to, and message-id. The date, subject, in-reply-to, and 5174 message-id fields are strings. The from, sender, reply-to, to, 5175 cc, and bcc fields are parenthesized lists of address 5176 structures. 5178 An address structure is a parenthesized list that describes an 5179 electronic mail address. The fields of an address structure 5180 are in the following order: personal name, [SMTP] at-domain- 5181 list (source route), mailbox name, and host name. 5183 [RFC-5322] group syntax is indicated by a special form of 5184 address structure in which the host name field is NIL. If the 5185 mailbox name field is also NIL, this is an end of group marker 5186 (semi-colon in RFC 822 syntax). If the mailbox name field is 5187 non-NIL, this is a start of group marker, and the mailbox name 5188 field holds the group name phrase. 5190 If the Date, Subject, In-Reply-To, and Message-ID header lines 5191 are absent in the [RFC-5322] header, the corresponding member 5192 of the envelope is NIL; if these header lines are present but 5193 empty the corresponding member of the envelope is the empty 5194 string. 5196 Note: some servers may return a NIL envelope member in the 5197 "present but empty" case. Clients SHOULD treat NIL and 5198 empty string as identical. 5200 Note: [RFC-5322] requires that all messages have a valid 5201 Date header. Therefore, the date member in the envelope can 5202 not be NIL or the empty string. 5204 Note: [RFC-5322] requires that the In-Reply-To and Message- 5205 ID headers, if present, have non-empty content. Therefore, 5206 the in-reply-to and message-id members in the envelope can 5207 not be the empty string. 5209 If the From, To, Cc, and Bcc header lines are absent in the 5210 [RFC-5322] header, or are present but empty, the corresponding 5211 member of the envelope is NIL. 5213 If the Sender or Reply-To lines are absent in the [RFC-5322] 5214 header, or are present but empty, the server sets the 5215 corresponding member of the envelope to be the same value as 5216 the from member (the client is not expected to know to do 5217 this). 5219 Note: [RFC-5322] requires that all messages have a valid 5220 From header. Therefore, the from, sender, and reply-to 5221 members in the envelope can not be NIL. 5223 FLAGS A parenthesized list of flags that are set for this message. 5225 INTERNALDATE A string representing the internal date of the message. 5227 RFC822.SIZE A number expressing the [RFC-5322] size of the message. 5229 UID A number expressing the unique identifier of the message. 5231 Example: S: * 23 FETCH (FLAGS (\Seen) RFC822.SIZE 44827) 5233 7.5. Server Responses - Command Continuation Request 5235 The command continuation request response is indicated by a "+" token 5236 instead of a tag. This form of response indicates that the server is 5237 ready to accept the continuation of a command from the client. The 5238 remainder of this response is a line of text. 5240 This response is used in the AUTHENTICATE command to transmit server 5241 data to the client, and request additional client data. This 5242 response is also used if an argument to any command is a 5243 synchronizing literal. 5245 The client is not permitted to send the octets of the synchronizing 5246 literal unless the server indicates that it is expected. This 5247 permits the server to process commands and reject errors on a line- 5248 by-line basis. The remainder of the command, including the CRLF that 5249 terminates a command, follows the octets of the literal. If there 5250 are any additional command arguments, the literal octets are followed 5251 by a space and those arguments. 5253 Example: C: A001 LOGIN {11} 5254 S: + Ready for additional command text 5255 C: FRED FOOBAR {7} 5256 S: + Ready for additional command text 5257 C: fat man 5258 S: A001 OK LOGIN completed 5259 C: A044 BLURDYBLOOP {102856} 5260 S: A044 BAD No such command as "BLURDYBLOOP" 5262 8. Sample IMAP4rev2 connection 5264 The following is a transcript of an IMAP4rev2 connection. A long 5265 line in this sample is broken for editorial clarity. 5267 S: * OK IMAP4rev2 Service Ready 5268 C: a001 login mrc secret 5269 S: a001 OK LOGIN completed 5270 C: a002 select inbox 5271 S: * 18 EXISTS 5272 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 5273 S: * OK [UIDVALIDITY 3857529045] UIDs valid 5274 S: a002 OK [READ-WRITE] SELECT completed 5275 C: a003 fetch 12 full 5276 S: * 12 FETCH (FLAGS (\Seen) INTERNALDATE "17-Jul-1996 02:44:25 -0700" 5277 RFC822.SIZE 4286 ENVELOPE ("Wed, 17 Jul 1996 02:23:25 -0700 (PDT)" 5278 "IMAP4rev2 WG mtg summary and minutes" 5279 (("Terry Gray" NIL "gray" "cac.washington.edu")) 5280 (("Terry Gray" NIL "gray" "cac.washington.edu")) 5281 (("Terry Gray" NIL "gray" "cac.washington.edu")) 5282 ((NIL NIL "imap" "cac.washington.edu")) 5283 ((NIL NIL "minutes" "CNRI.Reston.VA.US") 5284 ("John Klensin" NIL "KLENSIN" "MIT.EDU")) NIL NIL 5285 "") 5286 BODY ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 3028 5287 92)) 5288 S: a003 OK FETCH completed 5289 C: a004 fetch 12 body[header] 5290 S: * 12 FETCH (BODY[HEADER] {342} 5291 S: Date: Wed, 17 Jul 1996 02:23:25 -0700 (PDT) 5292 S: From: Terry Gray 5293 S: Subject: IMAP4rev2 WG mtg summary and minutes 5294 S: To: imap@cac.washington.edu 5295 S: cc: minutes@CNRI.Reston.VA.US, John Klensin 5296 S: Message-Id: 5297 S: MIME-Version: 1.0 5298 S: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 5299 S: 5300 S: ) 5301 S: a004 OK FETCH completed 5302 C: a005 store 12 +flags \deleted 5303 S: * 12 FETCH (FLAGS (\Seen \Deleted)) 5304 S: a005 OK +FLAGS completed 5305 C: a006 logout 5306 S: * BYE IMAP4rev2 server terminating connection 5307 S: a006 OK LOGOUT completed 5309 9. Formal Syntax 5311 The following syntax specification uses the Augmented Backus-Naur 5312 Form (ABNF) notation as specified in [ABNF]. 5314 In the case of alternative or optional rules in which a later rule 5315 overlaps an earlier rule, the rule which is listed earlier MUST take 5316 priority. For example, "\Seen" when parsed as a flag is the \Seen 5317 flag name and not a flag-extension, even though "\Seen" can be parsed 5318 as a flag-extension. Some, but not all, instances of this rule are 5319 noted below. 5321 Note: [ABNF] rules MUST be followed strictly; in particular: 5323 (1) Except as noted otherwise, all alphabetic characters are case- 5324 insensitive. The use of upper or lower case characters to define 5325 token strings is for editorial clarity only. Implementations MUST 5326 accept these strings in a case-insensitive fashion. 5328 (2) In all cases, SP refers to exactly one space. It is NOT 5329 permitted to substitute TAB, insert additional spaces, or 5330 otherwise treat SP as being equivalent to LWSP. 5332 (3) The ASCII NUL character, %x00, MUST NOT be used at any time. 5334 address = "(" addr-name SP addr-adl SP addr-mailbox SP 5335 addr-host ")" 5337 addr-adl = nstring 5338 ; Holds route from [RFC-5322] route-addr if 5339 ; non-NIL 5341 addr-host = nstring 5342 ; NIL indicates [RFC-5322] group syntax. 5343 ; Otherwise, holds [RFC-5322] domain name 5345 addr-mailbox = nstring 5346 ; NIL indicates end of [RFC-5322] group; if 5347 ; non-NIL and addr-host is NIL, holds 5348 ; [RFC-5322] group name. 5349 ; Otherwise, holds [RFC-5322] local-part 5350 ; after removing [RFC-5322] quoting 5352 addr-name = nstring 5353 ; If non-NIL, holds phrase from [RFC-5322] 5354 ; mailbox after removing [RFC-5322] quoting 5356 append = "APPEND" SP mailbox [SP flag-list] [SP date-time] SP 5357 literal 5359 append-uid = uniqueid 5361 astring = 1*ASTRING-CHAR / string 5362 ASTRING-CHAR = ATOM-CHAR / resp-specials 5364 atom = 1*ATOM-CHAR 5366 ATOM-CHAR = 5368 atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards / 5369 quoted-specials / resp-specials 5371 authenticate = "AUTHENTICATE" SP auth-type [SP initial-resp] 5372 *(CRLF base64) 5374 auth-type = atom 5375 ; Defined by [SASL] 5377 base64 = *(4base64-char) [base64-terminal] 5379 base64-char = ALPHA / DIGIT / "+" / "/" 5380 ; Case-sensitive 5382 base64-terminal = (2base64-char "==") / (3base64-char "=") 5384 body = "(" (body-type-1part / body-type-mpart) ")" 5386 body-extension = nstring / number / 5387 "(" body-extension *(SP body-extension) ")" 5388 ; Future expansion. Client implementations 5389 ; MUST accept body-extension fields. Server 5390 ; implementations MUST NOT generate 5391 ; body-extension fields except as defined by 5392 ; future standard or standards-track 5393 ; revisions of this specification. 5395 body-ext-1part = body-fld-md5 [SP body-fld-dsp [SP body-fld-lang 5396 [SP body-fld-loc *(SP body-extension)]]] 5397 ; MUST NOT be returned on non-extensible 5398 ; "BODY" fetch 5400 body-ext-mpart = body-fld-param [SP body-fld-dsp [SP body-fld-lang 5401 [SP body-fld-loc *(SP body-extension)]]] 5402 ; MUST NOT be returned on non-extensible 5403 ; "BODY" fetch 5405 body-fields = body-fld-param SP body-fld-id SP body-fld-desc SP 5406 body-fld-enc SP body-fld-octets 5408 body-fld-desc = nstring 5409 body-fld-dsp = "(" string SP body-fld-param ")" / nil 5411 body-fld-enc = (DQUOTE ("7BIT" / "8BIT" / "BINARY" / "BASE64"/ 5412 "QUOTED-PRINTABLE") DQUOTE) / string 5414 body-fld-id = nstring 5416 body-fld-lang = nstring / "(" string *(SP string) ")" 5418 body-fld-loc = nstring 5420 body-fld-lines = number 5422 body-fld-md5 = nstring 5424 body-fld-octets = number 5426 body-fld-param = "(" string SP string *(SP string SP string) ")" / nil 5428 body-type-1part = (body-type-basic / body-type-msg / body-type-text) 5429 [SP body-ext-1part] 5431 body-type-basic = media-basic SP body-fields 5432 ; MESSAGE subtype MUST NOT be "RFC822" or "GLOBAL" 5434 body-type-mpart = 1*body SP media-subtype 5435 [SP body-ext-mpart] 5436 ; MULTIPART body part 5438 body-type-msg = media-message SP body-fields SP envelope 5439 SP body SP body-fld-lines 5441 body-type-text = media-text SP body-fields SP body-fld-lines 5443 capability = ("AUTH=" auth-type) / atom 5444 ; New capabilities MUST begin with "X" or be 5445 ; registered with IANA as standard or 5446 ; standards-track 5448 capability-data = "CAPABILITY" *(SP capability) SP "IMAP4rev2" 5449 *(SP capability) 5450 ; Servers MUST implement the STARTTLS, AUTH=PLAIN, 5451 ; and LOGINDISABLED capabilities 5452 ; Servers which offer RFC 1730 compatibility MUST 5453 ; list "IMAP4" as the first capability. 5455 CHAR8 = %x01-ff 5456 ; any OCTET except NUL, %x00 5458 charset = atom / quoted 5460 childinfo-extended-item = "CHILDINFO" SP "(" 5461 list-select-base-opt-quoted 5462 *(SP list-select-base-opt-quoted) ")" 5463 ; Extended data item (mbox-list-extended-item) 5464 ; returned when the RECURSIVEMATCH 5465 ; selection option is specified. 5466 ; Note 1: the CHILDINFO tag can be returned 5467 ; with and without surrounding quotes, as per 5468 ; mbox-list-extended-item-tag production. 5469 ; Note 2: The selection options are always returned 5470 ; quoted, unlike their specification in 5471 ; the extended LIST command. 5473 child-mbox-flag = "\HasChildren" / "\HasNoChildren" 5474 ; attributes for CHILDREN return option, at most one 5475 ; possible per LIST response 5477 command = tag SP (command-any / command-auth / command-nonauth / 5478 command-select) CRLF 5479 ; Modal based on state 5481 command-any = "CAPABILITY" / "LOGOUT" / "NOOP" / enable / x-command 5482 ; Valid in all states 5484 command-auth = append / create / delete / examine / list / 5485 Namespace-Command / 5486 rename / select / status / subscribe / unsubscribe / 5487 idle 5488 ; Valid only in Authenticated or Selected state 5490 command-nonauth = login / authenticate / "STARTTLS" 5491 ; Valid only when in Not Authenticated state 5493 command-select = "CLOSE" / "UNSELECT" / "EXPUNGE" / copy / 5494 move / fetch / store / search / uid 5495 ; Valid only when in Selected state 5497 continue-req = "+" SP (resp-text / base64) CRLF 5499 copy = "COPY" SP sequence-set SP mailbox 5501 create = "CREATE" SP mailbox 5502 ; Use of INBOX gives a NO error 5504 date = date-text / DQUOTE date-text DQUOTE 5505 date-day = 1*2DIGIT 5506 ; Day of month 5508 date-day-fixed = (SP DIGIT) / 2DIGIT 5509 ; Fixed-format version of date-day 5511 date-month = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / 5512 "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec" 5514 date-text = date-day "-" date-month "-" date-year 5516 date-year = 4DIGIT 5518 date-time = DQUOTE date-day-fixed "-" date-month "-" date-year 5519 SP time SP zone DQUOTE 5521 delete = "DELETE" SP mailbox 5522 ; Use of INBOX gives a NO error 5524 digit-nz = %x31-39 5525 ; 1-9 5527 eitem-standard-tag = atom 5528 ; a tag for extended list data defined in a Standard 5529 ; Track or Experimental RFC. 5531 eitem-vendor-tag = vendor-token "-" atom 5532 ; a vendor-specific tag for extended list data 5534 enable = "ENABLE" 1*(SP capability) 5536 enable-data = "ENABLED" *(SP capability) 5538 envelope = "(" env-date SP env-subject SP env-from SP 5539 env-sender SP env-reply-to SP env-to SP env-cc SP 5540 env-bcc SP env-in-reply-to SP env-message-id ")" 5542 env-bcc = "(" 1*address ")" / nil 5544 env-cc = "(" 1*address ")" / nil 5546 env-date = nstring 5548 env-from = "(" 1*address ")" / nil 5550 env-in-reply-to = nstring 5552 env-message-id = nstring 5553 env-reply-to = "(" 1*address ")" / nil 5555 env-sender = "(" 1*address ")" / nil 5557 env-subject = nstring 5559 env-to = "(" 1*address ")" / nil 5561 esearch-response = "ESEARCH" [search-correlator] [SP "UID"] 5562 *(SP search-return-data) 5563 ; ESEARCH response replaces SEARCH response 5564 ; from IMAP4rev1. 5566 examine = "EXAMINE" SP mailbox 5568 fetch = "FETCH" SP sequence-set SP ("ALL" / "FULL" / "FAST" / 5569 fetch-att / "(" fetch-att *(SP fetch-att) ")") 5571 fetch-att = "ENVELOPE" / "FLAGS" / "INTERNALDATE" / 5572 "RFC822.SIZE" / 5573 "BODY" ["STRUCTURE"] / "UID" / 5574 "BODY" section [partial] / 5575 "BODY.PEEK" section [partial] / 5576 "BINARY" [".PEEK"] section-binary [partial] / 5577 "BINARY.SIZE" section-binary 5579 flag = "\Answered" / "\Flagged" / "\Deleted" / 5580 "\Seen" / "\Draft" / flag-keyword / flag-extension 5581 ; Does not include "\Recent" 5583 flag-extension = "\" atom 5584 ; Future expansion. Client implementations 5585 ; MUST accept flag-extension flags. Server 5586 ; implementations MUST NOT generate 5587 ; flag-extension flags except as defined by 5588 ; future standard or standards-track 5589 ; revisions of this specification. 5590 ; "\Recent" was defined in RFC 3501 5591 ; and is now deprecated. 5593 flag-fetch = flag 5595 flag-keyword = "$MDNSent" / "$Forwarded" / atom 5597 flag-list = "(" [flag *(SP flag)] ")" 5599 flag-perm = flag / "\*" 5600 greeting = "*" SP (resp-cond-auth / resp-cond-bye) CRLF 5602 header-fld-name = astring 5604 header-list = "(" header-fld-name *(SP header-fld-name) ")" 5606 idle = "IDLE" CRLF "DONE" 5608 initial-resp = (base64 / "=") 5609 ; "initial response" defined in 5610 ; Section 5.1 of [RFC4422] 5612 list = "LIST" [SP list-select-opts] SP mailbox SP mbox-or-pat 5613 [SP list-return-opts] 5615 list-mailbox = 1*list-char / string 5617 list-char = ATOM-CHAR / list-wildcards / resp-specials 5619 list-return-opts = "RETURN" SP 5620 "(" [return-option *(SP return-option)] ")" 5621 ; list return options, e.g., CHILDREN 5623 list-select-base-opt = "SUBSCRIBED" / option-extension 5624 ; options that can be used by themselves 5626 list-select-base-opt-quoted = DQUOTE list-select-base-opt DQUOTE 5628 list-select-independent-opt = "REMOTE" / option-extension 5629 ; options that do not syntactically interact with 5630 ; other options 5632 list-select-mod-opt = "RECURSIVEMATCH" / option-extension 5633 ; options that require a list-select-base-opt 5634 ; to also be present 5636 list-select-opt = list-select-base-opt / list-select-independent-opt 5637 / list-select-mod-opt 5638 ; An option registration template is described in 5639 ; Section 9.3 of this document. 5641 list-select-opts = "(" [ 5642 (*(list-select-opt SP) list-select-base-opt 5643 *(SP list-select-opt)) 5644 / (list-select-independent-opt 5645 *(SP list-select-independent-opt)) 5646 ] ")" 5648 ; Any number of options may be in any order. 5649 ; If a list-select-mod-opt appears, then a 5650 ; list-select-base-opt must also appear. 5651 ; This allows these: 5652 ; () 5653 ; (REMOTE) 5654 ; (SUBSCRIBED) 5655 ; (SUBSCRIBED REMOTE) 5656 ; (SUBSCRIBED RECURSIVEMATCH) 5657 ; (SUBSCRIBED REMOTE RECURSIVEMATCH) 5658 ; But does NOT allow these: 5659 ; (RECURSIVEMATCH) 5660 ; (REMOTE RECURSIVEMATCH) 5662 list-wildcards = "%" / "*" 5664 literal = "{" number ["+"] "}" CRLF *CHAR8 5665 ; represents the number of CHAR8s. 5666 ; A non-synchronizing literal is distinguished from 5667 ; a synchronizing literal by presence of the "+" 5668 ; before the closing "}". 5669 ; Non synchronizing literals are not allowed when 5670 ; sent from server to the client. 5672 literal8 = "~{" number "}" CRLF *OCTET 5673 ; represents the number of OCTETs 5674 ; in the response string. 5676 login = "LOGIN" SP userid SP password 5678 mailbox = "INBOX" / astring 5679 ; INBOX is case-insensitive. All case variants of 5680 ; INBOX (e.g., "iNbOx") MUST be interpreted as INBOX 5681 ; not as an astring. An astring which consists of 5682 ; the case-insensitive sequence "I" "N" "B" "O" "X" 5683 ; is considered to be INBOX and not an astring. 5684 ; Refer to section 5.1 for further 5685 ; semantic details of mailbox names. 5687 mailbox-data = "FLAGS" SP flag-list / "LIST" SP mailbox-list / 5688 esearch-response / 5689 "STATUS" SP mailbox SP "(" [status-att-list] ")" / 5690 number SP "EXISTS" / Namespace-Response 5692 mailbox-list = "(" [mbx-list-flags] ")" SP 5693 (DQUOTE QUOTED-CHAR DQUOTE / nil) SP mailbox 5694 [SP mbox-list-extended] 5695 ; This is the list information pointed to by the ABNF 5696 ; item "mailbox-data", which is defined in [IMAP4] 5698 mbox-list-extended = "(" [mbox-list-extended-item 5699 *(SP mbox-list-extended-item)] ")" 5701 mbox-list-extended-item = mbox-list-extended-item-tag SP 5702 tagged-ext-val 5704 mbox-list-extended-item-tag = astring 5705 ; The content MUST conform to either "eitem-vendor-tag" 5706 ; or "eitem-standard-tag" ABNF productions. 5708 mbox-or-pat = list-mailbox / patterns 5710 mbx-list-flags = *(mbx-list-oflag SP) mbx-list-sflag 5711 *(SP mbx-list-oflag) / 5712 mbx-list-oflag *(SP mbx-list-oflag) 5714 mbx-list-oflag = "\Noinferiors" / child-mbox-flag / 5715 "\Subscribed" / "\Remote" / flag-extension 5716 ; Other flags; multiple possible per LIST response 5718 mbx-list-sflag = "\NonExistent" / "\Noselect" / "\Marked" / "\Unmarked" 5719 ; Selectability flags; only one per LIST response 5721 media-basic = ((DQUOTE ("APPLICATION" / "AUDIO" / "IMAGE" / 5722 "MESSAGE" / "VIDEO" / "FONT") DQUOTE) / string) SP 5723 media-subtype 5724 ; Defined in [MIME-IMT]. 5725 ; FONT defined in RFC YYYY. 5727 media-message = DQUOTE "MESSAGE" DQUOTE SP 5728 DQUOTE ("RFC822" / "GLOBAL") DQUOTE 5729 ; Defined in [MIME-IMT] 5731 media-subtype = string 5732 ; Defined in [MIME-IMT] 5734 media-text = DQUOTE "TEXT" DQUOTE SP media-subtype 5735 ; Defined in [MIME-IMT] 5737 message-data = nz-number SP ("EXPUNGE" / ("FETCH" SP msg-att)) 5739 move = "MOVE" SP sequence-set SP mailbox 5741 msg-att = "(" (msg-att-dynamic / msg-att-static) 5742 *(SP (msg-att-dynamic / msg-att-static)) ")" 5744 msg-att-dynamic = "FLAGS" SP "(" [flag-fetch *(SP flag-fetch)] ")" 5745 ; MAY change for a message 5747 msg-att-static = "ENVELOPE" SP envelope / "INTERNALDATE" SP date-time / 5748 "RFC822.SIZE" SP number / 5749 "BODY" ["STRUCTURE"] SP body / 5750 "BODY" section ["<" number ">"] SP nstring / 5751 "BINARY" section-binary SP (nstring / literal8) / 5752 "BINARY.SIZE" section-binary SP number / 5753 "UID" SP uniqueid 5754 ; MUST NOT change for a message 5756 Namespace = nil / "(" 1*Namespace-Descr ")" 5758 Namespace-Command = "NAMESPACE" 5760 Namespace-Descr = "(" string SP 5761 (DQUOTE QUOTED-CHAR DQUOTE / nil) 5762 [Namespace-Response-Extensions] ")" 5764 Namespace-Response-Extensions = *(Namespace-Response-Extension) 5766 Namespace-Response-Extension = SP string SP 5767 "(" string *(SP string) ")" 5769 Namespace-Response = "NAMESPACE" SP Namespace 5770 SP Namespace SP Namespace 5771 ; The first Namespace is the Personal Namespace(s). 5772 ; The second Namespace is the Other Users' 5773 ; Namespace(s). 5774 ; The third Namespace is the Shared Namespace(s). 5776 nil = "NIL" 5778 nstring = string / nil 5780 number = 1*DIGIT 5781 ; Unsigned 32-bit integer 5782 ; (0 <= n < 4,294,967,296) 5784 number64 = 1*DIGIT 5785 ; Unsigned 63-bit integer 5786 ; (0 <= n <= 9,223,372,036,854,775,807) 5788 nz-number = digit-nz *DIGIT 5789 ; Non-zero unsigned 32-bit integer 5790 ; (0 < n < 4,294,967,296) 5792 option-extension = (option-standard-tag / option-vendor-tag) 5793 [SP option-value] 5795 option-standard-tag = atom 5796 ; an option defined in a Standards Track or 5797 ; Experimental RFC 5799 option-val-comp = astring / 5800 option-val-comp *(SP option-val-comp) / 5801 "(" option-val-comp ")" 5803 option-value = "(" option-val-comp ")" 5805 option-vendor-tag = vendor-token "-" atom 5806 ; a vendor-specific option, non-standard 5808 partial-range = number ["." nz-number] 5809 ; Copied from RFC 5092 (IMAP URL) 5811 partial = "<" number "." nz-number ">" 5812 ; Partial FETCH request. 0-based offset of 5813 ; the first octet, followed by the number of octets 5814 ; in the fragment. 5816 password = astring 5818 patterns = "(" list-mailbox *(SP list-mailbox) ")" 5820 quoted = DQUOTE *QUOTED-CHAR DQUOTE 5822 QUOTED-CHAR = / 5823 "\" quoted-specials / UTF8-2 / UTF8-3 / UTF8-4 5825 quoted-specials = DQUOTE / "\" 5827 rename = "RENAME" SP mailbox SP mailbox 5828 ; Use of INBOX as a destination gives a NO error 5830 response = *(continue-req / response-data) response-done 5832 response-data = "*" SP (resp-cond-state / resp-cond-bye / 5833 mailbox-data / message-data / capability-data / 5834 enable-data) CRLF 5836 response-done = response-tagged / response-fatal 5838 response-fatal = "*" SP resp-cond-bye CRLF 5839 ; Server closes connection immediately 5841 response-tagged = tag SP resp-cond-state CRLF 5843 resp-code-apnd = "APPENDUID" SP nz-number SP append-uid 5845 resp-code-copy = "COPYUID" SP nz-number SP uid-set SP uid-set 5847 resp-cond-auth = ("OK" / "PREAUTH") SP resp-text 5848 ; Authentication condition 5850 resp-cond-bye = "BYE" SP resp-text 5852 resp-cond-state = ("OK" / "NO" / "BAD") SP resp-text 5853 ; Status condition 5855 resp-specials = "]" 5857 resp-text = ["[" resp-text-code "]" SP] [text] 5859 resp-text-code = "ALERT" / 5860 "BADCHARSET" [SP "(" charset *(SP charset) ")" ] / 5861 capability-data / "PARSE" / 5862 "PERMANENTFLAGS" SP "(" 5863 [flag-perm *(SP flag-perm)] ")" / 5864 "READ-ONLY" / "READ-WRITE" / "TRYCREATE" / 5865 "UIDNEXT" SP nz-number / "UIDVALIDITY" SP nz-number / 5866 resp-code-apnd / resp-code-copy / "UIDNOTSTICKY" / 5867 "UNAVAILABLE" / "AUTHENTICATIONFAILED" / 5868 "AUTHORIZATIONFAILED" / "EXPIRED" / 5869 "PRIVACYREQUIRED" / "CONTACTADMIN" / "NOPERM" / 5870 "INUSE" / "EXPUNGEISSUED" / "CORRUPTION" / 5871 "SERVERBUG" / "CLIENTBUG" / "CANNOT" / 5872 "LIMIT" / "OVERQUOTA" / "ALREADYEXISTS" / 5873 "NONEXISTENT" / 5874 "CLOSED" / 5875 "UNKNOWN-CTE" / 5876 atom [SP 1*] 5878 return-option = "SUBSCRIBED" / "CHILDREN" / status-option / 5879 option-extension 5881 search = "SEARCH" [search-return-opts] 5882 SP search-program 5884 search-correlator = SP "(" "TAG" SP tag-string ")" 5886 search-key = "ALL" / "ANSWERED" / "BCC" SP astring / 5887 "BEFORE" SP date / "BODY" SP astring / 5888 "CC" SP astring / "DELETED" / "FLAGGED" / 5889 "FROM" SP astring / "KEYWORD" SP flag-keyword / 5890 "ON" SP date / "SEEN" / 5891 "SINCE" SP date / "SUBJECT" SP astring / 5892 "TEXT" SP astring / "TO" SP astring / 5893 "UNANSWERED" / "UNDELETED" / "UNFLAGGED" / 5894 "UNKEYWORD" SP flag-keyword / "UNSEEN" / 5895 ; Above this line were in [IMAP2] 5896 "DRAFT" / "HEADER" SP header-fld-name SP astring / 5897 "LARGER" SP number / "NOT" SP search-key / 5898 "OR" SP search-key SP search-key / 5899 "SENTBEFORE" SP date / "SENTON" SP date / 5900 "SENTSINCE" SP date / "SMALLER" SP number / 5901 "UID" SP sequence-set / "UNDRAFT" / sequence-set / 5902 "(" search-key *(SP search-key) ")" 5904 search-modifier-name = tagged-ext-label 5906 search-mod-params = tagged-ext-val 5907 ; This non-terminal shows recommended syntax 5908 ; for future extensions. 5910 search-program = ["CHARSET" SP charset SP] 5911 search-key *(SP search-key) 5912 ; CHARSET argument to SEARCH MUST be 5913 ; registered with IANA. 5915 search-ret-data-ext = search-modifier-name SP search-return-value 5916 ; Note that not every SEARCH return option 5917 ; is required to have the corresponding 5918 ; ESEARCH return data. 5920 search-return-data = "MIN" SP nz-number / 5921 "MAX" SP nz-number / 5922 "ALL" SP sequence-set / 5923 "COUNT" SP number / 5924 search-ret-data-ext 5925 ; All return data items conform to 5926 ; search-ret-data-ext syntax 5928 search-return-opts = SP "RETURN" SP "(" [search-return-opt 5929 *(SP search-return-opt)] ")" 5931 search-return-opt = "MIN" / "MAX" / "ALL" / "COUNT" / 5932 search-ret-opt-ext 5933 ; conforms to generic search-ret-opt-ext 5934 ; syntax 5936 search-ret-opt-ext = search-modifier-name [SP search-mod-params] 5937 search-return-value = tagged-ext-val 5938 ; Data for the returned search option. 5939 ; A single "nz-number"/"number"/"number64" value 5940 ; can be returned as an atom (i.e., without 5941 ; quoting). A sequence-set can be returned 5942 ; as an atom as well. 5944 section = "[" [section-spec] "]" 5946 section-binary = "[" [section-part] "]" 5948 section-msgtext = "HEADER" / "HEADER.FIELDS" [".NOT"] SP header-list / 5949 "TEXT" 5950 ; top-level or MESSAGE/RFC822 or MESSAGE/GLOBAL part 5952 section-part = nz-number *("." nz-number) 5953 ; body part reference. 5954 ; Allows for accessing nested body parts. 5956 section-spec = section-msgtext / (section-part ["." section-text]) 5958 section-text = section-msgtext / "MIME" 5959 ; text other than actual body part (headers, etc.) 5961 select = "SELECT" SP mailbox 5963 seq-number = nz-number / "*" 5964 ; message sequence number (COPY, FETCH, STORE 5965 ; commands) or unique identifier (UID COPY, 5966 ; UID FETCH, UID STORE commands). 5967 ; * represents the largest number in use. In 5968 ; the case of message sequence numbers, it is 5969 ; the number of messages in a non-empty mailbox. 5970 ; In the case of unique identifiers, it is the 5971 ; unique identifier of the last message in the 5972 ; mailbox or, if the mailbox is empty, the 5973 ; mailbox's current UIDNEXT value. 5974 ; The server should respond with a tagged BAD 5975 ; response to a command that uses a message 5976 ; sequence number greater than the number of 5977 ; messages in the selected mailbox. This 5978 ; includes "*" if the selected mailbox is empty. 5980 seq-range = seq-number ":" seq-number 5981 ; two seq-number values and all values between 5982 ; these two regardless of order. 5983 ; Example: 2:4 and 4:2 are equivalent and indicate 5984 ; values 2, 3, and 4. 5986 ; Example: a unique identifier sequence range of 5987 ; 3291:* includes the UID of the last message in 5988 ; the mailbox, even if that value is less than 3291. 5990 sequence-set = (seq-number / seq-range) ["," sequence-set] 5991 ; set of seq-number values, regardless of order. 5992 ; Servers MAY coalesce overlaps and/or execute the 5993 ; sequence in any order. 5994 ; Example: a message sequence number set of 5995 ; 2,4:7,9,12:* for a mailbox with 15 messages is 5996 ; equivalent to 2,4,5,6,7,9,12,13,14,15 5997 ; Example: a message sequence number set of *:4,5:7 5998 ; for a mailbox with 10 messages is equivalent to 5999 ; 10,9,8,7,6,5,4,5,6,7 and MAY be reordered and 6000 ; overlap coalesced to be 4,5,6,7,8,9,10. 6002 status = "STATUS" SP mailbox SP 6003 "(" status-att *(SP status-att) ")" 6005 status-att = "MESSAGES" / "UIDNEXT" / "UIDVALIDITY" / 6006 "UNSEEN" / "DELETED" / "SIZE" 6008 status-att-val = ("MESSAGES" SP number) / 6009 ("UIDNEXT" SP nz-number) / 6010 ("UIDVALIDITY" SP nz-number) / 6011 ("UNSEEN" SP number) / 6012 ("DELETED" SP number) / 6013 ("SIZE" SP number64) 6014 ; Extensions to the STATUS responses 6015 ; should extend this production. 6016 ; Extensions should use the generic 6017 ; syntax defined by tagged-ext. 6019 status-att-list = status-att-val *(SP status-att-val) 6021 status-option = "STATUS" SP "(" status-att *(SP status-att) ")" 6022 ; This ABNF production complies with 6023 ; syntax. 6025 store = "STORE" SP sequence-set SP store-att-flags 6027 store-att-flags = (["+" / "-"] "FLAGS" [".SILENT"]) SP 6028 (flag-list / (flag *(SP flag))) 6030 string = quoted / literal 6032 subscribe = "SUBSCRIBE" SP mailbox 6033 tag = 1* 6035 tagged-ext-label = tagged-label-fchar *tagged-label-char 6036 ;; Is a valid RFC 3501 "atom". 6038 tagged-label-fchar = ALPHA / "-" / "_" / "." 6040 tagged-label-char = tagged-label-fchar / DIGIT / ":" 6042 tagged-ext-comp = astring / 6043 tagged-ext-comp *(SP tagged-ext-comp) / 6044 "(" tagged-ext-comp ")" 6045 ;; Extensions that follow this general 6046 ;; syntax should use nstring instead of 6047 ;; astring when appropriate in the context 6048 ;; of the extension. 6049 ;; Note that a message set or a "number" 6050 ;; can always be represented as an "atom". 6051 ;; An URL should be represented as 6052 ;; a "quoted" string. 6054 tagged-ext-simple = sequence-set / number / number64 6056 tagged-ext-val = tagged-ext-simple / 6057 "(" [tagged-ext-comp] ")" 6059 text = 1*TEXT-CHAR 6061 TEXT-CHAR = 6063 time = 2DIGIT ":" 2DIGIT ":" 2DIGIT 6064 ; Hours minutes seconds 6066 uid = "UID" SP 6067 (copy / move / fetch / search / store / uid-expunge) 6068 ; Unique identifiers used instead of message 6069 ; sequence numbers 6071 uid-expunge = "EXPUNGE" SP sequence-set 6072 ; Unique identifiers used instead of message 6073 ; sequence numbers 6075 uid-set = (uniqueid / uid-range) *("," uid-set) 6077 uid-range = (uniqueid ":" uniqueid) 6078 ; two uniqueid values and all values 6079 ; between these two regards of order. 6080 ; Example: 2:4 and 4:2 are equivalent. 6082 uniqueid = nz-number 6083 ; Strictly ascending 6085 unsubscribe = "UNSUBSCRIBE" SP mailbox 6087 userid = astring 6089 UTF8-2 = 6091 UTF8-3 = 6093 UTF8-4 = 6095 x-command = "X" atom 6097 zone = ("+" / "-") 4DIGIT 6098 ; Signed four-digit value of hhmm representing 6099 ; hours and minutes east of Greenwich (that is, 6100 ; the amount that the given time differs from 6101 ; Universal Time). Subtracting the timezone 6102 ; from the given time will give the UT form. 6103 ; The Universal Time zone is "+0000". 6105 10. Author's Note 6107 This document is a revision or rewrite of earlier documents, and 6108 supercedes the protocol specification in those documents: RFC 2060, 6109 RFC 1730, unpublished IMAP2bis.TXT document, RFC 1176, and RFC 1064. 6111 11. Security Considerations 6113 IMAP4rev2 protocol transactions, including electronic mail data, are 6114 sent in the clear over the network unless protection from snooping is 6115 negotiated. This can be accomplished either by the use of IMAPS 6116 service, STARTTLS command, negotiated privacy protection in the 6117 AUTHENTICATE command, or some other protection mechanism. 6119 11.1. STARTTLS Security Considerations 6121 IMAP client and server implementations MUST comply with relevant TLS 6122 recommendations from [RFC8314]. 6124 Additionally, when using TLS 1.2, IMAP implementations MUST implement 6125 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 cipher suite, and SHOULD 6126 implement the TLS_RSA_WITH_AES_128_CBC_SHA [TLS] cipher suite. This 6127 is important as it assures that any two compliant implementations can 6128 be configured to interoperate. Other TLS cipher suites recommended 6129 in RFC 7525 are RECOMMENDED: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 6130 TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 and 6131 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384. All other cipher suites are 6132 OPTIONAL. Note that this is a change from section 2.1 of [IMAP-TLS]. 6134 During the [TLS] negotiation, the client MUST check its understanding 6135 of the server hostname against the server's identity as presented in 6136 the server Certificate message, in order to prevent man-in-the-middle 6137 attacks. This procedure is described in [RFC7817]. 6139 Both the client and server MUST check the result of the STARTTLS 6140 command and subsequent [TLS] negotiation to see whether acceptable 6141 authentication and/or privacy was achieved. 6143 11.2. COPYUID and APPENDUID response codes 6145 The COPYUID and APPENDUID response codes return information about the 6146 mailbox, which may be considered sensitive if the mailbox has 6147 permissions set that permit the client to COPY or APPEND to the 6148 mailbox, but not SELECT or EXAMINE it. 6150 Consequently, these response codes SHOULD NOT be issued if the client 6151 does not have access to SELECT or EXAMINE the mailbox. 6153 11.3. LIST command and Other Users' namespace 6155 In response to a LIST command containing an argument of the Other 6156 Users' Namespace prefix, a server SHOULD NOT list users that have not 6157 granted list access to their personal mailboxes to the currently 6158 authenticated user. Providing such a list, could compromise security 6159 by potentially disclosing confidential information of who is located 6160 on the server, or providing a starting point of a list of user 6161 accounts to attack. 6163 11.4. Other Security Considerations 6165 A server error message for an AUTHENTICATE command which fails due to 6166 invalid credentials SHOULD NOT detail why the credentials are 6167 invalid. 6169 Use of the LOGIN command sends passwords in the clear. This can be 6170 avoided by using the AUTHENTICATE command with a [SASL] mechanism 6171 that does not use plaintext passwords, by first negotiating 6172 encryption via STARTTLS or some other protection mechanism. 6174 A server implementation MUST implement a configuration that, at the 6175 time of authentication, requires: 6176 (1) The STARTTLS command has been negotiated. 6177 OR 6178 (2) Some other mechanism that protects the session from password 6179 snooping has been provided. 6180 OR 6181 (3) The following measures are in place: 6182 (a) The LOGINDISABLED capability is advertised, and [SASL] mechanisms 6183 (such as PLAIN) using plaintext passwords are NOT advertised in the 6184 CAPABILITY list. 6185 AND 6186 (b) The LOGIN command returns an error even if the password is 6187 correct. 6188 AND 6189 (c) The AUTHENTICATE command returns an error with all [SASL] 6190 mechanisms that use plaintext passwords, even if the password is 6191 correct. 6193 A server error message for a failing LOGIN command SHOULD NOT specify 6194 that the user name, as opposed to the password, is invalid. 6196 A server SHOULD have mechanisms in place to limit or delay failed 6197 AUTHENTICATE/LOGIN attempts. 6199 Additional security considerations are discussed in the section 6200 discussing the AUTHENTICATE and LOGIN commands. 6202 12. IANA Considerations 6204 IANA is requested to update "Service Names and Transport Protocol 6205 Port Numbers" registry as follows: 6207 1. Registration for TCP "imap" port 143 should be updated to point 6208 to this document and RFC 3501. 6210 2. Registration for TCP "imaps" port 993 should be updated to point 6211 to this document, RFC 8314 and RFC 3501. 6213 3. Both UDP port 143 and UDP port 993 should be marked as "Reserved" 6214 in the registry. 6216 Additional IANA actions are specified in subsection of this section. 6218 12.1. Updates to IMAP4 Capabilities registry 6220 IMAP4 capabilities are registered by publishing a standards track or 6221 IESG approved informational or experimental RFC. The registry is 6222 currently located at: http://www.iana.org/assignments/ 6223 imap4-capabilities 6224 As this specification revises the STARTTLS and LOGINDISABLED 6225 extensions previously defined in [IMAP-TLS], IANA is requested to 6226 update registry entries for these 2 extensions to point to this 6227 document. 6229 12.2. GSSAPI/SASL service name 6231 GSSAPI/Kerberos/SASL service names are registered by publishing a 6232 standards track or IESG approved experimental RFC. The registry is 6233 currently located at: http://www.iana.org/assignments/gssapi-service- 6234 names 6236 IANA is requested to update the "imap" service name previously 6237 registered in RFC 3501, to point to this document. 6239 13. References 6241 13.1. Normative References 6243 [ABNF] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 6244 Specifications: ABNF", STD 68, RFC 5234, January 2008, 6245 . 6247 [ANONYMOUS] 6248 Zeilenga, K., "Anonymous Simple Authentication and 6249 Security Layer (SASL) Mechanism", RFC 4505, June 2006, 6250 . 6252 [CHARSET] Freed, N. and J. Postel, "IANA Charset Registration 6253 Procedures", BCP 19, RFC 2978, October 2000, 6254 . 6256 [SCRAM-SHA-256] 6257 Hansen, T., "SCRAM-SHA-256 and SCRAM-SHA-256-PLUS Simple 6258 Authentication and Security Layer (SASL) Mechanisms", 6259 RFC 7677, DOI 10.17487/RFC7677, November 2015, 6260 . 6262 [DISPOSITION] 6263 Troost, R., Dorner, S., and K. Moore, Ed., "Communicating 6264 Presentation Information in Internet Messages: The 6265 Content-Disposition Header Field", RFC 2183, August 1997, 6266 . 6268 [PLAIN] Zeilenga, K., Ed., "The PLAIN Simple Authentication and 6269 Security Layer (SASL) Mechanism", RFC 4616, August 2006, 6270 . 6272 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 6273 Requirement Levels", BCP 14, RFC 2119, 6274 DOI 10.17487/RFC2119, March 1997, 6275 . 6277 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 6278 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 6279 May 2017, . 6281 [LANGUAGE-TAGS] 6282 Alvestrand, H., "Content Language Headers", RFC 3282, May 6283 2002, . 6285 [LOCATION] 6286 Palme, J., Hopmann, A., and N. Shelness, "MIME 6287 Encapsulation of Aggregate Documents, such as HTML 6288 (MHTML)", RFC 2557, March 1999, 6289 . 6291 [MD5] Myers, J. and M. Rose, "The Content-MD5 Header Field", 6292 RFC 1864, October 1995, 6293 . 6295 [MIME-HDRS] 6296 Moore, K., "MIME (Multipurpose Internet Mail Extensions) 6297 Part Three: Message Header Extensions for Non-ASCII Text", 6298 RFC 2047, November 1996, 6299 . 6301 [MIME-IMB] 6302 Freed, N. and N. Borenstein, "Multipurpose Internet Mail 6303 Extensions (MIME) Part One: Format of Internet Message 6304 Bodies", RFC 2045, November 1996, 6305 . 6307 [MIME-IMT] 6308 Freed, N. and N. Borenstein, "Multipurpose Internet Mail 6309 Extensions (MIME) Part Two: Media Types", RFC 2046, 6310 November 1996, . 6312 [RFC2231] Freed, N. and K. Moore, "MIME Parameter Value and Encoded 6313 Word Extensions: Character Sets, Languages, and 6314 Continuations", RFC 2231, DOI 10.17487/RFC2231, November 6315 1997, . 6317 [RFC-5322] 6318 Resnick, P., Ed., "Internet Message Format", RFC 5322, 6319 October 2008, . 6321 [SASL] Melnikov, A., Ed. and K. Zeilenga, Ed., "Simple 6322 Authentication and Security Layer (SASL)", RFC 4422, June 6323 2006, . 6325 [TLS] Dierks, T. and E. Rescorla, "The Transport Layer Security 6326 (TLS) Protocol Version 1.2", RFC 5246, August 2008, 6327 . 6329 [UTF-7] Goldsmith, D. and M. Davis, "UTF-7 A Mail-Safe 6330 Transformation Format of Unicode", RFC 2152, May 1997, 6331 . 6333 [UTF-8] Yergeau, F., "UTF-8, a transformation format of ISO 6334 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 6335 2003, . 6337 [MULTIAPPEND] 6338 Crispin, M., "Internet Message Access Protocol (IMAP) - 6339 MULTIAPPEND Extension", RFC 3502, March 2003, 6340 . 6342 [NET-UNICODE] 6343 Klensin, J. and M. Padlipsky, "Unicode Format for Network 6344 Interchange", RFC 5198, DOI 10.17487/RFC5198, March 2008, 6345 . 6347 [I18N-HDRS] 6348 Yang, A., Steele, S., and N. Freed, "Internationalized 6349 Email Headers", RFC 6532, DOI 10.17487/RFC6532, February 6350 2012, . 6352 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 6353 Encodings", RFC 4648, DOI 10.17487/RFC4648, October 2006, 6354 . 6356 [RFC7817] Melnikov, A., "Updated Transport Layer Security (TLS) 6357 Server Identity Check Procedure for Email-Related 6358 Protocols", RFC 7817, DOI 10.17487/RFC7817, March 2016, 6359 . 6361 [RFC8098] Hansen, T., Ed. and A. Melnikov, Ed., "Message Disposition 6362 Notification", STD 85, RFC 8098, DOI 10.17487/RFC8098, 6363 February 2017, . 6365 [RFC8314] Moore, K. and C. Newman, "Cleartext Considered Obsolete: 6366 Use of Transport Layer Security (TLS) for Email Submission 6367 and Access", RFC 8314, DOI 10.17487/RFC8314, January 2018, 6368 . 6370 [IMAP-IMPLEMENTATION] 6371 Leiba, B., "IMAP4 Implementation Recommendations", 6372 RFC 2683, September 1999, 6373 . 6375 [IMAP-MULTIACCESS] 6376 Gahrns, M., "IMAP4 Multi-Accessed Mailbox Practice", 6377 RFC 2180, July 1997, 6378 . 6380 13.2. Informative References (related protocols) 6382 [RFC5258] Leiba, B. and A. Melnikov, "Internet Message Access 6383 Protocol version 4 - LIST Command Extensions", RFC 5258, 6384 DOI 10.17487/RFC5258, June 2008, 6385 . 6387 [RFC2193] Gahrns, M., "IMAP4 Mailbox Referrals", RFC 2193, 6388 DOI 10.17487/RFC2193, September 1997, 6389 . 6391 [RFC3348] Gahrns, M. and R. Cheng, "The Internet Message Action 6392 Protocol (IMAP4) Child Mailbox Extension", RFC 3348, 6393 DOI 10.17487/RFC3348, July 2002, 6394 . 6396 [RFC7888] Melnikov, A., Ed., "IMAP4 Non-synchronizing Literals", 6397 RFC 7888, DOI 10.17487/RFC7888, May 2016, 6398 . 6400 [IMAP-DISC] 6401 Melnikov, A., Ed., "Synchronization Operations for 6402 Disconnected IMAP4 Clients", RFC 4549, June 2006, 6403 . 6405 [IMAP-I18N] 6406 Newman, C., Gulbrandsen, A., and A. Melnikov, "Internet 6407 Message Access Protocol Internationalization", RFC 5255, 6408 DOI 10.17487/RFC5255, June 2008, 6409 . 6411 [IMAP-MODEL] 6412 Crispin, M., "Distributed Electronic Mail Models in 6413 IMAP4", RFC 1733, December 1994, 6414 . 6416 [IMAP-UTF-8] 6417 Resnick, P., Ed., Newman, C., Ed., and S. Shen, Ed., "IMAP 6418 Support for UTF-8", RFC 6855, DOI 10.17487/RFC6855, March 6419 2013, . 6421 [SMTP] Klensin, J., "Simple Mail Transfer Protocol", RFC 5321, 6422 October 2008, . 6424 [RFC3516] Nerenberg, L., "IMAP4 Binary Content Extension", RFC 3516, 6425 DOI 10.17487/RFC3516, April 2003, 6426 . 6428 [RFC4314] Melnikov, A., "IMAP4 Access Control List (ACL) Extension", 6429 RFC 4314, December 2005, 6430 . 6432 [RFC2087] Myers, J., "IMAP4 QUOTA extension", RFC 2087, January 6433 1997, . 6435 [IMAP-URL] 6436 Melnikov, A., Ed. and C. Newman, "IMAP URL Scheme", 6437 RFC 5092, DOI 10.17487/RFC5092, November 2007, 6438 . 6440 13.3. Informative References (historical aspects of IMAP and related 6441 protocols) 6443 [IMAP-COMPAT] 6444 Crispin, M., "IMAP4 Compatibility with IMAP2bis", 6445 RFC 2061, December 1996, 6446 . 6448 [IMAP-HISTORICAL] 6449 Crispin, M., "IMAP4 Compatibility with IMAP2 and 6450 IMAP2bis", RFC 1732, December 1994, 6451 . 6453 [IMAP-OBSOLETE] 6454 Crispin, M., "Internet Message Access Protocol - Obsolete 6455 Syntax", RFC 2062, December 1996, 6456 . 6458 [IMAP2] Crispin, M., "Interactive Mail Access Protocol: Version 6459 2", RFC 1176, August 1990, 6460 . 6462 [RFC-822] Crocker, D., "STANDARD FOR THE FORMAT OF ARPA INTERNET 6463 TEXT MESSAGES", STD 11, RFC 822, August 1982, 6464 . 6466 [IMAP-TLS] 6467 Newman, C., "Using TLS with IMAP, POP3 and ACAP", 6468 RFC 2595, June 1999, 6469 . 6471 Appendix A. Backward compatibility with IMAP4rev1 6473 An implementation that wants to remain compatible with IMAP4rev1 can 6474 advertise both IMAP4rev1 and IMAP4rev2 in its CAPABILITY response/ 6475 response code. While some IMAP4rev1 responses were removed in 6476 IMAP4rev2, their presence will not break IMAP4rev2-only clients. 6478 If both IMAP4rev1 and IMAP4rev2 are advertised, an IMAP client that 6479 wants to use IMAP4rev2 MUST issue an "ENABLE IMAP4rev2" command. 6481 Servers advertising both IMAP4rev1 and IMAP4rev2 SHOULD NOT 6483 generate UTF-8 quoted strings unless the client has issued "ENABLE 6484 IMAP4rev2". Consider implementation of mechanisms described or 6485 referenced in [IMAP-UTF-8] to achieve this goal. 6487 Servers advertising both IMAP4rev1 and IMAP4rev2, and clients 6488 intending to be compatible with IMAP4rev1 servers MUST be compatible 6489 with the international mailbox naming convention described in the 6490 following subsection. 6492 A.1. Mailbox International Naming Convention for compatibility with 6493 IMAP4rev1 6495 Support for the Mailbox International Naming Convention described in 6496 this section is not required for IMAP4rev2-only clients and servers. 6498 By convention, international mailbox names in IMAP4rev1 are specified 6499 using a modified version of the UTF-7 encoding described in [UTF-7]. 6500 Modified UTF-7 may also be usable in servers that implement an 6501 earlier version of this protocol. 6503 In modified UTF-7, printable US-ASCII characters, except for "&", 6504 represent themselves; that is, characters with octet values 0x20-0x25 6505 and 0x27-0x7e. The character "&" (0x26) is represented by the two- 6506 octet sequence "&-". 6508 All other characters (octet values 0x00-0x1f and 0x7f-0xff) are 6509 represented in modified BASE64, with a further modification from 6511 [UTF-7] that "," is used instead of "/". Modified BASE64 MUST NOT be 6512 used to represent any printing US-ASCII character which can represent 6513 itself. Only characters inside the modified BASE64 alphabet are 6514 permitted in modified BASE64 text. 6516 "&" is used to shift to modified BASE64 and "-" to shift back to US- 6517 ASCII. There is no implicit shift from BASE64 to US-ASCII, and null 6518 shifts ("-&" while in BASE64; note that "&-" while in US-ASCII means 6519 "&") are not permitted. However, all names start in US-ASCII, and 6520 MUST end in US-ASCII; that is, a name that ends with a non-ASCII 6521 ISO-10646 character MUST end with a "-"). 6523 The purpose of these modifications is to correct the following 6524 problems with UTF-7: 6526 1. UTF-7 uses the "+" character for shifting; this conflicts with 6527 the common use of "+" in mailbox names, in particular USENET 6528 newsgroup names. 6530 2. UTF-7's encoding is BASE64 which uses the "/" character; this 6531 conflicts with the use of "/" as a popular hierarchy delimiter. 6533 3. UTF-7 prohibits the unencoded usage of "\"; this conflicts with 6534 the use of "\" as a popular hierarchy delimiter. 6536 4. UTF-7 prohibits the unencoded usage of "~"; this conflicts with 6537 the use of "~" in some servers as a home directory indicator. 6539 5. UTF-7 permits multiple alternate forms to represent the same 6540 string; in particular, printable US-ASCII characters can be 6541 represented in encoded form. 6543 Although modified UTF-7 is a convention, it establishes certain 6544 requirements on server handling of any mailbox name with an embedded 6545 "&" character. In particular, server implementations MUST preserve 6546 the exact form of the modified BASE64 portion of a modified UTF-7 6547 name and treat that text as case-sensitive, even if names are 6548 otherwise case-insensitive or case-folded. 6550 Server implementations SHOULD verify that any mailbox name with an 6551 embedded "&" character, used as an argument to CREATE, is: in the 6552 correctly modified UTF-7 syntax, has no superfluous shifts, and has 6553 no encoding in modified BASE64 of any printing US-ASCII character 6554 which can represent itself. However, client implementations MUST NOT 6555 depend upon the server doing this, and SHOULD NOT attempt to create a 6556 mailbox name with an embedded "&" character unless it complies with 6557 the modified UTF-7 syntax. 6559 Server implementations which export a mail store that does not follow 6560 the modified UTF-7 convention MUST convert to modified UTF-7 any 6561 mailbox name that contains either non-ASCII characters or the "&" 6562 character. 6564 For example, here is a mailbox name which mixes English, Chinese, 6565 and Japanese text: ~peter/mail/&U,BTFw-/&ZeVnLIqe- 6567 For example, the string "&Jjo!" is not a valid mailbox name 6568 because it does not contain a shift to US-ASCII before the "!". 6569 The correct form is "&Jjo-!". The string "&U,BTFw-&ZeVnLIqe-" is 6570 not permitted because it contains a superfluous shift. The 6571 correct form is "&U,BTF2XlZyyKng-". 6573 Appendix B. Backward compatibility with BINARY extension 6575 IMAP4rev2 is incorporates subset of functionality provided by the 6576 BINARY extension [RFC3516], in particular it includes additional 6577 FETCH items (BINARY, BINARY.PEEK and BINARY.SIZE), but not extensions 6578 to the APPEND command. IMAP4rev2 implementations that supports full 6579 RFC 3516 functionality need to also advertise the BINARY token in the 6580 CAPABILITY response. 6582 Appendix C. Changes from RFC 3501 / IMAP4rev1 6584 The following is the plan for remaining changes. The plan might 6585 change over time. 6587 1. Fold in the following extensions/RFC: RFC 5530 (IMAP Response 6588 Codes, done), UIDPLUS (done), ENABLE (done), ESEARCH (done), 6589 SPECIAL-USE (list of new mailbox attributes is done), LITERAL- 6590 (done), NAMESPACE (done), SASL-IR (done), IDLE (done), MOVE 6591 (done). 6593 2. Add CLOSED response code (from CONDSTORE) - done 6595 3. Add support for $MDNSent and $Forwarded IMAP keywords - done. 6596 Add more examples showing their use? Also add other keywords 6597 like $Phishing, $Junk, $NonJunk? 6599 4. Require all unsolicited FETCH updates to include UID - done. 6601 5. Update recommendations on TLS ciphers to match UTA WG work (as 6602 per RFC 8314, RFC 7525 and RFC 7817) - done. 6604 6. Possibly fold in the following extensions/RFC: Base LIST- 6605 EXTENDED syntax plus deprecate LSUB (replace it with LIST 6606 \Subscribed) minus the requirement to support multiple list 6607 patterns - done, STATUS-in-LIST - done, SEARCHRES, BINARY (only 6608 the FETCH changes on leaf body part and make APPEND related ones 6609 optional. See the mailing list discussion) - done. 6611 6. 6613 7. Add STATUS SIZE (total mailbox size) - done. Add STATUS DELETED 6614 (number of messages with \Deleted flag set) - done. 6616 8. Drop UTF-7, all mailboxes are always in UTF-8 - done. 6618 9. Revise IANA registration of IMAP extensions and give advice on 6619 use of "X-" convention. 6621 10. Allow word-based searching (as per Chris Newman)? Need to 6622 discuss header field search, where exact/substring match is 6623 still required for interoperability. 6625 The following changes since RFC 3501 were done so far: 6627 1. Folded in IMAP UNSELECT (RFC 3691), UIDPLUS (RFC 4315), ESEARCH 6628 (RFC 4731), ENABLE (RFC 5161), IDLE (RFC 2177), SASL-IR (RFC 6629 4959), LIST-STATUS (RFC 5819) and MOVE (RFC 6851) extensions. 6630 Also folded RFC 5530 and FETCH side of the BINARY extension (RFC 6631 3516). 6633 2. Clarified that server should decode parameter value 6634 continuations as described in [RFC2231]. This requirement was 6635 hidden in RFC 2231 itself. 6637 3. SEARCH command now requires to return ESEARCH response (SEARCH 6638 response is now deprecated). 6640 4. Added CLOSED response code from RFC 7162. SELECT/EXAMINE when a 6641 mailbox is already selected now require for the CLOSED response 6642 code to be returned. 6644 5. Updated to use modern TLS-related recommendations as per RFC 6645 8314, RFC 7817, RFC 7525. 6647 6. For future extensibility extended ABNF for tagged-ext-simple to 6648 allow for bare number64. 6650 7. Added SHOULD level requirement on IMAP servers to support 6651 $MDNSent and $Forwarded keywords. 6653 8. Added STATUS SIZE and STATUS DELETED. 6655 9. Mailbox names and message headers now allow for UTF-8. Support 6656 for Modified UTF-7 in mailbox names is not required, unless 6657 compatibility with IMAP4rev1 is desired. 6659 10. UNSEEN response code on SELECT/EXAMINE is now deprecated. 6661 11. RECENT response on SELECT/EXAMINE, \Recent flag, RECENT STATUS, 6662 SEARCH NEW items are now deprecated. 6664 12. Clarified that the server doesn't need to send a new 6665 PERMANENTFLAGS response code when a new keyword was successfully 6666 added and the server advertised \* earlier for the same mailbox. 6668 13. Removed the CHECK command. Clients should use NOOP instead. 6670 14. RFC822, RFC822.HEADER and RFC822.TEXT FETCH data items were 6671 deprecated. Clients should use the corresponding BODY[] 6672 variants instead. 6674 15. Replaced DIGEST-MD5 SASL mechanism with SCRAM-SHA-256. DIGEST- 6675 MD5 was deprecated. 6677 16. LSUB command was deprecated. Clients should use LIST 6678 (SUBSCRIBED) instead. 6680 17. resp-text ABNF non terminal was updated to allow for empty text. 6682 18. IDLE command can now return updates not related to the currently 6683 selected mailbox state. 6685 Appendix D. Acknowledgement 6687 Earlier versions of this document were edited by Mark Crispin. 6688 Sadly, he is no longer available to help with this work. Editors of 6689 this revisions are hoping that Mark would have approved. 6691 Chris Newman has contributed text on I18N and use of UTF-8 in 6692 messages and mailbox names. 6694 Thank you to Tony Hansen for helping with the index generation. 6695 Thank you to Timo Sirainen, Bron Gondwana and Arnt Gulbrandsen for 6696 extensive feedback. 6698 This document incorporate text from RFC 4315 (by Mark Crispin), RFC 6699 4466 (by Cyrus Daboo), RFC 4731 (by Dave Cridland), RFC 5161 (by Arnt 6700 Gulbrandsen), RFC 5530 (by Arnt Gulbrandsen), RFC 5819 (by Timo 6701 Sirainen), RFC 6154 (by Jamie Nicolson) 6702 so work done by authors/editors of these documents is appreciated. 6703 Note that editors of this document were redacted from the above list. 6705 Index 6707 $ 6708 $Forwarded (predefined flag) 12 6709 $MDNSent (predefined flag) 12 6711 + 6712 +FLAGS 83 6713 +FLAGS.SILENT 83 6715 - 6716 -FLAGS 83 6717 -FLAGS.SILENT 83 6719 A 6720 ALERT (response code) 90 6721 ALL (fetch item) 79 6722 ALL (search key) 75 6723 ALL (search result option) 74 6724 ALREADYEXISTS (response code) 90 6725 ANSWERED (search key) 75 6726 APPEND (command) 66 6727 APPENDUID (response code) 91 6728 AUTHENTICATE (command) 28 6729 AUTHENTICATIONFAILED (response code) 91 6730 AUTHORIZATIONFAILED (response code) 92 6732 B 6733 BAD (response) 99 6734 BADCHARSET (response code) 92 6735 BCC (search key) 76 6736 BEFORE (search key) 76 6737 BINARY.PEEK[]<> (fetch item) 80 6738 BINARY.SIZE[] (fetch item) 80 6739 BINARY.SIZE[] (fetch result) 109 6740 BINARY[]<> (fetch result) 108 6741 BINARY[]<> (fetch item) 79 6742 BODY (fetch item) 80 6743 BODY (fetch result) 109 6744 BODY (search key) 76 6745 BODY.PEEK[
]<> (fetch item) 82 6746 BODYSTRUCTURE (fetch item) 82 6747 BODYSTRUCTURE (fetch result) 110 6748 BODY[
]<> (fetch result) 109 6749 BODY[
]<> (fetch item) 80 6750 BYE (response) 100 6751 Body Structure (message attribute) 13 6753 C 6754 CANNOT (response code) 92 6755 CAPABILITY (command) 24 6756 CAPABILITY (response code) 92 6757 CAPABILITY (response) 101 6758 CC (search key) 76 6759 CLIENTBUG (response code) 92 6760 CLOSE (command) 71 6761 CLOSED (response code) 93 6762 CONTACTADMIN (response code) 93 6763 COPY (command) 84 6764 COPYUID (response code) 93 6765 CORRUPTION (response code) 94 6766 COUNT (search result option) 74 6767 CREATE (command) 37 6769 D 6770 DELETE (command) 38 6771 DELETED (search key) 76 6772 DELETED (status item) 66 6773 DRAFT (search key) 76 6775 E 6776 ENABLE (command) 32 6777 ENVELOPE (fetch item) 82 6778 ENVELOPE (fetch result) 112 6779 ESEARCH (response) 106 6780 EXAMINE (command) 36 6781 EXPIRED (response code) 94 6782 EXPUNGE (command) 72 6783 EXPUNGE (response) 107 6784 EXPUNGEISSUED (response code) 94 6785 Envelope Structure (message attribute) 13 6787 F 6788 FAST (fetch item) 79 6789 FETCH (command) 79 6790 FETCH (response) 108 6791 FLAGGED (search key) 76 6792 FLAGS (fetch item) 82 6793 FLAGS (fetch result) 113 6794 FLAGS (response) 106 6795 FLAGS (store command data item) 83 6796 FLAGS.SILENT (store command data item) 83 6797 FROM (search key) 76 6798 FULL (fetch item) 79 6799 Flags (message attribute) 11 6801 H 6802 HEADER (part specifier) 80 6803 HEADER (search key) 76 6804 HEADER.FIELDS (part specifier) 80 6805 HEADER.FIELDS.NOT (part specifier) 80 6807 I 6808 IDLE (command) 69 6809 INTERNALDATE (fetch item) 82 6810 INTERNALDATE (fetch result) 113 6811 INUSE (response code) 94 6812 Internal Date (message attribute) 12 6814 K 6815 KEYWORD (search key) 76 6816 Keyword (type of flag) 12 6818 L 6819 LARGER (search key) 76 6820 LIMIT (response code) 95 6821 LIST (command) 42 6822 LIST (response) 102 6823 LOGOUT (command) 26 6825 M 6826 MAX (search result option) 74 6827 MAY (specification requirement term) 5 6828 MESSAGES (status item) 66 6829 MIME (part specifier) 81 6830 MIN (search result option) 74 6831 MOVE (command) 85 6832 MUST (specification requirement term) 5 6833 MUST NOT (specification requirement term) 5 6834 Message Sequence Number (message attribute) 11 6836 N 6837 NAMESPACE (command) 60 6838 NAMESPACE (response) 105 6839 NO (response) 98 6840 NONEXISTENT (response code) 95 6841 NOOP (command) 25 6842 NOPERM (response code) 95 6843 NOT (search key) 76 6844 NOT RECOMMENDED (specification requirement term) 5 6846 O 6847 OK (response) 98 6848 ON (search key) 76 6849 OPTIONAL (specification requirement term) 5 6850 OR (search key) 76 6851 OVERQUOTA (response code) 95 6853 P 6854 PARSE (response code) 96 6855 PERMANENTFLAGS (response code) 96 6856 PREAUTH (response) 99 6857 PRIVACYREQUIRED (response code) 96 6858 Permanent Flag (class of flag) 12 6859 Predefined keywords 12 6861 R 6862 READ-ONLY (response code) 96 6863 READ-WRITE (response code) 97 6864 RECOMMENDED (specification requirement term) 5 6865 RENAME (command) 39 6866 REQUIRED (specification requirement term) 5 6867 RFC822.SIZE (fetch item) 82 6868 RFC822.SIZE (fetch result) 114 6870 S 6871 SEARCH (command) 73 6872 SEEN (search key) 77 6873 SELECT (command) 34 6874 SENTBEFORE (search key) 77 6875 SENTON (search key) 77 6876 SENTSINCE (search key) 77 6877 SERVERBUG (response code) 97 6878 SHOULD (specification requirement term) 5 6879 SHOULD NOT (specification requirement term) 5 6880 SINCE (search key) 77 6881 SIZE (status item) 66 6882 SMALLER (search key) 77 6883 STARTTLS (command) 27 6884 STATUS (command) 65 6885 STATUS (response) 105 6886 STORE (command) 83 6887 SUBJECT (search key) 77 6888 SUBSCRIBE (command) 41 6889 Session Flag (class of flag) 12 6890 System Flag (type of flag) 11 6892 T 6893 TEXT (part specifier) 80 6894 TEXT (search key) 77 6895 TO (search key) 77 6896 TRYCREATE (response code) 97 6898 U 6899 UID (command) 87 6900 UID (fetch item) 82 6901 UID (fetch result) 114 6902 UID (search key) 77 6903 UIDNEXT (response code) 97 6904 UIDNEXT (status item) 66 6905 UIDNOTSTICKY (response code) 97 6906 UIDVALIDITY (response code) 97 6907 UIDVALIDITY (status item) 66 6908 UNANSWERED (search key) 77 6909 UNAVAILABLE (response code) 98 6910 UNDELETED (search key) 77 6911 UNDRAFT (search key) 77 6912 UNFLAGGED (search key) 77 6913 UNKEYWORD (search key) 77 6914 UNKNOWN-CTE (response code) 98 6915 UNSEEN (search key) 77 6916 UNSEEN (status item) 66 6917 UNSELECT (command) 72 6918 UNSUBSCRIBE (command) 42 6919 Unique Identifier (UID) (message attribute) 9 6921 X 6922 X (command) 88 6924 [ 6925 [RFC-5322] Size (message attribute) 13 6927 \ 6928 \All (mailbox name attribute) 103 6929 \Answered (system flag) 11 6930 \Archive (mailbox name attribute) 104 6931 \Deleted (system flag) 12 6932 \Draft (system flag) 12 6933 \Drafts (mailbox name attribute) 104 6934 \Flagged (mailbox name attribute) 104 6935 \Flagged (system flag) 11 6936 \HasChildren (mailbox name attribute) 102 6937 \HasNoChildren (mailbox name attribute) 103 6938 \Junk (mailbox name attribute) 104 6939 \Marked (mailbox name attribute) 103 6940 \Noinferiors (mailbox name attribute) 102 6941 \NonExistent (mailbox name attribute) 102 6942 \Noselect (mailbox name attribute) 102 6943 \Recent (system flag) 12 6944 \Remote (mailbox name attribute) 103 6945 \Seen (system flag) 11 6946 \Sent (mailbox name attribute) 104 6947 \Subscribed (mailbox name attribute) 103 6948 \Trash (mailbox name attribute) 104 6949 \Unmarked (mailbox name attribute) 103 6951 Authors' Addresses 6953 Alexey Melnikov (editor) 6954 Isode Ltd 6955 14 Castle Mews 6956 Hampton, Middlesex TW12 2NP 6957 UK 6959 Email: Alexey.Melnikov@isode.com 6961 Barry Leiba (editor) 6962 Huawei Technologies 6964 Phone: +1 646 827 0648 6965 Email: barryleiba@computer.org 6966 URI: http://internetmessagingtechnology.org/