idnits 2.17.00 (12 Aug 2021) /tmp/idnits57784/draft-ietf-extra-imap4rev2-13.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The document seems to lack an Introduction section. ** There are 2 instances of too long lines in the document, the longest one being 2 characters in excess of 72. -- The draft header indicates that this document obsoletes RFC3501, but the abstract doesn't seem to mention this, which it should. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == The document seems to contain a disclaimer for pre-RFC5378 work, but was first submitted on or after 10 November 2008. The disclaimer is usually necessary only for documents that revise or obsolete older RFCs, and that take significant amounts of text from those RFCs. If you can contact all authors of the source material and they are willing to grant the BCP78 rights to the IETF Trust, you can and should remove the disclaimer. Otherwise, the disclaimer is needed and you can ignore this comment. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (March 9, 2020) is 802 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 6848, but not defined == Missing Reference: 'IMAP-OBSOLETE' is mentioned on line 6843, but not defined == Missing Reference: 'IMAP-COMPAT' is mentioned on line 6833, but not defined == Missing Reference: 'IMAP-HISTORICAL' is mentioned on line 6838, but not defined == Missing Reference: 'RFC-822' is mentioned on line 6852, but not defined ** Obsolete undefined reference: RFC 822 (Obsoleted by RFC 2822) == Missing Reference: 'IMAP-DISC' is mentioned on line 6775, but not defined == Missing Reference: 'RFC3503' is mentioned on line 6747, but not defined == Missing Reference: 'IMAP-KEYWORDS-REG' is mentioned on line 6815, but not defined == Missing Reference: 'SMTP' is mentioned on line 6796, but not defined == Missing Reference: 'RFC7888' is mentioned on line 6771, but not defined -- Looks like a reference, but probably isn't: '1' on line 880 == Missing Reference: 'IMAP-URL' is mentioned on line 6810, but not defined == Missing Reference: 'UIDVALIDITY 3857529045' is mentioned on line 5628, but not defined == Missing Reference: 'UIDNEXT 4392' is mentioned on line 1713, but not defined == Missing Reference: 'RFC5258' is mentioned on line 6757, but not defined == Missing Reference: 'RFC2193' is mentioned on line 6762, but not defined == Missing Reference: 'RFC3348' is mentioned on line 6766, but not defined ** Obsolete undefined reference: RFC 3348 (Obsoleted by RFC 5258) == Missing Reference: 'RFC4314' is mentioned on line 6803, but not defined == Missing Reference: 'UIDNEXT 2' is mentioned on line 3172, but not defined == Missing Reference: 'UIDVALIDITY 1' is mentioned on line 3243, but not defined == Missing Reference: 'CHARSET-REG' is mentioned on line 6825, but not defined == Missing Reference: 'IMAP-I18N' is mentioned on line 6780, but not defined == Missing Reference: 'HEADER' is mentioned on line 5645, but not defined == Missing Reference: 'BADCHARSET UTF-8' is mentioned on line 3813, but not defined == Missing Reference: 'UID' is mentioned on line 4223, but not defined == Missing Reference: 'RFC2087' is mentioned on line 6807, but not defined ** Obsolete undefined reference: RFC 2087 (Obsoleted by RFC 9208) == Missing Reference: 'IMAP-MAILBOX-NAME-ATTRS-REG' is mentioned on line 6820, but not defined == Missing Reference: 'READ-WRITE' is mentioned on line 5629, but not defined == Missing Reference: 'RFC4422' is mentioned on line 5966, but not defined == Missing Reference: 'IMAP4' is mentioned on line 6052, but not defined == Missing Reference: 'Namespace-Response-Extensions' is mentioned on line 6118, but not defined == Missing Reference: 'IMAP-TLS' is mentioned on line 6856, but not defined == Missing Reference: 'RFC5256' is mentioned on line 6752, but not defined == Missing Reference: 'IMAP-MODEL' is mentioned on line 6786, but not defined == Missing Reference: 'IMAP-UTF-8' is mentioned on line 6874, but not defined == Missing Reference: 'RFC3516' is mentioned on line 6963, 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 (~~), 37 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: September 10, 2020 March 9, 2020 8 INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev2 9 draft-ietf-extra-imap4rev2-13 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 September 10, 2020. 48 Copyright Notice 50 Copyright (c) 2020 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 . . . . . . . . . . . 13 90 2.3.4. [RFC-5322] Size Message Attribute . . . . . . . . . . 13 91 2.3.5. Envelope Structure Message Attribute . . . . . . . . 14 92 2.3.6. Body Structure Message Attribute . . . . . . . . . . 14 93 2.4. Message Texts . . . . . . . . . . . . . . . . . . . . . . 14 94 3. State and Flow Diagram . . . . . . . . . . . . . . . . . . . 14 95 3.1. Not Authenticated State . . . . . . . . . . . . . . . . . 14 96 3.2. Authenticated State . . . . . . . . . . . . . . . . . . . 14 97 3.3. Selected State . . . . . . . . . . . . . . . . . . . . . 15 98 3.4. Logout State . . . . . . . . . . . . . . . . . . . . . . 15 99 4. Data Formats . . . . . . . . . . . . . . . . . . . . . . . . 17 100 4.1. Atom . . . . . . . . . . . . . . . . . . . . . . . . . . 17 101 4.1.1. Sequence set and UID set . . . . . . . . . . . . . . 17 102 4.2. Number . . . . . . . . . . . . . . . . . . . . . . . . . 17 103 4.3. String . . . . . . . . . . . . . . . . . . . . . . . . . 17 104 4.3.1. 8-bit and Binary Strings . . . . . . . . . . . . . . 18 105 4.4. Parenthesized List . . . . . . . . . . . . . . . . . . . 19 106 4.5. NIL . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 107 5. Operational Considerations . . . . . . . . . . . . . . . . . 20 108 5.1. Mailbox Naming . . . . . . . . . . . . . . . . . . . . . 20 109 5.1.1. Mailbox Hierarchy Naming . . . . . . . . . . . . . . 21 110 5.1.2. Namespaces . . . . . . . . . . . . . . . . . . . . . 21 111 5.2. Mailbox Size and Message Status Updates . . . . . . . . . 23 112 5.3. Response when no Command in Progress . . . . . . . . . . 23 113 5.4. Autologout Timer . . . . . . . . . . . . . . . . . . . . 23 114 5.5. Multiple Commands in Progress (Command Pipelining) . . . 23 115 6. Client Commands . . . . . . . . . . . . . . . . . . . . . . . 25 116 6.1. Client Commands - Any State . . . . . . . . . . . . . . . 25 117 6.1.1. CAPABILITY Command . . . . . . . . . . . . . . . . . 25 118 6.1.2. NOOP Command . . . . . . . . . . . . . . . . . . . . 26 119 6.1.3. LOGOUT Command . . . . . . . . . . . . . . . . . . . 27 120 6.2. Client Commands - Not Authenticated State . . . . . . . . 27 121 6.2.1. STARTTLS Command . . . . . . . . . . . . . . . . . . 28 122 6.2.2. AUTHENTICATE Command . . . . . . . . . . . . . . . . 29 123 6.2.3. LOGIN Command . . . . . . . . . . . . . . . . . . . . 32 124 6.3. Client Commands - Authenticated State . . . . . . . . . . 33 125 6.3.1. ENABLE Command . . . . . . . . . . . . . . . . . . . 33 126 6.3.2. SELECT Command . . . . . . . . . . . . . . . . . . . 35 127 6.3.3. EXAMINE Command . . . . . . . . . . . . . . . . . . . 37 128 6.3.4. CREATE Command . . . . . . . . . . . . . . . . . . . 38 129 6.3.5. DELETE Command . . . . . . . . . . . . . . . . . . . 39 130 6.3.6. RENAME Command . . . . . . . . . . . . . . . . . . . 40 131 6.3.7. SUBSCRIBE Command . . . . . . . . . . . . . . . . . . 42 132 6.3.8. UNSUBSCRIBE Command . . . . . . . . . . . . . . . . . 43 133 6.3.9. LIST Command . . . . . . . . . . . . . . . . . . . . 43 134 6.3.10. NAMESPACE Command . . . . . . . . . . . . . . . . . . 61 135 6.3.11. STATUS Command . . . . . . . . . . . . . . . . . . . 66 136 6.3.12. APPEND Command . . . . . . . . . . . . . . . . . . . 67 137 6.3.13. IDLE Command . . . . . . . . . . . . . . . . . . . . 70 138 6.4. Client Commands - Selected State . . . . . . . . . . . . 72 139 6.4.1. CLOSE Command . . . . . . . . . . . . . . . . . . . . 72 140 6.4.2. UNSELECT Command . . . . . . . . . . . . . . . . . . 73 141 6.4.3. EXPUNGE Command . . . . . . . . . . . . . . . . . . . 73 142 6.4.4. SEARCH Command . . . . . . . . . . . . . . . . . . . 74 143 6.4.5. FETCH Command . . . . . . . . . . . . . . . . . . . . 86 144 6.4.6. STORE Command . . . . . . . . . . . . . . . . . . . . 90 145 6.4.7. COPY Command . . . . . . . . . . . . . . . . . . . . 91 146 6.4.8. MOVE Command . . . . . . . . . . . . . . . . . . . . 92 147 6.4.9. UID Command . . . . . . . . . . . . . . . . . . . . . 94 148 6.5. Client Commands - Experimental/Expansion . . . . . . . . 96 149 6.5.1. X Command . . . . . . . . . . . . . . . . . . . 96 150 7. Server Responses . . . . . . . . . . . . . . . . . . . . . . 97 151 7.1. Server Responses - Status Responses . . . . . . . . . . . 98 152 7.1.1. OK Response . . . . . . . . . . . . . . . . . . . . . 106 153 7.1.2. NO Response . . . . . . . . . . . . . . . . . . . . . 106 154 7.1.3. BAD Response . . . . . . . . . . . . . . . . . . . . 106 155 7.1.4. PREAUTH Response . . . . . . . . . . . . . . . . . . 107 156 7.1.5. BYE Response . . . . . . . . . . . . . . . . . . . . 107 157 7.2. Server Responses - Server and Mailbox Status . . . . . . 108 158 7.2.1. The ENABLED Response . . . . . . . . . . . . . . . . 108 159 7.2.2. CAPABILITY Response . . . . . . . . . . . . . . . . . 108 160 7.2.3. LIST Response . . . . . . . . . . . . . . . . . . . . 109 161 7.2.4. NAMESPACE Response . . . . . . . . . . . . . . . . . 113 162 7.2.5. STATUS Response . . . . . . . . . . . . . . . . . . . 113 163 7.2.6. ESEARCH Response . . . . . . . . . . . . . . . . . . 113 164 7.2.7. FLAGS Response . . . . . . . . . . . . . . . . . . . 114 165 7.3. Server Responses - Mailbox Size . . . . . . . . . . . . . 114 166 7.3.1. EXISTS Response . . . . . . . . . . . . . . . . . . . 115 167 7.4. Server Responses - Message Status . . . . . . . . . . . . 115 168 7.4.1. EXPUNGE Response . . . . . . . . . . . . . . . . . . 115 169 7.4.2. FETCH Response . . . . . . . . . . . . . . . . . . . 116 170 7.5. Server Responses - Command Continuation Request . . . . . 122 171 8. Sample IMAP4rev2 connection . . . . . . . . . . . . . . . . . 122 172 9. Formal Syntax . . . . . . . . . . . . . . . . . . . . . . . . 123 173 10. Author's Note . . . . . . . . . . . . . . . . . . . . . . . . 140 174 11. Security Considerations . . . . . . . . . . . . . . . . . . . 140 175 11.1. STARTTLS Security Considerations . . . . . . . . . . . . 141 176 11.2. COPYUID and APPENDUID response codes . . . . . . . . . . 141 177 11.3. LIST command and Other Users' namespace . . . . . . . . 141 178 11.4. Other Security Considerations . . . . . . . . . . . . . 141 179 12. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 142 180 12.1. Updates to IMAP4 Capabilities registry . . . . . . . . . 143 181 12.2. GSSAPI/SASL service name . . . . . . . . . . . . . . . . 143 182 13. References . . . . . . . . . . . . . . . . . . . . . . . . . 143 183 13.1. Normative References . . . . . . . . . . . . . . . . . . 143 184 13.2. Informative References (related protocols) . . . . . . . 146 185 13.3. Informative References (historical aspects of IMAP and 186 related protocols) . . . . . . . . . . . . . . . . . . . 148 187 Appendix A. Backward compatibility with IMAP4rev1 . . . . . . . 149 188 A.1. Mailbox International Naming Convention for compatibility 189 with IMAP4rev1 . . . . . . . . . . . . . . . . . . . . . 149 190 Appendix B. Backward compatibility with BINARY extension . . . . 151 191 Appendix C. Changes from RFC 3501 / IMAP4rev1 . . . . . . . . . 151 192 Appendix D. Acknowledgement . . . . . . . . . . . . . . . . . . 153 193 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 194 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 159 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. In all cases, "RFC822" should be interpreted as a 285 reference to the updated [RFC-5322] standard. 287 2. Protocol Overview 289 2.1. Link Level 291 The IMAP4rev2 protocol assumes a reliable data stream such as that 292 provided by TCP. When TCP is used, an IMAP4rev2 server listens on 293 port 143 or port 993 (IMAP-over-TLS). 295 2.2. Commands and Responses 297 An IMAP4rev2 connection consists of the establishment of a client/ 298 server network connection, an initial greeting from the server, and 299 client/server interactions. These client/server interactions consist 300 of a client command, server data, and a server completion result 301 response. 303 All interactions transmitted by client and server are in the form of 304 lines, that is, strings that end with a CRLF. The protocol receiver 305 of an IMAP4rev2 client or server is either reading a line, or is 306 reading a sequence of octets with a known count followed by a line. 308 2.2.1. Client Protocol Sender and Server Protocol Receiver 310 The client command begins an operation. Each client command is 311 prefixed with an identifier (typically a short alphanumeric string, 312 e.g., A0001, A0002, etc.) called a "tag". A different tag is 313 generated by the client for each command. (More formally: the client 314 SHOULD generate a unique tag for every command, but a server MUST 315 accept tag reuse.) 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 non-zero 32-bit value assigned to each message, which 401 when used with the unique identifier validity value (see below) forms 402 a 64-bit value that MUST NOT refer to any other message in the 403 mailbox or any subsequent mailbox with the same name forever. Unique 404 identifiers are assigned in a strictly ascending fashion in the 405 mailbox; as each message is added to the mailbox it is assigned a 406 higher UID than the message(s) which were added previously. Unlike 407 message sequence numbers, unique identifiers are not necessarily 408 contiguous. 410 The unique identifier of a message MUST NOT change during the 411 session, and SHOULD NOT change between sessions. Any change of 412 unique identifiers between sessions MUST be detectable using the 413 UIDVALIDITY mechanism discussed below. Persistent unique identifiers 414 are required for a client to resynchronize its state from a previous 415 session with the server (e.g., disconnected or offline access 416 clients); this is discussed further in [IMAP-DISC]. 418 Associated with every mailbox are two 32-bit unsigned non-zero values 419 which aid in unique identifier handling: the next unique identifier 420 value (UIDNEXT) and the unique identifier validity value 421 (UIDVALIDITY). 423 The next unique identifier value is the predicted value that will be 424 assigned to a new message in the mailbox. Unless the unique 425 identifier validity also changes (see below), the next unique 426 identifier value MUST have the following two characteristics. First, 427 the next unique identifier value MUST NOT change unless new messages 428 are added to the mailbox; and second, the next unique identifier 429 value MUST change whenever new messages are added to the mailbox, 430 even if those new messages are subsequently expunged. 432 Note: The next unique identifier value is intended to provide a 433 means for a client to determine whether any messages have been 434 delivered to the mailbox since the previous time it checked this 435 value. It is not intended to provide any guarantee that any 436 message will have this unique identifier. A client can only 437 assume, at the time that it obtains the next unique identifier 438 value, that messages arriving after that time will have a UID 439 greater than or equal to that value. 441 The unique identifier validity value is sent in a UIDVALIDITY 442 response code in an OK untagged response at mailbox selection time. 443 If unique identifiers from an earlier session fail to persist in this 444 session, the unique identifier validity value MUST be greater than 445 the one used in the earlier session. 447 Note: Ideally, unique identifiers SHOULD persist at all times. 448 Although this specification recognizes that failure to persist can 449 be unavoidable in certain server environments, it STRONGLY 450 ENCOURAGES message store implementation techniques that avoid this 451 problem. For example: 453 1. Unique identifiers MUST be strictly ascending in the mailbox 454 at all times. If the physical message store is re-ordered by 455 a non-IMAP agent, this requires that the unique identifiers in 456 the mailbox be regenerated, since the former unique 457 identifiers are no longer strictly ascending as a result of 458 the re-ordering. 460 2. If the message store has no mechanism to store unique 461 identifiers, it must regenerate unique identifiers at each 462 session, and each session must have a unique UIDVALIDITY 463 value. 465 3. If the mailbox is deleted and a new mailbox with the same name 466 is created at a later date, the server must either keep track 467 of unique identifiers from the previous instance of the 468 mailbox, or it must assign a new UIDVALIDITY value to the new 469 instance of the mailbox. A good UIDVALIDITY value to use in 470 this case is a 32-bit representation of the creation date/time 471 of the mailbox. It is alright to use a constant such as 1, 472 but only if it guaranteed that unique identifiers will never 473 be reused, even in the case of a mailbox being deleted (or 474 renamed) and a new mailbox by the same name created at some 475 future time. 477 4. The combination of mailbox name, UIDVALIDITY, and UID must 478 refer to a single immutable message on that server forever. 479 In particular, the internal date, [RFC-5322] size, envelope, 480 body structure, and message texts (all BODY[...] fetch data 481 items) must never change. This does not include message 482 numbers, nor does it include attributes that can be set by a 483 STORE command (e.g., FLAGS). 485 2.3.1.2. Message Sequence Number Message Attribute 487 A relative position from 1 to the number of messages in the mailbox. 488 This position MUST be ordered by ascending unique identifier. As 489 each new message is added, it is assigned a message sequence number 490 that is 1 higher than the number of messages in the mailbox before 491 that new message was added. 493 Message sequence numbers can be reassigned during the session. For 494 example, when a message is permanently removed (expunged) from the 495 mailbox, the message sequence number for all subsequent messages is 496 decremented. The number of messages in the mailbox is also 497 decremented. Similarly, a new message can be assigned a message 498 sequence number that was once held by some other message prior to an 499 expunge. 501 In addition to accessing messages by relative position in the 502 mailbox, message sequence numbers can be used in mathematical 503 calculations. For example, if an untagged "11 EXISTS" is received, 504 and previously an untagged "8 EXISTS" was received, three new 505 messages have arrived with message sequence numbers of 9, 10, and 11. 506 Another example, if message 287 in a 523 message mailbox has UID 507 12345, there are exactly 286 messages which have lesser UIDs and 236 508 messages which have greater UIDs. 510 2.3.2. Flags Message Attribute 512 A list of zero or more named tokens associated with the message. A 513 flag is set by its addition to this list, and is cleared by its 514 removal. There are two types of flags in IMAP4rev2. A flag of 515 either type can be permanent or session-only. 517 A system flag is a flag name that is pre-defined in this 518 specification and begin with "\". Certain system flags (\Deleted and 519 \Seen) have special semantics described elsewhere in this document. 520 The currently-defined system flags are: 522 \Seen Message has been read 524 \Answered Message has been answered 526 \Flagged Message is "flagged" for urgent/special attention 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 SEARCH, allowed and preserved in APPEND, COPY, MOVE commands) by 543 server implementations: 545 $Forwarded Message has been forwarded to another email address, 546 embedded within or attached to a new message. An email client 547 sets this keyword when it successfully forwards the message to 548 another email address. Typical usage of this keyword is to show a 549 different (or additional) icon for a message that has been 550 forwarded. Once set, the flag SHOULD NOT be cleared. 552 $MDNSent Message Disposition Notification [RFC8098] was generated 553 and sent for this message. See [RFC3503] for more details on how 554 this keyword is used. 556 $Junk The user (or a delivery agent on behalf of the user) may 557 choose to mark a message as definitely containing junk ($Junk; see 558 also the related keyword $NotJunk). The $Junk keyword can be used 559 to mark (and potentially move/delete messages later), group or 560 hide undesirable messages. See [IMAP-KEYWORDS-REG] for more 561 information. 563 $NotJunk The user (or a delivery agent on behalf of the user) may 564 choose to mark a message as definitely not containing junk 565 ($NotJunk; see also the related keyword $Junk). The $NotJunk 566 keyword can be used to mark, group or show messages that the user 567 wants to see. See [IMAP-KEYWORDS-REG] for more information. 569 $Phishing The $Phishing keyword can be used by a delivery agent to 570 mark a message as highly likely to be a phishing email. An email 571 that's determined to be a phishing email by the delivery agent 572 should also be considered a junk email and have the appropriate 573 junk filtering applied, including setting the $Junk flag and 574 placing in the \Junk special-use mailbox if available. 576 If both the $Phishing flag and the $Junk flag are set, the user 577 agent should display an additional warning message to the user. 578 User agents should not use the term "phishing" in their warning 579 message as most users do not understand this term. Phrasing of 580 the form "this message may be trying to steal your personal 581 information" is recommended. Additionally the user agent may 582 display a warning when clicking on any hyperlinks within the 583 message. 584 The requirement for both $Phishing and $Junk to be set before a 585 user agent displays a warning is for better backwards 586 compatibility with existing clients that understand the $Junk flag 587 but not the $Phishing flag. This so that when an unextended 588 client removes the $Junk flag, an extended client will also show 589 the correct state. See [IMAP-KEYWORDS-REG] for more information. 591 $Junk and $NotJunk are mutually exclusive. If more than one of them 592 is set for a message, the client MUST treat this as if none of them 593 is set and SHOULD unset both of them on the IMAP server. 595 Other registered keywords can be found in the "IMAP and JMAP 596 Keywords" registry [IMAP-KEYWORDS-REG]. 598 A flag can be permanent or session-only on a per-flag basis. 599 Permanent flags are those which the client can add or remove from the 600 message flags permanently; that is, concurrent and subsequent 601 sessions will see any change in permanent flags. Changes to session 602 flags are valid only in that session. 604 2.3.3. Internal Date Message Attribute 606 The internal date and time of the message on the server. This is not 607 the date and time in the [RFC-5322] header, but rather a date and 608 time which reflects when the message was received. In the case of 609 messages delivered via [SMTP], this SHOULD be the date and time of 610 final delivery of the message as defined by [SMTP]. In the case of 611 messages delivered by the IMAP4rev2 COPY or MOVE command, this SHOULD 612 be the internal date and time of the source message. In the case of 613 messages delivered by the IMAP4rev2 APPEND command, this SHOULD be 614 the date and time as specified in the APPEND command description. 615 All other cases are implementation defined. 617 2.3.4. [RFC-5322] Size Message Attribute 619 The number of octets in the message, as expressed in [RFC-5322] 620 format. 622 2.3.5. Envelope Structure Message Attribute 624 A parsed representation of the [RFC-5322] header of the message. 625 Note that the IMAP Envelope structure is not the same as an [SMTP] 626 envelope. 628 2.3.6. Body Structure Message Attribute 630 A parsed representation of the [MIME-IMB] body structure information 631 of the message. 633 2.4. Message Texts 635 In addition to being able to fetch the full [RFC-5322] text of a 636 message, IMAP4rev2 permits the fetching of portions of the full 637 message text. Specifically, it is possible to fetch the [RFC-5322] 638 message header, [RFC-5322] message body, a [MIME-IMB] body part, or a 639 [MIME-IMB] header. 641 3. State and Flow Diagram 643 Once the connection between client and server is established, an 644 IMAP4rev2 connection is in one of four states. The initial state is 645 identified in the server greeting. Most commands are only valid in 646 certain states. It is a protocol error for the client to attempt a 647 command while the connection is in an inappropriate state, and the 648 server will respond with a BAD or NO (depending upon server 649 implementation) command completion result. 651 3.1. Not Authenticated State 653 In the not authenticated state, the client MUST supply authentication 654 credentials before most commands will be permitted. This state is 655 entered when a connection starts unless the connection has been pre- 656 authenticated. 658 3.2. Authenticated State 660 In the authenticated state, the client is authenticated and MUST 661 select a mailbox to access before commands that affect messages will 662 be permitted. This state is entered when a pre-authenticated 663 connection starts, when acceptable authentication credentials have 664 been provided, after an error in selecting a mailbox, or after a 665 successful CLOSE command. 667 3.3. Selected State 669 In a selected state, a mailbox has been selected to access. This 670 state is entered when a mailbox has been successfully selected. 672 3.4. Logout State 674 In the logout state, the connection is being terminated. This state 675 can be entered as a result of a client request (via the LOGOUT 676 command) or by unilateral action on the part of either the client or 677 server. 679 If the client requests the logout state, the server MUST send an 680 untagged BYE response and a tagged OK response to the LOGOUT command 681 before the server closes the connection; and the client MUST read the 682 tagged OK response to the LOGOUT command before the client closes the 683 connection. 685 A server SHOULD NOT unilaterally close the connection without sending 686 an untagged BYE response that contains the reason for having done so. 687 A client SHOULD NOT unilaterally close the connection, and instead 688 SHOULD issue a LOGOUT command. If the server detects that the client 689 has unilaterally closed the connection, the server MAY omit the 690 untagged BYE response and simply close its connection. 692 +----------------------+ 693 |connection established| 694 +----------------------+ 695 || 696 \/ 697 +--------------------------------------+ 698 | server greeting | 699 +--------------------------------------+ 700 || (1) || (2) || (3) 701 \/ || || 702 +-----------------+ || || 703 |Not Authenticated| || || 704 +-----------------+ || || 705 || (7) || (4) || || 706 || \/ \/ || 707 || +----------------+ || 708 || | Authenticated |<=++ || 709 || +----------------+ || || 710 || || (7) || (5) || (6) || 711 || || \/ || || 712 || || +--------+ || || 713 || || |Selected|==++ || 714 || || +--------+ || 715 || || || (7) || 716 \/ \/ \/ \/ 717 +--------------------------------------+ 718 | Logout | 719 +--------------------------------------+ 720 || 721 \/ 722 +-------------------------------+ 723 |both sides close the connection| 724 +-------------------------------+ 726 (1) connection without pre-authentication (OK greeting) 727 (2) pre-authenticated connection (PREAUTH greeting) 728 (3) rejected connection (BYE greeting) 729 (4) successful LOGIN or AUTHENTICATE command 730 (5) successful SELECT or EXAMINE command 731 (6) CLOSE command, unsolicited CLOSED response code or 732 failed SELECT or EXAMINE command 733 (7) LOGOUT command, server shutdown, or connection closed 735 4. Data Formats 737 IMAP4rev2 uses textual commands and responses. Data in IMAP4rev2 can 738 be in one of several forms: atom, number, string, parenthesized list, 739 or NIL. Note that a particular data item may take more than one 740 form; for example, a data item defined as using "astring" syntax may 741 be either an atom or a string. 743 4.1. Atom 745 An atom consists of one or more non-special characters. 747 4.1.1. Sequence set and UID set 749 A set of messages can be referenced by a sequence set containing 750 either message sequence numbers or unique identifiers. See Section 9 751 for details. Sequence sets can contain ranges (e.g. "5:50"), an 752 enumeration of specific message/UID numbers, a special symbol "*", or 753 a combination of the above. 755 A "UID set" is similar to the sequence set of unique identifiers; 756 however, the "*" value for a sequence number is not permitted. 758 4.2. Number 760 A number consists of one or more digit characters, and represents a 761 numeric value. 763 4.3. String 765 A string is in one of three forms: synchonizing literal, non- 766 synchronizing literal or quoted string. The synchronizing literal 767 form is the general form of string. The non-synchronizing literal 768 form is also the general form, but has length limitation. The quoted 769 string form is an alternative that avoids the overhead of processing 770 a literal at the cost of limitations of characters which may be used. 772 When the distinction between synchronizing and non-synchronizing 773 literals is not important, this document just uses the term 774 "literal". 776 A synchronizing literal is a sequence of zero or more octets 777 (including CR and LF), prefix-quoted with an octet count in the form 778 of an open brace ("{"), the number of octets, close brace ("}"), and 779 CRLF. In the case of synchronizing literals transmitted from server 780 to client, the CRLF is immediately followed by the octet data. In 781 the case of synchronizing literals transmitted from client to server, 782 the client MUST wait to receive a command continuation request 783 (described later in this document) before sending the octet data (and 784 the remainder of the command). 786 The non-synchronizing literal is an alternate form of synchronizing 787 literal, and it may appear in communication from client to server 788 instead of the synchonizing form of literal. The non-synchronizing 789 literal form MUST NOT be sent from server to client. The non- 790 synchronizing literal is distinguished from the synchronizing literal 791 by having a plus ("+") between the octet count and the closing brace 792 ("}"). The server does not generate a command continuation request 793 in response to a non-synchronizing literal, and clients are not 794 required to wait before sending the octets of a non- synchronizing 795 literal. Non-synchronizing literals MUST NOT be larger than 4096 796 octets. Any literal larger than 4096 bytes MUST be sent as a 797 synchronizing literal. (Non-synchronizing literals defined in this 798 document are the same as non-synchronizing literals defined by the 799 LITERAL- extension from [RFC7888]. See that document for details on 800 how to handle invalid non-synchronizing literals longer than 4096 801 octets and for interaction with other IMAP extensions.) 803 A quoted string is a sequence of zero or more Unicode characters, 804 excluding CR and LF, encoded in UTF-8, with double quote (<">) 805 characters at each end. 807 The empty string is represented as "" (a quoted string with zero 808 characters between double quotes), as {0} followed by CRLF (a 809 synchronizing literal with an octet count of 0) or as {0+} followed 810 by CRLF (a non-synchronizing literal with an octet count of 0). 812 Note: Even if the octet count is 0, a client transmitting a 813 synchronizing literal MUST wait to receive a command continuation 814 request. 816 4.3.1. 8-bit and Binary Strings 818 8-bit textual and binary mail is supported through the use of a 819 [MIME-IMB] content transfer encoding. IMAP4rev2 implementations MAY 820 transmit 8-bit or multi-octet characters in literals, but SHOULD do 821 so only when the [CHARSET] is identified. 823 IMAP4rev2 is compatible with [I18N-HDRS]. As a result, the 824 identified charset for header-field values with 8-bit content is 825 UTF-8 [UTF-8]. IMAP4rev2 implementations MUST accept and MAY 826 transmit [UTF-8] text in quoted-strings as long as the string does 827 not contain NUL, CR, or LF. This differs from IMAP4rev1 828 implementations. 830 Although a BINARY content transfer encoding is defined, unencoded 831 binary strings are not permitted, unless returned in a in 832 response to BINARY.PEEK[]<> or 833 BINARY[]<> FETCH data item. A "binary 834 string" is any string with NUL characters. A string with an 835 excessive amount of CTL characters MAY also be considered to be 836 binary. Unless returned in response to BINARY.PEEK[...]/BINARY[...] 837 FETCH, client and server implementations MUST encode binary data into 838 a textual form, such as BASE64, before transmitting the data. 840 4.4. Parenthesized List 842 Data structures are represented as a "parenthesized list"; a sequence 843 of data items, delimited by space, and bounded at each end by 844 parentheses. A parenthesized list can contain other parenthesized 845 lists, using multiple levels of parentheses to indicate nesting. 847 The empty list is represented as () -- a parenthesized list with no 848 members. 850 4.5. NIL 852 The special form "NIL" represents the non-existence of a particular 853 data item that is represented as a string or parenthesized list, as 854 distinct from the empty string "" or the empty parenthesized list (). 856 Note: NIL is never used for any data item which takes the form of 857 an atom. For example, a mailbox name of "NIL" is a mailbox named 858 NIL as opposed to a non-existent mailbox name. This is because 859 mailbox uses "astring" syntax which is an atom or a string. 860 Conversely, an addr-name of NIL is a non-existent personal name, 861 because addr-name uses "nstring" syntax which is NIL or a string, 862 but never an atom. 864 Examples: 866 The following LIST response: 868 * LIST () "/" NIL 870 is equivalent to: 871 * LIST () "/" "NIL" 873 as LIST response ABNF is using astring for mailbox name. 875 However, the following response 877 * FETCH 1 (BODY[1] NIL) 879 is not equivalent to: 880 * FETCH 1 (BODY[1] "NIL") 881 The former means absence of the body part, while the latter 882 means that it contains literal sequence of characters "NIL". 884 5. Operational Considerations 886 The following rules are listed here to ensure that all IMAP4rev2 887 implementations interoperate properly. 889 5.1. Mailbox Naming 891 In IMAP4rev2, Mailbox names are encoded in Net-Unicode [NET-UNICODE] 892 (this differs from IMAP4rev1). Client implementations MAY attempt to 893 create Net-Unicode mailbox names, and MUST interpret any 8-bit 894 mailbox names returned by LIST as [NET-UNICODE]. Server 895 implementations MUST prohibit the creation of 8-bit mailbox names 896 that do not comply with Net-Unicode. However, servers MAY accept a 897 de-normalized UTF-8 mailbox name and convert it to Unicode 898 normalization form "NFC" (as per Net-Unicode requirements) prior to 899 mailbox creation. Servers that choose to accept such de-normalized 900 UTF-8 mailbox names MUST accept them in all IMAP commands that have a 901 mailbox name parameter. In particular SELECT must open the 902 same mailbox that was successfully created with CREATE , even 903 if is a de-normalized UTF-8 mailbox name. 905 The case-insensitive mailbox name INBOX is a special name reserved to 906 mean "the primary mailbox for this user on this server". (Note that 907 this special name may not exist on some servers for some users, for 908 example if the user has no access to personal namespace.) The 909 interpretation of all other names is implementation-dependent. 911 In particular, this specification takes no position on case 912 sensitivity in non-INBOX mailbox names. Some server implementations 913 are fully case-sensitive in ASCII range; others preserve case of a 914 newly-created name but otherwise are case-insensitive; and yet others 915 coerce names to a particular case. Client implementations must be 916 able to interact with any of these. 918 There are certain client considerations when creating a new mailbox 919 name: 921 1. Any character which is one of the atom-specials (see the Formal 922 Syntax) will require that the mailbox name be represented as a 923 quoted string or literal. 925 2. CTL and other non-graphic characters are difficult to represent 926 in a user interface and are best avoided. Servers MAY refuse to 927 create mailbox names containing Unicode CTL characters. 929 3. Although the list-wildcard characters ("%" and "*") are valid in 930 a mailbox name, it is difficult to use such mailbox names with 931 the LIST command due to the conflict with wildcard 932 interpretation. 934 4. Usually, a character (determined by the server implementation) is 935 reserved to delimit levels of hierarchy. 937 5. Two characters, "#" and "&", have meanings by convention, and 938 should be avoided except when used in that convention. 940 5.1.1. Mailbox Hierarchy Naming 942 If it is desired to export hierarchical mailbox names, mailbox names 943 MUST be left-to-right hierarchical using a single character to 944 separate levels of hierarchy. The same hierarchy separator character 945 is used for all levels of hierarchy within a single name. 947 5.1.2. Namespaces 949 Personal Namespace: A namespace that the server considers within the 950 personal scope of the authenticated user on a particular connection. 951 Typically, only the authenticated user has access to mailboxes in 952 their Personal Namespace. It is the part of the namespace that 953 belongs to the user that is allocated for mailboxes. If an INBOX 954 exists for a user, it MUST appear within the user's personal 955 namespace. In the typical case, there SHOULD be only one Personal 956 Namespace on a server. 958 Other Users' Namespace: A namespace that consists of mailboxes from 959 the Personal Namespaces of other users. To access mailboxes in the 960 Other Users' Namespace, the currently authenticated user MUST be 961 explicitly granted access rights. For example, it is common for a 962 manager to grant to their secretary access rights to their mailbox. 963 In the typical case, there SHOULD be only one Other Users' Namespace 964 on a server. 966 Shared Namespace: A namespace that consists of mailboxes that are 967 intended to be shared amongst users and do not exist within a user's 968 Personal Namespace. 970 The namespaces a server uses MAY differ on a per-user basis. 972 5.1.2.1. Historic Mailbox Namespace Naming Convention 974 By convention, the first hierarchical element of any mailbox name 975 which begins with "#" identifies the "namespace" of the remainder of 976 the name. This makes it possible to disambiguate between different 977 types of mailbox stores, each of which have their own namespaces. 979 For example, implementations which offer access to USENET 980 newsgroups MAY use the "#news" namespace to partition the USENET 981 newsgroup namespace from that of other mailboxes. Thus, the 982 comp.mail.misc newsgroup would have a mailbox name of 983 "#news.comp.mail.misc", and the name "comp.mail.misc" can refer to 984 a different object (e.g., a user's private mailbox). 986 Namespaces that include the "#" character are not IMAP URL [IMAP-URL] 987 friendly requiring the "#" character to be represented as %23 when 988 within URLs. As such, server implementers MAY instead consider using 989 namespace prefixes that do not contain the "#" character. 991 5.1.2.2. Common namespace models 993 Previous version of this protocol does not define a default server 994 namespace. Two common namespace models have evolved: 996 The "Personal Mailbox" model, in which the default namespace that is 997 presented consists of only the user's personal mailboxes. To access 998 shared mailboxes, the user must use an escape mechanism to reach 999 another namespace. 1001 The "Complete Hierarchy" model, in which the default namespace that 1002 is presented includes the user's personal mailboxes along with any 1003 other mailboxes they have access to. 1005 5.2. Mailbox Size and Message Status Updates 1007 At any time, a server can send data that the client did not request. 1008 Sometimes, such behavior is REQUIRED. For example, agents other than 1009 the server MAY add messages to the mailbox (e.g., new message 1010 delivery), change the flags of the messages in the mailbox (e.g., 1011 simultaneous access to the same mailbox by multiple agents), or even 1012 remove messages from the mailbox. A server MUST send mailbox size 1013 updates automatically if a mailbox size change is observed during the 1014 processing of a command. A server SHOULD send message flag updates 1015 automatically, without requiring the client to request such updates 1016 explicitly. 1018 Special rules exist for server notification of a client about the 1019 removal of messages to prevent synchronization errors; see the 1020 description of the EXPUNGE response for more detail. In particular, 1021 it is NOT permitted to send an EXISTS response that would reduce the 1022 number of messages in the mailbox; only the EXPUNGE response can do 1023 this. 1025 Regardless of what implementation decisions a client makes on 1026 remembering data from the server, a client implementation MUST record 1027 mailbox size updates. It MUST NOT assume that any command after the 1028 initial mailbox selection will return the size of the mailbox. 1030 5.3. Response when no Command in Progress 1032 Server implementations are permitted to send an untagged response 1033 (except for EXPUNGE) while there is no command in progress. Server 1034 implementations that send such responses MUST deal with flow control 1035 considerations. Specifically, they MUST either (1) verify that the 1036 size of the data does not exceed the underlying transport's available 1037 window size, or (2) use non-blocking writes. 1039 5.4. Autologout Timer 1041 If a server has an inactivity autologout timer that applies to 1042 sessions after authentication, the duration of that timer MUST be at 1043 least 30 minutes. The receipt of ANY command from the client during 1044 that interval SHOULD suffice to reset the autologout timer. 1046 5.5. Multiple Commands in Progress (Command Pipelining) 1048 The client MAY send another command without waiting for the 1049 completion result response of a command, subject to ambiguity rules 1050 (see below) and flow control constraints on the underlying data 1051 stream. Similarly, a server MAY begin processing another command 1052 before processing the current command to completion, subject to 1053 ambiguity rules. However, any command continuation request responses 1054 and command continuations MUST be negotiated before any subsequent 1055 command is initiated. 1057 The exception is if an ambiguity would result because of a command 1058 that would affect the results of other commands. If the server 1059 detects a possible ambiguity, it MUST execute commands to completion 1060 in the order given by the client. 1062 The most obvious example of ambiguity is when a command would affect 1063 the results of another command, e.g., a FETCH of a message's flags 1064 and a STORE of that same message's flags. 1066 A non-obvious ambiguity occurs with commands that permit an untagged 1067 EXPUNGE response (commands other than FETCH, STORE, and SEARCH), 1068 since an untagged EXPUNGE response can invalidate sequence numbers in 1069 a subsequent command. This is not a problem for FETCH, STORE, or 1070 SEARCH commands because servers are prohibited from sending EXPUNGE 1071 responses while any of those commands are in progress. Therefore, if 1072 the client sends any command other than FETCH, STORE, or SEARCH, it 1073 MUST wait for the completion result response before sending a command 1074 with message sequence numbers. 1076 Note: EXPUNGE responses are permitted while UID FETCH, UID STORE, 1077 and UID SEARCH are in progress. If the client sends a UID 1078 command, it MUST wait for a completion result response before 1079 sending a command which uses message sequence numbers (this may 1080 include UID SEARCH). Any message sequence numbers in an argument 1081 to UID SEARCH are associated with messages prior to the effect of 1082 any untagged EXPUNGE returned by the UID SEARCH. 1084 For example, the following non-waiting command sequences are invalid: 1086 FETCH + NOOP + STORE 1088 STORE + COPY + FETCH 1090 COPY + COPY 1092 The following are examples of valid non-waiting command sequences: 1094 FETCH + STORE + SEARCH + NOOP 1096 STORE + COPY + EXPUNGE 1098 UID SEARCH + UID SEARCH may be valid or invalid as a non-waiting 1099 command sequence, depending upon whether or not the second UID 1100 SEARCH contains message sequence numbers. 1102 Use of SEARCH result variable (see Section 6.4.4.1) creates direct 1103 dependency between two commands. See Section 6.4.4.2 for more 1104 considerations about pipelining such dependent commands. 1106 6. Client Commands 1108 IMAP4rev2 commands are described in this section. Commands are 1109 organized by the state in which the command is permitted. Commands 1110 which are permitted in multiple states are listed in the minimum 1111 permitted state (for example, commands valid in authenticated and 1112 selected state are listed in the authenticated state commands). 1114 Command arguments, identified by "Arguments:" in the command 1115 descriptions below, are described by function, not by syntax. The 1116 precise syntax of command arguments is described in the Formal Syntax 1117 (Section 9). 1119 Some commands cause specific server responses to be returned; these 1120 are identified by "Responses:" in the command descriptions below. 1121 See the response descriptions in the Responses section for 1122 information on these responses, and the Formal Syntax section for the 1123 precise syntax of these responses. It is possible for server data to 1124 be transmitted as a result of any command. Thus, commands that do 1125 not specifically require server data specify "no specific responses 1126 for this command" instead of "none". 1128 The "Result:" in the command description refers to the possible 1129 tagged status responses to a command, and any special interpretation 1130 of these status responses. 1132 The state of a connection is only changed by successful commands 1133 which are documented as changing state. A rejected command (BAD 1134 response) never changes the state of the connection or of the 1135 selected mailbox. A failed command (NO response) generally does not 1136 change the state of the connection or of the selected mailbox; the 1137 exception being the SELECT and EXAMINE commands. 1139 6.1. Client Commands - Any State 1141 The following commands are valid in any state: CAPABILITY, NOOP, and 1142 LOGOUT. 1144 6.1.1. CAPABILITY Command 1146 Arguments: none 1148 Responses: REQUIRED untagged response: CAPABILITY 1149 Result: OK - capability completed 1150 BAD - command unknown or arguments invalid 1152 The CAPABILITY command requests a listing of capabilities that the 1153 server supports. The server MUST send a single untagged CAPABILITY 1154 response with "IMAP4rev2" as one of the listed capabilities before 1155 the (tagged) OK response. 1157 A capability name which begins with "AUTH=" indicates that the server 1158 supports that particular authentication mechanism. All such names 1159 are, by definition, part of this specification. For example, the 1160 authorization capability for an experimental "blurdybloop" 1161 authenticator would be "AUTH=XBLURDYBLOOP" and not 1162 "XAUTH=BLURDYBLOOP" or "XAUTH=XBLURDYBLOOP". 1164 Other capability names refer to extensions, revisions, or amendments 1165 to this specification. See the documentation of the CAPABILITY 1166 response for additional information. No capabilities, beyond the 1167 base IMAP4rev2 set defined in this specification, are enabled without 1168 explicit client action to invoke the capability. 1170 Client and server implementations MUST implement the STARTTLS, 1171 LOGINDISABLED, and AUTH=PLAIN (described in [PLAIN]) capabilities. 1172 See the Security Considerations section for important information. 1174 See the section entitled "Client Commands - Experimental/Expansion" 1175 for information about the form of site or implementation-specific 1176 capabilities. 1178 Example: C: abcd CAPABILITY 1179 S: * CAPABILITY IMAP4rev2 STARTTLS AUTH=GSSAPI 1180 LOGINDISABLED 1181 S: abcd OK CAPABILITY completed 1182 C: efgh STARTTLS 1183 S: efgh OK STARTLS completed 1184 1185 C: ijkl CAPABILITY 1186 S: * CAPABILITY IMAP4rev2 AUTH=GSSAPI AUTH=PLAIN 1187 S: ijkl OK CAPABILITY completed 1189 6.1.2. NOOP Command 1191 Arguments: none 1193 Responses: no specific responses for this command (but see below) 1195 Result: OK - noop completed 1196 BAD - command unknown or arguments invalid 1198 The NOOP command always succeeds. It does nothing. 1200 Since any command can return a status update as untagged data, the 1201 NOOP command can be used as a periodic poll for new messages or 1202 message status updates during a period of inactivity (the IDLE 1203 command Section 6.3.13 should be used instead of NOOP if real-time 1204 updates to mailbox state are desirable). The NOOP command can also 1205 be used to reset any inactivity autologout timer on the server. 1207 Example: C: a002 NOOP 1208 S: a002 OK NOOP completed 1209 . . . 1210 C: a047 NOOP 1211 S: * 22 EXPUNGE 1212 S: * 23 EXISTS 1213 S: * 14 FETCH (UID 1305 FLAGS (\Seen \Deleted)) 1214 S: a047 OK NOOP completed 1216 6.1.3. LOGOUT Command 1218 Arguments: none 1220 Responses: REQUIRED untagged response: BYE 1222 Result: OK - logout completed 1223 BAD - command unknown or arguments invalid 1225 The LOGOUT command informs the server that the client is done with 1226 the connection. The server MUST send a BYE untagged response before 1227 the (tagged) OK response, and then close the network connection. 1229 Example: C: A023 LOGOUT 1230 S: * BYE IMAP4rev2 Server logging out 1231 S: A023 OK LOGOUT completed 1232 (Server and client then close the connection) 1234 6.2. Client Commands - Not Authenticated State 1236 In the not authenticated state, the AUTHENTICATE or LOGIN command 1237 establishes authentication and enters the authenticated state. The 1238 AUTHENTICATE command provides a general mechanism for a variety of 1239 authentication techniques, privacy protection, and integrity 1240 checking; whereas the LOGIN command uses a traditional user name and 1241 plaintext password pair and has no means of establishing privacy 1242 protection or integrity checking. 1244 The STARTTLS command is an alternate form of establishing session 1245 privacy protection and integrity checking, but does not by itself 1246 establish authentication or enter the authenticated state. 1248 Server implementations MAY allow access to certain mailboxes without 1249 establishing authentication. This can be done by means of the 1250 ANONYMOUS [SASL] authenticator described in [ANONYMOUS]. An older 1251 convention is a LOGIN command using the userid "anonymous"; in this 1252 case, a password is required although the server may choose to accept 1253 any password. The restrictions placed on anonymous users are 1254 implementation-dependent. 1256 Once authenticated (including as anonymous), it is not possible to 1257 re-enter not authenticated state. 1259 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 1260 the following commands are valid in the not authenticated state: 1261 STARTTLS, AUTHENTICATE and LOGIN. See the Security Considerations 1262 section for important information about these commands. 1264 6.2.1. STARTTLS Command 1266 Arguments: none 1268 Responses: no specific response for this command 1270 Result: OK - starttls completed, begin TLS negotiation 1271 BAD - command unknown or arguments invalid 1273 A [TLS] negotiation begins immediately after the CRLF at the end of 1274 the tagged OK response from the server. Once a client issues a 1275 STARTTLS command, it MUST NOT issue further commands until a server 1276 response is seen and the [TLS] negotiation is complete. 1278 The server remains in the non-authenticated state, even if client 1279 credentials are supplied during the [TLS] negotiation. This does not 1280 preclude an authentication mechanism such as EXTERNAL (defined in 1281 [SASL]) from using client identity determined by the [TLS] 1282 negotiation. 1284 Once [TLS] has been started, the client MUST discard cached 1285 information about server capabilities and SHOULD re-issue the 1286 CAPABILITY command. This is necessary to protect against man-in- 1287 the-middle attacks which alter the capabilities list prior to 1288 STARTTLS. The server MAY advertise different capabilities, and in 1289 particular SHOULD NOT advertise the STARTTLS capability, after a 1290 successful STARTTLS command. 1292 Example: C: a001 CAPABILITY 1293 S: * CAPABILITY IMAP4rev2 STARTTLS LOGINDISABLED 1294 S: a001 OK CAPABILITY completed 1295 C: a002 STARTTLS 1296 S: a002 OK Begin TLS negotiation now 1297 1298 C: a003 CAPABILITY 1299 S: * CAPABILITY IMAP4rev2 AUTH=PLAIN 1300 S: a003 OK CAPABILITY completed 1301 C: a004 LOGIN joe password 1302 S: a004 OK LOGIN completed 1304 6.2.2. AUTHENTICATE Command 1306 Arguments: SASL authentication mechanism name 1307 OPTIONAL initial response 1309 Responses: continuation data can be requested 1311 Result: OK - authenticate completed, now in authenticated state 1312 NO - authenticate failure: unsupported authentication 1313 mechanism, credentials rejected 1314 BAD - command unknown or arguments invalid, 1315 authentication exchange cancelled 1317 The AUTHENTICATE command indicates a [SASL] authentication mechanism 1318 to the server. If the server supports the requested authentication 1319 mechanism, it performs an authentication protocol exchange to 1320 authenticate and identify the client. It MAY also negotiate an 1321 OPTIONAL security layer for subsequent protocol interactions. If the 1322 requested authentication mechanism is not supported, the server 1323 SHOULD reject the AUTHENTICATE command by sending a tagged NO 1324 response. 1326 The AUTHENTICATE command supports the optional "initial response" 1327 feature defined in Section 5.1 of [SASL]. The client doesn't need to 1328 use it. If a SASL mechanism supports "initial response", but it is 1329 not specified by the client, the server handles this as specified in 1330 Section 3 of [SASL]. 1332 The service name specified by this protocol's profile of [SASL] is 1333 "imap". 1335 The authentication protocol exchange consists of a series of server 1336 challenges and client responses that are specific to the 1337 authentication mechanism. A server challenge consists of a command 1338 continuation request response with the "+" token followed by a BASE64 1339 encoded (see Section 4 of [RFC4648]) string. The client response 1340 consists of a single line consisting of a BASE64 encoded string. If 1341 the client wishes to cancel an authentication exchange, it issues a 1342 line consisting of a single "*". If the server receives such a 1343 response, or if it receives an invalid BASE64 string (e.g. 1344 characters outside the BASE64 alphabet, or non-terminal "="), it MUST 1345 reject the AUTHENTICATE command by sending a tagged BAD response. 1347 As with any other client response, this initial response MUST be 1348 encoded as BASE64. It also MUST be transmitted outside of a quoted 1349 string or literal. To send a zero-length initial response, the 1350 client MUST send a single pad character ("="). This indicates that 1351 the response is present, but is a zero-length string. 1353 When decoding the BASE64 data in the initial response, decoding 1354 errors MUST be treated as in any normal SASL client response, i.e. 1355 with a tagged BAD response. In particular, the server should check 1356 for any characters not explicitly allowed by the BASE64 alphabet, as 1357 well as any sequence of BASE64 characters that contains the pad 1358 character ('=') anywhere other than the end of the string (e.g., 1359 "=AAA" and "AAA=BBB" are not allowed). 1361 If the client uses an initial response with a SASL mechanism that 1362 does not support an initial response, the server MUST reject the 1363 command with a tagged BAD response. 1365 If a security layer is negotiated through the [SASL] authentication 1366 exchange, it takes effect immediately following the CRLF that 1367 concludes the authentication exchange for the client, and the CRLF of 1368 the tagged OK response for the server. 1370 While client and server implementations MUST implement the 1371 AUTHENTICATE command itself, it is not required to implement any 1372 authentication mechanisms other than the PLAIN mechanism described in 1373 [PLAIN]. Also, an authentication mechanism is not required to 1374 support any security layers. 1376 Note: a server implementation MUST implement a configuration in 1377 which it does NOT permit any plaintext password mechanisms, unless 1378 either the STARTTLS command has been negotiated or some other 1379 mechanism that protects the session from password snooping has 1380 been provided. Server sites SHOULD NOT use any configuration 1381 which permits a plaintext password mechanism without such a 1382 protection mechanism against password snooping. Client and server 1383 implementations SHOULD implement additional [SASL] mechanisms that 1384 do not use plaintext passwords, such the GSSAPI mechanism 1385 described in [SASL] and/or the SCRAM-SHA-256/SCRAM-SHA-256-PLUS 1386 [SCRAM-SHA-256] mechanisms. 1388 Servers and clients can support multiple authentication mechanisms. 1389 The server SHOULD list its supported authentication mechanisms in the 1390 response to the CAPABILITY command so that the client knows which 1391 authentication mechanisms to use. 1393 A server MAY include a CAPABILITY response code in the tagged OK 1394 response of a successful AUTHENTICATE command in order to send 1395 capabilities automatically. It is unnecessary for a client to send a 1396 separate CAPABILITY command if it recognizes these automatic 1397 capabilities. This should only be done if a security layer was not 1398 negotiated by the AUTHENTICATE command, because the tagged OK 1399 response as part of an AUTHENTICATE command is not protected by 1400 encryption/integrity checking. [SASL] requires the client to re- 1401 issue a CAPABILITY command in this case. The server MAY advertise 1402 different capabilities after a successful AUTHENTICATE command. 1404 If an AUTHENTICATE command fails with a NO response, the client MAY 1405 try another authentication mechanism by issuing another AUTHENTICATE 1406 command. It MAY also attempt to authenticate by using the LOGIN 1407 command (see Section 6.2.3 for more detail). In other words, the 1408 client MAY request authentication types in decreasing order of 1409 preference, with the LOGIN command as a last resort. 1411 The authorization identity passed from the client to the server 1412 during the authentication exchange is interpreted by the server as 1413 the user name whose privileges the client is requesting. 1415 Example: S: * OK IMAP4rev2 Server 1416 C: A001 AUTHENTICATE GSSAPI 1417 S: + 1418 C: YIIB+wYJKoZIhvcSAQICAQBuggHqMIIB5qADAgEFoQMCAQ6iBw 1419 MFACAAAACjggEmYYIBIjCCAR6gAwIBBaESGxB1Lndhc2hpbmd0 1420 b24uZWR1oi0wK6ADAgEDoSQwIhsEaW1hcBsac2hpdmFtcy5jYW 1421 Mud2FzaGluZ3Rvbi5lZHWjgdMwgdCgAwIBAaEDAgEDooHDBIHA 1422 cS1GSa5b+fXnPZNmXB9SjL8Ollj2SKyb+3S0iXMljen/jNkpJX 1423 AleKTz6BQPzj8duz8EtoOuNfKgweViyn/9B9bccy1uuAE2HI0y 1424 C/PHXNNU9ZrBziJ8Lm0tTNc98kUpjXnHZhsMcz5Mx2GR6dGknb 1425 I0iaGcRerMUsWOuBmKKKRmVMMdR9T3EZdpqsBd7jZCNMWotjhi 1426 vd5zovQlFqQ2Wjc2+y46vKP/iXxWIuQJuDiisyXF0Y8+5GTpAL 1427 pHDc1/pIGmMIGjoAMCAQGigZsEgZg2on5mSuxoDHEA1w9bcW9n 1428 FdFxDKpdrQhVGVRDIzcCMCTzvUboqb5KjY1NJKJsfjRQiBYBdE 1429 NKfzK+g5DlV8nrw81uOcP8NOQCLR5XkoMHC0Dr/80ziQzbNqhx 1430 O6652Npft0LQwJvenwDI13YxpwOdMXzkWZN/XrEqOWp6GCgXTB 1431 vCyLWLlWnbaUkZdEYbKHBPjd8t/1x5Yg== 1432 S: + YGgGCSqGSIb3EgECAgIAb1kwV6ADAgEFoQMCAQ+iSzBJoAMC 1433 AQGiQgRAtHTEuOP2BXb9sBYFR4SJlDZxmg39IxmRBOhXRKdDA0 1434 uHTCOT9Bq3OsUTXUlk0CsFLoa8j+gvGDlgHuqzWHPSQg== 1435 C: 1436 S: + YDMGCSqGSIb3EgECAgIBAAD/////6jcyG4GE3KkTzBeBiVHe 1437 ceP2CWY0SR0fAQAgAAQEBAQ= 1438 C: YDMGCSqGSIb3EgECAgIBAAD/////3LQBHXTpFfZgrejpLlLImP 1439 wkhbfa2QteAQAgAG1yYwE= 1440 S: A001 OK GSSAPI authentication successful 1442 Note: The line breaks within server challenges and client responses 1443 are for editorial clarity and are not in real authenticators. 1445 6.2.3. LOGIN Command 1447 Arguments: user name 1448 password 1450 Responses: no specific responses for this command 1452 Result: OK - login completed, now in authenticated state 1453 NO - login failure: user name or password rejected 1454 BAD - command unknown or arguments invalid 1456 The LOGIN command identifies the client to the server and carries the 1457 plaintext password authenticating this user. 1459 A server MAY include a CAPABILITY response code in the tagged OK 1460 response to a successful LOGIN command in order to send capabilities 1461 automatically. It is unnecessary for a client to send a separate 1462 CAPABILITY command if it recognizes these automatic capabilities. 1464 Example: C: a001 LOGIN SMITH SESAME 1465 S: a001 OK LOGIN completed 1467 Note: Use of the LOGIN command over an insecure network (such as the 1468 Internet) is a security risk, because anyone monitoring network 1469 traffic can obtain plaintext passwords. The LOGIN command SHOULD NOT 1470 be used except as a last resort, and it is recommended that client 1471 implementations have a means to disable any automatic use of the 1472 LOGIN command. 1474 Unless either the client is accessing IMAP service on IMAPS port 1475 [RFC8314], the STARTTLS command has been negotiated or some other 1476 mechanism that protects the session from password snooping has been 1477 provided, a server implementation MUST implement a configuration in 1478 which it advertises the LOGINDISABLED capability and does NOT permit 1479 the LOGIN command. Server sites SHOULD NOT use any configuration 1480 which permits the LOGIN command without such a protection mechanism 1481 against password snooping. A client implementation MUST NOT send a 1482 LOGIN command if the LOGINDISABLED capability is advertised. 1484 6.3. Client Commands - Authenticated State 1486 In the authenticated state, commands that manipulate mailboxes as 1487 atomic entities are permitted. Of these commands, the SELECT and 1488 EXAMINE commands will select a mailbox for access and enter the 1489 selected state. 1491 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 1492 the following commands are valid in the authenticated state: ENABLE, 1493 SELECT, EXAMINE, NAMESPACE, CREATE, DELETE, RENAME, SUBSCRIBE, 1494 UNSUBSCRIBE, LIST, STATUS, APPEND and IDLE. 1496 6.3.1. ENABLE Command 1498 Arguments: capability names 1500 Responses: no specific responses for this command 1502 Result: OK - Relevant capabilities enabled 1503 BAD - No arguments, or syntax error in an argument 1505 Several IMAP extensions allow the server to return unsolicited 1506 responses specific to these extensions in certain circumstances. 1507 However, servers cannot send those unsolicited responses (with the 1508 exception of response codes (see Section 7.1) included in tagged or 1509 untagged OK/NO/BAD responses, which can always be sent) until they 1510 know that the clients support such extensions and thus won't choke on 1511 the extension response data. 1513 The ENABLE command provides an explicit indication from the client 1514 that it supports particular extensions. It is designed such that the 1515 client can send a simple constant string with the extensions it 1516 supports, and the server will enable the shared subset that both 1517 support. 1519 The ENABLE command takes a list of capability names, and requests the 1520 server to enable the named extensions. Once enabled using ENABLE, 1521 each extension remains active until the IMAP connection is closed. 1522 For each argument, the server does the following: 1524 o If the argument is not an extension known to the server, the 1525 server MUST ignore the argument. 1527 o If the argument is an extension known to the server, and it is not 1528 specifically permitted to be enabled using ENABLE, the server MUST 1529 ignore the argument. (Note that knowing about an extension 1530 doesn't necessarily imply supporting that extension.) 1532 o If the argument is an extension that is supported by the server 1533 and that needs to be enabled, the server MUST enable the extension 1534 for the duration of the connection. Note that once an extension 1535 is enabled, there is no way to disable it. 1537 If the ENABLE command is successful, the server MUST send an untagged 1538 ENABLED response Section 7.2.1. 1540 Clients SHOULD only include extensions that need to be enabled by the 1541 server. For example, a client can enable IMAP4rev2 specific 1542 behaviour when both IMAP4rev1 and IMAP4rev2 are advertised in the 1543 CAPABILITY response. Future RFCs may add to this list. 1545 The ENABLE command is only valid in the authenticated state, before 1546 any mailbox is selected. Clients MUST NOT issue ENABLE once they 1547 SELECT/EXAMINE a mailbox; however, server implementations don't have 1548 to check that no mailbox is selected or was previously selected 1549 during the duration of a connection. 1551 The ENABLE command can be issued multiple times in a session. It is 1552 additive; i.e., "ENABLE a b", followed by "ENABLE c" is the same as a 1553 single command "ENABLE a b c". When multiple ENABLE commands are 1554 issued, each corresponding ENABLED response SHOULD only contain 1555 extensions enabled by the corresponding ENABLE command, i.e. for the 1556 above example, the ENABLED response to "ENABLE c" should not contain 1557 "a" or "b". 1559 There are no limitations on pipelining ENABLE. For example, it is 1560 possible to send ENABLE and then immediately SELECT, or a LOGIN 1561 immediately followed by ENABLE. 1563 The server MUST NOT change the CAPABILITY list as a result of 1564 executing ENABLE; i.e., a CAPABILITY command issued right after an 1565 ENABLE command MUST list the same capabilities as a CAPABILITY 1566 command issued before the ENABLE command. This is demonstrated in 1567 the following example: 1569 C: t1 CAPABILITY 1570 S: * CAPABILITY IMAP4rev2 ID LITERAL+ X-GOOD-IDEA 1571 S: t1 OK foo 1572 C: t2 ENABLE CONDSTORE X-GOOD-IDEA 1573 S: * ENABLED X-GOOD-IDEA 1574 S: t2 OK foo 1575 C: t3 CAPABILITY 1576 S: * CAPABILITY IMAP4rev2 ID LITERAL+ X-GOOD-IDEA 1577 S: t3 OK foo again 1579 In the following example, the client enables CONDSTORE: 1581 C: a1 ENABLE CONDSTORE 1582 S: * ENABLED CONDSTORE 1583 S: a1 OK Conditional Store enabled 1585 6.3.1.1. Note to Designers of Extensions That May Use the ENABLE 1586 Command 1588 Designers of IMAP extensions are discouraged from creating extensions 1589 that require ENABLE unless there is no good alternative design. 1590 Specifically, extensions that cause potentially incompatible behavior 1591 changes to deployed server responses (and thus benefit from ENABLE) 1592 have a higher complexity cost than extensions that do not. 1594 6.3.2. SELECT Command 1596 Arguments: mailbox name 1598 Responses: REQUIRED untagged responses: FLAGS, EXISTS 1599 REQUIRED OK untagged responses: PERMANENTFLAGS, 1600 UIDNEXT, UIDVALIDITY 1602 Result: OK - select completed, now in selected state 1603 NO - select failure, now in authenticated state: no 1604 such mailbox, can't access mailbox 1605 BAD - command unknown or arguments invalid 1607 The SELECT command selects a mailbox so that messages in the mailbox 1608 can be accessed. Before returning an OK to the client, the server 1609 MUST send the following untagged data to the client. Note that 1610 earlier versions of this protocol only required the FLAGS and EXISTS 1611 untagged data; consequently, client implementations SHOULD implement 1612 default behavior for missing data as discussed with the individual 1613 item. 1615 FLAGS Defined flags in the mailbox. See the description of the 1616 FLAGS response for more detail. 1618 EXISTS The number of messages in the mailbox. See the 1619 description of the EXISTS response for more detail. 1621 OK [PERMANENTFLAGS ()] A list of message flags that 1622 the client can change permanently. If this is missing, the client 1623 should assume that all flags can be changed permanently. 1625 OK [UIDNEXT ] The next unique identifier value. Refer to 1626 Section 2.3.1.1 for more information. If this is missing, the 1627 client can not make any assumptions about the next unique 1628 identifier value. 1630 OK [UIDVALIDITY ] The unique identifier validity value. Refer to 1631 Section 2.3.1.1 for more information. If this is missing, the 1632 server does not support unique identifiers. 1634 Only one mailbox can be selected at a time in a connection; 1635 simultaneous access to multiple mailboxes requires multiple 1636 connections. The SELECT command automatically deselects any 1637 currently selected mailbox before attempting the new selection. 1638 Consequently, if a mailbox is selected and a SELECT command that 1639 fails is attempted, no mailbox is selected. When deselecting a 1640 selected mailbox, the server MUST return an untagged OK response with 1641 the "[CLOSED]" response code when the currently selected mailbox is 1642 closed (see Paragraph 10). 1644 If the client is permitted to modify the mailbox, the server SHOULD 1645 prefix the text of the tagged OK response with the "[READ-WRITE]" 1646 response code. 1648 If the client is not permitted to modify the mailbox but is permitted 1649 read access, the mailbox is selected as read-only, and the server 1650 MUST prefix the text of the tagged OK response to SELECT with the 1651 "[READ-ONLY]" response code. Read-only access through SELECT differs 1652 from the EXAMINE command in that certain read-only mailboxes MAY 1653 permit the change of permanent state on a per-user (as opposed to 1654 global) basis. Netnews messages marked in a server-based .newsrc 1655 file are an example of such per-user permanent state that can be 1656 modified with read-only mailboxes. 1658 Example: C: A142 SELECT INBOX 1659 S: * 172 EXISTS 1660 S: * OK [UIDVALIDITY 3857529045] UIDs valid 1661 S: * OK [UIDNEXT 4392] Predicted next UID 1662 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1663 S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited 1664 S: A142 OK [READ-WRITE] SELECT completed 1666 Example: C: A142 SELECT INBOX 1667 S: * 172 EXISTS 1668 S: * OK [UIDVALIDITY 3857529045] UIDs valid 1669 S: * OK [UIDNEXT 4392] Predicted next UID 1670 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1671 S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited 1672 S: A142 OK [READ-WRITE] SELECT completed 1673 [...some time later...] 1674 C: A143 SELECT Drafts 1675 S: * OK [CLOSED] Previous mailbox is now closed 1676 S: * 5 EXISTS 1677 S: * OK [UIDVALIDITY 9877410381] UIDs valid 1678 S: * OK [UIDNEXT 102] Predicted next UID 1679 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1680 S: * OK [PERMANENTFLAGS (\Deleted \Seen \Answered 1681 \Flagged \Draft \*)] System flags and keywords allowed 1682 S: A143 OK [READ-WRITE] SELECT completed 1684 Note that IMAP4rev1 compliant servers can also send the untagged 1685 RECENT response which was deprecated in IMAP4rev2. E.g. "* 0 1686 RECENT". Pure IMAP4rev2 clients are advised to ignore the untagged 1687 RECENT response. 1689 6.3.3. EXAMINE Command 1691 Arguments: mailbox name 1693 Responses: REQUIRED untagged responses: FLAGS, EXISTS 1694 REQUIRED OK untagged responses: PERMANENTFLAGS, 1695 UIDNEXT, UIDVALIDITY 1697 Result: OK - examine completed, now in selected state 1698 NO - examine failure, now in authenticated state: no 1699 such mailbox, can't access mailbox BAD - command unknown 1700 or arguments invalid 1702 The EXAMINE command is identical to SELECT and returns the same 1703 output; however, the selected mailbox is identified as read-only. No 1704 changes to the permanent state of the mailbox, including per-user 1705 state, are permitted. 1707 The text of the tagged OK response to the EXAMINE command MUST begin 1708 with the "[READ-ONLY]" response code. 1710 Example: C: A932 EXAMINE blurdybloop 1711 S: * 17 EXISTS 1712 S: * OK [UIDVALIDITY 3857529045] UIDs valid 1713 S: * OK [UIDNEXT 4392] Predicted next UID 1714 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1715 S: * OK [PERMANENTFLAGS ()] No permanent flags permitted 1716 S: A932 OK [READ-ONLY] EXAMINE completed 1718 6.3.4. CREATE Command 1720 Arguments: mailbox name 1722 Responses: no specific responses for this command 1724 Result: OK - create completed 1725 NO - create failure: can't create mailbox with that name 1726 BAD - command unknown or arguments invalid 1728 The CREATE command creates a mailbox with the given name. An OK 1729 response is returned only if a new mailbox with that name has been 1730 created. It is an error to attempt to create INBOX or a mailbox with 1731 a name that refers to an extant mailbox. Any error in creation will 1732 return a tagged NO response. If a client attempts to create a UTF-8 1733 mailbox name that is not a valid Net-Unicode name, the server MUST 1734 reject the creation or convert the name to Net-Unicode prior to 1735 creating the mailbox. 1737 If the mailbox name is suffixed with the server's hierarchy separator 1738 character (as returned from the server by a LIST command), this is a 1739 declaration that the client intends to create mailbox names under 1740 this name in the hierarchy. Server implementations that do not 1741 require this declaration MUST ignore the declaration. In any case, 1742 the name created is without the trailing hierarchy delimiter. 1744 If the server's hierarchy separator character appears elsewhere in 1745 the name, the server SHOULD create any superior hierarchical names 1746 that are needed for the CREATE command to be successfully completed. 1747 In other words, an attempt to create "foo/bar/zap" on a server in 1748 which "/" is the hierarchy separator character SHOULD create foo/ and 1749 foo/bar/ if they do not already exist. 1751 If a new mailbox is created with the same name as a mailbox which was 1752 deleted, its unique identifiers MUST be greater than any unique 1753 identifiers used in the previous incarnation of the mailbox UNLESS 1754 the new incarnation has a different unique identifier validity value. 1755 See the description of the UID command for more detail. 1757 Example: C: A003 CREATE owatagusiam/ 1758 S: A003 OK CREATE completed 1759 C: A004 CREATE owatagusiam/blurdybloop 1760 S: A004 OK CREATE completed 1762 Note: The interpretation of this example depends on whether "/" 1763 was returned as the hierarchy separator from LIST. If "/" is the 1764 hierarchy separator, a new level of hierarchy named "owatagusiam" 1765 with a member called "blurdybloop" is created. Otherwise, two 1766 mailboxes at the same hierarchy level are created. 1768 6.3.5. DELETE Command 1770 Arguments: mailbox name 1772 Responses: no specific responses for this command 1774 Result: OK - delete completed 1775 NO - delete failure: can't delete mailbox with that name 1776 BAD - command unknown or arguments invalid 1778 The DELETE command permanently removes the mailbox with the given 1779 name. A tagged OK response is returned only if the mailbox has been 1780 deleted. It is an error to attempt to delete INBOX or a mailbox name 1781 that does not exist. 1783 The DELETE command MUST NOT remove inferior hierarchical names. For 1784 example, if a mailbox "foo" has an inferior "foo.bar" (assuming "." 1785 is the hierarchy delimiter character), removing "foo" MUST NOT remove 1786 "foo.bar". It is an error to attempt to delete a name that has 1787 inferior hierarchical names and also has the \Noselect mailbox name 1788 attribute (see the description of the LIST response for more 1789 details). 1791 It is permitted to delete a name that has inferior hierarchical names 1792 and does not have the \Noselect mailbox name attribute. If the 1793 server implementation does not permit deleting the name while 1794 inferior hierarchical names exists then it SHOULD disallow the DELETE 1795 command by returning tagged NO response or it MAY allow the DELETE 1796 command, but sets the \Noselect mailbox name attribute for that name. 1797 In any case, all messages in that mailbox are removed by the DELETE 1798 command. 1800 The value of the highest-used unique identifier of the deleted 1801 mailbox MUST be preserved so that a new mailbox created with the same 1802 name will not reuse the identifiers of the former incarnation, UNLESS 1803 the new incarnation has a different unique identifier validity value. 1804 See the description of the UID command for more detail. 1806 Examples: C: A682 LIST "" * 1807 S: * LIST () "/" blurdybloop 1808 S: * LIST (\Noselect) "/" foo 1809 S: * LIST () "/" foo/bar 1810 S: A682 OK LIST completed 1811 C: A683 DELETE blurdybloop 1812 S: A683 OK DELETE completed 1813 C: A684 DELETE foo 1814 S: A684 NO Name "foo" has inferior hierarchical names 1815 C: A685 DELETE foo/bar 1816 S: A685 OK DELETE Completed 1817 C: A686 LIST "" * 1818 S: * LIST (\Noselect) "/" foo 1819 S: A686 OK LIST completed 1820 C: A687 DELETE foo 1821 S: A687 OK DELETE Completed 1822 C: A82 LIST "" * 1823 S: * LIST () "." blurdybloop 1824 S: * LIST () "." foo 1825 S: * LIST () "." foo.bar 1826 S: A82 OK LIST completed 1827 C: A83 DELETE blurdybloop 1828 S: A83 OK DELETE completed 1829 C: A84 DELETE foo 1830 S: A84 OK DELETE Completed 1831 C: A85 LIST "" * 1832 S: * LIST () "." foo.bar 1833 S: A85 OK LIST completed 1834 C: A86 LIST "" % 1835 S: * LIST (\Noselect) "." foo 1836 S: A86 OK LIST completed 1838 6.3.6. RENAME Command 1840 Arguments: existing mailbox name 1841 new mailbox name 1843 Responses: no specific responses for this command 1845 Result: OK - rename completed 1846 NO - rename failure: can't rename mailbox with that name, 1847 can't rename to mailbox with that name 1848 BAD - command unknown or arguments invalid 1850 The RENAME command changes the name of a mailbox. A tagged OK 1851 response is returned only if the mailbox has been renamed. It is an 1852 error to attempt to rename from a mailbox name that does not exist or 1853 to a mailbox name that already exists. Any error in renaming will 1854 return a tagged NO response. 1856 If the name has inferior hierarchical names, then the inferior 1857 hierarchical names MUST also be renamed. For example, a rename of 1858 "foo" to "zap" will rename "foo/bar" (assuming "/" is the hierarchy 1859 delimiter character) to "zap/bar". 1861 If the server's hierarchy separator character appears in the name, 1862 the server SHOULD create any superior hierarchical names that are 1863 needed for the RENAME command to complete successfully. In other 1864 words, an attempt to rename "foo/bar/zap" to baz/rag/zowie on a 1865 server in which "/" is the hierarchy separator character SHOULD 1866 create baz/ and baz/rag/ if they do not already exist. 1868 The value of the highest-used unique identifier of the old mailbox 1869 name MUST be preserved so that a new mailbox created with the same 1870 name will not reuse the identifiers of the former incarnation, UNLESS 1871 the new incarnation has a different unique identifier validity value. 1872 See the description of the UID command for more detail. 1874 Renaming INBOX is permitted, and has special behavior. (Note that 1875 some servers refuse renaming INBOX). It moves all messages in INBOX 1876 to a new mailbox with the given name, leaving INBOX empty. If the 1877 server implementation supports inferior hierarchical names of INBOX, 1878 these are unaffected by a rename of INBOX. 1880 Examples: C: A682 LIST "" * 1881 S: * LIST () "/" blurdybloop 1882 S: * LIST (\Noselect) "/" foo 1883 S: * LIST () "/" foo/bar 1884 S: A682 OK LIST completed 1885 C: A683 RENAME blurdybloop sarasoop 1886 S: A683 OK RENAME completed 1887 C: A684 RENAME foo zowie 1888 S: A684 OK RENAME Completed 1889 C: A685 LIST "" * 1890 S: * LIST () "/" sarasoop 1891 S: * LIST (\Noselect) "/" zowie 1892 S: * LIST () "/" zowie/bar 1893 S: A685 OK LIST completed 1895 C: Z432 LIST "" * 1896 S: * LIST () "." INBOX 1897 S: * LIST () "." INBOX.bar 1898 S: Z432 OK LIST completed 1899 C: Z433 RENAME INBOX old-mail 1900 S: Z433 OK RENAME completed 1901 C: Z434 LIST "" * 1902 S: * LIST () "." INBOX 1903 S: * LIST () "." INBOX.bar 1904 S: * LIST () "." old-mail 1905 S: Z434 OK LIST completed 1907 Note that renaming a mailbox doesn't update subscription information 1908 on the original name. To keep subscription information in sync, the 1909 following sequence of commands can be used: 1911 C: 1001 RENAME X Y 1912 C: 1002 SUBSCRIBE Y 1913 C: 1003 UNSUBSCRIBE X 1915 Note that the above sequence of commands doesn't account for updating 1916 subscription for any children mailboxes of mailbox X. 1918 6.3.7. SUBSCRIBE Command 1920 Arguments: mailbox 1922 Responses: no specific responses for this command 1924 Result: OK - subscribe completed 1925 NO - subscribe failure: can't subscribe to that name 1926 BAD - command unknown or arguments invalid 1928 The SUBSCRIBE command adds the specified mailbox name to the server's 1929 set of "active" or "subscribed" mailboxes as returned by the LIST 1930 (SUBSCRIBED) command. This command returns a tagged OK response if 1931 the subscription is successful or if the mailbox is already 1932 subscribed. 1934 A server MAY validate the mailbox argument to SUBSCRIBE to verify 1935 that it exists. However, it SHOULD NOT unilaterally remove an 1936 existing mailbox name from the subscription list even if a mailbox by 1937 that name no longer exists. 1939 Note: This requirement is because a server site can choose to 1940 routinely remove a mailbox with a well-known name (e.g., "system- 1941 alerts") after its contents expire, with the intention of 1942 recreating it when new contents are appropriate. 1944 Example: C: A002 SUBSCRIBE #news.comp.mail.mime 1945 S: A002 OK SUBSCRIBE completed 1947 6.3.8. UNSUBSCRIBE Command 1949 Arguments: mailbox name 1951 Responses: no specific responses for this command 1953 Result: OK - unsubscribe completed 1954 NO - unsubscribe failure: can't unsubscribe that name 1955 BAD - command unknown or arguments invalid 1957 The UNSUBSCRIBE command removes the specified mailbox name from the 1958 server's set of "active" or "subscribed" mailboxes as returned by the 1959 LIST (SUBSCRIBED) command. This command returns a tagged OK response 1960 if the unsubscription is successful or if the mailbox is not 1961 subscribed. 1963 Example: C: A002 UNSUBSCRIBE #news.comp.mail.mime 1964 S: A002 OK UNSUBSCRIBE completed 1966 6.3.9. LIST Command 1968 Arguments (basic): reference name 1969 mailbox name with possible wildcards 1971 Arguments (extended): selection options (OPTIONAL) 1972 reference name 1973 mailbox patterns 1974 return options (OPTIONAL) 1976 Responses: untagged responses: LIST 1978 Result: OK - list completed 1979 NO - list failure: can't list that reference or name 1980 BAD - command unknown or arguments invalid 1982 The LIST command returns a subset of names from the complete set of 1983 all names available to the client. Zero or more untagged LIST 1984 replies are returned, containing the name attributes, hierarchy 1985 delimiter, name, and possible extension information; see the 1986 description of the LIST reply for more detail. 1988 The LIST command SHOULD return its data quickly, without undue delay. 1989 For example, it SHOULD NOT go to excess trouble to calculate the 1990 \Marked or \Unmarked status or perform other processing; if each name 1991 requires 1 second of processing, then a list of 1200 names would take 1992 20 minutes! 1994 The extended LIST command, originally introduced in [RFC5258], 1995 provides capabilities beyond that of the original IMAP LIST command. 1996 The extended syntax is being used if one or more of the following 1997 conditions is true: 1999 1. if the first word after the command name begins with a 2000 parenthesis ("LIST selection options") 2002 2. if the second word after the command name begins with a 2003 parenthesis ("multiple mailbox patterns") 2005 3. if the LIST command has more than 2 parameters ("LIST return 2006 options") 2008 An empty ("" string) reference name argument indicates that the 2009 mailbox name is interpreted as by SELECT. The returned mailbox names 2010 MUST match the supplied mailbox name pattern(s). A non-empty 2011 reference name argument is the name of a mailbox or a level of 2012 mailbox hierarchy, and indicates the context in which the mailbox 2013 name is interpreted. Clients SHOULD use the empty reference 2014 argument. 2016 In the basic syntax only, an empty ("" string) mailbox name argument 2017 is a special request to return the hierarchy delimiter and the root 2018 name of the name given in the reference. The value returned as the 2019 root MAY be the empty string if the reference is non-rooted or is an 2020 empty string. In all cases, a hierarchy delimiter (or NIL if there 2021 is no hierarchy) is returned. This permits a client to get the 2022 hierarchy delimiter (or find out that the mailbox names are flat) 2023 even when no mailboxes by that name currently exist. 2025 In the extended syntax, any mailbox name arguments that are empty 2026 strings are ignored. There is no special meaning for empty mailbox 2027 names when the extended syntax is used. 2029 The reference and mailbox name arguments are interpreted into a 2030 canonical form that represents an unambiguous left-to-right 2031 hierarchy. The returned mailbox names will be in the interpreted 2032 form, that we call "canonical LIST pattern" later in this document. 2033 To define the term "canonical LIST pattern" formally: it refers to 2034 the canonical pattern constructed internally by the server from the 2035 reference and mailbox name arguments. 2037 Note: The interpretation of the reference argument is 2038 implementation-defined. It depends upon whether the server 2039 implementation has a concept of the "current working directory" 2040 and leading "break out characters", which override the current 2041 working directory. 2043 For example, on a server which exports a UNIX or NT filesystem, 2044 the reference argument contains the current working directory, and 2045 the mailbox name argument would contain the name as interpreted in 2046 the current working directory. 2048 If a server implementation has no concept of break out characters, 2049 the canonical form is normally the reference name appended with 2050 the mailbox name. Note that if the server implements the 2051 namespace convention (Section 5.1.2.1), "#" is a break out 2052 character and must be treated as such. 2054 If the reference argument is not a level of mailbox hierarchy 2055 (that is, it is a \NoInferiors name), and/or the reference 2056 argument does not end with the hierarchy delimiter, it is 2057 implementation-dependent how this is interpreted. For example, a 2058 reference of "foo/bar" and mailbox name of "rag/baz" could be 2059 interpreted as "foo/bar/rag/baz", "foo/barrag/baz", or "foo/rag/ 2060 baz". A client SHOULD NOT use such a reference argument except at 2061 the explicit request of the user. A hierarchical browser MUST NOT 2062 make any assumptions about server interpretation of the reference 2063 unless the reference is a level of mailbox hierarchy AND ends with 2064 the hierarchy delimiter. 2066 Any part of the reference argument that is included in the 2067 interpreted form SHOULD prefix the interpreted form. It SHOULD also 2068 be in the same form as the reference name argument. This rule 2069 permits the client to determine if the returned mailbox name is in 2070 the context of the reference argument, or if something about the 2071 mailbox argument overrode the reference argument. Without this rule, 2072 the client would have to have knowledge of the server's naming 2073 semantics including what characters are "breakouts" that override a 2074 naming context. 2076 For example, here are some examples of how references 2077 and mailbox names might be interpreted on a UNIX-based 2078 server: 2080 Reference Mailbox Name Interpretation 2081 ------------ ------------ -------------- 2082 ~smith/Mail/ foo.* ~smith/Mail/foo.* 2083 archive/ % archive/% 2084 #news. comp.mail.* #news.comp.mail.* 2085 ~smith/Mail/ /usr/doc/foo /usr/doc/foo 2086 archive/ ~fred/Mail/* ~fred/Mail/* 2088 The first three examples demonstrate interpretations in 2089 the context of the reference argument. Note that 2090 "~smith/Mail" SHOULD NOT be transformed into something 2091 like "/u2/users/smith/Mail", or it would be impossible 2092 for the client to determine that the interpretation was 2093 in the context of the reference. 2095 The character "*" is a wildcard, and matches zero or more characters 2096 at this position. The character "%" is similar to "*", but it does 2097 not match a hierarchy delimiter. If the "%" wildcard is the last 2098 character of a mailbox name argument, matching levels of hierarchy 2099 are also returned. If these levels of hierarchy are not also 2100 selectable mailboxes, they are returned with the \Noselect mailbox 2101 name attribute (see the description of the LIST response for more 2102 details). 2104 If multiple mailbox patterns are used (in the extended syntax), a 2105 mailbox matches if it matches at least one mailbox pattern. If a 2106 mailbox matches more than one pattern, it is still only returned 2107 once. Any syntactically valid pattern that is not accepted by a 2108 server for any reason MUST be silently ignored. 2110 Selection options tell the server to limit the mailbox names that are 2111 selected by the LIST operation. If selection options are used, the 2112 mailboxes returned are those that match both the list of canonical 2113 LIST patterns and the selection options. Unless a particular 2114 selection option provides special rules, the selection options are 2115 cumulative: a mailbox that matches the mailbox patterns is selected 2116 only if it also matches all of the selection options. (An example of 2117 a selection option with special rules is the RECURSIVEMATCH option.) 2119 Return options control what information is returned for each matched 2120 mailbox. Return options MUST NOT cause the server to report 2121 information about additional mailbox names other than those that 2122 match the canonical LIST patterns and selection options. If no 2123 return options are specified, the client is only expecting 2124 information about mailbox attributes. The server MAY return other 2125 information about the matched mailboxes, and clients MUST be able to 2126 handle that situation. 2128 Initial selection options and return options are defined in the 2129 following subsections, and new ones will also be defined in 2130 extensions. Initial options defined in this document MUST be 2131 supported. Each non-initial option will be enabled by a capability 2132 string (one capability may enable multiple options), and a client 2133 MUST NOT send an option for which the server has not advertised 2134 support. A server MUST respond to options it does not recognize with 2135 a BAD response. The client SHOULD NOT specify any option more than 2136 once; however, if the client does this, the server MUST act as if it 2137 received the option only once. The order in which options are 2138 specified by the client is not significant. 2140 In general, each selection option except RECURSIVEMATCH will have a 2141 corresponding return option. The REMOTE selection option is an 2142 anomaly in this regard, and does not have a corresponding return 2143 option. That is because it expands, rather than restricts, the set 2144 of mailboxes that are returned. Future extensions to this 2145 specification should keep parallelism in mind and define a pair of 2146 corresponding options. 2148 Server implementations are permitted to "hide" otherwise accessible 2149 mailboxes from the wildcard characters, by preventing certain 2150 characters or names from matching a wildcard in certain situations. 2151 For example, a UNIX-based server might restrict the interpretation of 2152 "*" so that an initial "/" character does not match. 2154 The special name INBOX is included in the output from LIST, if INBOX 2155 is supported by this server for this user and if the uppercase string 2156 "INBOX" matches the interpreted reference and mailbox name arguments 2157 with wildcards as described above. The criteria for omitting INBOX 2158 is whether SELECT INBOX will return failure; it is not relevant 2159 whether the user's real INBOX resides on this or some other server. 2161 6.3.9.1. LIST Selection Options 2163 The selection options defined in this specification are as follows: 2165 SUBSCRIBED - causes the LIST command to list subscribed names, 2166 rather than the existing mailboxes. This will often be a subset 2167 of the actual mailboxes. It's also possible for this list to 2168 contain the names of mailboxes that don't exist. In any case, the 2169 list MUST include exactly those mailbox names that match the 2170 canonical list pattern and are subscribed to. 2172 This option defines a mailbox attribute, "\Subscribed", that 2173 indicates that a mailbox name is subscribed to. The "\Subscribed" 2174 attribute MUST be supported and MUST be accurately computed when 2175 the SUBSCRIBED selection option is specified. 2177 Note that the SUBSCRIBED selection option implies the SUBSCRIBED 2178 return option (see below). 2180 REMOTE - causes the LIST command to show remote mailboxes as well as 2181 local ones, as described in [RFC2193]. This option is intended to 2182 replace the RLIST command and, in conjunction with the SUBSCRIBED 2183 selection option, the RLSUB command. Servers that don't support 2184 remote mailboxes just ignore this option. 2186 This option defines a mailbox attribute, "\Remote", that indicates 2187 that a mailbox is a remote mailbox. The "\Remote" attribute MUST 2188 be accurately computed when the REMOTE option is specified. 2190 The REMOTE selection option has no interaction with other options. 2191 Its effect is to tell the server to apply the other options, if 2192 any, to remote mailboxes, in addition to local ones. In 2193 particular, it has no interaction with RECURSIVEMATCH (see below). 2194 A request for (REMOTE RECURSIVEMATCH) is invalid, because a 2195 request for (RECURSIVEMATCH) is also invalid. A request for 2196 (REMOTE RECURSIVEMATCH SUBSCRIBED) is asking for all subscribed 2197 mailboxes, both local and remote. 2199 RECURSIVEMATCH - this option forces the server to return information 2200 about parent mailboxes that don't match other selection options, 2201 but have some submailboxes that do. Information about children is 2202 returned in the CHILDINFO extended data item, as described in 2203 Section 6.3.9.6. 2205 Note 1: In order for a parent mailbox to be returned, it still has 2206 to match the canonical LIST pattern. 2208 Note 2: When returning the CHILDINFO extended data item, it 2209 doesn't matter whether or not the submailbox matches the canonical 2210 LIST pattern. See also example 9 in Section 6.3.9.7. 2212 The RECURSIVEMATCH option MUST NOT occur as the only selection 2213 option (or only with REMOTE), as it only makes sense when other 2214 selection options are also used. The server MUST return BAD 2215 tagged response in such case. 2217 Note that even if the RECURSIVEMATCH option is specified, the 2218 client MUST still be able to handle a case when a CHILDINFO 2219 extended data item is returned and there are no submailboxes that 2220 meet the selection criteria of the subsequent LIST command, as 2221 they can be deleted/renamed after the LIST response was sent, but 2222 before the client had a chance to access them. 2224 6.3.9.2. LIST Return Options 2226 The return options defined in this specification are as follows: 2228 SUBSCRIBED - causes the LIST command to return subscription state 2229 for all matching mailbox names. The "\Subscribed" attribute MUST 2230 be supported and MUST be accurately computed when the SUBSCRIBED 2231 return option is specified. Further, all mailbox flags MUST be 2232 accurately computed (this differs from the behavior of the 2233 obsolete LSUB command from IMAP4rev1). 2235 CHILDREN - requests mailbox child information as originally proposed 2236 in [RFC3348]. See Section 6.3.9.5, below, for details. This 2237 option MUST be supported by all servers. 2239 STATUS - requests STATUS response for each matching mailbox. 2241 This option takes STATUS data items as parameters. For each 2242 selectable mailbox matching the list pattern and selection 2243 options, the server MUST return an untagged LIST response 2244 followed by an untagged STATUS response containing the 2245 information requested in the STATUS return option. 2247 If an attempted STATUS for a listed mailbox fails because the 2248 mailbox can't be selected (e.g., if the "l" ACL right [RFC4314] 2249 is granted to the mailbox and the "r" right is not granted, or 2250 due to a race condition between LIST and STATUS changing the 2251 mailbox to \NoSelect), the STATUS response MUST NOT be returned 2252 and the LIST response MUST include the \NoSelect attribute. 2253 This means the server may have to buffer the LIST reply until 2254 it has successfully looked up the necessary STATUS information. 2256 If the server runs into unexpected problems while trying to 2257 look up the STATUS information, it MAY drop the corresponding 2258 STATUS reply. In such a situation, the LIST command would 2259 still return a tagged OK reply. 2261 6.3.9.3. General Principles for Returning LIST Responses 2263 This section outlines several principles that can be used by server 2264 implementations of this document to decide whether a LIST response 2265 should be returned, as well as how many responses and what kind of 2266 information they may contain. 2268 1. At most one LIST response should be returned for each mailbox 2269 name that matches the canonical LIST pattern. Server 2270 implementors must not assume that clients will be able to 2271 assemble mailbox attributes and other information returned in 2272 multiple LIST responses. 2274 2. There are only two reasons for including a matching mailbox name 2275 in the responses to the LIST command (note that the server is 2276 allowed to return unsolicited responses at any time, and such 2277 responses are not governed by this rule): 2279 A. The mailbox name also satisfies the selection criteria. 2281 B. The mailbox name doesn't satisfy the selection criteria, but 2282 it has at least one descendant mailbox name that satisfies 2283 the selection criteria and that doesn't match the canonical 2284 LIST pattern. 2286 For more information on this case, see the CHILDINFO extended 2287 data item described in Section 6.3.9.6. Note that the 2288 CHILDINFO extended data item can only be returned when the 2289 RECURSIVEMATCH selection option is specified. 2291 3. Attributes returned in the same LIST response must be treated 2292 additively. For example, the following response 2294 S: * LIST (\Subscribed \NonExistent) "/" "Fruit/Peach" 2296 means that the "Fruit/Peach" mailbox doesn't exist, but it is 2297 subscribed. 2299 6.3.9.4. Additional LIST-related Requirements on Clients 2301 All clients MUST treat a LIST attribute with a stronger meaning as 2302 implying any attribute that can be inferred from it. (See 2303 Section 7.2.3 for the list of currently defined attributes). For 2304 example, the client must treat the presence of the \NoInferiors 2305 attribute as if the \HasNoChildren attribute was also sent by the 2306 server. 2308 The following table summarizes inference rules. 2310 +--------------------+-------------------+ 2311 | returned attribute | implied attribute | 2312 +--------------------+-------------------+ 2313 | \NoInferiors | \HasNoChildren | 2314 | \NonExistent | \NoSelect | 2315 +--------------------+-------------------+ 2317 6.3.9.5. The CHILDREN Return Option 2319 The CHILDREN return option implements the Child Mailbox Extension, 2320 originally proposed by Mike Gahrns and Raymond Cheng, of Microsoft 2321 Corporation. Most of the information in this section is taken 2322 directly from their original specification [RFC3348]. The CHILDREN 2323 return option is simply an indication that the client wants this 2324 information; a server MAY provide it even if the option is not 2325 specified. 2327 Many IMAP4 clients present to the user a hierarchical view of the 2328 mailboxes that a user has access to. Rather than initially 2329 presenting to the user the entire mailbox hierarchy, it is often 2330 preferable to show to the user a collapsed outline list of the 2331 mailbox hierarchy (particularly if there is a large number of 2332 mailboxes). The user can then expand the collapsed outline hierarchy 2333 as needed. It is common to include within the collapsed hierarchy a 2334 visual clue (such as a ''+'') to indicate that there are child 2335 mailboxes under a particular mailbox. When the visual clue is 2336 clicked, the hierarchy list is expanded to show the child mailboxes. 2337 The CHILDREN return option provides a mechanism for a client to 2338 efficiently determine whether a particular mailbox has children, 2339 without issuing a LIST "" * or a LIST "" % for each mailbox name. 2340 The CHILDREN return option defines two new attributes that MUST be 2341 returned within a LIST response: \HasChildren and \HasNoChildren. 2342 Although these attributes MAY be returned in response to any LIST 2343 command, the CHILDREN return option is provided to indicate that the 2344 client particularly wants this information. If the CHILDREN return 2345 option is present, the server MUST return these attributes even if 2346 their computation is expensive. 2348 \HasChildren 2350 The presence of this attribute indicates that the mailbox has 2351 child mailboxes. A server SHOULD NOT set this attribute if 2352 there are child mailboxes and the user does not have permission 2353 to access any of them. In this case, \HasNoChildren SHOULD be 2354 used. In many cases, however, a server may not be able to 2355 efficiently compute whether a user has access to any child 2356 mailbox. Note that even though the \HasChildren attribute for a 2357 mailbox must be correct at the time of processing of the 2358 mailbox, a client must be prepared to deal with a situation when 2359 a mailbox is marked with the \HasChildren attribute, but no 2360 child mailbox appears in the response to the LIST command. This 2361 might happen, for example, due to children mailboxes being 2362 deleted or made inaccessible to the user (using access control) 2363 by another client before the server is able to list them. 2365 \HasNoChildren 2367 The presence of this attribute indicates that the mailbox has NO 2368 child mailboxes that are accessible to the currently 2369 authenticated user. 2371 It is an error for the server to return both a \HasChildren and a 2372 \HasNoChildren attribute in the same LIST response. 2374 Note: the \HasNoChildren attribute should not be confused with the 2375 the \NoInferiors attribute, which indicates that no child mailboxes 2376 exist now and none can be created in the future. 2378 6.3.9.6. CHILDINFO Extended Data Item 2380 The CHILDINFO extended data item MUST NOT be returned unless the 2381 client has specified the RECURSIVEMATCH selection option. 2383 The CHILDINFO extended data item in a LIST response describes the 2384 selection criteria that has caused it to be returned and indicates 2385 that the mailbox has at least one descendant mailbox that matches the 2386 selection criteria. 2388 Note: Some servers allow for mailboxes to exist without requiring 2389 their parent to exist. For example, a mailbox "Customers/ABC" can 2390 exist while the mailbox "Customers" does not. As CHILDINFO extended 2391 data item is not allowed if the RECURSIVEMATCH selection option is 2392 not specified, such servers SHOULD use the "\NonExistent 2393 \HasChildren" attribute pair to signal to the client that there is a 2394 descendant mailbox that matches the selection criteria. See example 2395 11 in Section 6.3.9.7. 2397 The returned selection criteria allow the client to distinguish a 2398 solicited response from an unsolicited one, as well as to distinguish 2399 among solicited responses caused by multiple pipelined LIST commands 2400 that specify different criteria. 2402 Servers SHOULD ONLY return a non-matching mailbox name along with 2403 CHILDINFO if at least one matching child is not also being returned. 2404 That is, servers SHOULD suppress redundant CHILDINFO responses. 2406 Examples 8 and 10 in Section 6.3.9.7 demonstrate the difference 2407 between present CHILDINFO extended data item and the "\HasChildren" 2408 attribute. 2410 The following table summarizes interaction between the "\NonExistent" 2411 attribute and CHILDINFO (the first column indicates whether the 2412 parent mailbox exists): 2414 +--------+--------------+--------------------+----------------------+ 2415 | exists | meets the | has a child that | returned LIST- | 2416 | | selection | meets the | EXTENDED attributes | 2417 | | criteria | selection criteria | and CHILDINFO | 2418 +--------+--------------+--------------------+----------------------+ 2419 | no | no | no | no LIST response | 2420 | | | | returned | 2421 | yes | no | no | no LIST response | 2422 | | | | returned | 2423 | no | yes | no | (\NonExistent | 2424 | | | | ) | 2425 | yes | yes | no | () | 2426 | no | no | yes | (\NonExistent) + | 2427 | | | | CHILDINFO | 2428 | yes | no | yes | () + CHILDINFO | 2429 | no | yes | yes | (\NonExistent | 2430 | | | | ) + CHILDINFO | 2431 | yes | yes | yes | () + CHILDINFO | 2432 +--------+--------------+--------------------+----------------------+ 2434 where is one or more attributes that correspond to the 2435 selection criteria; for example, for the SUBSCRIBED option the 2436 is \Subscribed. 2438 6.3.9.7. LIST Command Examples 2440 This example shows some uses of the basic LIST command: 2442 Example: C: A101 LIST "" "" 2443 S: * LIST (\Noselect) "/" "" 2444 S: A101 OK LIST Completed 2445 C: A102 LIST #news.comp.mail.misc "" 2446 S: * LIST (\Noselect) "." #news. 2447 S: A102 OK LIST Completed 2448 C: A103 LIST /usr/staff/jones "" 2449 S: * LIST (\Noselect) "/" / 2450 S: A103 OK LIST Completed 2451 C: A202 LIST ~/Mail/ % 2452 S: * LIST (\Noselect) "/" ~/Mail/foo 2453 S: * LIST () "/" ~/Mail/meetings 2454 S: A202 OK LIST completed 2456 Extended examples: 2458 1: The first example shows the complete local hierarchy that will 2459 be used for the other examples. 2461 C: A01 LIST "" "*" 2462 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2463 S: * LIST () "/" "Fruit" 2464 S: * LIST () "/" "Fruit/Apple" 2465 S: * LIST () "/" "Fruit/Banana" 2466 S: * LIST () "/" "Tofu" 2467 S: * LIST () "/" "Vegetable" 2468 S: * LIST () "/" "Vegetable/Broccoli" 2469 S: * LIST () "/" "Vegetable/Corn" 2470 S: A01 OK done 2472 2: In the next example, we will see the subscribed mailboxes. This 2473 is similar to, but not equivalent with, . Note 2474 that the mailbox called "Fruit/Peach" is subscribed to, but does 2475 not actually exist (perhaps it was deleted while still 2476 subscribed). The "Fruit" mailbox is not subscribed to, but it 2477 has two subscribed children. The "Vegetable" mailbox is 2478 subscribed and has two children; one of them is subscribed as 2479 well. 2481 C: A02 LIST (SUBSCRIBED) "" "*" 2482 S: * LIST (\Marked \NoInferiors \Subscribed) "/" "inbox" 2483 S: * LIST (\Subscribed) "/" "Fruit/Banana" 2484 S: * LIST (\Subscribed \NonExistent) "/" "Fruit/Peach" 2485 S: * LIST (\Subscribed) "/" "Vegetable" 2486 S: * LIST (\Subscribed) "/" "Vegetable/Broccoli" 2487 S: A02 OK done 2489 3: The next example shows the use of the CHILDREN option. The 2490 client, without having to list the second level of hierarchy, 2491 now knows which of the top-level mailboxes have submailboxes 2492 (children) and which do not. Note that it's not necessary for 2493 the server to return the \HasNoChildren attribute for the inbox, 2494 because the \NoInferiors attribute already implies that, and has 2495 a stronger meaning. 2497 C: A03 LIST () "" "%" RETURN (CHILDREN) 2498 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2499 S: * LIST (\HasChildren) "/" "Fruit" 2500 S: * LIST (\HasNoChildren) "/" "Tofu" 2501 S: * LIST (\HasChildren) "/" "Vegetable" 2502 S: A03 OK done 2504 4: In this example, we see more mailboxes that reside on another 2505 server. This is similar to the command . 2507 C: A04 LIST (REMOTE) "" "%" RETURN (CHILDREN) 2508 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2509 S: * LIST (\HasChildren) "/" "Fruit" 2510 S: * LIST (\HasNoChildren) "/" "Tofu" 2511 S: * LIST (\HasChildren) "/" "Vegetable" 2512 S: * LIST (\Remote) "/" "Bread" 2513 S: * LIST (\HasChildren \Remote) "/" "Meat" 2514 S: A04 OK done 2516 5: The following example also requests the server to include 2517 mailboxes that reside on another server. The server returns 2518 information about all mailboxes that are subscribed. This is 2519 similar to the command . We also see the use of 2520 two selection options. 2522 C: A05 LIST (REMOTE SUBSCRIBED) "" "*" 2523 S: * LIST (\Marked \NoInferiors \Subscribed) "/" "inbox" 2524 S: * LIST (\Subscribed) "/" "Fruit/Banana" 2525 S: * LIST (\Subscribed \NonExistent) "/" "Fruit/Peach" 2526 S: * LIST (\Subscribed) "/" "Vegetable" 2527 S: * LIST (\Subscribed) "/" "Vegetable/Broccoli" 2528 S: * LIST (\Remote \Subscribed) "/" "Bread" 2529 S: A05 OK done 2531 6: The following example requests the server to include mailboxes 2532 that reside on another server. The server is asked to return 2533 subscription information for all returned mailboxes. This is 2534 different from the example above. 2536 Note that the output of this command is not a superset of the 2537 output in the previous example, as it doesn't include LIST 2538 response for the non-existent "Fruit/Peach". 2540 C: A06 LIST (REMOTE) "" "*" RETURN (SUBSCRIBED) 2541 S: * LIST (\Marked \NoInferiors \Subscribed) "/" "inbox" 2542 S: * LIST () "/" "Fruit" 2543 S: * LIST () "/" "Fruit/Apple" 2544 S: * LIST (\Subscribed) "/" "Fruit/Banana" 2545 S: * LIST () "/" "Tofu" 2546 S: * LIST (\Subscribed) "/" "Vegetable" 2547 S: * LIST (\Subscribed) "/" "Vegetable/Broccoli" 2548 S: * LIST () "/" "Vegetable/Corn" 2549 S: * LIST (\Remote \Subscribed) "/" "Bread" 2550 S: * LIST (\Remote) "/" "Meat" 2551 S: A06 OK done 2553 7: In the following example, the client has specified multiple 2554 mailbox patterns. Note that this example does not use the 2555 mailbox hierarchy used in the previous examples. 2557 C: BBB LIST "" ("INBOX" "Drafts" "Sent/%") 2558 S: * LIST () "/" "INBOX" 2559 S: * LIST (\NoInferiors) "/" "Drafts" 2560 S: * LIST () "/" "Sent/March2004" 2561 S: * LIST (\Marked) "/" "Sent/December2003" 2562 S: * LIST () "/" "Sent/August2004" 2563 S: BBB OK done 2565 8: The following example demonstrates the difference between the 2566 \HasChildren attribute and the CHILDINFO extended data item. 2568 Let's assume there is the following hierarchy: 2570 C: C01 LIST "" "*" 2571 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2572 S: * LIST () "/" "Foo" 2573 S: * LIST () "/" "Foo/Bar" 2574 S: * LIST () "/" "Foo/Baz" 2575 S: * LIST () "/" "Moo" 2576 S: C01 OK done 2578 If the client asks RETURN (CHILDREN), it will get this: 2580 C: CA3 LIST "" "%" RETURN (CHILDREN) 2581 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2582 S: * LIST (\HasChildren) "/" "Foo" 2583 S: * LIST (\HasNoChildren) "/" "Moo" 2584 S: CA3 OK done 2586 A) Let's also assume that the mailbox "Foo/Baz" is the only 2587 subscribed mailbox. Then we get this result: 2589 C: C02 LIST (SUBSCRIBED) "" "*" 2590 S: * LIST (\Subscribed) "/" "Foo/Baz" 2591 S: C02 OK done 2593 Now, if the client issues , the server 2594 will return no mailboxes (as the mailboxes "Moo", "Foo", and 2595 "Inbox" are NOT subscribed). However, if the client issues 2596 this: 2598 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2599 S: * LIST () "/" "Foo" ("CHILDINFO" ("SUBSCRIBED")) 2600 S: C04 OK done 2602 (i.e., the mailbox "Foo" is not subscribed, but it has a child 2603 that is.) 2605 A1) If the mailbox "Foo" had also been subscribed, the last 2606 command would return this: 2608 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2609 S: * LIST (\Subscribed) "/" "Foo" ("CHILDINFO" ("SUBSCRIBED")) 2610 S: C04 OK done 2612 or even this: 2614 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2615 S: * LIST (\Subscribed \HasChildren) "/" "Foo" ("CHILDINFO" 2616 ("SUBSCRIBED")) 2617 S: C04 OK done 2619 A2) If we assume instead that the mailbox "Foo" is not part of 2620 the original hierarchy and is not subscribed, the last command 2621 will give this result: 2623 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2624 S: * LIST (\NonExistent) "/" "Foo" ("CHILDINFO" ("SUBSCRIBED")) 2625 S: C04 OK done 2626 B) Now, let's assume that no mailbox is subscribed. In this 2627 case, the command will 2628 return no responses, as there are no subscribed children (even 2629 though "Foo" has children). 2631 C) And finally, suppose that only the mailboxes "Foo" and "Moo" 2632 are subscribed. In that case, we see this result: 2634 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" RETURN (CHILDREN) 2635 S: * LIST (\HasChildren \Subscribed) "/" "Foo" 2636 S: * LIST (\HasNoChildren \Subscribed) "/" "Moo" 2637 S: C04 OK done 2639 (which means that the mailbox "Foo" has children, but none of 2640 them is subscribed). 2642 9: The following example demonstrates that the CHILDINFO extended 2643 data item is returned whether or not children mailboxes match 2644 the canonical LIST pattern. 2646 Let's assume there is the following hierarchy: 2648 C: D01 LIST "" "*" 2649 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2650 S: * LIST () "/" "foo2" 2651 S: * LIST () "/" "foo2/bar1" 2652 S: * LIST () "/" "foo2/bar2" 2653 S: * LIST () "/" "baz2" 2654 S: * LIST () "/" "baz2/bar2" 2655 S: * LIST () "/" "baz2/bar22" 2656 S: * LIST () "/" "baz2/bar222" 2657 S: * LIST () "/" "eps2" 2658 S: * LIST () "/" "eps2/mamba" 2659 S: * LIST () "/" "qux2/bar2" 2660 S: D01 OK done 2662 And that the following mailboxes are subscribed: 2664 C: D02 LIST (SUBSCRIBED) "" "*" 2665 S: * LIST (\Subscribed) "/" "foo2/bar1" 2666 S: * LIST (\Subscribed) "/" "foo2/bar2" 2667 S: * LIST (\Subscribed) "/" "baz2/bar2" 2668 S: * LIST (\Subscribed) "/" "baz2/bar22" 2669 S: * LIST (\Subscribed) "/" "baz2/bar222" 2670 S: * LIST (\Subscribed) "/" "eps2" 2671 S: * LIST (\Subscribed) "/" "eps2/mamba" 2672 S: * LIST (\Subscribed) "/" "qux2/bar2" 2673 S: D02 OK done 2674 The client issues the following command first: 2676 C: D03 LIST (RECURSIVEMATCH SUBSCRIBED) "" "*2" 2677 S: * LIST () "/" "foo2" ("CHILDINFO" ("SUBSCRIBED")) 2678 S: * LIST (\Subscribed) "/" "foo2/bar2" 2679 S: * LIST (\Subscribed) "/" "baz2/bar2" 2680 S: * LIST (\Subscribed) "/" "baz2/bar22" 2681 S: * LIST (\Subscribed) "/" "baz2/bar222" 2682 S: * LIST (\Subscribed) "/" "eps2" ("CHILDINFO" ("SUBSCRIBED")) 2683 S: * LIST (\Subscribed) "/" "qux2/bar2" 2684 S: D03 OK done 2686 and the server may also include (but this would violate a SHOULD 2687 NOT in Section 3.5, because CHILDINFO is redundant) 2689 S: * LIST () "/" "baz2" ("CHILDINFO" ("SUBSCRIBED")) 2690 S: * LIST (\NonExistent) "/" "qux2" ("CHILDINFO" ("SUBSCRIBED")) 2692 The CHILDINFO extended data item is returned for mailboxes 2693 "foo2", "baz2", and "eps2", because all of them have subscribed 2694 children, even though for the mailbox "foo2" only one of the two 2695 subscribed children matches the pattern, for the mailbox "baz2" 2696 all the subscribed children match the pattern, and for the 2697 mailbox "eps2" none of the subscribed children matches the 2698 pattern. 2700 Note that if the client issues 2702 C: D03 LIST (RECURSIVEMATCH SUBSCRIBED) "" "*" 2703 S: * LIST () "/" "foo2" ("CHILDINFO" ("SUBSCRIBED")) 2704 S: * LIST (\Subscribed) "/" "foo2/bar1" 2705 S: * LIST (\Subscribed) "/" "foo2/bar2" 2706 S: * LIST () "/" "baz2" ("CHILDINFO" ("SUBSCRIBED")) 2707 S: * LIST (\Subscribed) "/" "baz2/bar2" 2708 S: * LIST (\Subscribed) "/" "baz2/bar22" 2709 S: * LIST (\Subscribed) "/" "baz2/bar222" 2710 S: * LIST (\Subscribed) "/" "eps2" ("CHILDINFO" ("SUBSCRIBED")) 2711 S: * LIST (\Subscribed) "/" "eps2/mamba" 2712 S: * LIST (\Subscribed) "/" "qux2/bar2" 2713 S: D03 OK done 2715 The LIST responses for mailboxes "foo2", "baz2", and "eps2" 2716 still have the CHILDINFO extended data item, even though this 2717 information is redundant and the client can determine it by 2718 itself. 2720 10: The following example shows usage of extended syntax for mailbox 2721 pattern. It also demonstrates that the presence of the 2722 CHILDINFO extended data item doesn't necessarily imply 2723 \HasChildren. 2725 C: a1 LIST "" ("foo") 2726 S: * LIST () "/" foo 2727 S: a1 OK done 2729 C: a2 LIST (SUBSCRIBED) "" "foo/*" 2730 S: * LIST (\Subscribed \NonExistent) "/" foo/bar 2731 S: a2 OK done 2733 C: a3 LIST (SUBSCRIBED RECURSIVEMATCH) "" foo RETURN (CHILDREN) 2734 S: * LIST (\HasNoChildren) "/" foo ("CHILDINFO" ("SUBSCRIBED")) 2735 S: a3 OK done 2737 11: The following example shows how a server that supports missing 2738 mailbox hierarchy elements can signal to a client that didn't 2739 specify the RECURSIVEMATCH selection option that there is a 2740 child mailbox that matches the selection criteria. 2742 C: a1 LIST (REMOTE) "" * 2743 S: * LIST () "/" music/rock 2744 S: * LIST (\Remote) "/" also/jazz 2745 S: a1 OK done 2747 C: a2 LIST () "" % 2748 S: * LIST (\NonExistent \HasChildren) "/" music 2749 S: a2 OK done 2751 C: a3 LIST (REMOTE) "" % 2752 S: * LIST (\NonExistent \HasChildren) "/" music 2753 S: * LIST (\NonExistent \HasChildren) "/" also 2754 S: a3 OK done 2756 C: a3.1 LIST "" (% music/rock) 2757 S: * LIST () "/" music/rock 2758 S: a3.1 OK done 2760 Because "music/rock" is the only mailbox under "music", there's 2761 no need for the server to also return "music". However clients 2762 must handle both cases. 2764 12: The following examples show use of STATUS return option. 2766 C: A01 LIST "" % RETURN (STATUS (MESSAGES UNSEEN)) 2767 S: * LIST () "." "INBOX" 2768 S: * STATUS "INBOX" (MESSAGES 17 UNSEEN 16) 2769 S: * LIST () "." "foo" 2770 S: * STATUS "foo" (MESSAGES 30 UNSEEN 29) 2771 S: * LIST (\NoSelect) "." "bar" 2772 S: A01 OK List completed. 2774 The "bar" mailbox isn't selectable, so it has no STATUS reply. 2776 C: A02 LIST (SUBSCRIBED RECURSIVEMATCH) "" % RETURN (STATUS 2777 (MESSAGES)) 2778 S: * LIST (\Subscribed) "." "INBOX" 2779 S: * STATUS "INBOX" (MESSAGES 17) 2780 S: * LIST () "." "foo" (CHILDINFO ("SUBSCRIBED")) 2781 S: A02 OK List completed. 2783 The LIST reply for "foo" is returned because it has matching 2784 children, but no STATUS reply is returned because "foo" itself 2785 doesn't match the selection criteria. 2787 6.3.10. NAMESPACE Command 2789 Arguments: none 2791 Responses: REQUIRED untagged responses: NAMESPACE 2793 Result: OK - command completed 2794 NO - Can't complete the command 2795 BAD - arguments invalid 2797 The NAMESPACE command causes a single ungagged NAMESPACE response to 2798 be returned. The untagged NAMESPACE response contains the prefix and 2799 hierarchy delimiter to the server's Personal Namespace(s), Other 2800 Users' Namespace(s), and Shared Namespace(s) that the server wishes 2801 to expose. The response will contain a NIL for any namespace class 2802 that is not available. Namespace-Response-Extensions ABNF non 2803 terminal is defined for extensibility and MAY be included in the 2804 response. 2806 Example 1: 2808 In this example a server supports a single personal namespace. No 2809 leading prefix is used on personal mailboxes and "/" is the hierarchy 2810 delimiter. 2812 C: A001 NAMESPACE 2813 S: * NAMESPACE (("" "/")) NIL NIL 2814 S: A001 OK NAMESPACE command completed 2816 Example 2: 2818 A user logged on anonymously to a server. No personal mailboxes are 2819 associated with the anonymous user and the user does not have access 2820 to the Other Users' Namespace. No prefix is required to access 2821 shared mailboxes and the hierarchy delimiter is "." 2823 C: A001 NAMESPACE 2824 S: * NAMESPACE NIL NIL (("" ".")) 2825 S: A001 OK NAMESPACE command completed 2827 Example 3: 2829 A server that contains a Personal Namespace and a single Shared 2830 Namespace. 2832 C: A001 NAMESPACE 2833 S: * NAMESPACE (("" "/")) NIL (("Public Folders/" "/")) 2834 S: A001 OK NAMESPACE command completed 2836 Example 4: 2838 A server that contains a Personal Namespace, Other Users' Namespace 2839 and multiple Shared Namespaces. Note that the hierarchy delimiter 2840 used within each namespace can be different. 2842 C: A001 NAMESPACE 2843 S: * NAMESPACE (("" "/")) (("~" "/")) (("#shared/" "/") 2844 ("#public/" "/")("#ftp/" "/")("#news." ".")) 2845 S: A001 OK NAMESPACE command completed 2847 The prefix string allows a client to do things such as automatically 2848 creating personal mailboxes or LISTing all available mailboxes within 2849 a namespace. 2851 Example 5: 2853 A server that supports only the Personal Namespace, with a leading 2854 prefix of INBOX to personal mailboxes and a hierarchy delimiter of 2855 "." 2856 C: A001 NAMESPACE 2857 S: * NAMESPACE (("INBOX." ".")) NIL NIL 2858 S: A001 OK NAMESPACE command completed 2860 < Automatically create a mailbox to store sent items.> 2862 C: A002 CREATE "INBOX.Sent Mail" 2863 S: A002 OK CREATE command completed 2865 Although typically a server will support only a single Personal 2866 Namespace, and a single Other User's Namespace, circumstances exist 2867 where there MAY be multiples of these, and a client MUST be prepared 2868 for them. If a client is configured such that it is required to 2869 create a certain mailbox, there can be circumstances where it is 2870 unclear which Personal Namespaces it should create the mailbox in. 2871 In these situations a client SHOULD let the user select which 2872 namespaces to create the mailbox in or just use the first personal 2873 namespace. 2875 Example 6: 2877 In this example, a server supports 2 Personal Namespaces. In 2878 addition to the regular Personal Namespace, the user has an 2879 additional personal namespace to allow access to mailboxes in an MH 2880 format mailstore. 2882 The client is configured to save a copy of all mail sent by the user 2883 into a mailbox called 'Sent Mail'. Furthermore, after a message is 2884 deleted from a mailbox, the client is configured to move that message 2885 to a mailbox called 'Deleted Items'. 2887 Note that this example demonstrates how some extension flags can be 2888 passed to further describe the #mh namespace. 2890 C: A001 NAMESPACE 2891 S: * NAMESPACE (("" "/")("#mh/" "/" "X-PARAM" 2892 ("FLAG1" "FLAG2"))) NIL NIL 2893 S: A001 OK NAMESPACE command completed 2895 < It is desired to keep only one copy of sent mail. 2896 It is unclear which Personal Namespace the client 2897 should use to create the 'Sent Mail' mailbox. 2898 The user is prompted to select a namespace and only 2899 one 'Sent Mail' mailbox is created. > 2901 C: A002 CREATE "Sent Mail" 2902 S: A002 OK CREATE command completed 2904 < The client is designed so that it keeps two 2905 'Deleted Items' mailboxes, one for each namespace. > 2907 C: A003 CREATE "Delete Items" 2908 S: A003 OK CREATE command completed 2910 C: A004 CREATE "#mh/Deleted Items" 2911 S: A004 OK CREATE command completed 2913 The next level of hierarchy following the Other Users' Namespace 2914 prefix SHOULD consist of , where is a user name 2915 as per the LOGIN or AUTHENTICATE command. 2917 A client can construct a LIST command by appending a "%" to the Other 2918 Users' Namespace prefix to discover the Personal Namespaces of other 2919 users that are available to the currently authenticated user. 2921 In response to such a LIST command, a server SHOULD NOT return user 2922 names that have not granted access to their personal mailboxes to the 2923 user in question. 2925 A server MAY return a LIST response containing only the names of 2926 users that have explicitly granted access to the user in question. 2928 Alternatively, a server MAY return NO to such a LIST command, 2929 requiring that a user name be included with the Other Users' 2930 Namespace prefix before listing any other user's mailboxes. 2932 Example 7: 2934 A server that supports providing a list of other user's mailboxes 2935 that are accessible to the currently logged on user. 2937 C: A001 NAMESPACE 2938 S: * NAMESPACE (("" "/")) (("Other Users/" "/")) NIL 2939 S: A001 OK NAMESPACE command completed 2941 C: A002 LIST "" "Other Users/%" 2942 S: * LIST () "/" "Other Users/Mike" 2943 S: * LIST () "/" "Other Users/Karen" 2944 S: * LIST () "/" "Other Users/Matthew" 2945 S: * LIST () "/" "Other Users/Tesa" 2946 S: A002 OK LIST command completed 2948 Example 8: 2950 A server that does not support providing a list of other user's 2951 mailboxes that are accessible to the currently logged on user. The 2952 mailboxes are listable if the client includes the name of the other 2953 user with the Other Users' Namespace prefix. 2955 C: A001 NAMESPACE 2956 S: * NAMESPACE (("" "/")) (("#Users/" "/")) NIL 2957 S: A001 OK NAMESPACE command completed 2959 < In this example, the currently logged on user has access to 2960 the Personal Namespace of user Mike, but the server chose to 2961 suppress this information in the LIST response. However, 2962 by appending the user name Mike (received through user input) 2963 to the Other Users' Namespace prefix, the client is able 2964 to get a listing of the personal mailboxes of user Mike. > 2966 C: A002 LIST "" "#Users/%" 2967 S: A002 NO The requested item could not be found. 2969 C: A003 LIST "" "#Users/Mike/%" 2970 S: * LIST () "/" "#Users/Mike/INBOX" 2971 S: * LIST () "/" "#Users/Mike/Foo" 2972 S: A003 OK LIST command completed. 2974 A prefix string might not contain a hierarchy delimiter, because in 2975 some cases it is not needed as part of the prefix. 2977 Example 9: 2979 A server that allows access to the Other Users' Namespace by 2980 prefixing the others' mailboxes with a '~' followed by , 2981 where is a user name as per the LOGIN or AUTHENTICATE 2982 command. 2984 C: A001 NAMESPACE 2985 S: * NAMESPACE (("" "/")) (("~" "/")) NIL 2986 S: A001 OK NAMESPACE command completed 2988 < List the mailboxes for user mark > 2990 C: A002 LIST "" "~mark/%" 2991 S: * LIST () "/" "~mark/INBOX" 2992 S: * LIST () "/" "~mark/foo" 2993 S: A002 OK LIST command completed 2995 6.3.11. STATUS Command 2997 Arguments: mailbox name 2998 status data item names 3000 Responses: REQUIRED untagged responses: STATUS 3002 Result: OK - status completed 3003 NO - status failure: no status for that name 3004 BAD - command unknown or arguments invalid 3006 The STATUS command requests the status of the indicated mailbox. It 3007 does not change the currently selected mailbox, nor does it affect 3008 the state of any messages in the queried mailbox. 3010 The STATUS command provides an alternative to opening a second 3011 IMAP4rev2 connection and doing an EXAMINE command on a mailbox to 3012 query that mailbox's status without deselecting the current mailbox 3013 in the first IMAP4rev2 connection. 3015 Unlike the LIST command, the STATUS command is not guaranteed to be 3016 fast in its response. Under certain circumstances, it can be quite 3017 slow. In some implementations, the server is obliged to open the 3018 mailbox read-only internally to obtain certain status information. 3019 Also unlike the LIST command, the STATUS command does not accept 3020 wildcards. 3022 Note: The STATUS command is intended to access the status of 3023 mailboxes other than the currently selected mailbox. Because the 3024 STATUS command can cause the mailbox to be opened internally, and 3025 because this information is available by other means on the 3026 selected mailbox, the STATUS command SHOULD NOT be used on the 3027 currently selected mailbox. However, servers MUST be able to 3028 execute STATUS command on the selected mailbox. (This might also 3029 implicitly happen when STATUS return option is used in a LIST 3030 command). 3032 The STATUS command MUST NOT be used as a "check for new messages 3033 in the selected mailbox" operation (refer to sections Section 7, 3034 Section 7.3.1 for more information about the proper method for new 3035 message checking). 3037 STATUS SIZE (see below) can take a significant amount of time, 3038 depending upon server implementation. Clients should use STATUS 3039 SIZE cautiously. 3041 The currently defined status data items that can be requested are: 3043 MESSAGES The number of messages in the mailbox. 3045 UIDNEXT The next unique identifier value of the mailbox. Refer to 3046 Section 2.3.1.1 for more information. 3048 UIDVALIDITY The unique identifier validity value of the mailbox. 3049 Refer to Section 2.3.1.1 for more information. 3051 UNSEEN The number of messages which do not have the \Seen flag set. 3053 DELETED The number of messages which have the \Deleted flag set. 3055 SIZE The total size of the mailbox in octets. This is not strictly 3056 required to be an exact value, but it MUST be equal to or greater 3057 than the sum of the values of the RFC822.SIZE FETCH message data 3058 items (see Section 6.4.5) of all messages in the mailbox. 3060 Example: C: A042 STATUS blurdybloop (UIDNEXT MESSAGES) 3061 S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) 3062 S: A042 OK STATUS completed 3064 6.3.12. APPEND Command 3066 Arguments: mailbox name 3067 OPTIONAL flag parenthesized list 3068 OPTIONAL date/time string 3069 message literal 3071 Responses: no specific responses for this command 3073 Result: OK - append completed 3074 NO - append error: can't append to that mailbox, error 3075 in flags or date/time or message text 3076 BAD - command unknown or arguments invalid 3078 The APPEND command appends the literal argument as a new message to 3079 the end of the specified destination mailbox. This argument SHOULD 3080 be in the format of an [RFC-5322] or [I18N-HDRS] message. 8-bit 3081 characters are permitted in the message. A server implementation 3082 that is unable to preserve 8-bit data properly MUST be able to 3083 reversibly convert 8-bit APPEND data to 7-bit using a [MIME-IMB] 3084 content transfer encoding. 3086 Note: There may be exceptions, e.g., draft messages, in which 3087 required [RFC-5322] header lines are omitted in the message 3088 literal argument to APPEND. The full implications of doing so 3089 must be understood and carefully weighed. 3091 If a flag parenthesized list is specified, the flags SHOULD be set in 3092 the resulting message; otherwise, the flag list of the resulting 3093 message is set to empty by default. 3095 If a date-time is specified, the internal date SHOULD be set in the 3096 resulting message; otherwise, the internal date of the resulting 3097 message is set to the current date and time by default. 3099 If the append is unsuccessful for any reason, the mailbox MUST be 3100 restored to its state before the APPEND attempt (other than possibly 3101 keeping the changed mailbox's UIDNEXT value); no partial appending is 3102 permitted. 3104 If the destination mailbox does not exist, a server MUST return an 3105 error, and MUST NOT automatically create the mailbox. Unless it is 3106 certain that the destination mailbox can not be created, the server 3107 MUST send the response code "[TRYCREATE]" as the prefix of the text 3108 of the tagged NO response. This gives a hint to the client that it 3109 can attempt a CREATE command and retry the APPEND if the CREATE is 3110 successful. 3112 On successful completion of an APPEND, the server SHOULD return an 3113 APPENDUID response code. 3115 In the case of a mailbox that has permissions set so that the client 3116 can APPEND to the mailbox, but not SELECT or EXAMINE it, the server 3117 SHOULD NOT send an APPENDUID response code as it would disclose 3118 information about the mailbox. 3120 In the case of a mailbox that has UIDNOTSTICKY status (see 3121 UIDNOTSTICKY response code definition), the server MAY omit the 3122 APPENDUID response code as it is not meaningful. 3124 If the server does not return the APPENDUID response codes, the 3125 client can discover this information by selecting the destination 3126 mailbox. The location of messages placed in the destination mailbox 3127 by APPEND can be determined by using FETCH and/or SEARCH commands 3128 (e.g., for Message-ID or some unique marker placed in the message in 3129 an APPEND). 3131 If the mailbox is currently selected, the normal new message actions 3132 SHOULD occur. Specifically, the server SHOULD notify the client 3133 immediately via an untagged EXISTS response. If the server does not 3134 do so, the client MAY issue a NOOP command after one or more APPEND 3135 commands. 3137 Example: C: A003 APPEND saved-messages (\Seen) {310} 3138 S: + Ready for literal data 3139 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST) 3140 C: From: Fred Foobar 3141 C: Subject: afternoon meeting 3142 C: To: mooch@owatagu.siam.edu 3143 C: Message-Id: 3144 C: MIME-Version: 1.0 3145 C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 3146 C: 3147 C: Hello Joe, do you think we can meet at 3:30 tomorrow? 3148 C: 3149 S: A003 OK APPEND completed 3151 Example: C: A003 APPEND saved-messages (\Seen) {297} 3152 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST) 3153 C: From: Fred Foobar 3154 C: Subject: afternoon meeting 3155 C: To: mooch@example.com 3156 C: Message-Id: 3157 C: MIME-Version: 1.0 3158 C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 3159 C: 3160 C: Hello Joe, do you think we can meet at 3:30 tomorrow? 3161 C: 3162 S: A003 OK [APPENDUID 38505 3955] APPEND completed 3163 C: A004 COPY 2:4 meeting 3164 S: A004 OK [COPYUID 38505 304,319:320 3956:3958] Done 3165 C: A005 UID COPY 305:310 meeting 3166 S: A005 OK No matching messages, so nothing copied 3167 C: A006 COPY 2 funny 3168 S: A006 OK Done 3169 C: A007 SELECT funny 3170 S: * 1 EXISTS 3171 S: * OK [UIDVALIDITY 3857529045] Validity session-only 3172 S: * OK [UIDNEXT 2] Predicted next UID 3173 S: * NO [UIDNOTSTICKY] Non-persistent UIDs 3174 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 3175 S: * OK [PERMANENTFLAGS (\Deleted \Seen)] Limited 3176 S: A007 OK [READ-WRITE] SELECT completed 3178 In this example, A003 and A004 demonstrate successful appending and 3179 copying to a mailbox that returns the UIDs assigned to the messages. 3180 A005 is an example in which no messages were copied; this is because 3181 in A003, we see that message 2 had UID 304, and message 3 had UID 3182 319; therefore, UIDs 305 through 310 do not exist (refer to 3183 Section 2.3.1.1 for further explanation). A006 is an example of a 3184 message being copied that did not return a COPYUID; and, as expected, 3185 A007 shows that the mail store containing that mailbox does not 3186 support persistent UIDs. 3188 Note: The APPEND command is not used for message delivery, because 3189 it does not provide a mechanism to transfer [SMTP] envelope 3190 information. 3192 6.3.13. IDLE Command 3194 Arguments: none 3196 Responses: continuation data will be requested; the client sends the 3197 continuation data "DONE" to end the command 3199 Result: OK - IDLE completed after client sent "DONE" 3200 NO - failure: the server will not allow the IDLE command 3201 at this time 3202 BAD - command unknown or arguments invalid 3204 Without the IDLE command a client requires to poll the server for 3205 changes to the selected mailbox (new mail, deletions, flag changes). 3206 It's often more desirable to have the server transmit updates to the 3207 client in real time. This allows a user to see new mail immediately. 3208 The IDLE command allows a client to tell the server that it's ready 3209 to accept such real-time updates. 3211 The IDLE command is sent from the client to the server when the 3212 client is ready to accept unsolicited update messages. The server 3213 requests a response to the IDLE command using the continuation ("+") 3214 response. The IDLE command remains active until the client responds 3215 to the continuation, and as long as an IDLE command is active, the 3216 server is now free to send untagged EXISTS, EXPUNGE, FETCH, and other 3217 responses at any time. If the server choose to send unsolicited 3218 FETCH responses, they MUST include UID FETCH item. 3220 The IDLE command is terminated by the receipt of a "DONE" 3221 continuation from the client; such response satisfies the server's 3222 continuation request. At that point, the server MAY send any 3223 remaining queued untagged responses and then MUST immediately send 3224 the tagged response to the IDLE command and prepare to process other 3225 commands. As for other commands, the processing of any new command 3226 may cause the sending of unsolicited untagged responses, subject to 3227 the ambiguity limitations. The client MUST NOT send a command while 3228 the server is waiting for the DONE, since the server will not be able 3229 to distinguish a command from a continuation. 3231 The server MAY consider a client inactive if it has an IDLE command 3232 running, and if such a server has an inactivity timeout it MAY log 3233 the client off implicitly at the end of its timeout period. Because 3234 of that, clients using IDLE are advised to terminate the IDLE and re- 3235 issue it at least every 29 minutes to avoid being logged off. This 3236 still allows a client to receive immediate mailbox updates even 3237 though it need only "poll" at half hour intervals. 3239 Example: C: A001 SELECT INBOX 3240 S: * FLAGS (\Deleted \Seen \Flagged) 3241 S: * OK [PERMANENTFLAGS (\Deleted \Seen \Flagged)] Limited 3242 S: * 3 EXISTS 3243 S: * OK [UIDVALIDITY 1] 3244 S: A001 OK [READ-WRITE] SELECT completed 3245 C: A002 IDLE 3246 S: + idling 3247 ...time passes; new mail arrives... 3248 S: * 4 EXISTS 3249 C: DONE 3250 S: A002 OK IDLE terminated 3251 ...another client expunges message 2 now... 3252 C: A003 FETCH 4 ALL 3253 S: * 4 FETCH (...) 3254 S: A003 OK FETCH completed 3255 C: A004 IDLE 3256 S: * 2 EXPUNGE 3257 S: * 3 EXISTS 3258 S: + idling 3259 ...time passes; another client expunges message 3... 3260 S: * 3 EXPUNGE 3261 S: * 2 EXISTS 3262 ...time passes; new mail arrives... 3263 S: * 3 EXISTS 3264 C: DONE 3265 S: A004 OK IDLE terminated 3266 C: A005 FETCH 3 ALL 3267 S: * 3 FETCH (...) 3268 S: A005 OK FETCH completed 3269 C: A006 IDLE 3271 6.4. Client Commands - Selected State 3273 In the selected state, commands that manipulate messages in a mailbox 3274 are permitted. 3276 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 3277 and the authenticated state commands (SELECT, EXAMINE, NAMESPACE, 3278 CREATE, DELETE, RENAME, SUBSCRIBE, UNSUBSCRIBE, LIST, STATUS, and 3279 APPEND), the following commands are valid in the selected state: 3280 CLOSE, UNSELECT, EXPUNGE, SEARCH, FETCH, STORE, COPY, MOVE, and UID. 3282 6.4.1. CLOSE Command 3284 Arguments: none 3286 Responses: no specific responses for this command 3287 Result: OK - close completed, now in authenticated state 3288 BAD - command unknown or arguments invalid 3290 The CLOSE command permanently removes all messages that have the 3291 \Deleted flag set from the currently selected mailbox, and returns to 3292 the authenticated state from the selected state. No untagged EXPUNGE 3293 responses are sent. 3295 No messages are removed, and no error is given, if the mailbox is 3296 selected by an EXAMINE command or is otherwise selected read-only. 3298 Even if a mailbox is selected, a SELECT, EXAMINE, or LOGOUT command 3299 MAY be issued without previously issuing a CLOSE command. The 3300 SELECT, EXAMINE, and LOGOUT commands implicitly close the currently 3301 selected mailbox without doing an expunge. However, when many 3302 messages are deleted, a CLOSE-LOGOUT or CLOSE-SELECT sequence is 3303 considerably faster than an EXPUNGE-LOGOUT or EXPUNGE-SELECT because 3304 no untagged EXPUNGE responses (which the client would probably 3305 ignore) are sent. 3307 Example: C: A341 CLOSE 3308 S: A341 OK CLOSE completed 3310 6.4.2. UNSELECT Command 3312 Arguments: none 3314 Responses: no specific responses for this command 3316 Result: OK - unselect completed, now in authenticated state 3317 BAD - no mailbox selected, or argument supplied but none 3318 permitted 3320 The UNSELECT command frees server's resources associated with the 3321 selected mailbox and returns the server to the authenticated state. 3322 This command performs the same actions as CLOSE, except that no 3323 messages are permanently removed from the currently selected mailbox. 3325 Example: C: A342 UNSELECT 3326 S: A342 OK Unselect completed 3328 6.4.3. EXPUNGE Command 3330 Arguments: none 3332 Responses: untagged responses: EXPUNGE 3334 Result: OK - expunge completed 3335 NO - expunge failure: can't expunge (e.g., permission 3336 denied) 3337 BAD - command unknown or arguments invalid 3339 The EXPUNGE command permanently removes all messages that have the 3340 \Deleted flag set from the currently selected mailbox. Before 3341 returning an OK to the client, an untagged EXPUNGE response is sent 3342 for each message that is removed. 3344 Example: C: A202 EXPUNGE 3345 S: * 3 EXPUNGE 3346 S: * 3 EXPUNGE 3347 S: * 5 EXPUNGE 3348 S: * 8 EXPUNGE 3349 S: A202 OK EXPUNGE completed 3351 Note: In this example, messages 3, 4, 7, and 11 had the \Deleted flag 3352 set. See the description of the EXPUNGE response for further 3353 explanation. 3355 6.4.4. SEARCH Command 3357 Arguments: OPTIONAL result specifier 3358 OPTIONAL [CHARSET] specification 3359 searching criteria (one or more) 3361 Responses: OPTIONAL untagged response: ESEARCH 3363 Result: OK - search completed 3364 NO - search error: can't search that [CHARSET] or 3365 criteria 3366 BAD - command unknown or arguments invalid 3368 The SEARCH command searches the mailbox for messages that match the 3369 given searching criteria. 3371 The SEARCH command may contain result options. Result options 3372 control what kind of information is returned about messages matching 3373 the search criteria in an untagged ESEARCH response. If no result 3374 option is specified or empty list of options is specified "()", ALL 3375 is assumed (see below). The order of individual options is 3376 arbitrary. Individual options may contain parameters enclosed in 3377 parentheses (*). If an option has parameters, they consist of atoms 3378 and/or strings and/or lists in a specific order. Any options not 3379 defined by extensions that the server supports must be rejected with 3380 a BAD response. 3382 (*) - if an option has a mandatory parameter, which can always be 3383 represented as a number or a sequence-set, the option parameter does 3384 not need the enclosing (). See ABNF for more details. 3386 This document specifies the following result options: 3388 MIN 3390 Return the lowest message number/UID that satisfies the SEARCH 3391 criteria. 3393 If the SEARCH results in no matches, the server MUST NOT 3394 include the MIN result option in the ESEARCH response; however, 3395 it still MUST send the ESEARCH response. 3397 MAX 3399 Return the highest message number/UID that satisfies the SEARCH 3400 criteria. 3402 If the SEARCH results in no matches, the server MUST NOT 3403 include the MAX result option in the ESEARCH response; however, 3404 it still MUST send the ESEARCH response. 3406 ALL 3408 Return all message numbers/UIDs that satisfy the SEARCH 3409 criteria using the sequence-set syntax. Note, the client MUST 3410 NOT assume that messages/UIDs will be listed in any particular 3411 order. 3413 If the SEARCH results in no matches, the server MUST NOT 3414 include the ALL result option in the ESEARCH response; however, 3415 it still MUST send the ESEARCH response. 3417 COUNT Return number of the messages that satisfy the SEARCH 3418 criteria. This result option MUST always be included in the 3419 ESEARCH response. 3421 SAVE 3423 This option tells the server to remember the result of the 3424 SEARCH or UID SEARCH command (as well as any command based on 3425 SEARCH, e.g., SORT and THREAD [RFC5256]>) and store it in an 3426 internal variable that we will reference as the "search result 3427 variable". The client can use the "$" marker to reference the 3428 content of this internal variable. The "$" marker can be used 3429 instead of message sequence or UID sequence in order to 3430 indicate that the server should substitute it with the list of 3431 messages from the search result variable. Thus, the client can 3432 use the result of the latest remembered SEARCH command as a 3433 parameter to another command. See Section 6.4.4.1 for details 3434 on how the value of the search result variable is determined, 3435 how it is affected by other commands executed, and how SAVE 3436 return option interacts with other return options. 3438 In absence of any other SEARCH result option, the SAVE result 3439 option also suppresses any ESEARCH response that would have 3440 been otherwise returned by the SEARCH command. 3442 Note: future extensions to this document can allow servers to return 3443 multiple ESEARCH responses for a single extended SEARCH command. 3444 However all options specified above MUST result in a single ESEARCH 3445 response. These extensions will have to describe how results from 3446 multiple ESEARCH responses are to be amalgamated. 3448 Searching criteria consist of one or more search keys. 3450 When multiple keys are specified, the result is the intersection (AND 3451 function) of all the messages that match those keys. For example, 3452 the criteria DELETED FROM "SMITH" SINCE 1-Feb-1994 refers to all 3453 deleted messages from Smith with INTERNALDATE greater than February 3454 1, 1994. A search key can also be a parenthesized list of one or 3455 more search keys (e.g., for use with the OR and NOT keys). 3457 Server implementations MAY exclude [MIME-IMB] body parts with 3458 terminal content media types other than TEXT and MESSAGE from 3459 consideration in SEARCH matching. 3461 The OPTIONAL [CHARSET] specification consists of the word "CHARSET" 3462 followed by a registered [CHARSET] [CHARSET-REG]. It indicates the 3463 [CHARSET] of the strings that appear in the search criteria. 3464 [MIME-IMB] content transfer encodings, and [MIME-HDRS] strings in 3465 [RFC-5322]/[MIME-IMB] headers, MUST be decoded before comparing text. 3466 Servers MUST support US-ASCII and UTF-8 charsets; other [CHARSET]s 3467 MAY be supported. Clients SHOULD use UTF-8. Note that if "CHARSET" 3468 is not provided IMAP4rev2 server MUST assume UTF-8, so selecting 3469 CHARSET UTF-8 is redundant. It is permitted for improved 3470 compatibility with existing IMAP4rev1 clients. 3472 If the server does not support the specified [CHARSET], it MUST 3473 return a tagged NO response (not a BAD). This response SHOULD 3474 contain the BADCHARSET response code, which MAY list the [CHARSET]s 3475 supported by the server. 3477 In all search keys that use strings, a message matches the key if the 3478 string is a substring of the associated text. The matching SHOULD be 3479 case-insensitive for characters within ASCII range. Consider using 3480 [IMAP-I18N] for language-sensitive case-insensitive searching. Note 3481 that the empty string is a substring; this is useful when doing a 3482 HEADER search in order to test for a header field presence in the 3483 message. 3485 The defined search keys are as follows. Refer to the Formal Syntax 3486 section for the precise syntactic definitions of the arguments. 3488 Messages with message sequence numbers corresponding 3489 to the specified message sequence number set. 3491 ALL All messages in the mailbox; the default initial key for ANDing. 3493 ANSWERED Messages with the \Answered flag set. 3495 BCC Messages that contain the specified string in the 3496 envelope structure's BCC field. 3498 BEFORE Messages whose internal date (disregarding time and 3499 timezone) is earlier than the specified date. 3501 BODY Messages that contain the specified string in the body 3502 of the message. Unlike TEXT (see below), this doesn't match any 3503 header fields. 3505 CC Messages that contain the specified string in the 3506 envelope structure's CC field. 3508 DELETED Messages with the \Deleted flag set. 3510 DRAFT Messages with the \Draft flag set. 3512 FLAGGED Messages with the \Flagged flag set. 3514 FROM Messages that contain the specified string in the 3515 envelope structure's FROM field. 3517 HEADER Messages that have a header with the 3518 specified field-name (as defined in [RFC-5322]) and that contains 3519 the specified string in the text of the header (what comes after 3520 the colon). If the string to search is zero-length, this matches 3521 all messages that have a header line with the specified field-name 3522 regardless of the contents. Servers should use substring search 3523 for this SEARCH item, as clients can use it for automatic 3524 processing not initiated by end users. For example this can be 3525 used for searching for Message-ID or Content-Type header field 3526 values that need to be exact, or for searches in header fields 3527 that the IMAP server might not know anything about. 3529 KEYWORD Messages with the specified keyword flag set. 3531 LARGER Messages with an [RFC-5322] size larger than the 3532 specified number of octets. 3534 NOT Messages that do not match the specified search 3535 key. 3537 ON Messages whose internal date (disregarding time and 3538 timezone) is within the specified date. 3540 OR Messages that match either search 3541 key. 3543 SEEN Messages that have the \Seen flag set. 3545 SENTBEFORE Messages whose [RFC-5322] Date: header 3546 (disregarding time and timezone) is earlier than the specified 3547 date. 3549 SENTON Messages whose [RFC-5322] Date: header (disregarding 3550 time and timezone) is within the specified date. 3552 SENTSINCE Messages whose [RFC-5322] Date: header 3553 (disregarding time and timezone) is within or later than the 3554 specified date. 3556 SINCE Messages whose internal date (disregarding time and 3557 timezone) is within or later than the specified date. 3559 SMALLER Messages with an [RFC-5322] size smaller than the 3560 specified number of octets. 3562 SUBJECT Messages that contain the specified string in the 3563 envelope structure's SUBJECT field. 3565 TEXT Messages that contain the specified string in the 3566 header (including MIME header fields) or body of the message. 3568 TO Messages that contain the specified string in the 3569 envelope structure's TO field. 3571 UID Messages with unique identifiers corresponding to 3572 the specified unique identifier set. Sequence set ranges are 3573 permitted. 3575 UNANSWERED Messages that do not have the \Answered flag set. 3577 UNDELETED Messages that do not have the \Deleted flag set. 3579 UNDRAFT Messages that do not have the \Draft flag set. 3581 UNFLAGGED Messages that do not have the \Flagged flag set. 3583 UNKEYWORD Messages that do not have the specified keyword 3584 flag set. 3586 UNSEEN Messages that do not have the \Seen flag set. 3588 Example: C: A282 SEARCH RETURN (MIN COUNT) FLAGGED 3589 SINCE 1-Feb-1994 NOT FROM "Smith" 3590 S: * ESEARCH (TAG "A282") MIN 2 COUNT 3 3591 S: A282 OK SEARCH completed 3593 Example: C: A283 SEARCH RETURN () FLAGGED 3594 SINCE 1-Feb-1994 NOT FROM "Smith" 3595 S: * ESEARCH (TAG "A283") ALL 2,10:11 3596 S: A283 OK SEARCH completed 3598 Example: C: A284 SEARCH TEXT "string not in mailbox" 3599 S: * ESEARCH (TAG "A284") 3600 S: A284 OK SEARCH completed 3601 C: A285 SEARCH CHARSET UTF-8 TEXT {6} 3602 S: + Ready for literal text 3603 C: XXXXXX 3604 S: * ESEARCH (TAG "A285") ALL 43 3605 S: A285 OK SEARCH completed 3607 Note: Since this document is restricted to 7-bit ASCII text, it is 3608 not possible to show actual UTF-8 data. The "XXXXXX" is a 3609 placeholder for what would be 6 octets of 8-bit data in an actual 3610 transaction. 3612 The following example demonstrates finding the first unseen message 3613 in the mailbox: 3615 Example: C: A284 SEARCH RETURN (MIN) UNSEEN 3616 S: * ESEARCH (TAG "A284") MIN 4 3617 S: A284 OK SEARCH completed 3619 The following example demonstrates that if the ESEARCH UID indicator 3620 is present, all data in the ESEARCH response is referring to UIDs; 3621 for example, the MIN result specifier will be followed by a UID. 3623 Example: C: A285 UID SEARCH RETURN (MIN MAX) 1:5000 3624 S: * ESEARCH (TAG "A285") UID MIN 7 MAX 3800 3625 S: A285 OK SEARCH completed 3627 The following example demonstrates returning the number of deleted 3628 messages: 3630 Example: C: A286 SEARCH RETURN (COUNT) DELETED 3631 S: * ESEARCH (TAG "A286") COUNT 15 3632 S: A286 OK SEARCH completed 3634 6.4.4.1. SAVE result option and SEARCH result variable 3636 Upon successful completion of a SELECT or an EXAMINE command (after 3637 the tagged OK response), the current search result variable is reset 3638 to the empty sequence. 3640 A successful SEARCH command with the SAVE result option sets the 3641 value of the search result variable to the list of messages found in 3642 the SEARCH command. For example, if no messages were found, the 3643 search result variable will contain the empty sequence. 3645 Any of the following SEARCH commands MUST NOT change the search 3646 result variable: 3648 a SEARCH command that caused the server to return the BAD tagged 3649 response, 3651 a SEARCH command with no SAVE result option that caused the server 3652 to return NO tagged response, 3654 a successful SEARCH command with no SAVE result option. 3656 A SEARCH command with the SAVE result option that caused the server 3657 to return the NO tagged response sets the value of the search result 3658 variable to the empty sequence. 3660 When a message listed in the search result variable is EXPUNGEd, it 3661 is automatically removed from the list. Implementors are reminded 3662 that if the server stores the list as a list of message numbers, it 3663 MUST automatically adjust them when notifying the client about 3664 expunged messages, as described in Section 7.4.1. 3666 If the server decides to send a new UIDVALIDITY value while the 3667 mailbox is opened, this causes resetting of the search variable to 3668 the empty sequence. 3670 Note that even if the "$" marker contains the empty sequence of 3671 messages, it must be treated by all commands accepting message sets 3672 as parameters as a valid, but non-matching list of messages. For 3673 example, the "FETCH $" command would return a tagged OK response and 3674 no FETCH responses. See also the Example 5 in Section 6.4.4.4. 3676 The SAVE result option doesn't change whether the server would return 3677 items corresponding to MIN, MAX, ALL, or COUNT result options. 3679 When the SAVE result option is combined with the MIN or MAX result 3680 option, and both ALL and COUNT result options are absent, the 3681 corresponding MIN/MAX is returned (if the search result is not 3682 empty), but the "$" marker would contain a single message as returned 3683 in the MIN/MAX return item. 3685 If the SAVE result option is combined with both MIN and MAX result 3686 options, and both ALL and COUNT result options are absent, the "$" 3687 marker would contain zero, one or two messages as returned in the 3688 MIN/MAX return items. 3690 If the SAVE result option is combined with the ALL and/or COUNT 3691 result option(s), the "$" marker would always contain all messages 3692 found by the SEARCH or UID SEARCH command. 3694 The following table summarizes the additional requirement on ESEARCH 3695 server implementations described in this section. 3697 +------------------------------+--------------------+ 3698 | Combination of Result option | "$" marker value | 3699 +------------------------------+--------------------+ 3700 | SAVE MIN | MIN | 3701 | SAVE MAX | MAX | 3702 | SAVE MIN MAX | MIN & MAX | 3703 | SAVE * [m] | all found messages | 3704 +------------------------------+--------------------+ 3706 where '*' means "ALL" and/or "COUNT", and '[m]' means optional "MIN" 3707 and/or "MAX" 3709 Implementation note: server implementors should note that "$" can 3710 reference IMAP message sequences or UID sequences, depending on the 3711 context where it is used. For example, the "$" marker can be set as 3712 a result of a SEARCH (SAVE) command and used as a parameter to a UID 3713 FETCH command (which accepts a UID sequence, not a message sequence), 3714 or the "$" marker can be set as a result of a UID SEARCH (SAVE) 3715 command and used as a parameter to a FETCH command (which accepts a 3716 message sequence, not a UID sequence). Server implementations need 3717 to automatically map the "$" marker value to message numbers or UIDs, 3718 depending on context where the "$" marker is used. 3720 6.4.4.2. Multiple Commands in Progress 3722 Use of a SEARCH RETURN (SAVE) command followed by a command using the 3723 "$" marker creates direct dependency between the two commands. As 3724 directed by Section 5.5, a server MUST execute the two commands in 3725 the order they were received. 3727 A client MAY pipeline a SEARCH RETURN (SAVE) command with one or more 3728 command using the "$" marker, as long as this doesn't create an 3729 ambiguity, as described in by Section 5.5. Examples 7-9 in 3730 Section 6.4.4.4 explain this in more details. 3732 6.4.4.3. Refusing to Save Search Results 3734 In some cases, the server MAY refuse to save a SEARCH (SAVE) result, 3735 for example, if an internal limit on the number of saved results is 3736 reached. In this case, the server MUST return a tagged NO response 3737 containing the NOTSAVED response code and set the search result 3738 variable to the empty sequence, as described in Section 6.4.4.1. 3740 6.4.4.4. Examples showing use of SAVE result option 3742 Only in this section: explanatory comments in examples that start 3743 with // are not part of the protocol. 3745 1) The following example demonstrates how the client can use the 3746 result of a SEARCH command to FETCH headers of interesting messages: 3748 Example 1: 3749 C: A282 SEARCH RETURN (SAVE) FLAGGED SINCE 1-Feb-1994 3750 NOT FROM "Smith" 3751 S: A282 OK SEARCH completed, result saved 3752 C: A283 FETCH $ (UID INTERNALDATE FLAGS BODY.PEEK[HEADER]) 3753 S: * 2 FETCH (UID 14 ... 3754 S: * 84 FETCH (UID 100 ... 3755 S: * 882 FETCH (UID 1115 ... 3756 S: A283 OK completed 3758 The client can also pipeline the two commands: 3760 Example 2: 3761 C: A282 SEARCH RETURN (SAVE) FLAGGED SINCE 1-Feb-1994 3762 NOT FROM "Smith" 3763 C: A283 FETCH $ (UID INTERNALDATE FLAGS BODY.PEEK[HEADER]) 3764 S: A282 OK SEARCH completed 3765 S: * 2 FETCH (UID 14 ... 3766 S: * 84 FETCH (UID 100 ... 3767 S: * 882 FETCH (UID 1115 ... 3768 S: A283 OK completed 3770 2) The following example demonstrates that the result of one SEARCH 3771 command can be used as input to another SEARCH command: 3773 Example 3: 3774 C: A300 SEARCH RETURN (SAVE) SINCE 1-Jan-2004 3775 NOT FROM "Smith" 3776 S: A300 OK SEARCH completed 3777 C: A301 UID SEARCH UID $ SMALLER 4096 3778 S: * ESEARCH (TAG "A301") UID ALL 17,900,901 3779 S: A301 OK completed 3781 Note that the second command in Example 3 can be replaced with: 3782 C: A301 UID SEARCH $ SMALLER 4096 3783 and the result of the command would be the same. 3785 3) The following example shows that the "$" marker can be combined 3786 with other message numbers using the OR SEARCH criterion. 3788 Example 4: 3789 C: P282 SEARCH RETURN (SAVE) SINCE 1-Feb-1994 3790 NOT FROM "Smith" 3791 S: P282 OK SEARCH completed 3792 C: P283 SEARCH CHARSET UTF-8 (OR $ 1,3000:3021) TEXT {8} 3793 C: YYYYYYYY 3794 S: * ESEARCH (TAG "P283") ALL 882,1102,3003,3005:3006 3795 S: P283 OK completed 3797 Note: Since this document format is restricted to 7-bit ASCII text, 3798 it is not possible to show actual UTF-8 data. The "YYYYYYYY" is a 3799 placeholder for what would be 8 octets of 8-bit data in an actual 3800 transaction. 3802 4) The following example demonstrates that a failed SEARCH sets the 3803 search result variable to the empty list. The server doesn't 3804 implement the KOI8-R charset. 3806 Example 5: 3807 C: B282 SEARCH RETURN (SAVE) SINCE 1-Feb-1994 3808 NOT FROM "Smith" 3809 S: B282 OK SEARCH completed 3810 C: B283 SEARCH RETURN (SAVE) CHARSET KOI8-R 3811 (OR $ 1,3000:3021) TEXT {4} 3812 C: XXXX 3813 S: B283 NO [BADCHARSET UTF-8] KOI8-R is not supported 3814 //After this command the saved result variable contains 3815 //no messages. A client that wants to reissue the B283 3816 //SEARCH command with another CHARSET would have to reissue 3817 //the B282 command as well. One possible workaround for 3818 //this is to include the desired CHARSET parameter 3819 //in the earliest SEARCH RETURN (SAVE) command in a 3820 //sequence of related SEARCH commands, to cause 3821 //the earliest SEARCH in the sequence to fail. 3822 //A better approach might be to always use CHARSET UTF-8 3823 //instead. 3825 Note: Since this document format is restricted to 7-bit ASCII text, 3826 it is not possible to show actual KOI8-R data. The "XXXX" is a 3827 placeholder for what would be 4 octets of 8-bit data in an actual 3828 transaction. 3830 5) The following example demonstrates that it is not an error to use 3831 the "$" marker when it contains no messages. 3833 Example 6: 3834 C: E282 SEARCH RETURN (SAVE) SINCE 28-Oct-2006 3835 NOT FROM "Eric" 3836 C: E283 COPY $ "Other Messages" 3837 //The "$" contains no messages 3838 S: E282 OK SEARCH completed 3839 S: E283 OK COPY completed, nothing copied 3841 Example 7: 3842 C: F282 SEARCH RETURN (SAVE) KEYWORD $Junk 3843 C: F283 COPY $ "Junk" 3844 C: F284 STORE $ +FLAGS.Silent (\Deleted) 3845 S: F282 OK SEARCH completed 3846 S: F283 OK COPY completed 3847 S: F284 OK STORE completed 3849 Example 8: 3850 C: G282 SEARCH RETURN (SAVE) KEYWORD $Junk 3851 C: G283 SEARCH RETURN (ALL) SINCE 28-Oct-2006 3852 FROM "Eric" 3853 // The server can execute the two SEARCH commands 3854 // in any order, as they don't have any dependency. 3855 // For example, it may return: 3856 S: * ESEARCH (TAG "G283") ALL 3:15,27,29:103 3857 S: G283 OK SEARCH completed 3858 S: G282 OK SEARCH completed 3860 The following example demonstrates that the result of the second 3861 SEARCH RETURN (SAVE) always overrides the result of the first. 3863 Example 9: 3864 C: H282 SEARCH RETURN (SAVE) KEYWORD $Junk 3865 C: H283 SEARCH RETURN (SAVE) SINCE 28-Oct-2006 3866 FROM "Eric" 3867 S: H282 OK SEARCH completed 3868 S: H283 OK SEARCH completed 3869 // At this point "$" would contain results of H283 3871 The following example demonstrates behavioral difference for 3872 different combinations of ESEARCH result options. 3874 Example 10: 3875 C: C282 SEARCH RETURN (ALL) SINCE 12-Feb-2006 3876 NOT FROM "Smith" 3877 S: * ESEARCH (TAG "C283") ALL 2,10:15,21 3878 //$ value hasn't changed 3879 S: C282 OK SEARCH completed 3881 C: C283 SEARCH RETURN (ALL SAVE) SINCE 12-Feb-2006 3882 NOT FROM "Smith" 3883 S: * ESEARCH (TAG "C283") ALL 2,10:15,21 3884 //$ value is 2,10:15,21 3885 S: C283 OK SEARCH completed 3887 C: C284 SEARCH RETURN (SAVE MIN) SINCE 12-Feb-2006 3888 NOT FROM "Smith" 3889 S: * ESEARCH (TAG "C284") MIN 2 3890 //$ value is 2 3891 S: C284 OK SEARCH completed 3893 C: C285 SEARCH RETURN (MAX SAVE MIN) SINCE 3894 12-Feb-2006 NOT FROM "Smith" 3895 S: * ESEARCH (TAG "C285") MIN 2 MAX 21 3896 //$ value is 2,21 3897 S: C285 OK SEARCH completed 3899 C: C286 SEARCH RETURN (MAX SAVE MIN COUNT) 3900 SINCE 12-Feb-2006 NOT FROM "Smith" 3901 S: * ESEARCH (TAG "C286") MIN 2 MAX 21 COUNT 8 3902 //$ value is 2,10:15,21 3903 S: C286 OK SEARCH completed 3905 C: C286 SEARCH RETURN (ALL SAVE MIN) SINCE 3906 12-Feb-2006 NOT FROM "Smith" 3907 S: * ESEARCH (TAG "C286") MIN 2 ALL 2,10:15,21 3908 //$ value is 2,10:15,21 3909 S: C286 OK SEARCH completed 3911 6.4.5. FETCH Command 3913 Arguments: sequence set 3914 message data item names or macro 3916 Responses: untagged responses: FETCH 3918 Result: OK - fetch completed 3919 NO - fetch error: can't fetch that data 3920 BAD - command unknown or arguments invalid 3922 The FETCH command retrieves data associated with a message in the 3923 mailbox. The data items to be fetched can be either a single atom or 3924 a parenthesized list. 3926 Most data items, identified in the formal syntax under the msg-att- 3927 static rule, are static and MUST NOT change for any particular 3928 message. Other data items, identified in the formal syntax under the 3929 msg-att-dynamic rule, MAY change, either as a result of a STORE 3930 command or due to external events. 3932 For example, if a client receives an ENVELOPE for a message when 3933 it already knows the envelope, it can safely ignore the newly 3934 transmitted envelope. 3936 There are three macros which specify commonly-used sets of data 3937 items, and can be used instead of data items. A macro must be used 3938 by itself, and not in conjunction with other macros or data items. 3940 ALL Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE) 3942 FAST Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE) 3944 FULL Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE 3945 BODY) 3947 The currently defined data items that can be fetched are: 3949 BINARY[]<> 3951 Requests that the specified section be transmitted after 3952 performing Content-Transfer-Encoding-related decoding. 3954 The argument, if present, requests that a subset of 3955 the data be returned. The semantics of a partial FETCH BINARY 3956 command are the same as for a partial FETCH BODY command, with 3957 the exception that the arguments refer to the DECODED 3958 section data. 3960 BINARY.PEEK[]<> An alternate form of 3961 BINARY[] that does not implicitly set the \Seen 3962 flag. 3964 BINARY.SIZE[] 3966 Requests the decoded size of the section (i.e., the size to 3967 expect in response to the corresponding FETCH BINARY request). 3969 Note: client authors are cautioned that this might be an 3970 expensive operation for some server implementations. 3971 Needlessly issuing this request could result in degraded 3972 performance due to servers having to calculate the value every 3973 time the request is issued. 3975 BODY Non-extensible form of BODYSTRUCTURE. 3977 BODY[
]<> 3979 The text of a particular body section. The section 3980 specification is a set of zero or more part specifiers 3981 delimited by periods. A part specifier is either a part number 3982 or one of the following: HEADER, HEADER.FIELDS, 3983 HEADER.FIELDS.NOT, MIME, and TEXT. An empty section 3984 specification refers to the entire message, including the 3985 header. 3987 Every message has at least one part number. Non-[MIME-IMB] 3988 messages, and non-multipart [MIME-IMB] messages with no 3989 encapsulated message, only have a part 1. 3991 Multipart messages are assigned consecutive part numbers, as 3992 they occur in the message. If a particular part is of type 3993 message or multipart, its parts MUST be indicated by a period 3994 followed by the part number within that nested multipart part. 3996 A part of type MESSAGE/RFC822 or MESSAGE/GLOBAL also has nested 3997 part numbers, referring to parts of the MESSAGE part's body. 3999 The HEADER, HEADER.FIELDS, HEADER.FIELDS.NOT, and TEXT part 4000 specifiers can be the sole part specifier or can be prefixed by 4001 one or more numeric part specifiers, provided that the numeric 4002 part specifier refers to a part of type MESSAGE/RFC822 or 4003 MESSAGE/GLOBAL. The MIME part specifier MUST be prefixed by 4004 one or more numeric part specifiers. 4006 The HEADER, HEADER.FIELDS, and HEADER.FIELDS.NOT part 4007 specifiers refer to the [RFC-5322] header of the message or of 4008 an encapsulated [MIME-IMT] MESSAGE/RFC822 or MESSAGE/GLOBAL 4009 message. HEADER.FIELDS and HEADER.FIELDS.NOT are followed by a 4010 list of field-name (as defined in [RFC-5322]) names, and return 4011 a subset of the header. The subset returned by HEADER.FIELDS 4012 contains only those header fields with a field-name that 4013 matches one of the names in the list; similarly, the subset 4014 returned by HEADER.FIELDS.NOT contains only the header fields 4015 with a non-matching field-name. The field-matching is ASCII 4016 range case-insensitive but otherwise exact. Subsetting does 4017 not exclude the [RFC-5322] delimiting blank line between the 4018 header and the body; the blank line is included in all header 4019 fetches, except in the case of a message which has no body and 4020 no blank line. 4022 The MIME part specifier refers to the [MIME-IMB] header for 4023 this part. 4025 The TEXT part specifier refers to the text body of the message, 4026 omitting the [RFC-5322] header. 4028 Here is an example of a complex message with some of its 4029 part specifiers: 4031 HEADER ([RFC-5322] header of the message) 4032 TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 4033 1 TEXT/PLAIN 4034 2 APPLICATION/OCTET-STREAM 4035 3 MESSAGE/RFC822 4036 3.HEADER ([RFC-5322] header of the message) 4037 3.TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 4038 3.1 TEXT/PLAIN 4039 3.2 APPLICATION/OCTET-STREAM 4040 4 MULTIPART/MIXED 4041 4.1 IMAGE/GIF 4042 4.1.MIME ([MIME-IMB] header for the IMAGE/GIF) 4043 4.2 MESSAGE/RFC822 4044 4.2.HEADER ([RFC-5322] header of the message) 4045 4.2.TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 4046 4.2.1 TEXT/PLAIN 4047 4.2.2 MULTIPART/ALTERNATIVE 4048 4.2.2.1 TEXT/PLAIN 4049 4.2.2.2 TEXT/RICHTEXT 4051 It is possible to fetch a substring of the designated text. 4052 This is done by appending an open angle bracket ("<"), the 4053 octet position of the first desired octet, a period, the 4054 maximum number of octets desired, and a close angle bracket 4055 (">") to the part specifier. If the starting octet is beyond 4056 the end of the text, an empty string is returned. 4058 Any partial fetch that attempts to read beyond the end of the 4059 text is truncated as appropriate. A partial fetch that starts 4060 at octet 0 is returned as a partial fetch, even if this 4061 truncation happened. 4063 Note: This means that BODY[]<0.2048> of a 1500-octet message 4064 will return BODY[]<0> with a literal of size 1500, not 4065 BODY[]. 4067 Note: A substring fetch of a HEADER.FIELDS or 4068 HEADER.FIELDS.NOT part specifier is calculated after 4069 subsetting the header. 4071 The \Seen flag is implicitly set; if this causes the flags to 4072 change, they SHOULD be included as part of the FETCH responses. 4074 BODY.PEEK[
]<> An alternate form of BODY[
] 4075 that does not implicitly set the \Seen flag. 4077 BODYSTRUCTURE The [MIME-IMB] body structure of the message. This is 4078 computed by the server by parsing the [MIME-IMB] header fields in 4079 the [RFC-5322] header and [MIME-IMB] headers. 4081 ENVELOPE The envelope structure of the message. This is computed by 4082 the server by parsing the [RFC-5322] header into the component 4083 parts, defaulting various fields as necessary. 4085 FLAGS The flags that are set for this message. 4087 INTERNALDATE The internal date of the message. 4089 RFC822.SIZE The [RFC-5322] size of the message. 4091 UID The unique identifier for the message. 4093 Example: C: A654 FETCH 2:4 (FLAGS BODY[HEADER.FIELDS (DATE FROM)]) 4094 S: * 2 FETCH .... 4095 S: * 3 FETCH .... 4096 S: * 4 FETCH .... 4097 S: A654 OK FETCH completed 4099 6.4.6. STORE Command 4101 Arguments: sequence set 4102 message data item name 4103 value for message data item 4105 Responses: untagged responses: FETCH 4107 Result: OK - store completed 4108 NO - store error: can't store that data 4109 BAD - command unknown or arguments invalid 4111 The STORE command alters data associated with a message in the 4112 mailbox. Normally, STORE will return the updated value of the data 4113 with an untagged FETCH response. A suffix of ".SILENT" in the data 4114 item name prevents the untagged FETCH, and the server SHOULD assume 4115 that the client has determined the updated value itself or does not 4116 care about the updated value. 4118 Note: Regardless of whether or not the ".SILENT" suffix was used, 4119 the server SHOULD send an untagged FETCH response if a change to a 4120 message's flags from an external source is observed. The intent 4121 is that the status of the flags is determinate without a race 4122 condition. 4124 The currently defined data items that can be stored are: 4126 FLAGS Replace the flags for the message with the 4127 argument. The new value of the flags is returned as if a FETCH of 4128 those flags was done. 4130 FLAGS.SILENT Equivalent to FLAGS, but without returning 4131 a new value. 4133 +FLAGS Add the argument to the flags for the message. 4134 The new value of the flags is returned as if a FETCH of those 4135 flags was done. 4137 +FLAGS.SILENT Equivalent to +FLAGS, but without 4138 returning a new value. 4140 -FLAGS Remove the argument from the flags for the 4141 message. The new value of the flags is returned as if a FETCH of 4142 those flags was done. 4144 -FLAGS.SILENT Equivalent to -FLAGS, but without 4145 returning a new value. 4147 Example: C: A003 STORE 2:4 +FLAGS (\Deleted) 4148 S: * 2 FETCH (FLAGS (\Deleted \Seen)) 4149 S: * 3 FETCH (FLAGS (\Deleted)) 4150 S: * 4 FETCH (FLAGS (\Deleted \Flagged \Seen)) 4151 S: A003 OK STORE completed 4153 6.4.7. COPY Command 4155 Arguments: sequence set 4156 mailbox name 4158 Responses: no specific responses for this command 4159 Result: OK - copy completed 4160 NO - copy error: can't copy those messages or to that 4161 name 4162 BAD - command unknown or arguments invalid 4164 The COPY command copies the specified message(s) to the end of the 4165 specified destination mailbox. The flags and internal date of the 4166 message(s) SHOULD be preserved in the copy. 4168 If the destination mailbox does not exist, a server SHOULD return an 4169 error. It SHOULD NOT automatically create the mailbox. Unless it is 4170 certain that the destination mailbox can not be created, the server 4171 MUST send the response code "[TRYCREATE]" as the prefix of the text 4172 of the tagged NO response. This gives a hint to the client that it 4173 can attempt a CREATE command and retry the COPY if the CREATE is 4174 successful. 4176 If the COPY command is unsuccessful for any reason, server 4177 implementations MUST restore the destination mailbox to its state 4178 before the COPY attempt. 4180 On successful completion of a COPY, the server SHOULD return a 4181 COPYUID response code. 4183 In the case of a mailbox that has permissions set so that the client 4184 can COPY to the mailbox, but not SELECT or EXAMINE it, the server 4185 SHOULD NOT send an COPYUID response code as it would disclose 4186 information about the mailbox. 4188 In the case of a mailbox that has UIDNOTSTICKY status (see the 4189 UIDNOTSTICKY response code), the server MAY omit the COPYUID response 4190 code as it is not meaningful. 4192 If the server does not return the COPYUID response code, the client 4193 can discover this information by selecting the destination mailbox. 4194 The location of messages placed in the destination mailbox by COPY 4195 can be determined by using FETCH and/or SEARCH commands (e.g., for 4196 Message-ID). 4198 Example: C: A003 COPY 2:4 MEETING 4199 S: A003 OK COPY completed 4201 6.4.8. MOVE Command 4203 Arguments: sequence set 4204 mailbox name 4206 Responses: no specific responses for this command 4207 Result: OK - move completed 4208 NO - move error: can't move those messages or to that 4209 name 4210 BAD - command unknown or arguments invalid 4212 The MOVE command moves the specified message(s) to the end of the 4213 specified destination mailbox. The flags and internal date of the 4214 message(s) SHOULD be preserved. 4216 This means that a new message is created in the target mailbox with a 4217 new UID, the original message is removed from the source mailbox, and 4218 it appears to the client as a single action. This has the same 4219 effect for each message as this sequence: 4221 1. [UID] COPY 4223 2. [UID] STORE +FLAGS.SILENT \DELETED 4225 3. UID EXPUNGE 4227 Although the effect of the MOVE is the same as the preceding steps, 4228 the semantics are not identical: The intermediate states produced by 4229 those steps do not occur, and the response codes are different. In 4230 particular, though the COPY and EXPUNGE response codes will be 4231 returned, response codes for a STORE MUST NOT be generated and the 4232 \Deleted flag MUST NOT be set for any message. 4234 Because a MOVE applies to a set of messages, it might fail partway 4235 through the set. Regardless of whether the command is successful in 4236 moving the entire set, each individual message SHOULD either be moved 4237 or unaffected. The server MUST leave each message in a state where 4238 it is in at least one of the source or target mailboxes (no message 4239 can be lost or orphaned). The server SHOULD NOT leave any message in 4240 both mailboxes (it would be bad for a partial failure to result in a 4241 bunch of duplicate messages). This is true even if the server 4242 returns a tagged NO response to the command. 4244 Because of the similarity of MOVE to COPY, extensions that affect 4245 COPY affect MOVE in the same way. Response codes such as TRYCREATE 4246 (see Section 7.1), as well as those defined by extensions, are sent 4247 as appropriate. 4249 Servers SHOULD send COPYUID in response to a UID MOVE (see 4250 Section 6.4.9) command. For additional information see Section 7.1. 4252 Servers are also advised to send the COPYUID response code in an 4253 untagged OK before sending EXPUNGE or moved responses. (Sending 4254 COPYUID in the tagged OK, as described in the UIDPLUS specification, 4255 means that clients first receive an EXPUNGE for a message and 4256 afterwards COPYUID for the same message. It can be unnecessarily 4257 difficult to process that sequence usefully.) 4259 An example: 4260 C: a UID MOVE 42:69 foo 4261 S: * OK [COPYUID 432432 42:69 1202:1229] 4262 S: * 22 EXPUNGE 4263 S: (more expunges) 4264 S: a OK Done 4266 Note that the server may send unrelated EXPUNGE responses as well, if 4267 any happen to have been expunged at the same time; this is normal 4268 IMAP operation. 4270 Note that moving a message to the currently selected mailbox (that 4271 is, where the source and target mailboxes are the same) is allowed 4272 when copying the message to the currently selected mailbox is 4273 allowed. 4275 The server may send EXPUNGE responses before the tagged response, so 4276 the client cannot safely send more commands with message sequence 4277 number arguments while the server is processing MOVE. 4279 MOVE and UID MOVE can be pipelined with other commands, but care has 4280 to be taken. Both commands modify sequence numbers and also allow 4281 unrelated EXPUNGE responses. The renumbering of other messages in 4282 the source mailbox following any EXPUNGE response can be surprising 4283 and makes it unsafe to pipeline any command that relies on message 4284 sequence numbers after a MOVE or UID MOVE. Similarly, MOVE cannot be 4285 pipelined with a command that might cause message renumbering. See 4286 Section 5.5, for more information about ambiguities as well as 4287 handling requirements for both clients and servers. 4289 6.4.9. UID Command 4291 Arguments: command name 4292 command arguments 4294 Responses: untagged responses: FETCH, ESEARCH, EXPUNGE 4296 Result: OK - UID command completed 4297 NO - UID command error 4298 BAD - command unknown or arguments invalid 4300 The UID command has three forms. In the first form, it takes as its 4301 arguments a COPY, MOVE, FETCH, or STORE command with arguments 4302 appropriate for the associated command. However, the numbers in the 4303 sequence set argument are unique identifiers instead of message 4304 sequence numbers. Sequence set ranges are permitted, but there is no 4305 guarantee that unique identifiers will be contiguous. 4307 A non-existent unique identifier is ignored without any error message 4308 generated. Thus, it is possible for a UID FETCH command to return an 4309 OK without any data or a UID COPY, UID MOVE or UID STORE to return an 4310 OK without performing any operations. 4312 In the second form, the UID command takes an EXPUNGE command with an 4313 extra parameter the specified a sequence set of UIDs to operate on. 4314 The UID EXPUNGE command permanently removes all messages that both 4315 have the \Deleted flag set and have a UID that is included in the 4316 specified sequence set from the currently selected mailbox. If a 4317 message either does not have the \Deleted flag set or has a UID that 4318 is not included in the specified sequence set, it is not affected. 4320 UID EXPUNGE is particularly useful for disconnected use clients. 4321 By using UID EXPUNGE instead of EXPUNGE when resynchronizing with 4322 the server, the client can ensure that it does not inadvertantly 4323 remove any messages that have been marked as \Deleted by other 4324 clients between the time that the client was last connected and 4325 the time the client resynchronizes. 4327 Example: C: A003 UID EXPUNGE 3000:3002 4328 S: * 3 EXPUNGE 4329 S: * 3 EXPUNGE 4330 S: * 3 EXPUNGE 4331 S: A003 OK UID EXPUNGE completed 4333 In the third form, the UID command takes a SEARCH command with SEARCH 4334 command arguments. The interpretation of the arguments is the same 4335 as with SEARCH; however, the numbers returned in a ESEARCH response 4336 for a UID SEARCH command are unique identifiers instead of message 4337 sequence numbers. Also, the corresponding ESEARCH response MUST 4338 include the UID indicator. For example, the command UID SEARCH 1:100 4339 UID 443:557 returns the unique identifiers corresponding to the 4340 intersection of two sequence sets, the message sequence number range 4341 1:100 and the UID range 443:557. 4343 Note: in the above example, the UID range 443:557 appears. The 4344 same comment about a non-existent unique identifier being ignored 4345 without any error message also applies here. Hence, even if 4346 neither UID 443 or 557 exist, this range is valid and would 4347 include an existing UID 495. 4349 Also note that a UID range of 559:* always includes the UID of the 4350 last message in the mailbox, even if 559 is higher than any 4351 assigned UID value. This is because the contents of a range are 4352 independent of the order of the range endpoints. Thus, any UID 4353 range with * as one of the endpoints indicates at least one 4354 message (the message with the highest numbered UID), unless the 4355 mailbox is empty. 4357 The number after the "*" in an untagged FETCH or EXPUNGE response is 4358 always a message sequence number, not a unique identifier, even for a 4359 UID command response. However, server implementations MUST 4360 implicitly include the UID message data item as part of any FETCH 4361 response caused by a UID command, regardless of whether a UID was 4362 specified as a message data item to the FETCH. 4364 Note: The rule about including the UID message data item as part of a 4365 FETCH response primarily applies to the UID FETCH and UID STORE 4366 commands, including a UID FETCH command that does not include UID as 4367 a message data item. Although it is unlikely that the other UID 4368 commands will cause an untagged FETCH, this rule applies to these 4369 commands as well. 4371 Example: C: A999 UID FETCH 4827313:4828442 FLAGS 4372 S: * 23 FETCH (FLAGS (\Seen) UID 4827313) 4373 S: * 24 FETCH (FLAGS (\Seen) UID 4827943) 4374 S: * 25 FETCH (FLAGS (\Seen) UID 4828442) 4375 S: A999 OK UID FETCH completed 4377 6.5. Client Commands - Experimental/Expansion 4379 6.5.1. X Command 4381 Arguments: implementation defined 4383 Responses: implementation defined 4385 Result: OK - command completed 4386 NO - failure 4387 BAD - command unknown or arguments invalid 4389 Any command prefixed with an X is an experimental command. Commands 4390 which are not part of this specification, a standard or standards- 4391 track revision of this specification, or an IESG-approved 4392 experimental protocol, MUST use the X prefix. 4394 Any added untagged responses issued by an experimental command MUST 4395 also be prefixed with an X. Server implementations MUST NOT send any 4396 such untagged responses, unless the client requested it by issuing 4397 the associated experimental command. 4399 Example: C: a441 CAPABILITY 4400 S: * CAPABILITY IMAP4rev2 XPIG-LATIN 4401 S: a441 OK CAPABILITY completed 4402 C: A442 XPIG-LATIN 4403 S: * XPIG-LATIN ow-nay eaking-spay ig-pay atin-lay 4404 S: A442 OK XPIG-LATIN ompleted-cay 4406 7. Server Responses 4408 Server responses are in three forms: status responses, server data, 4409 and command continuation request. The information contained in a 4410 server response, identified by "Contents:" in the response 4411 descriptions below, is described by function, not by syntax. The 4412 precise syntax of server responses is described in the Formal Syntax 4413 section. 4415 The client MUST be prepared to accept any response at all times. 4417 Status responses can be tagged or untagged. Tagged status responses 4418 indicate the completion result (OK, NO, or BAD status) of a client 4419 command, and have a tag matching the command. 4421 Some status responses, and all server data, are untagged. An 4422 untagged response is indicated by the token "*" instead of a tag. 4423 Untagged status responses indicate server greeting, or server status 4424 that does not indicate the completion of a command (for example, an 4425 impending system shutdown alert). For historical reasons, untagged 4426 server data responses are also called "unsolicited data", although 4427 strictly speaking, only unilateral server data is truly 4428 "unsolicited". 4430 Certain server data MUST be recorded by the client when it is 4431 received; this is noted in the description of that data. Such data 4432 conveys critical information which affects the interpretation of all 4433 subsequent commands and responses (e.g., updates reflecting the 4434 creation or destruction of messages). 4436 Other server data SHOULD be recorded for later reference; if the 4437 client does not need to record the data, or if recording the data has 4438 no obvious purpose (e.g., a SEARCH response when no SEARCH command is 4439 in progress), the data SHOULD be ignored. 4441 An example of unilateral untagged server data occurs when the IMAP 4442 connection is in the selected state. In the selected state, the 4443 server checks the mailbox for new messages as part of command 4444 execution. Normally, this is part of the execution of every command; 4445 hence, a NOOP command suffices to check for new messages. If new 4446 messages are found, the server sends untagged EXISTS response 4447 reflecting the new size of the mailbox. Server implementations that 4448 offer multiple simultaneous access to the same mailbox SHOULD also 4449 send appropriate unilateral untagged FETCH and EXPUNGE responses if 4450 another agent changes the state of any message flags or expunges any 4451 messages. 4453 Command continuation request responses use the token "+" instead of a 4454 tag. These responses are sent by the server to indicate acceptance 4455 of an incomplete client command and readiness for the remainder of 4456 the command. 4458 7.1. Server Responses - Status Responses 4460 Status responses are OK, NO, BAD, PREAUTH and BYE. OK, NO, and BAD 4461 can be tagged or untagged. PREAUTH and BYE are always untagged. 4463 Status responses MAY include an OPTIONAL "response code". A response 4464 code consists of data inside square brackets in the form of an atom, 4465 possibly followed by a space and arguments. The response code 4466 contains additional information or status codes for client software 4467 beyond the OK/NO/BAD condition, and are defined when there is a 4468 specific action that a client can take based upon the additional 4469 information. 4471 The currently defined response codes are: 4473 ALERT 4475 The human-readable text contains a special alert that MUST be 4476 presented to the user in a fashion that calls the user's 4477 attention to the message. 4479 ALREADYEXISTS 4481 The operation attempts to create something that already exists, 4482 such as when the CREATE or RENAME directories attempt to create 4483 a mailbox and there is already one of that name. 4485 C: o356 RENAME this that 4486 S: o356 NO [ALREADYEXISTS] Mailbox "that" already exists 4488 APPENDUID 4490 Followed by the UIDVALIDITY of the destination mailbox and the 4491 UID assigned to the appended message in the destination 4492 mailbox, indicates that the message has been appended to the 4493 destination mailbox with that UID. 4495 If the server also supports the [MULTIAPPEND] extension, and if 4496 multiple messages were appended in the APPEND command, then the 4497 second value is a UID set containing the UIDs assigned to the 4498 appended messages, in the order they were transmitted in the 4499 APPEND command. This UID set may not contain extraneous UIDs 4500 or the symbol "*". 4502 Note: the UID set form of the APPENDUID response code MUST 4503 NOT be used if only a single message was appended. In 4504 particular, a server MUST NOT send a range such as 123:123. 4505 This is because a client that does not support [MULTIAPPEND] 4506 expects only a single UID and not a UID set. 4508 UIDs are assigned in strictly ascending order in the mailbox 4509 (refer to Section 2.3.1.1); note that a range of 12:10 is 4510 exactly equivalent to 10:12 and refers to the sequence 4511 10,11,12. 4513 This response code is returned in a tagged OK response to the 4514 APPEND command. 4516 AUTHENTICATIONFAILED 4518 Authentication failed for some reason on which the server is 4519 unwilling to elaborate. Typically, this includes "unknown 4520 user" and "bad password". 4522 This is the same as not sending any response code, except that 4523 when a client sees AUTHENTICATIONFAILED, it knows that the 4524 problem wasn't, e.g., UNAVAILABLE, so there's no point in 4525 trying the same login/password again later. 4527 C: b LOGIN "fred" "foo" 4528 S: b NO [AUTHENTICATIONFAILED] Authentication failed 4530 AUTHORIZATIONFAILED 4532 Authentication succeeded in using the authentication identity, 4533 but the server cannot or will not allow the authentication 4534 identity to act as the requested authorization identity. This 4535 is only applicable when the authentication and authorization 4536 identities are different. 4538 C: c1 AUTHENTICATE PLAIN 4539 [...] 4540 S: c1 NO [AUTHORIZATIONFAILED] No such authorization-ID 4541 C: c2 AUTHENTICATE PLAIN 4542 [...] 4543 S: c2 NO [AUTHORIZATIONFAILED] Authenticator is not an admin 4545 BADCHARSET 4547 Optionally followed by a parenthesized list of charsets. A 4548 SEARCH failed because the given charset is not supported by 4549 this implementation. If the optional list of charsets is 4550 given, this lists the charsets that are supported by this 4551 implementation. 4553 CANNOT 4555 The operation violates some invariant of the server and can 4556 never succeed. 4558 C: l create "///////" 4559 S: l NO [CANNOT] Adjacent slashes are not supported 4561 CAPABILITY 4563 Followed by a list of capabilities. This can appear in the 4564 initial OK or PREAUTH response to transmit an initial 4565 capabilities list. It can also appear in tagged responses to 4566 LOGIN or AUTHENTICATE commands. This makes it unnecessary for 4567 a client to send a separate CAPABILITY command if it recognizes 4568 this response. 4570 CLIENTBUG 4572 The server has detected a client bug. This can accompany all 4573 of OK, NO, and BAD, depending on what the client bug is. 4575 C: k1 select "/archive/projects/experiment-iv" 4576 [...] 4577 S: k1 OK [READ-ONLY] Done 4578 C: k2 status "/archive/projects/experiment-iv" (messages) 4579 [...] 4580 S: k2 OK [CLIENTBUG] Done 4582 CLOSED 4584 The CLOSED response code has no parameters. A server return 4585 the CLOSED response code when the currently selected mailbox is 4586 closed implicitly using the SELECT/EXAMINE command on another 4587 mailbox. The CLOSED response code serves as a boundary between 4588 responses for the previously opened mailbox (which was closed) 4589 and the newly selected mailbox; all responses before the CLOSED 4590 response code relate to the mailbox that was closed, and all 4591 subsequent responses relate to the newly opened mailbox. 4593 There is no need to return the CLOSED response code on 4594 completion of the CLOSE or the UNSELECT command (or similar), 4595 whose purpose is to close the currently selected mailbox 4596 without opening a new one. 4598 The server MAY also return an unsolicited CLOSED response code 4599 when it wants to force the client to return to authenticated 4600 state. For example, the server can do that when the mailbox 4601 requires repairs or is deleted in another session. 4603 CONTACTADMIN 4605 The user should contact the system administrator or support 4606 desk. 4608 C: e login "fred" "foo" 4609 S: e OK [CONTACTADMIN] 4611 COPYUID 4613 Followed by the UIDVALIDITY of the destination mailbox, a UID 4614 set containing the UIDs of the message(s) in the source mailbox 4615 that were copied to the destination mailbox and containing the 4616 UIDs assigned to the copied message(s) in the destination 4617 mailbox, indicates that the message(s) have been copied to the 4618 destination mailbox with the stated UID(s). 4620 The source UID set is in the order the message(s) were copied; 4621 the destination UID set corresponds to the source UID set and 4622 is in the same order. Neither of the UID sets may contain 4623 extraneous UIDs or the symbol "*". 4625 UIDs are assigned in strictly ascending order in the mailbox 4626 (refer to Section 2.3.1.1); note that a range of 12:10 is 4627 exactly equivalent to 10:12 and refers to the sequence 4628 10,11,12. 4630 This response code is returned in a tagged OK response to the 4631 COPY command. 4633 CORRUPTION 4635 The server discovered that some relevant data (e.g., the 4636 mailbox) are corrupt. This response code does not include any 4637 information about what's corrupt, but the server can write that 4638 to its logfiles. 4640 C: i select "/archive/projects/experiment-iv" 4641 S: i NO [CORRUPTION] Cannot open mailbox 4643 EXPIRED 4645 Either authentication succeeded or the server no longer had the 4646 necessary data; either way, access is no longer permitted using 4647 that passphrase. The client or user should get a new 4648 passphrase. 4650 C: d login "fred" "foo" 4651 S: d NO [EXPIRED] That password isn't valid any more 4653 EXPUNGEISSUED 4655 Someone else has issued an EXPUNGE for the same mailbox. The 4656 client may want to issue NOOP soon. [IMAP-MULTIACCESS] 4657 discusses this subject in depth. 4659 C: h search from fred@example.com 4660 S: * ESEARCH (TAG "h") ALL 1:3,5,8,13,21,42 4661 S: h OK [EXPUNGEISSUED] Search completed 4663 INUSE 4665 An operation has not been carried out because it involves 4666 sawing off a branch someone else is sitting on. Someone else 4667 may be holding an exclusive lock needed for this operation, or 4668 the operation may involve deleting a resource someone else is 4669 using, typically a mailbox. 4671 The operation may succeed if the client tries again later. 4673 C: g delete "/archive/projects/experiment-iv" 4674 S: g NO [INUSE] Mailbox in use 4676 LIMIT 4678 The operation ran up against an implementation limit of some 4679 kind, such as the number of flags on a single message or the 4680 number of flags used in a mailbox. 4682 C: m STORE 42 FLAGS f1 f2 f3 f4 f5 ... f250 4683 S: m NO [LIMIT] At most 32 flags in one mailbox supported 4685 NONEXISTENT 4687 The operation attempts to delete something that does not exist. 4688 Similar to ALREADYEXISTS. 4690 C: p RENAME this that 4691 S: p NO [NONEXISTENT] No such mailbox 4693 NOPERM 4695 The access control system (e.g., Access Control List (ACL), see 4696 [RFC4314] does not permit this user to carry out an operation, 4697 such as selecting or creating a mailbox. 4699 C: f select "/archive/projects/experiment-iv" 4700 S: f NO [NOPERM] Access denied 4702 OVERQUOTA 4704 The user would be over quota after the operation. (The user 4705 may or may not be over quota already.) 4707 Note that if the server sends OVERQUOTA but doesn't support the 4708 IMAP QUOTA extension defined by [RFC2087], then there is a 4709 quota, but the client cannot find out what the quota is. 4711 C: n1 uid copy 1:* oldmail 4712 S: n1 NO [OVERQUOTA] Sorry 4714 C: n2 uid copy 1:* oldmail 4715 S: n2 OK [OVERQUOTA] You are now over your soft quota 4717 PARSE 4719 The human-readable text represents an error in parsing the 4720 [RFC-5322] header or [MIME-IMB] headers of a message in the 4721 mailbox. 4723 PERMANENTFLAGS 4725 Followed by a parenthesized list of flags, indicates which of 4726 the known flags the client can change permanently. Any flags 4727 that are in the FLAGS untagged response, but not the 4728 PERMANENTFLAGS list, can not be set permanently. The 4729 PERMANENTFLAGS list can also include the special flag \*, which 4730 indicates that it is possible to create new keywords by 4731 attempting to store those keywords in the mailbox. If the 4732 client attempts to STORE a flag that is not in the 4733 PERMANENTFLAGS list, the server will either ignore the change 4734 or store the state change for the remainder of the current 4735 session only. 4737 There is no need for a server that included the special flag \* 4738 to return a new PERMANENTFLAGS response code when a new keyword 4739 was successfully set on a message upon client request. However 4740 if the server has a limit on the number of different keywords 4741 that can be stored in a mailbox and that limit is reached, the 4742 server MUST send a new PERMANENTFLAGS response code without the 4743 special flag \*. 4745 PRIVACYREQUIRED 4747 The operation is not permitted due to a lack of privacy. If 4748 Transport Layer Security (TLS) is not in use, the client could 4749 try STARTTLS (see Section 6.2.1) and then repeat the operation. 4751 C: d login "fred" "foo" 4752 S: d NO [PRIVACYREQUIRED] Connection offers no privacy 4754 C: d select inbox 4755 S: d NO [PRIVACYREQUIRED] Connection offers no privacy 4757 READ-ONLY 4759 The mailbox is selected read-only, or its access while selected 4760 has changed from read-write to read-only. 4762 READ-WRITE 4764 The mailbox is selected read-write, or its access while 4765 selected has changed from read-only to read-write. 4767 SERVERBUG 4769 The server encountered a bug in itself or violated one of its 4770 own invariants. 4772 C: j select "/archive/projects/experiment-iv" 4773 S: j NO [SERVERBUG] This should not happen 4775 TRYCREATE 4777 An APPEND or COPY attempt is failing because the target mailbox 4778 does not exist (as opposed to some other reason). This is a 4779 hint to the client that the operation can succeed if the 4780 mailbox is first created by the CREATE command. 4782 UIDNEXT 4784 Followed by a decimal number, indicates the next unique 4785 identifier value. Refer to Section 2.3.1.1 for more 4786 information. 4788 UIDNOTSTICKY 4790 The selected mailbox is supported by a mail store that does not 4791 support persistent UIDs; that is, UIDVALIDITY will be different 4792 each time the mailbox is selected. Consequently, APPEND or 4793 COPY to this mailbox will not return an APPENDUID or COPYUID 4794 response code. 4796 This response code is returned in an untagged NO response to 4797 the SELECT command. 4799 Note: servers SHOULD NOT have any UIDNOTSTICKY mail stores. 4800 This facility exists to support legacy mail stores in which 4801 it is technically infeasible to support persistent UIDs. 4802 This should be avoided when designing new mail stores. 4804 UIDVALIDITY 4806 Followed by a decimal number, indicates the unique identifier 4807 validity value. Refer to Section 2.3.1.1 for more information. 4809 UNAVAILABLE 4811 Temporary failure because a subsystem is down. For example, an 4812 IMAP server that uses a Lightweight Directory Access Protocol 4813 (LDAP) or Radius server for authentication might use this 4814 response code when the LDAP/Radius server is down. 4816 C: a LOGIN "fred" "foo" 4817 S: a NO [UNAVAILABLE] User's backend down for maintenance 4819 UNKNOWN-CTE 4821 The server does not know how to decode the section's Content- 4822 Transfer-Encoding. 4824 Client implementations MUST ignore response codes that they do not 4825 recognize. 4827 7.1.1. OK Response 4829 Contents: OPTIONAL response code 4830 human-readable text 4832 The OK response indicates an information message from the server. 4833 When tagged, it indicates successful completion of the associated 4834 command. The human-readable text MAY be presented to the user as an 4835 information message. The untagged form indicates an information-only 4836 message; the nature of the information MAY be indicated by a response 4837 code. 4839 The untagged form is also used as one of three possible greetings at 4840 connection startup. It indicates that the connection is not yet 4841 authenticated and that a LOGIN or an AUTHENTICATE command is needed. 4843 Example: S: * OK IMAP4rev2 server ready 4844 C: A001 LOGIN fred blurdybloop 4845 S: * OK [ALERT] System shutdown in 10 minutes 4846 S: A001 OK LOGIN Completed 4848 7.1.2. NO Response 4850 Contents: OPTIONAL response code 4851 human-readable text 4853 The NO response indicates an operational error message from the 4854 server. When tagged, it indicates unsuccessful completion of the 4855 associated command. The untagged form indicates a warning; the 4856 command can still complete successfully. The human-readable text 4857 describes the condition. 4859 Example: C: A222 COPY 1:2 owatagusiam 4860 S: * NO Disk is 98% full, please delete unnecessary data 4861 S: A222 OK COPY completed 4862 C: A223 COPY 3:200 blurdybloop 4863 S: * NO Disk is 98% full, please delete unnecessary data 4864 S: * NO Disk is 99% full, please delete unnecessary data 4865 S: A223 NO COPY failed: disk is full 4867 7.1.3. BAD Response 4869 Contents: OPTIONAL response code 4870 human-readable text 4872 The BAD response indicates an error message from the server. When 4873 tagged, it reports a protocol-level error in the client's command; 4874 the tag indicates the command that caused the error. The untagged 4875 form indicates a protocol-level error for which the associated 4876 command can not be determined; it can also indicate an internal 4877 server failure. The human-readable text describes the condition. 4879 Example: C: ...very long command line... 4880 S: * BAD Command line too long 4881 C: ...empty line... 4882 S: * BAD Empty command line 4883 C: A443 EXPUNGE 4884 S: * BAD Disk crash, attempting salvage to a new disk! 4885 S: * OK Salvage successful, no data lost 4886 S: A443 OK Expunge completed 4888 7.1.4. PREAUTH Response 4890 Contents: OPTIONAL response code 4891 human-readable text 4893 The PREAUTH response is always untagged, and is one of three possible 4894 greetings at connection startup. It indicates that the connection 4895 has already been authenticated by external means; thus no LOGIN/ 4896 AUTHENTICATE command is needed. 4898 Example: S: * PREAUTH IMAP4rev2 server logged in as Smith 4900 7.1.5. BYE Response 4902 Contents: OPTIONAL response code 4903 human-readable text 4905 The BYE response is always untagged, and indicates that the server is 4906 about to close the connection. The human-readable text MAY be 4907 displayed to the user in a status report by the client. The BYE 4908 response is sent under one of four conditions: 4910 1. as part of a normal logout sequence. The server will close the 4911 connection after sending the tagged OK response to the LOGOUT 4912 command. 4914 2. as a panic shutdown announcement. The server closes the 4915 connection immediately. 4917 3. as an announcement of an inactivity autologout. The server 4918 closes the connection immediately. 4920 4. as one of three possible greetings at connection startup, 4921 indicating that the server is not willing to accept a connection 4922 from this client. The server closes the connection immediately. 4924 The difference between a BYE that occurs as part of a normal LOGOUT 4925 sequence (the first case) and a BYE that occurs because of a failure 4926 (the other three cases) is that the connection closes immediately in 4927 the failure case. In all cases the client SHOULD continue to read 4928 response data from the server until the connection is closed; this 4929 will ensure that any pending untagged or completion responses are 4930 read and processed. 4932 Example: S: * BYE Autologout; idle for too long 4934 7.2. Server Responses - Server and Mailbox Status 4936 These responses are always untagged. This is how server and mailbox 4937 status data are transmitted from the server to the client. Many of 4938 these responses typically result from a command with the same name. 4940 7.2.1. The ENABLED Response 4942 Contents: capability listing 4944 The ENABLED response occurs as a result of an ENABLE command. The 4945 capability listing contains a space-separated listing of capability 4946 names that the server supports and that were successfully enabled. 4947 The ENABLED response may contain no capabilities, which means that no 4948 extensions listed by the client were successfully enabled. 4950 7.2.2. CAPABILITY Response 4952 Contents: capability listing 4954 The CAPABILITY response occurs as a result of a CAPABILITY command. 4955 The capability listing contains a space-separated listing of 4956 capability names that the server supports. The capability listing 4957 MUST include the atom "IMAP4rev2". 4959 In addition, client and server implementations MUST implement the 4960 STARTTLS, LOGINDISABLED, and AUTH=PLAIN (described in [PLAIN]) 4961 capabilities. See the Security Considerations section for important 4962 information. 4964 A capability name which begins with "AUTH=" indicates that the server 4965 supports that particular authentication mechanism. 4967 The LOGINDISABLED capability indicates that the LOGIN command is 4968 disabled, and that the server will respond with a tagged NO response 4969 to any attempt to use the LOGIN command even if the user name and 4970 password are valid. An IMAP client MUST NOT issue the LOGIN command 4971 if the server advertises the LOGINDISABLED capability. 4973 Other capability names indicate that the server supports an 4974 extension, revision, or amendment to the IMAP4rev2 protocol. Server 4975 responses MUST conform to this document until the client issues a 4976 command that uses the associated capability. 4978 Capability names MUST either begin with "X" or be informational, 4979 experimental or standards-track IMAP4rev2 extensions, revisions, or 4980 amendments registered with IANA. A server MUST NOT offer 4981 unregistered or non-standard capability names, unless such names are 4982 prefixed with an "X". 4984 Client implementations SHOULD NOT require any capability name other 4985 than "IMAP4rev2", and MUST ignore any unknown capability names. 4987 A server MAY send capabilities automatically, by using the CAPABILITY 4988 response code in the initial PREAUTH or OK responses, and by sending 4989 an updated CAPABILITY response code in the tagged OK response as part 4990 of a successful authentication. It is unnecessary for a client to 4991 send a separate CAPABILITY command if it recognizes these automatic 4992 capabilities. 4994 Example: S: * CAPABILITY IMAP4rev2 STARTTLS AUTH=GSSAPI XPIG-LATIN 4996 7.2.3. LIST Response 4998 Contents: name attributes 4999 hierarchy delimiter 5000 name 5001 OPTIONAL extension data 5003 The LIST response occurs as a result of a LIST command. It returns a 5004 single name that matches the LIST specification. There can be 5005 multiple LIST responses for a single LIST command. 5007 The following base mailbox name attributes are defined: 5009 \NonExistent The "\NonExistent" attribute indicates that a mailbox 5010 name does not refer to an existing mailbox. Note that this 5011 attribute is not meaningful by itself, as mailbox names that match 5012 the canonical LIST pattern but don't exist must not be returned 5013 unless one of the two conditions listed below is also satisfied: 5015 1. The mailbox name also satisfies the selection criteria (for 5016 example, it is subscribed and the "SUBSCRIBED" selection 5017 option has been specified). 5019 2. "RECURSIVEMATCH" has been specified, and the mailbox name has 5020 at least one descendant mailbox name that does not match the 5021 LIST pattern and does match the selection criteria. 5023 In practice, this means that the "\NonExistent" attribute is 5024 usually returned with one or more of "\Subscribed", "\Remote", 5025 "\HasChildren", or the CHILDINFO extended data item. 5027 The "\NonExistent" attribute implies "\NoSelect". 5029 \Noinferiors It is not possible for any child levels of hierarchy to 5030 exist under this name; no child levels exist now and none can be 5031 created in the future. 5033 \Noselect It is not possible to use this name as a selectable 5034 mailbox. 5036 \HasChildren The presence of this attribute indicates that the 5037 mailbox has child mailboxes. A server SHOULD NOT set this 5038 attribute if there are child mailboxes and the user does not have 5039 permission to access any of them. In this case, \HasNoChildren 5040 SHOULD be used. In many cases, however, a server may not be able 5041 to efficiently compute whether a user has access to any child 5042 mailbox. Note that even though the \HasChildren attribute for a 5043 mailbox must be correct at the time of processing of the mailbox, 5044 a client must be prepared to deal with a situation when a mailbox 5045 is marked with the \HasChildren attribute, but no child mailbox 5046 appears in the response to the LIST command. This might happen, 5047 for example, due to children mailboxes being deleted or made 5048 inaccessible to the user (using access control) by another client 5049 before the server is able to list them. 5051 \HasNoChildren The presence of this attribute indicates that the 5052 mailbox has NO child mailboxes that are accessible to the 5053 currently authenticated user. 5055 \Marked The mailbox has been marked "interesting" by the server; the 5056 mailbox probably contains messages that have been added since the 5057 last time the mailbox was selected. 5059 \Unmarked The mailbox does not contain any additional messages since 5060 the last time the mailbox was selected. 5062 \Subscribed The mailbox name was subscribed to using the SUBSCRIBE 5063 command. 5065 \Remote The mailbox is a remote mailbox. 5067 It is an error for the server to return both a \HasChildren and a 5068 \HasNoChildren attribute in the same LIST response. 5070 Note: the \HasNoChildren attribute should not be confused with the 5071 \NoInferiors attribute, which indicates that no child mailboxes 5072 exist now and none can be created in the future. 5074 If it is not feasible for the server to determine whether or not the 5075 mailbox is "interesting", the server SHOULD NOT send either \Marked 5076 or \Unmarked. The server MUST NOT send more than one of \Marked, 5077 \Unmarked, and \Noselect for a single mailbox, and MAY send none of 5078 these. 5080 In addition to the base mailbox name attributes defined above, an 5081 IMAP server MAY also include any or all of the following attributes 5082 that denote "role" (or "special-use") of a mailbox. These attributes 5083 are included along with base attributes defined above. A given 5084 mailbox may have none, one, or more than one of these attributes. In 5085 some cases, a special use is advice to a client about what to put in 5086 that mailbox. In other cases, it's advice to a client about what to 5087 expect to find there. 5089 \All This mailbox presents all messages in the user's message store. 5090 Implementations MAY omit some messages, such as, perhaps, those in 5091 \Trash and \Junk. When this special use is supported, it is 5092 almost certain to represent a virtual mailbox. 5094 \Archive This mailbox is used to archive messages. The meaning of 5095 an "archival" mailbox is server-dependent; typically, it will be 5096 used to get messages out of the inbox, or otherwise keep them out 5097 of the user's way, while still making them accessible. 5099 \Drafts This mailbox is used to hold draft messages -- typically, 5100 messages that are being composed but have not yet been sent. In 5101 some server implementations, this might be a virtual mailbox, 5102 containing messages from other mailboxes that are marked with the 5103 "\Draft" message flag. Alternatively, this might just be advice 5104 that a client put drafts here. 5106 \Flagged This mailbox presents all messages marked in some way as 5107 "important". When this special use is supported, it is likely to 5108 represent a virtual mailbox collecting messages (from other 5109 mailboxes) that are marked with the "\Flagged" message flag. 5111 \Junk This mailbox is where messages deemed to be junk mail are 5112 held. Some server implementations might put messages here 5113 automatically. Alternatively, this might just be advice to a 5114 client-side spam filter. 5116 \Sent This mailbox is used to hold copies of messages that have been 5117 sent. Some server implementations might put messages here 5118 automatically. Alternatively, this might just be advice that a 5119 client save sent messages here. 5121 \Trash This mailbox is used to hold messages that have been deleted 5122 or marked for deletion. In some server implementations, this 5123 might be a virtual mailbox, containing messages from other 5124 mailboxes that are marked with the "\Deleted" message flag. 5125 Alternatively, this might just be advice that a client that 5126 chooses not to use the IMAP "\Deleted" model should use this as 5127 its trash location. In server implementations that strictly 5128 expect the IMAP "\Deleted" model, this special use is likely not 5129 to be supported. 5131 All of special-use attributes are OPTIONAL, and any given server or 5132 message store may support any combination of the attributes, or none 5133 at all. In most cases, there will likely be at most one mailbox with 5134 a given attribute for a given user, but in some server or message 5135 store implementations it might be possible for multiple mailboxes to 5136 have the same special-use attribute. 5138 Special-use attributes are likely to be user-specific. User Adam 5139 might share his \Sent mailbox with user Barb, but that mailbox is 5140 unlikely to also serve as Barb's \Sent mailbox. 5142 Other mailbox name attributes can be found in the "IMAP Mailbox Name 5143 Attributes" registry [IMAP-MAILBOX-NAME-ATTRS-REG]. 5145 The hierarchy delimiter is a character used to delimit levels of 5146 hierarchy in a mailbox name. A client can use it to create child 5147 mailboxes, and to search higher or lower levels of naming hierarchy. 5148 All children of a top-level hierarchy node MUST use the same 5149 separator character. A NIL hierarchy delimiter means that no 5150 hierarchy exists; the name is a "flat" name. 5152 The name represents an unambiguous left-to-right hierarchy, and MUST 5153 be valid for use as a reference in LIST command. Unless \Noselect or 5154 \NonExistent is indicated, the name MUST also be valid as an argument 5155 for commands, such as SELECT, that accept mailbox names. 5157 The name might be followed by an OPTIONAL series of extended fields, 5158 a parenthesized list of tagged data (also referred to as "extended 5159 data item"). The first element of an extended field is a tag, which 5160 identifies the type of data. The server MAY return data in the 5161 extended fields that was not directly solicited by the client in the 5162 corresponding LIST command. For example, the client can enable extra 5163 extended fields by using another IMAP extension that make use of the 5164 extended LIST responses. The client MUST ignore all extended fields 5165 it doesn't recognize. 5167 Example: S: * LIST (\Noselect) "/" ~/Mail/foo 5169 Example: S: * LIST (\Marked) ":" Tables (tablecloth (("edge" "lacy") 5170 ("color" "red")) Sample "text") 5171 S: * LIST () ":" Tables:new (tablecloth ("edge" "lacy") 5172 Sample ("text" "more text")) 5174 7.2.4. NAMESPACE Response 5176 Contents: the prefix and hierarchy delimiter to the server's 5177 Personal Namespace(s), Other Users' Namespace(s), and 5178 Shared Namespace(s) 5180 The NAMESPACE response occurs as a result of a NAMESPACE command. It 5181 contains the prefix and hierarchy delimiter to the server's Personal 5182 Namespace(s), Other Users' Namespace(s), and Shared Namespace(s) that 5183 the server wishes to expose. The response will contain a NIL for any 5184 namespace class that is not available. Namespace-Response-Extensions 5185 ABNF non terminal is defined for extensibility and MAY be included in 5186 the response. 5188 Example: S: * NAMESPACE (("" "/")) (("~" "/")) NIL 5190 7.2.5. STATUS Response 5192 Contents: name 5193 status parenthesized list 5195 The STATUS response occurs as a result of an STATUS command. It 5196 returns the mailbox name that matches the STATUS specification and 5197 the requested mailbox status information. 5199 Example: S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) 5201 7.2.6. ESEARCH Response 5203 Contents: one or more search-return-data pairs 5205 The ESEARCH response occurs as a result of a SEARCH or UID SEARCH 5206 command. 5208 The ESEARCH response starts with an optional search correlator. If 5209 it is missing, then the response was not caused by a particular IMAP 5210 command, whereas if it is present, it contains the tag of the command 5211 that caused the response to be returned. 5213 The search correlator is followed by an optional UID indicator. If 5214 this indicator is present, all data in the ESEARCH response refers to 5215 UIDs, otherwise all returned data refers to message numbers. 5217 The rest of the ESEARCH response contains one or more search data 5218 pairs. Each pair starts with unique return item name, followed by a 5219 space and the corresponding data. Search data pairs may be returned 5220 in any order. Unless specified otherwise by an extension, any return 5221 item name SHOULD appear only once in an ESEARCH response. 5223 [[TBD: describe the most common search data pairs returned.]] 5225 Example: S: * ESEARCH UID COUNT 5 ALL 4:19,21,28 5227 Example: S: * ESEARCH (TAG "a567") UID COUNT 5 ALL 4:19,21,28 5229 Example: S: * ESEARCH COUNT 5 ALL 1:17,21 5231 7.2.7. FLAGS Response 5233 Contents: flag parenthesized list 5235 The FLAGS response occurs as a result of a SELECT or EXAMINE command. 5236 The flag parenthesized list identifies the flags (at a minimum, the 5237 system-defined flags) that are applicable for this mailbox. Flags 5238 other than the system flags can also exist, depending on server 5239 implementation. 5241 The update from the FLAGS response MUST be recorded by the client. 5243 Example: S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 5245 7.3. Server Responses - Mailbox Size 5247 These responses are always untagged. This is how changes in the size 5248 of the mailbox are transmitted from the server to the client. 5249 Immediately following the "*" token is a number that represents a 5250 message count. 5252 7.3.1. EXISTS Response 5254 Contents: none 5256 The EXISTS response reports the number of messages in the mailbox. 5257 This response occurs as a result of a SELECT or EXAMINE command, and 5258 if the size of the mailbox changes (e.g., new messages). 5260 The update from the EXISTS response MUST be recorded by the client. 5262 Example: S: * 23 EXISTS 5264 7.4. Server Responses - Message Status 5266 These responses are always untagged. This is how message data are 5267 transmitted from the server to the client, often as a result of a 5268 command with the same name. Immediately following the "*" token is a 5269 number that represents a message sequence number. 5271 7.4.1. EXPUNGE Response 5273 Contents: none 5275 The EXPUNGE response reports that the specified message sequence 5276 number has been permanently removed from the mailbox. The message 5277 sequence number for each successive message in the mailbox is 5278 immediately decremented by 1, and this decrement is reflected in 5279 message sequence numbers in subsequent responses (including other 5280 untagged EXPUNGE responses). 5282 The EXPUNGE response also decrements the number of messages in the 5283 mailbox; it is not necessary to send an EXISTS response with the new 5284 value. 5286 As a result of the immediate decrement rule, message sequence numbers 5287 that appear in a set of successive EXPUNGE responses depend upon 5288 whether the messages are removed starting from lower numbers to 5289 higher numbers, or from higher numbers to lower numbers. For 5290 example, if the last 5 messages in a 9-message mailbox are expunged, 5291 a "lower to higher" server will send five untagged EXPUNGE responses 5292 for message sequence number 5, whereas a "higher to lower server" 5293 will send successive untagged EXPUNGE responses for message sequence 5294 numbers 9, 8, 7, 6, and 5. 5296 An EXPUNGE response MUST NOT be sent when no command is in progress, 5297 nor while responding to a FETCH, STORE, or SEARCH command. This rule 5298 is necessary to prevent a loss of synchronization of message sequence 5299 numbers between client and server. A command is not "in progress" 5300 until the complete command has been received; in particular, a 5301 command is not "in progress" during the negotiation of command 5302 continuation. 5304 Note: UID FETCH, UID STORE, and UID SEARCH are different commands 5305 from FETCH, STORE, and SEARCH. An EXPUNGE response MAY be sent 5306 during a UID command. 5308 The update from the EXPUNGE response MUST be recorded by the client. 5310 Example: S: * 44 EXPUNGE 5312 7.4.2. FETCH Response 5314 Contents: message data 5316 The FETCH response returns data about a message to the client. The 5317 data are pairs of data item names and their values in parentheses. 5318 This response occurs as the result of a FETCH or STORE command, as 5319 well as by unilateral server decision (e.g., flag updates). 5321 The current data items are: 5323 BINARY[]<> 5325 An or expressing the content of the 5326 specified section after removing any Content-Transfer-Encoding- 5327 related encoding. If is present it refers to the 5328 offset within the DECODED section data. 5330 If the domain of the decoded data is "8bit" and the data does 5331 not contain the NUL octet, the server SHOULD return the data in 5332 a instead of a ; this allows the client to 5333 determine if the "8bit" data contains the NUL octet without 5334 having to explicitly scan the data stream for for NULs. 5336 Messaging clients and servers have been notoriously lax in 5337 their adherence to the Internet CRLF convention for terminating 5338 lines of textual data (text/* media types) in Internet 5339 protocols. When sending data in BINARY[...] FETCH data item, 5340 servers MUST ensure that textual line-oriented sections are 5341 always transmitted using the IMAP4 CRLF line termination 5342 syntax, regardless of the underlying storage representation of 5343 the data on the server. 5345 If the server does not know how to decode the section's 5346 Content-Transfer-Encoding, it MUST fail the request and issue a 5347 "NO" response that contains the "UNKNOWN-CTE" response code. 5349 BINARY.SIZE[] 5351 The size of the section after removing any Content-Transfer- 5352 Encoding-related encoding. The value returned MUST match the 5353 size of the or that will be returned by 5354 the corresponding FETCH BINARY request. 5356 If the server does not know how to decode the section's 5357 Content-Transfer-Encoding, it MUST fail the request and issue a 5358 "NO" response that contains the "UNKNOWN-CTE" response code. 5360 BODY A form of BODYSTRUCTURE without extension data. 5362 BODY[
]<> 5364 A string expressing the body contents of the specified section. 5365 The string SHOULD be interpreted by the client according to the 5366 content transfer encoding, body type, and subtype. 5368 If the origin octet is specified, this string is a substring of 5369 the entire body contents, starting at that origin octet. This 5370 means that BODY[]<0> MAY be truncated, but BODY[] is NEVER 5371 truncated. 5373 Note: The origin octet facility MUST NOT be used by a server 5374 in a FETCH response unless the client specifically requested 5375 it by means of a FETCH of a BODY[
]<> data 5376 item. 5378 8-bit textual data is permitted if a [CHARSET] identifier is 5379 part of the body parameter parenthesized list for this section. 5380 Note that headers (part specifiers HEADER or MIME, or the 5381 header portion of a MESSAGE/RFC822 or MESSAGE/GLOBAL part), MAY 5382 be in UTF-8. Note also that the [RFC-5322] delimiting blank 5383 line between the header and the body is not affected by header 5384 line subsetting; the blank line is always included as part of 5385 header data, except in the case of a message which has no body 5386 and no blank line. 5388 Non-textual data such as binary data MUST be transfer encoded 5389 into a textual form, such as BASE64, prior to being sent to the 5390 client. To derive the original binary data, the client MUST 5391 decode the transfer encoded string. 5393 BODYSTRUCTURE 5395 A parenthesized list that describes the [MIME-IMB] body 5396 structure of a message. This is computed by the server by 5397 parsing the [MIME-IMB] header fields, defaulting various fields 5398 as necessary. 5400 For example, a simple text message of 48 lines and 2279 octets 5401 can have a body structure of: ("TEXT" "PLAIN" ("CHARSET" "US- 5402 ASCII") NIL NIL "7BIT" 2279 48) 5404 Multiple parts are indicated by parenthesis nesting. Instead 5405 of a body type as the first element of the parenthesized list, 5406 there is a sequence of one or more nested body structures. The 5407 second element of the parenthesized list is the multipart 5408 subtype (mixed, digest, parallel, alternative, etc.). 5410 For example, a two part message consisting of a text and a 5411 BASE64-encoded text attachment can have a body structure of: 5412 (("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 1152 5413 23)("TEXT" "PLAIN" ("CHARSET" "US-ASCII" "NAME" "cc.diff") 5414 "<960723163407.20117h@cac.washington.edu>" "Compiler diff" 5415 "BASE64" 4554 73) "MIXED") 5417 Extension data follows the multipart subtype. Extension data 5418 is never returned with the BODY fetch, but can be returned with 5419 a BODYSTRUCTURE fetch. Extension data, if present, MUST be in 5420 the defined order. The extension data of a multipart body part 5421 are in the following order: 5423 body parameter parenthesized list A parenthesized list of 5424 attribute/value pairs [e.g., ("foo" "bar" "baz" "rag") where 5425 "bar" is the value of "foo", and "rag" is the value of 5426 "baz"] as defined in [MIME-IMB]. Servers SHOULD decode 5427 parameter value continuations as described in [RFC2231], for 5428 example, if the message contains parameters "foo*0*" and 5429 "foo*1*", the server should RFC2231-decode them, concatenate 5430 and return the resulting value as "foo*". 5432 body disposition A parenthesized list, consisting of a 5433 disposition type string, followed by a parenthesized list of 5434 disposition attribute/value pairs as defined in 5435 [DISPOSITION]. Servers SHOULD decode parameter value 5436 continuations as described in [RFC2231]. 5438 body language A string or parenthesized list giving the body 5439 language value as defined in [LANGUAGE-TAGS]. 5441 body location A string giving the body content URI as defined 5442 in [LOCATION]. 5444 Any following extension data are not yet defined in this 5445 version of the protocol. Such extension data can consist of 5446 zero or more NILs, strings, numbers, or potentially nested 5447 parenthesized lists of such data. Client implementations that 5448 do a BODYSTRUCTURE fetch MUST be prepared to accept such 5449 extension data. Server implementations MUST NOT send such 5450 extension data until it has been defined by a revision of this 5451 protocol. 5453 The basic fields of a non-multipart body part are in the 5454 following order: 5456 body type A string giving the content media type name as 5457 defined in [MIME-IMB]. 5459 body subtype A string giving the content subtype name as 5460 defined in [MIME-IMB]. 5462 body parameter parenthesized list A parenthesized list of 5463 attribute/value pairs [e.g., ("foo" "bar" "baz" "rag") where 5464 "bar" is the value of "foo" and "rag" is the value of "baz"] 5465 as defined in [MIME-IMB]. 5467 body id A string giving the Content-ID header field value as 5468 defined in Section 7 of [MIME-IMB]. 5470 body description A string giving the Content-Description 5471 header field value as defined in Section 8 of [MIME-IMB]. 5473 body encoding A string giving the content transfer encoding as 5474 defined in Section 6 of [MIME-IMB]. 5476 body size A number giving the size of the body in octets. 5477 Note that this size is the size in its transfer encoding and 5478 not the resulting size after any decoding. 5480 A body type of type MESSAGE and subtype RFC822 contains, 5481 immediately after the basic fields, the envelope structure, 5482 body structure, and size in text lines of the encapsulated 5483 message. 5485 A body type of type TEXT contains, immediately after the basic 5486 fields, the size of the body in text lines. Note that this 5487 size is the size in its content transfer encoding and not the 5488 resulting size after any decoding. 5490 Extension data follows the basic fields and the type-specific 5491 fields listed above. Extension data is never returned with the 5492 BODY fetch, but can be returned with a BODYSTRUCTURE fetch. 5493 Extension data, if present, MUST be in the defined order. 5495 The extension data of a non-multipart body part are in the 5496 following order: 5498 body MD5 A string giving the body MD5 value as defined in 5499 [MD5]. 5501 body disposition A parenthesized list with the same content 5502 and function as the body disposition for a multipart body 5503 part. 5505 body language A string or parenthesized list giving the body 5506 language value as defined in [LANGUAGE-TAGS]. 5508 body location A string giving the body content URI as defined 5509 in [LOCATION]. 5511 Any following extension data are not yet defined in this 5512 version of the protocol, and would be as described above under 5513 multipart extension data. 5515 ENVELOPE 5517 A parenthesized list that describes the envelope structure of a 5518 message. This is computed by the server by parsing the 5519 [RFC-5322] header into the component parts, defaulting various 5520 fields as necessary. 5522 The fields of the envelope structure are in the following 5523 order: date, subject, from, sender, reply-to, to, cc, bcc, in- 5524 reply-to, and message-id. The date, subject, in-reply-to, and 5525 message-id fields are strings. The from, sender, reply-to, to, 5526 cc, and bcc fields are parenthesized lists of address 5527 structures. 5529 An address structure is a parenthesized list that describes an 5530 electronic mail address. The fields of an address structure 5531 are in the following order: personal name, [SMTP] at-domain- 5532 list (source route, obs-route), mailbox name, and host name. 5534 [RFC-5322] group syntax is indicated by a special form of 5535 address structure in which the host name field is NIL. If the 5536 mailbox name field is also NIL, this is an end of group marker 5537 (semi-colon in RFC 822 syntax). If the mailbox name field is 5538 non-NIL, this is a start of group marker, and the mailbox name 5539 field holds the group name phrase. 5541 If the Date, Subject, In-Reply-To, and Message-ID header lines 5542 are absent in the [RFC-5322] header, the corresponding member 5543 of the envelope is NIL; if these header lines are present but 5544 empty the corresponding member of the envelope is the empty 5545 string. 5547 Note: some servers may return a NIL envelope member in the 5548 "present but empty" case. Clients SHOULD treat NIL and 5549 empty string as identical. 5551 Note: [RFC-5322] requires that all messages have a valid 5552 Date header. Therefore, the date member in the envelope can 5553 not be NIL or the empty string. 5555 Note: [RFC-5322] requires that the In-Reply-To and Message- 5556 ID headers, if present, have non-empty content. Therefore, 5557 the in-reply-to and message-id members in the envelope can 5558 not be the empty string. 5560 If the From, To, Cc, and Bcc header lines are absent in the 5561 [RFC-5322] header, or are present but empty, the corresponding 5562 member of the envelope is NIL. 5564 If the Sender or Reply-To lines are absent in the [RFC-5322] 5565 header, or are present but empty, the server sets the 5566 corresponding member of the envelope to be the same value as 5567 the from member (the client is not expected to know to do 5568 this). 5570 Note: [RFC-5322] requires that all messages have a valid 5571 From header. Therefore, the from, sender, and reply-to 5572 members in the envelope can not be NIL. 5574 FLAGS A parenthesized list of flags that are set for this message. 5576 INTERNALDATE A string representing the internal date of the message. 5578 RFC822.SIZE A number expressing the [RFC-5322] size of the message. 5580 UID A number expressing the unique identifier of the message. 5582 If the server chooses to send unsolicited FETCH responses, they MUST 5583 include UID FETCH item. Note that this is a new requirement when 5584 compared to RFC 3501. 5586 Example: S: * 23 FETCH (FLAGS (\Seen) RFC822.SIZE 44827) 5588 7.5. Server Responses - Command Continuation Request 5590 The command continuation request response is indicated by a "+" token 5591 instead of a tag. This form of response indicates that the server is 5592 ready to accept the continuation of a command from the client. The 5593 remainder of this response is a line of text. 5595 This response is used in the AUTHENTICATE command to transmit server 5596 data to the client, and request additional client data. This 5597 response is also used if an argument to any command is a 5598 synchronizing literal. 5600 The client is not permitted to send the octets of the synchronizing 5601 literal unless the server indicates that it is expected. This 5602 permits the server to process commands and reject errors on a line- 5603 by-line basis. The remainder of the command, including the CRLF that 5604 terminates a command, follows the octets of the literal. If there 5605 are any additional command arguments, the literal octets are followed 5606 by a space and those arguments. 5608 Example: C: A001 LOGIN {11} 5609 S: + Ready for additional command text 5610 C: FRED FOOBAR {7} 5611 S: + Ready for additional command text 5612 C: fat man 5613 S: A001 OK LOGIN completed 5614 C: A044 BLURDYBLOOP {102856} 5615 S: A044 BAD No such command as "BLURDYBLOOP" 5617 8. Sample IMAP4rev2 connection 5619 The following is a transcript of an IMAP4rev2 connection. A long 5620 line in this sample is broken for editorial clarity. 5622 S: * OK IMAP4rev2 Service Ready 5623 C: a001 login mrc secret 5624 S: a001 OK LOGIN completed 5625 C: a002 select inbox 5626 S: * 18 EXISTS 5627 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 5628 S: * OK [UIDVALIDITY 3857529045] UIDs valid 5629 S: a002 OK [READ-WRITE] SELECT completed 5630 C: a003 fetch 12 full 5631 S: * 12 FETCH (FLAGS (\Seen) INTERNALDATE "17-Jul-1996 02:44:25 -0700" 5632 RFC822.SIZE 4286 ENVELOPE ("Wed, 17 Jul 1996 02:23:25 -0700 (PDT)" 5633 "IMAP4rev2 WG mtg summary and minutes" 5634 (("Terry Gray" NIL "gray" "cac.washington.edu")) 5635 (("Terry Gray" NIL "gray" "cac.washington.edu")) 5636 (("Terry Gray" NIL "gray" "cac.washington.edu")) 5637 ((NIL NIL "imap" "cac.washington.edu")) 5638 ((NIL NIL "minutes" "CNRI.Reston.VA.US") 5639 ("John Klensin" NIL "KLENSIN" "MIT.EDU")) NIL NIL 5640 "") 5641 BODY ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 3028 5642 92)) 5643 S: a003 OK FETCH completed 5644 C: a004 fetch 12 body[header] 5645 S: * 12 FETCH (BODY[HEADER] {342} 5646 S: Date: Wed, 17 Jul 1996 02:23:25 -0700 (PDT) 5647 S: From: Terry Gray 5648 S: Subject: IMAP4rev2 WG mtg summary and minutes 5649 S: To: imap@cac.washington.edu 5650 S: cc: minutes@CNRI.Reston.VA.US, John Klensin 5651 S: Message-Id: 5652 S: MIME-Version: 1.0 5653 S: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 5654 S: 5655 S: ) 5656 S: a004 OK FETCH completed 5657 C: a005 store 12 +flags \deleted 5658 S: * 12 FETCH (FLAGS (\Seen \Deleted)) 5659 S: a005 OK +FLAGS completed 5660 C: a006 logout 5661 S: * BYE IMAP4rev2 server terminating connection 5662 S: a006 OK LOGOUT completed 5664 9. Formal Syntax 5666 The following syntax specification uses the Augmented Backus-Naur 5667 Form (ABNF) notation as specified in [ABNF]. 5669 In the case of alternative or optional rules in which a later rule 5670 overlaps an earlier rule, the rule which is listed earlier MUST take 5671 priority. For example, "\Seen" when parsed as a flag is the \Seen 5672 flag name and not a flag-extension, even though "\Seen" can be parsed 5673 as a flag-extension. Some, but not all, instances of this rule are 5674 noted below. 5676 Note: [ABNF] rules MUST be followed strictly; in particular: 5678 (1) Except as noted otherwise, all alphabetic characters are case- 5679 insensitive. The use of upper or lower case characters to define 5680 token strings is for editorial clarity only. Implementations MUST 5681 accept these strings in a case-insensitive fashion. 5683 (2) In all cases, SP refers to exactly one space. It is NOT 5684 permitted to substitute TAB, insert additional spaces, or 5685 otherwise treat SP as being equivalent to LWSP. 5687 (3) The ASCII NUL character, %x00, MUST NOT be used at any time. 5689 address = "(" addr-name SP addr-adl SP addr-mailbox SP 5690 addr-host ")" 5692 addr-adl = nstring 5693 ; Holds route from [RFC-5322] obs-route if 5694 ; non-NIL 5696 addr-host = nstring 5697 ; NIL indicates [RFC-5322] group syntax. 5698 ; Otherwise, holds [RFC-5322] domain name 5700 addr-mailbox = nstring 5701 ; NIL indicates end of [RFC-5322] group; if 5702 ; non-NIL and addr-host is NIL, holds 5703 ; [RFC-5322] group name. 5704 ; Otherwise, holds [RFC-5322] local-part 5705 ; after removing [RFC-5322] quoting 5707 addr-name = nstring 5708 ; If non-NIL, holds phrase from [RFC-5322] 5709 ; mailbox after removing [RFC-5322] quoting 5711 append = "APPEND" SP mailbox [SP flag-list] [SP date-time] SP 5712 literal 5714 append-uid = uniqueid 5716 astring = 1*ASTRING-CHAR / string 5717 ASTRING-CHAR = ATOM-CHAR / resp-specials 5719 atom = 1*ATOM-CHAR 5721 ATOM-CHAR = 5723 atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards / 5724 quoted-specials / resp-specials 5726 authenticate = "AUTHENTICATE" SP auth-type [SP initial-resp] 5727 *(CRLF base64) 5729 auth-type = atom 5730 ; Defined by [SASL] 5732 base64 = *(4base64-char) [base64-terminal] 5734 base64-char = ALPHA / DIGIT / "+" / "/" 5735 ; Case-sensitive 5737 base64-terminal = (2base64-char "==") / (3base64-char "=") 5739 body = "(" (body-type-1part / body-type-mpart) ")" 5741 body-extension = nstring / number / 5742 "(" body-extension *(SP body-extension) ")" 5743 ; Future expansion. Client implementations 5744 ; MUST accept body-extension fields. Server 5745 ; implementations MUST NOT generate 5746 ; body-extension fields except as defined by 5747 ; future standard or standards-track 5748 ; revisions of this specification. 5750 body-ext-1part = body-fld-md5 [SP body-fld-dsp [SP body-fld-lang 5751 [SP body-fld-loc *(SP body-extension)]]] 5752 ; MUST NOT be returned on non-extensible 5753 ; "BODY" fetch 5755 body-ext-mpart = body-fld-param [SP body-fld-dsp [SP body-fld-lang 5756 [SP body-fld-loc *(SP body-extension)]]] 5757 ; MUST NOT be returned on non-extensible 5758 ; "BODY" fetch 5760 body-fields = body-fld-param SP body-fld-id SP body-fld-desc SP 5761 body-fld-enc SP body-fld-octets 5763 body-fld-desc = nstring 5764 body-fld-dsp = "(" string SP body-fld-param ")" / nil 5766 body-fld-enc = (DQUOTE ("7BIT" / "8BIT" / "BINARY" / "BASE64"/ 5767 "QUOTED-PRINTABLE") DQUOTE) / string 5769 body-fld-id = nstring 5771 body-fld-lang = nstring / "(" string *(SP string) ")" 5773 body-fld-loc = nstring 5775 body-fld-lines = number 5777 body-fld-md5 = nstring 5779 body-fld-octets = number 5781 body-fld-param = "(" string SP string *(SP string SP string) ")" / nil 5783 body-type-1part = (body-type-basic / body-type-msg / body-type-text) 5784 [SP body-ext-1part] 5786 body-type-basic = media-basic SP body-fields 5787 ; MESSAGE subtype MUST NOT be "RFC822" or "GLOBAL" 5789 body-type-mpart = 1*body SP media-subtype 5790 [SP body-ext-mpart] 5791 ; MULTIPART body part 5793 body-type-msg = media-message SP body-fields SP envelope 5794 SP body SP body-fld-lines 5796 body-type-text = media-text SP body-fields SP body-fld-lines 5798 capability = ("AUTH=" auth-type) / atom 5799 ; New capabilities MUST begin with "X" or be 5800 ; registered with IANA as standard or 5801 ; standards-track 5803 capability-data = "CAPABILITY" *(SP capability) SP "IMAP4rev2" 5804 *(SP capability) 5805 ; Servers MUST implement the STARTTLS, AUTH=PLAIN, 5806 ; and LOGINDISABLED capabilities 5807 ; Servers which offer RFC 1730 compatibility MUST 5808 ; list "IMAP4" as the first capability. 5810 CHAR8 = %x01-ff 5811 ; any OCTET except NUL, %x00 5813 charset = atom / quoted 5815 childinfo-extended-item = "CHILDINFO" SP "(" 5816 list-select-base-opt-quoted 5817 *(SP list-select-base-opt-quoted) ")" 5818 ; Extended data item (mbox-list-extended-item) 5819 ; returned when the RECURSIVEMATCH 5820 ; selection option is specified. 5821 ; Note 1: the CHILDINFO tag can be returned 5822 ; with and without surrounding quotes, as per 5823 ; mbox-list-extended-item-tag production. 5824 ; Note 2: The selection options are always returned 5825 ; quoted, unlike their specification in 5826 ; the extended LIST command. 5828 child-mbox-flag = "\HasChildren" / "\HasNoChildren" 5829 ; attributes for CHILDREN return option, at most one 5830 ; possible per LIST response 5832 command = tag SP (command-any / command-auth / command-nonauth / 5833 command-select) CRLF 5834 ; Modal based on state 5836 command-any = "CAPABILITY" / "LOGOUT" / "NOOP" / enable / x-command 5837 ; Valid in all states 5839 command-auth = append / create / delete / examine / list / 5840 Namespace-Command / 5841 rename / select / status / subscribe / unsubscribe / 5842 idle 5843 ; Valid only in Authenticated or Selected state 5845 command-nonauth = login / authenticate / "STARTTLS" 5846 ; Valid only when in Not Authenticated state 5848 command-select = "CLOSE" / "UNSELECT" / "EXPUNGE" / copy / 5849 move / fetch / store / search / uid 5850 ; Valid only when in Selected state 5852 continue-req = "+" SP (resp-text / base64) CRLF 5854 copy = "COPY" SP sequence-set SP mailbox 5856 create = "CREATE" SP mailbox 5857 ; Use of INBOX gives a NO error 5859 date = date-text / DQUOTE date-text DQUOTE 5860 date-day = 1*2DIGIT 5861 ; Day of month 5863 date-day-fixed = (SP DIGIT) / 2DIGIT 5864 ; Fixed-format version of date-day 5866 date-month = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / 5867 "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec" 5869 date-text = date-day "-" date-month "-" date-year 5871 date-year = 4DIGIT 5873 date-time = DQUOTE date-day-fixed "-" date-month "-" date-year 5874 SP time SP zone DQUOTE 5876 delete = "DELETE" SP mailbox 5877 ; Use of INBOX gives a NO error 5879 digit-nz = %x31-39 5880 ; 1-9 5882 eitem-standard-tag = atom 5883 ; a tag for extended list data defined in a Standard 5884 ; Track or Experimental RFC. 5886 eitem-vendor-tag = vendor-token "-" atom 5887 ; a vendor-specific tag for extended list data 5889 enable = "ENABLE" 1*(SP capability) 5891 enable-data = "ENABLED" *(SP capability) 5893 envelope = "(" env-date SP env-subject SP env-from SP 5894 env-sender SP env-reply-to SP env-to SP env-cc SP 5895 env-bcc SP env-in-reply-to SP env-message-id ")" 5897 env-bcc = "(" 1*address ")" / nil 5899 env-cc = "(" 1*address ")" / nil 5901 env-date = nstring 5903 env-from = "(" 1*address ")" / nil 5905 env-in-reply-to = nstring 5907 env-message-id = nstring 5908 env-reply-to = "(" 1*address ")" / nil 5910 env-sender = "(" 1*address ")" / nil 5912 env-subject = nstring 5914 env-to = "(" 1*address ")" / nil 5916 esearch-response = "ESEARCH" [search-correlator] [SP "UID"] 5917 *(SP search-return-data) 5918 ; ESEARCH response replaces SEARCH response 5919 ; from IMAP4rev1. 5921 examine = "EXAMINE" SP mailbox 5923 fetch = "FETCH" SP sequence-set SP ("ALL" / "FULL" / "FAST" / 5924 fetch-att / "(" fetch-att *(SP fetch-att) ")") 5926 fetch-att = "ENVELOPE" / "FLAGS" / "INTERNALDATE" / 5927 "RFC822.SIZE" / 5928 "BODY" ["STRUCTURE"] / "UID" / 5929 "BODY" section [partial] / 5930 "BODY.PEEK" section [partial] / 5931 "BINARY" [".PEEK"] section-binary [partial] / 5932 "BINARY.SIZE" section-binary 5934 flag = "\Answered" / "\Flagged" / "\Deleted" / 5935 "\Seen" / "\Draft" / flag-keyword / flag-extension 5936 ; Does not include "\Recent" 5938 flag-extension = "\" atom 5939 ; Future expansion. Client implementations 5940 ; MUST accept flag-extension flags. Server 5941 ; implementations MUST NOT generate 5942 ; flag-extension flags except as defined by 5943 ; future standard or standards-track 5944 ; revisions of this specification. 5945 ; "\Recent" was defined in RFC 3501 5946 ; and is now deprecated. 5948 flag-fetch = flag 5950 flag-keyword = "$MDNSent" / "$Forwarded" / "$Junk" / 5951 "$NotJunk" / "$Phishing" / atom 5953 flag-list = "(" [flag *(SP flag)] ")" 5955 flag-perm = flag / "\*" 5956 greeting = "*" SP (resp-cond-auth / resp-cond-bye) CRLF 5958 header-fld-name = astring 5960 header-list = "(" header-fld-name *(SP header-fld-name) ")" 5962 idle = "IDLE" CRLF "DONE" 5964 initial-resp = (base64 / "=") 5965 ; "initial response" defined in 5966 ; Section 5.1 of [RFC4422] 5968 list = "LIST" [SP list-select-opts] SP mailbox SP mbox-or-pat 5969 [SP list-return-opts] 5971 list-mailbox = 1*list-char / string 5973 list-char = ATOM-CHAR / list-wildcards / resp-specials 5975 list-return-opts = "RETURN" SP 5976 "(" [return-option *(SP return-option)] ")" 5977 ; list return options, e.g., CHILDREN 5979 list-select-base-opt = "SUBSCRIBED" / option-extension 5980 ; options that can be used by themselves 5982 list-select-base-opt-quoted = DQUOTE list-select-base-opt DQUOTE 5984 list-select-independent-opt = "REMOTE" / option-extension 5985 ; options that do not syntactically interact with 5986 ; other options 5988 list-select-mod-opt = "RECURSIVEMATCH" / option-extension 5989 ; options that require a list-select-base-opt 5990 ; to also be present 5992 list-select-opt = list-select-base-opt / list-select-independent-opt 5993 / list-select-mod-opt 5994 ; An option registration template is described in 5995 ; Section 9.3 of this document. 5997 list-select-opts = "(" [ 5998 (*(list-select-opt SP) list-select-base-opt 5999 *(SP list-select-opt)) 6000 / (list-select-independent-opt 6001 *(SP list-select-independent-opt)) 6002 ] ")" 6004 ; Any number of options may be in any order. 6005 ; If a list-select-mod-opt appears, then a 6006 ; list-select-base-opt must also appear. 6007 ; This allows these: 6008 ; () 6009 ; (REMOTE) 6010 ; (SUBSCRIBED) 6011 ; (SUBSCRIBED REMOTE) 6012 ; (SUBSCRIBED RECURSIVEMATCH) 6013 ; (SUBSCRIBED REMOTE RECURSIVEMATCH) 6014 ; But does NOT allow these: 6015 ; (RECURSIVEMATCH) 6016 ; (REMOTE RECURSIVEMATCH) 6018 list-wildcards = "%" / "*" 6020 literal = "{" number ["+"] "}" CRLF *CHAR8 6021 ; represents the number of CHAR8s. 6022 ; A non-synchronizing literal is distinguished from 6023 ; a synchronizing literal by presence of the "+" 6024 ; before the closing "}". 6025 ; Non synchronizing literals are not allowed when 6026 ; sent from server to the client. 6028 literal8 = "~{" number "}" CRLF *OCTET 6029 ; represents the number of OCTETs 6030 ; in the response string. 6032 login = "LOGIN" SP userid SP password 6034 mailbox = "INBOX" / astring 6035 ; INBOX is case-insensitive. All case variants of 6036 ; INBOX (e.g., "iNbOx") MUST be interpreted as INBOX 6037 ; not as an astring. An astring which consists of 6038 ; the case-insensitive sequence "I" "N" "B" "O" "X" 6039 ; is considered to be INBOX and not an astring. 6040 ; Refer to section 5.1 for further 6041 ; semantic details of mailbox names. 6043 mailbox-data = "FLAGS" SP flag-list / "LIST" SP mailbox-list / 6044 esearch-response / 6045 "STATUS" SP mailbox SP "(" [status-att-list] ")" / 6046 number SP "EXISTS" / Namespace-Response 6048 mailbox-list = "(" [mbx-list-flags] ")" SP 6049 (DQUOTE QUOTED-CHAR DQUOTE / nil) SP mailbox 6050 [SP mbox-list-extended] 6051 ; This is the list information pointed to by the ABNF 6052 ; item "mailbox-data", which is defined in [IMAP4] 6054 mbox-list-extended = "(" [mbox-list-extended-item 6055 *(SP mbox-list-extended-item)] ")" 6057 mbox-list-extended-item = mbox-list-extended-item-tag SP 6058 tagged-ext-val 6060 mbox-list-extended-item-tag = astring 6061 ; The content MUST conform to either "eitem-vendor-tag" 6062 ; or "eitem-standard-tag" ABNF productions. 6064 mbox-or-pat = list-mailbox / patterns 6066 mbx-list-flags = *(mbx-list-oflag SP) mbx-list-sflag 6067 *(SP mbx-list-oflag) / 6068 mbx-list-oflag *(SP mbx-list-oflag) 6070 mbx-list-oflag = "\Noinferiors" / child-mbox-flag / 6071 "\Subscribed" / "\Remote" / flag-extension 6072 ; Other flags; multiple possible per LIST response 6074 mbx-list-sflag = "\NonExistent" / "\Noselect" / "\Marked" / "\Unmarked" 6075 ; Selectability flags; only one per LIST response 6077 media-basic = ((DQUOTE ("APPLICATION" / "AUDIO" / "IMAGE" / 6078 "MESSAGE" / "VIDEO" / "FONT") DQUOTE) / string) SP 6079 media-subtype 6080 ; Defined in [MIME-IMT]. 6081 ; FONT defined in RFC YYYY. 6083 media-message = DQUOTE "MESSAGE" DQUOTE SP 6084 DQUOTE ("RFC822" / "GLOBAL") DQUOTE 6085 ; Defined in [MIME-IMT] 6087 media-subtype = string 6088 ; Defined in [MIME-IMT] 6090 media-text = DQUOTE "TEXT" DQUOTE SP media-subtype 6091 ; Defined in [MIME-IMT] 6093 message-data = nz-number SP ("EXPUNGE" / ("FETCH" SP msg-att)) 6095 move = "MOVE" SP sequence-set SP mailbox 6097 msg-att = "(" (msg-att-dynamic / msg-att-static) 6098 *(SP (msg-att-dynamic / msg-att-static)) ")" 6100 msg-att-dynamic = "FLAGS" SP "(" [flag-fetch *(SP flag-fetch)] ")" 6101 ; MAY change for a message 6103 msg-att-static = "ENVELOPE" SP envelope / "INTERNALDATE" SP date-time / 6104 "RFC822.SIZE" SP number / 6105 "BODY" ["STRUCTURE"] SP body / 6106 "BODY" section ["<" number ">"] SP nstring / 6107 "BINARY" section-binary SP (nstring / literal8) / 6108 "BINARY.SIZE" section-binary SP number / 6109 "UID" SP uniqueid 6110 ; MUST NOT change for a message 6112 Namespace = nil / "(" 1*Namespace-Descr ")" 6114 Namespace-Command = "NAMESPACE" 6116 Namespace-Descr = "(" string SP 6117 (DQUOTE QUOTED-CHAR DQUOTE / nil) 6118 [Namespace-Response-Extensions] ")" 6120 Namespace-Response-Extensions = *(Namespace-Response-Extension) 6122 Namespace-Response-Extension = SP string SP 6123 "(" string *(SP string) ")" 6125 Namespace-Response = "NAMESPACE" SP Namespace 6126 SP Namespace SP Namespace 6127 ; The first Namespace is the Personal Namespace(s). 6128 ; The second Namespace is the Other Users' 6129 ; Namespace(s). 6130 ; The third Namespace is the Shared Namespace(s). 6132 nil = "NIL" 6134 nstring = string / nil 6136 number = 1*DIGIT 6137 ; Unsigned 32-bit integer 6138 ; (0 <= n < 4,294,967,296) 6140 number64 = 1*DIGIT 6141 ; Unsigned 63-bit integer 6142 ; (0 <= n <= 9,223,372,036,854,775,807) 6144 nz-number = digit-nz *DIGIT 6145 ; Non-zero unsigned 32-bit integer 6146 ; (0 < n < 4,294,967,296) 6148 option-extension = (option-standard-tag / option-vendor-tag) 6149 [SP option-value] 6151 option-standard-tag = atom 6152 ; an option defined in a Standards Track or 6153 ; Experimental RFC 6155 option-val-comp = astring / 6156 option-val-comp *(SP option-val-comp) / 6157 "(" option-val-comp ")" 6159 option-value = "(" option-val-comp ")" 6161 option-vendor-tag = vendor-token "-" atom 6162 ; a vendor-specific option, non-standard 6164 partial-range = number ["." nz-number] 6165 ; Copied from RFC 5092 (IMAP URL) 6167 partial = "<" number "." nz-number ">" 6168 ; Partial FETCH request. 0-based offset of 6169 ; the first octet, followed by the number of octets 6170 ; in the fragment. 6172 password = astring 6174 patterns = "(" list-mailbox *(SP list-mailbox) ")" 6176 quoted = DQUOTE *QUOTED-CHAR DQUOTE 6178 QUOTED-CHAR = / 6179 "\" quoted-specials / UTF8-2 / UTF8-3 / UTF8-4 6181 quoted-specials = DQUOTE / "\" 6183 rename = "RENAME" SP mailbox SP mailbox 6184 ; Use of INBOX as a destination gives a NO error 6186 response = *(continue-req / response-data) response-done 6188 response-data = "*" SP (resp-cond-state / resp-cond-bye / 6189 mailbox-data / message-data / capability-data / 6190 enable-data) CRLF 6192 response-done = response-tagged / response-fatal 6194 response-fatal = "*" SP resp-cond-bye CRLF 6195 ; Server closes connection immediately 6197 response-tagged = tag SP resp-cond-state CRLF 6199 resp-code-apnd = "APPENDUID" SP nz-number SP append-uid 6201 resp-code-copy = "COPYUID" SP nz-number SP uid-set SP uid-set 6203 resp-cond-auth = ("OK" / "PREAUTH") SP resp-text 6204 ; Authentication condition 6206 resp-cond-bye = "BYE" SP resp-text 6208 resp-cond-state = ("OK" / "NO" / "BAD") SP resp-text 6209 ; Status condition 6211 resp-specials = "]" 6213 resp-text = ["[" resp-text-code "]" SP] [text] 6215 resp-text-code = "ALERT" / 6216 "BADCHARSET" [SP "(" charset *(SP charset) ")" ] / 6217 capability-data / "PARSE" / 6218 "PERMANENTFLAGS" SP "(" 6219 [flag-perm *(SP flag-perm)] ")" / 6220 "READ-ONLY" / "READ-WRITE" / "TRYCREATE" / 6221 "UIDNEXT" SP nz-number / "UIDVALIDITY" SP nz-number / 6222 resp-code-apnd / resp-code-copy / "UIDNOTSTICKY" / 6223 "UNAVAILABLE" / "AUTHENTICATIONFAILED" / 6224 "AUTHORIZATIONFAILED" / "EXPIRED" / 6225 "PRIVACYREQUIRED" / "CONTACTADMIN" / "NOPERM" / 6226 "INUSE" / "EXPUNGEISSUED" / "CORRUPTION" / 6227 "SERVERBUG" / "CLIENTBUG" / "CANNOT" / 6228 "LIMIT" / "OVERQUOTA" / "ALREADYEXISTS" / 6229 "NONEXISTENT" / "NOTSAVED" / 6230 "CLOSED" / 6231 "UNKNOWN-CTE" / 6232 atom [SP 1*] 6234 return-option = "SUBSCRIBED" / "CHILDREN" / status-option / 6235 option-extension 6237 search = "SEARCH" [search-return-opts] 6238 SP search-program 6240 search-correlator = SP "(" "TAG" SP tag-string ")" 6242 search-key = "ALL" / "ANSWERED" / "BCC" SP astring / 6243 "BEFORE" SP date / "BODY" SP astring / 6244 "CC" SP astring / "DELETED" / "FLAGGED" / 6245 "FROM" SP astring / "KEYWORD" SP flag-keyword / 6246 "ON" SP date / "SEEN" / 6247 "SINCE" SP date / "SUBJECT" SP astring / 6248 "TEXT" SP astring / "TO" SP astring / 6249 "UNANSWERED" / "UNDELETED" / "UNFLAGGED" / 6250 "UNKEYWORD" SP flag-keyword / "UNSEEN" / 6251 ; Above this line were in [IMAP2] 6252 "DRAFT" / "HEADER" SP header-fld-name SP astring / 6253 "LARGER" SP number / "NOT" SP search-key / 6254 "OR" SP search-key SP search-key / 6255 "SENTBEFORE" SP date / "SENTON" SP date / 6256 "SENTSINCE" SP date / "SMALLER" SP number / 6257 "UID" SP sequence-set / "UNDRAFT" / sequence-set / 6258 "(" search-key *(SP search-key) ")" 6260 search-modifier-name = tagged-ext-label 6262 search-mod-params = tagged-ext-val 6263 ; This non-terminal shows recommended syntax 6264 ; for future extensions. 6266 search-program = ["CHARSET" SP charset SP] 6267 search-key *(SP search-key) 6268 ; CHARSET argument to SEARCH MUST be 6269 ; registered with IANA. 6271 search-ret-data-ext = search-modifier-name SP search-return-value 6272 ; Note that not every SEARCH return option 6273 ; is required to have the corresponding 6274 ; ESEARCH return data. 6276 search-return-data = "MIN" SP nz-number / 6277 "MAX" SP nz-number / 6278 "ALL" SP sequence-set / 6279 "COUNT" SP number / 6280 search-ret-data-ext 6281 ; All return data items conform to 6282 ; search-ret-data-ext syntax. 6283 ; Note that "$" marker is not allowed 6284 ; after the ALL return data item. 6286 search-return-opts = SP "RETURN" SP "(" [search-return-opt 6287 *(SP search-return-opt)] ")" 6289 search-return-opt = "MIN" / "MAX" / "ALL" / "COUNT" / 6290 "SAVE" / 6291 search-ret-opt-ext 6292 ; conforms to generic search-ret-opt-ext 6293 ; syntax 6295 search-ret-opt-ext = search-modifier-name [SP search-mod-params] 6297 search-return-value = tagged-ext-val 6298 ; Data for the returned search option. 6299 ; A single "nz-number"/"number"/"number64" value 6300 ; can be returned as an atom (i.e., without 6301 ; quoting). A sequence-set can be returned 6302 ; as an atom as well. 6304 section = "[" [section-spec] "]" 6306 section-binary = "[" [section-part] "]" 6308 section-msgtext = "HEADER" / "HEADER.FIELDS" [".NOT"] SP header-list / 6309 "TEXT" 6310 ; top-level or MESSAGE/RFC822 or MESSAGE/GLOBAL part 6312 section-part = nz-number *("." nz-number) 6313 ; body part reference. 6314 ; Allows for accessing nested body parts. 6316 section-spec = section-msgtext / (section-part ["." section-text]) 6318 section-text = section-msgtext / "MIME" 6319 ; text other than actual body part (headers, etc.) 6321 select = "SELECT" SP mailbox 6323 seq-number = nz-number / "*" 6324 ; message sequence number (COPY, FETCH, STORE 6325 ; commands) or unique identifier (UID COPY, 6326 ; UID FETCH, UID STORE commands). 6327 ; * represents the largest number in use. In 6328 ; the case of message sequence numbers, it is 6329 ; the number of messages in a non-empty mailbox. 6330 ; In the case of unique identifiers, it is the 6331 ; unique identifier of the last message in the 6332 ; mailbox or, if the mailbox is empty, the 6333 ; mailbox's current UIDNEXT value. 6334 ; The server should respond with a tagged BAD 6335 ; response to a command that uses a message 6336 ; sequence number greater than the number of 6337 ; messages in the selected mailbox. This 6338 ; includes "*" if the selected mailbox is empty. 6340 seq-range = seq-number ":" seq-number 6341 ; two seq-number values and all values between 6342 ; these two regardless of order. 6343 ; Example: 2:4 and 4:2 are equivalent and indicate 6344 ; values 2, 3, and 4. 6345 ; Example: a unique identifier sequence range of 6346 ; 3291:* includes the UID of the last message in 6347 ; the mailbox, even if that value is less than 3291. 6349 sequence-set = (seq-number / seq-range) ["," sequence-set] 6350 ; set of seq-number values, regardless of order. 6351 ; Servers MAY coalesce overlaps and/or execute the 6352 ; sequence in any order. 6353 ; Example: a message sequence number set of 6354 ; 2,4:7,9,12:* for a mailbox with 15 messages is 6355 ; equivalent to 2,4,5,6,7,9,12,13,14,15 6356 ; Example: a message sequence number set of *:4,5:7 6357 ; for a mailbox with 10 messages is equivalent to 6358 ; 10,9,8,7,6,5,4,5,6,7 and MAY be reordered and 6359 ; overlap coalesced to be 4,5,6,7,8,9,10. 6361 sequence-set =/ seq-last-command 6362 ; Allow for "result of the last command" indicator. 6364 seq-last-command = "$" 6366 status = "STATUS" SP mailbox SP 6367 "(" status-att *(SP status-att) ")" 6369 status-att = "MESSAGES" / "UIDNEXT" / "UIDVALIDITY" / 6370 "UNSEEN" / "DELETED" / "SIZE" 6372 status-att-val = ("MESSAGES" SP number) / 6373 ("UIDNEXT" SP nz-number) / 6374 ("UIDVALIDITY" SP nz-number) / 6375 ("UNSEEN" SP number) / 6376 ("DELETED" SP number) / 6377 ("SIZE" SP number64) 6378 ; Extensions to the STATUS responses 6379 ; should extend this production. 6380 ; Extensions should use the generic 6381 ; syntax defined by tagged-ext. 6383 status-att-list = status-att-val *(SP status-att-val) 6385 status-option = "STATUS" SP "(" status-att *(SP status-att) ")" 6386 ; This ABNF production complies with 6387 ; syntax. 6389 store = "STORE" SP sequence-set SP store-att-flags 6391 store-att-flags = (["+" / "-"] "FLAGS" [".SILENT"]) SP 6392 (flag-list / (flag *(SP flag))) 6394 string = quoted / literal 6396 subscribe = "SUBSCRIBE" SP mailbox 6398 tag = 1* 6400 tagged-ext-label = tagged-label-fchar *tagged-label-char 6401 ;; Is a valid RFC 3501 "atom". 6403 tagged-label-fchar = ALPHA / "-" / "_" / "." 6405 tagged-label-char = tagged-label-fchar / DIGIT / ":" 6407 tagged-ext-comp = astring / 6408 tagged-ext-comp *(SP tagged-ext-comp) / 6409 "(" tagged-ext-comp ")" 6410 ;; Extensions that follow this general 6411 ;; syntax should use nstring instead of 6412 ;; astring when appropriate in the context 6413 ;; of the extension. 6414 ;; Note that a message set or a "number" 6415 ;; can always be represented as an "atom". 6416 ;; An URL should be represented as 6417 ;; a "quoted" string. 6419 tagged-ext-simple = sequence-set / number / number64 6421 tagged-ext-val = tagged-ext-simple / 6422 "(" [tagged-ext-comp] ")" 6424 text = 1*TEXT-CHAR 6426 TEXT-CHAR = 6428 time = 2DIGIT ":" 2DIGIT ":" 2DIGIT 6429 ; Hours minutes seconds 6431 uid = "UID" SP 6432 (copy / move / fetch / search / store / uid-expunge) 6433 ; Unique identifiers used instead of message 6434 ; sequence numbers 6436 uid-expunge = "EXPUNGE" SP sequence-set 6437 ; Unique identifiers used instead of message 6438 ; sequence numbers 6440 uid-set = (uniqueid / uid-range) *("," uid-set) 6442 uid-range = (uniqueid ":" uniqueid) 6443 ; two uniqueid values and all values 6444 ; between these two regards of order. 6445 ; Example: 2:4 and 4:2 are equivalent. 6447 uniqueid = nz-number 6448 ; Strictly ascending 6450 unsubscribe = "UNSUBSCRIBE" SP mailbox 6452 userid = astring 6454 UTF8-2 = 6456 UTF8-3 = 6458 UTF8-4 = 6460 x-command = "X" atom 6462 zone = ("+" / "-") 4DIGIT 6463 ; Signed four-digit value of hhmm representing 6464 ; hours and minutes east of Greenwich (that is, 6465 ; the amount that the given time differs from 6466 ; Universal Time). Subtracting the timezone 6467 ; from the given time will give the UT form. 6468 ; The Universal Time zone is "+0000". 6470 10. Author's Note 6472 This document is a revision or rewrite of earlier documents, and 6473 supercedes the protocol specification in those documents: RFC 2060, 6474 RFC 1730, unpublished IMAP2bis.TXT document, RFC 1176, and RFC 1064. 6476 11. Security Considerations 6478 IMAP4rev2 protocol transactions, including electronic mail data, are 6479 sent in the clear over the network unless protection from snooping is 6480 negotiated. This can be accomplished either by the use of IMAPS 6481 service, STARTTLS command, negotiated privacy protection in the 6482 AUTHENTICATE command, or some other protection mechanism. 6484 11.1. STARTTLS Security Considerations 6486 IMAP client and server implementations MUST comply with relevant TLS 6487 recommendations from [RFC8314]. Additionally, when using TLS 1.2, 6488 IMAP implementations MUST implement 6489 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 cipher suite, and SHOULD 6490 implement the TLS_RSA_WITH_AES_128_CBC_SHA [TLS] cipher suite. This 6491 is important as it assures that any two compliant implementations can 6492 be configured to interoperate. Other TLS cipher suites recommended 6493 in RFC 7525 are RECOMMENDED: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 6494 TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 and 6495 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384. All other cipher suites are 6496 OPTIONAL. Note that this is a change from section 2.1 of [IMAP-TLS]. 6498 During the [TLS] negotiation, the client MUST check its understanding 6499 of the server hostname against the server's identity as presented in 6500 the server Certificate message, in order to prevent man-in-the-middle 6501 attacks. This procedure is described in [RFC7817]. 6503 Both the client and server MUST check the result of the STARTTLS 6504 command and subsequent [TLS] negotiation to see whether acceptable 6505 authentication and/or privacy was achieved. 6507 11.2. COPYUID and APPENDUID response codes 6509 The COPYUID and APPENDUID response codes return information about the 6510 mailbox, which may be considered sensitive if the mailbox has 6511 permissions set that permit the client to COPY or APPEND to the 6512 mailbox, but not SELECT or EXAMINE it. 6514 Consequently, these response codes SHOULD NOT be issued if the client 6515 does not have access to SELECT or EXAMINE the mailbox. 6517 11.3. LIST command and Other Users' namespace 6519 In response to a LIST command containing an argument of the Other 6520 Users' Namespace prefix, a server SHOULD NOT list users that have not 6521 granted list access to their personal mailboxes to the currently 6522 authenticated user. Providing such a list, could compromise security 6523 by potentially disclosing confidential information of who is located 6524 on the server, or providing a starting point of a list of user 6525 accounts to attack. 6527 11.4. Other Security Considerations 6529 A server error message for an AUTHENTICATE command which fails due to 6530 invalid credentials SHOULD NOT detail why the credentials are 6531 invalid. 6533 Use of the LOGIN command sends passwords in the clear. This can be 6534 avoided by using the AUTHENTICATE command with a [SASL] mechanism 6535 that does not use plaintext passwords, by first negotiating 6536 encryption via STARTTLS or some other protection mechanism. 6538 A server implementation MUST implement a configuration that, at the 6539 time of authentication, requires: 6540 (1) The STARTTLS command has been negotiated. 6541 OR 6542 (2) Some other mechanism that protects the session from password 6543 snooping has been provided. 6544 OR 6545 (3) The following measures are in place: 6546 (a) The LOGINDISABLED capability is advertised, and [SASL] mechanisms 6547 (such as PLAIN) using plaintext passwords are NOT advertised in the 6548 CAPABILITY list. 6549 AND 6550 (b) The LOGIN command returns an error even if the password is 6551 correct. 6552 AND 6553 (c) The AUTHENTICATE command returns an error with all [SASL] 6554 mechanisms that use plaintext passwords, even if the password is 6555 correct. 6557 A server error message for a failing LOGIN command SHOULD NOT specify 6558 that the user name, as opposed to the password, is invalid. 6560 A server SHOULD have mechanisms in place to limit or delay failed 6561 AUTHENTICATE/LOGIN attempts. 6563 Additional security considerations are discussed in the section 6564 discussing the AUTHENTICATE and LOGIN commands. 6566 12. IANA Considerations 6568 IANA is requested to update "Service Names and Transport Protocol 6569 Port Numbers" registry as follows: 6571 1. Registration for TCP "imap" port 143 should be updated to point 6572 to this document and RFC 3501. 6574 2. Registration for TCP "imaps" port 993 should be updated to point 6575 to this document, RFC 8314 and RFC 3501. 6577 3. Both UDP port 143 and UDP port 993 should be marked as "Reserved" 6578 in the registry. 6580 Additional IANA actions are specified in subsection of this section. 6582 12.1. Updates to IMAP4 Capabilities registry 6584 IMAP4 capabilities are registered by publishing a standards track or 6585 IESG approved informational or experimental RFC. The registry is 6586 currently located at: https://www.iana.org/assignments/ 6587 imap4-capabilities 6589 As this specification revises the STARTTLS and LOGINDISABLED 6590 extensions previously defined in [IMAP-TLS], IANA is requested to 6591 update registry entries for these 2 extensions to point to this 6592 document. 6594 12.2. GSSAPI/SASL service name 6596 GSSAPI/Kerberos/SASL service names are registered by publishing a 6597 standards track or IESG approved experimental RFC. The registry is 6598 currently located at: http://www.iana.org/assignments/gssapi-service- 6599 names 6601 IANA is requested to update the "imap" service name previously 6602 registered in RFC 3501, to point to this document. 6604 13. References 6606 13.1. Normative References 6608 [ABNF] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 6609 Specifications: ABNF", STD 68, RFC 5234, January 2008, 6610 . 6612 [ANONYMOUS] 6613 Zeilenga, K., "Anonymous Simple Authentication and 6614 Security Layer (SASL) Mechanism", RFC 4505, June 2006, 6615 . 6617 [CHARSET] Freed, N. and J. Postel, "IANA Charset Registration 6618 Procedures", BCP 19, RFC 2978, October 2000, 6619 . 6621 [SCRAM-SHA-256] 6622 Hansen, T., "SCRAM-SHA-256 and SCRAM-SHA-256-PLUS Simple 6623 Authentication and Security Layer (SASL) Mechanisms", 6624 RFC 7677, DOI 10.17487/RFC7677, November 2015, 6625 . 6627 [DISPOSITION] 6628 Troost, R., Dorner, S., and K. Moore, Ed., "Communicating 6629 Presentation Information in Internet Messages: The 6630 Content-Disposition Header Field", RFC 2183, August 1997, 6631 . 6633 [PLAIN] Zeilenga, K., Ed., "The PLAIN Simple Authentication and 6634 Security Layer (SASL) Mechanism", RFC 4616, August 2006, 6635 . 6637 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 6638 Requirement Levels", BCP 14, RFC 2119, 6639 DOI 10.17487/RFC2119, March 1997, 6640 . 6642 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 6643 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 6644 May 2017, . 6646 [LANGUAGE-TAGS] 6647 Alvestrand, H., "Content Language Headers", RFC 3282, May 6648 2002, . 6650 [LOCATION] 6651 Palme, J., Hopmann, A., and N. Shelness, "MIME 6652 Encapsulation of Aggregate Documents, such as HTML 6653 (MHTML)", RFC 2557, March 1999, 6654 . 6656 [MD5] Myers, J. and M. Rose, "The Content-MD5 Header Field", 6657 RFC 1864, October 1995, 6658 . 6660 [MIME-HDRS] 6661 Moore, K., "MIME (Multipurpose Internet Mail Extensions) 6662 Part Three: Message Header Extensions for Non-ASCII Text", 6663 RFC 2047, November 1996, 6664 . 6666 [MIME-IMB] 6667 Freed, N. and N. Borenstein, "Multipurpose Internet Mail 6668 Extensions (MIME) Part One: Format of Internet Message 6669 Bodies", RFC 2045, November 1996, 6670 . 6672 [MIME-IMT] 6673 Freed, N. and N. Borenstein, "Multipurpose Internet Mail 6674 Extensions (MIME) Part Two: Media Types", RFC 2046, 6675 November 1996, . 6677 [RFC2231] Freed, N. and K. Moore, "MIME Parameter Value and Encoded 6678 Word Extensions: Character Sets, Languages, and 6679 Continuations", RFC 2231, DOI 10.17487/RFC2231, November 6680 1997, . 6682 [RFC-5322] 6683 Resnick, P., Ed., "Internet Message Format", RFC 5322, 6684 October 2008, . 6686 [SASL] Melnikov, A., Ed. and K. Zeilenga, Ed., "Simple 6687 Authentication and Security Layer (SASL)", RFC 4422, June 6688 2006, . 6690 [TLS] Dierks, T. and E. Rescorla, "The Transport Layer Security 6691 (TLS) Protocol Version 1.2", RFC 5246, August 2008, 6692 . 6694 [UTF-7] Goldsmith, D. and M. Davis, "UTF-7 A Mail-Safe 6695 Transformation Format of Unicode", RFC 2152, May 1997, 6696 . 6698 [UTF-8] Yergeau, F., "UTF-8, a transformation format of ISO 6699 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 6700 2003, . 6702 [MULTIAPPEND] 6703 Crispin, M., "Internet Message Access Protocol (IMAP) - 6704 MULTIAPPEND Extension", RFC 3502, March 2003, 6705 . 6707 [NET-UNICODE] 6708 Klensin, J. and M. Padlipsky, "Unicode Format for Network 6709 Interchange", RFC 5198, DOI 10.17487/RFC5198, March 2008, 6710 . 6712 [I18N-HDRS] 6713 Yang, A., Steele, S., and N. Freed, "Internationalized 6714 Email Headers", RFC 6532, DOI 10.17487/RFC6532, February 6715 2012, . 6717 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 6718 Encodings", RFC 4648, DOI 10.17487/RFC4648, October 2006, 6719 . 6721 [RFC7817] Melnikov, A., "Updated Transport Layer Security (TLS) 6722 Server Identity Check Procedure for Email-Related 6723 Protocols", RFC 7817, DOI 10.17487/RFC7817, March 2016, 6724 . 6726 [RFC8098] Hansen, T., Ed. and A. Melnikov, Ed., "Message Disposition 6727 Notification", STD 85, RFC 8098, DOI 10.17487/RFC8098, 6728 February 2017, . 6730 [RFC8314] Moore, K. and C. Newman, "Cleartext Considered Obsolete: 6731 Use of Transport Layer Security (TLS) for Email Submission 6732 and Access", RFC 8314, DOI 10.17487/RFC8314, January 2018, 6733 . 6735 [IMAP-IMPLEMENTATION] 6736 Leiba, B., "IMAP4 Implementation Recommendations", 6737 RFC 2683, September 1999, 6738 . 6740 [IMAP-MULTIACCESS] 6741 Gahrns, M., "IMAP4 Multi-Accessed Mailbox Practice", 6742 RFC 2180, July 1997, 6743 . 6745 13.2. Informative References (related protocols) 6747 [RFC3503] Melnikov, A., "Message Disposition Notification (MDN) 6748 profile for Internet Message Access Protocol (IMAP)", 6749 RFC 3503, DOI 10.17487/RFC3503, March 2003, 6750 . 6752 [RFC5256] Crispin, M. and K. Murchison, "Internet Message Access 6753 Protocol - SORT and THREAD Extensions", RFC 5256, 6754 DOI 10.17487/RFC5256, June 2008, 6755 . 6757 [RFC5258] Leiba, B. and A. Melnikov, "Internet Message Access 6758 Protocol version 4 - LIST Command Extensions", RFC 5258, 6759 DOI 10.17487/RFC5258, June 2008, 6760 . 6762 [RFC2193] Gahrns, M., "IMAP4 Mailbox Referrals", RFC 2193, 6763 DOI 10.17487/RFC2193, September 1997, 6764 . 6766 [RFC3348] Gahrns, M. and R. Cheng, "The Internet Message Action 6767 Protocol (IMAP4) Child Mailbox Extension", RFC 3348, 6768 DOI 10.17487/RFC3348, July 2002, 6769 . 6771 [RFC7888] Melnikov, A., Ed., "IMAP4 Non-synchronizing Literals", 6772 RFC 7888, DOI 10.17487/RFC7888, May 2016, 6773 . 6775 [IMAP-DISC] 6776 Melnikov, A., Ed., "Synchronization Operations for 6777 Disconnected IMAP4 Clients", RFC 4549, June 2006, 6778 . 6780 [IMAP-I18N] 6781 Newman, C., Gulbrandsen, A., and A. Melnikov, "Internet 6782 Message Access Protocol Internationalization", RFC 5255, 6783 DOI 10.17487/RFC5255, June 2008, 6784 . 6786 [IMAP-MODEL] 6787 Crispin, M., "Distributed Electronic Mail Models in 6788 IMAP4", RFC 1733, December 1994, 6789 . 6791 [IMAP-UTF-8] 6792 Resnick, P., Ed., Newman, C., Ed., and S. Shen, Ed., "IMAP 6793 Support for UTF-8", RFC 6855, DOI 10.17487/RFC6855, March 6794 2013, . 6796 [SMTP] Klensin, J., "Simple Mail Transfer Protocol", RFC 5321, 6797 October 2008, . 6799 [RFC3516] Nerenberg, L., "IMAP4 Binary Content Extension", RFC 3516, 6800 DOI 10.17487/RFC3516, April 2003, 6801 . 6803 [RFC4314] Melnikov, A., "IMAP4 Access Control List (ACL) Extension", 6804 RFC 4314, December 2005, 6805 . 6807 [RFC2087] Myers, J., "IMAP4 QUOTA extension", RFC 2087, January 6808 1997, . 6810 [IMAP-URL] 6811 Melnikov, A., Ed. and C. Newman, "IMAP URL Scheme", 6812 RFC 5092, DOI 10.17487/RFC5092, November 2007, 6813 . 6815 [IMAP-KEYWORDS-REG] 6816 IANA, "IMAP and JMAP Keywords", December 2009, 6817 . 6820 [IMAP-MAILBOX-NAME-ATTRS-REG] 6821 IANA, "IMAP Mailbox Name Attributes", June 2018, 6822 . 6825 [CHARSET-REG] 6826 IANA, "Character Set Registrations", May 2015, 6827 . 6830 13.3. Informative References (historical aspects of IMAP and related 6831 protocols) 6833 [IMAP-COMPAT] 6834 Crispin, M., "IMAP4 Compatibility with IMAP2bis", 6835 RFC 2061, December 1996, 6836 . 6838 [IMAP-HISTORICAL] 6839 Crispin, M., "IMAP4 Compatibility with IMAP2 and 6840 IMAP2bis", RFC 1732, December 1994, 6841 . 6843 [IMAP-OBSOLETE] 6844 Crispin, M., "Internet Message Access Protocol - Obsolete 6845 Syntax", RFC 2062, December 1996, 6846 . 6848 [IMAP2] Crispin, M., "Interactive Mail Access Protocol: Version 6849 2", RFC 1176, August 1990, 6850 . 6852 [RFC-822] Crocker, D., "STANDARD FOR THE FORMAT OF ARPA INTERNET 6853 TEXT MESSAGES", STD 11, RFC 822, August 1982, 6854 . 6856 [IMAP-TLS] 6857 Newman, C., "Using TLS with IMAP, POP3 and ACAP", 6858 RFC 2595, June 1999, 6859 . 6861 Appendix A. Backward compatibility with IMAP4rev1 6863 An implementation that wants to remain compatible with IMAP4rev1 can 6864 advertise both IMAP4rev1 and IMAP4rev2 in its CAPABILITY response/ 6865 response code. While some IMAP4rev1 responses were removed in 6866 IMAP4rev2, their presence will not break IMAP4rev2-only clients. 6868 If both IMAP4rev1 and IMAP4rev2 are advertised, an IMAP client that 6869 wants to use IMAP4rev2 MUST issue an "ENABLE IMAP4rev2" command. 6871 Servers advertising both IMAP4rev1 and IMAP4rev2 SHOULD NOT generate 6872 UTF-8 quoted strings unless the client has issued "ENABLE IMAP4rev2". 6873 Consider implementation of mechanisms described or referenced in 6874 [IMAP-UTF-8] to achieve this goal. 6876 Servers advertising both IMAP4rev1 and IMAP4rev2, and clients 6877 intending to be compatible with IMAP4rev1 servers MUST be compatible 6878 with the international mailbox naming convention described in the 6879 following subsection. 6881 A.1. Mailbox International Naming Convention for compatibility with 6882 IMAP4rev1 6884 Support for the Mailbox International Naming Convention described in 6885 this section is not required for IMAP4rev2-only clients and servers. 6887 By convention, international mailbox names in IMAP4rev1 are specified 6888 using a modified version of the UTF-7 encoding described in [UTF-7]. 6889 Modified UTF-7 may also be usable in servers that implement an 6890 earlier version of this protocol. 6892 In modified UTF-7, printable US-ASCII characters, except for "&", 6893 represent themselves; that is, characters with octet values 0x20-0x25 6894 and 0x27-0x7e. The character "&" (0x26) is represented by the two- 6895 octet sequence "&-". 6897 All other characters (octet values 0x00-0x1f and 0x7f-0xff) are 6898 represented in modified BASE64, with a further modification from 6899 [UTF-7] that "," is used instead of "/". Modified BASE64 MUST NOT be 6900 used to represent any printing US-ASCII character which can represent 6901 itself. Only characters inside the modified BASE64 alphabet are 6902 permitted in modified BASE64 text. 6904 "&" is used to shift to modified BASE64 and "-" to shift back to US- 6905 ASCII. There is no implicit shift from BASE64 to US-ASCII, and null 6906 shifts ("-&" while in BASE64; note that "&-" while in US-ASCII means 6907 "&") are not permitted. However, all names start in US-ASCII, and 6908 MUST end in US-ASCII; that is, a name that ends with a non-ASCII 6909 ISO-10646 character MUST end with a "-"). 6911 The purpose of these modifications is to correct the following 6912 problems with UTF-7: 6914 1. UTF-7 uses the "+" character for shifting; this conflicts with 6915 the common use of "+" in mailbox names, in particular USENET 6916 newsgroup names. 6918 2. UTF-7's encoding is BASE64 which uses the "/" character; this 6919 conflicts with the use of "/" as a popular hierarchy delimiter. 6921 3. UTF-7 prohibits the unencoded usage of "\"; this conflicts with 6922 the use of "\" as a popular hierarchy delimiter. 6924 4. UTF-7 prohibits the unencoded usage of "~"; this conflicts with 6925 the use of "~" in some servers as a home directory indicator. 6927 5. UTF-7 permits multiple alternate forms to represent the same 6928 string; in particular, printable US-ASCII characters can be 6929 represented in encoded form. 6931 Although modified UTF-7 is a convention, it establishes certain 6932 requirements on server handling of any mailbox name with an embedded 6933 "&" character. In particular, server implementations MUST preserve 6934 the exact form of the modified BASE64 portion of a modified UTF-7 6935 name and treat that text as case-sensitive, even if names are 6936 otherwise case-insensitive or case-folded. 6938 Server implementations SHOULD verify that any mailbox name with an 6939 embedded "&" character, used as an argument to CREATE, is: in the 6940 correctly modified UTF-7 syntax, has no superfluous shifts, and has 6941 no encoding in modified BASE64 of any printing US-ASCII character 6942 which can represent itself. However, client implementations MUST NOT 6943 depend upon the server doing this, and SHOULD NOT attempt to create a 6944 mailbox name with an embedded "&" character unless it complies with 6945 the modified UTF-7 syntax. 6947 Server implementations which export a mail store that does not follow 6948 the modified UTF-7 convention MUST convert to modified UTF-7 any 6949 mailbox name that contains either non-ASCII characters or the "&" 6950 character. 6952 For example, here is a mailbox name which mixes English, Chinese, 6953 and Japanese text: ~peter/mail/&U,BTFw-/&ZeVnLIqe- 6954 For example, the string "&Jjo!" is not a valid mailbox name 6955 because it does not contain a shift to US-ASCII before the "!". 6956 The correct form is "&Jjo-!". The string "&U,BTFw-&ZeVnLIqe-" is 6957 not permitted because it contains a superfluous shift. The 6958 correct form is "&U,BTF2XlZyyKng-". 6960 Appendix B. Backward compatibility with BINARY extension 6962 IMAP4rev2 is incorporates subset of functionality provided by the 6963 BINARY extension [RFC3516], in particular it includes additional 6964 FETCH items (BINARY, BINARY.PEEK and BINARY.SIZE), but not extensions 6965 to the APPEND command. IMAP4rev2 implementations that supports full 6966 RFC 3516 functionality need to also advertise the BINARY token in the 6967 CAPABILITY response. 6969 Appendix C. Changes from RFC 3501 / IMAP4rev1 6971 The following is the plan for remaining changes. The plan might 6972 change over time. 6974 1. Revise IANA registration of IMAP extensions and give advice on 6975 use of "X-" convention. 6977 2. Allow word-based searching (as per Chris Newman)? Need to 6978 discuss header field search, where exact/substring match is still 6979 required for interoperability. 6981 The following changes were already done: 6983 1. Fold in the following extensions/RFC: RFC 5530 (IMAP Response 6984 Codes), UIDPLUS, ENABLE, ESEARCH, SPECIAL-USE (list of new 6985 mailbox attributes is done), LITERAL-, NAMESPACE, SASL-IR, IDLE, 6986 MOVE. 6988 2. Add CLOSED response code (from CONDSTORE). 6990 3. Add support for $Phishing, $Junk, $NonJunk, $MDNSent and 6991 $Forwarded IMAP keywords. Add more examples showing their use? 6993 4. Require all unsolicited FETCH updates to include UID. 6995 5. Update recommendations on TLS ciphers to match UTA WG work (as 6996 per RFC 8314, RFC 7525 and RFC 7817). 6998 6. Possibly fold in the following extensions/RFC: Base LIST-EXTENDED 6999 syntax plus deprecate LSUB (replace it with LIST \Subscribed) 7000 minus the requirement to support multiple list patterns, STATUS- 7001 in-LIST, SEARCHRES, BINARY (only the FETCH changes on leaf body 7002 part and make APPEND related ones optional. See the mailing list 7003 discussion). 7005 7. Add STATUS SIZE (total mailbox size). Add STATUS DELETED (number 7006 of messages with \Deleted flag set). 7008 8. Drop UTF-7, all mailboxes are always in UTF-8. 7010 The following changes since RFC 3501 were done so far: 7012 1. Folded in IMAP UNSELECT (RFC 3691), UIDPLUS (RFC 4315), ESEARCH 7013 (RFC 4731), ENABLE (RFC 5161), IDLE (RFC 2177), SASL-IR (RFC 7014 4959), LIST-STATUS (RFC 5819) and MOVE (RFC 6851) extensions. 7015 Also folded RFC 5530 and FETCH side of the BINARY extension (RFC 7016 3516). 7018 2. Clarified that server should decode parameter value 7019 continuations as described in [RFC2231]. This requirement was 7020 hidden in RFC 2231 itself. 7022 3. SEARCH command now requires to return ESEARCH response (SEARCH 7023 response is now deprecated). 7025 4. Added CLOSED response code from RFC 7162. SELECT/EXAMINE when a 7026 mailbox is already selected now require for the CLOSED response 7027 code to be returned. 7029 5. Updated to use modern TLS-related recommendations as per RFC 7030 8314, RFC 7817, RFC 7525. 7032 6. For future extensibility extended ABNF for tagged-ext-simple to 7033 allow for bare number64. 7035 7. Added SHOULD level requirement on IMAP servers to support 7036 $MDNSent, $Forwarded, $Junk, $NonJunk and $Phishing keywords. 7038 8. Added STATUS SIZE and STATUS DELETED. 7040 9. Mailbox names and message headers now allow for UTF-8. Support 7041 for Modified UTF-7 in mailbox names is not required, unless 7042 compatibility with IMAP4rev1 is desired. 7044 10. UNSEEN response code on SELECT/EXAMINE is now deprecated. 7046 11. RECENT response on SELECT/EXAMINE, \Recent flag, RECENT STATUS, 7047 SEARCH NEW items are now deprecated. 7049 12. Clarified that the server doesn't need to send a new 7050 PERMANENTFLAGS response code when a new keyword was successfully 7051 added and the server advertised \* earlier for the same mailbox. 7053 13. Removed the CHECK command. Clients should use NOOP instead. 7055 14. RFC822, RFC822.HEADER and RFC822.TEXT FETCH data items were 7056 deprecated. Clients should use the corresponding BODY[] 7057 variants instead. 7059 15. Replaced DIGEST-MD5 SASL mechanism with SCRAM-SHA-256. DIGEST- 7060 MD5 was deprecated. 7062 16. LSUB command was deprecated. Clients should use LIST 7063 (SUBSCRIBED) instead. 7065 17. resp-text ABNF non terminal was updated to allow for empty text. 7067 18. IDLE command can now return updates not related to the currently 7068 selected mailbox state. 7070 19. All unsolicited FETCH updates are required to include UID. 7072 Appendix D. Acknowledgement 7074 Earlier versions of this document were edited by Mark Crispin. 7075 Sadly, he is no longer available to help with this work. Editors of 7076 this revisions are hoping that Mark would have approved. 7078 Chris Newman has contributed text on I18N and use of UTF-8 in 7079 messages and mailbox names. 7081 Thank you to Tony Hansen for helping with the index generation. 7082 Thank you to Timo Sirainen, Bron Gondwana and Arnt Gulbrandsen for 7083 extensive feedback. 7085 This document incorporate text from RFC 4315 (by Mark Crispin), RFC 7086 4466 (by Cyrus Daboo), RFC 4731 (by Dave Cridland), RFC 5161 (by Arnt 7087 Gulbrandsen), RFC 5530 (by Arnt Gulbrandsen), RFC 5819 (by Timo 7088 Sirainen), RFC 6154 (by Jamie Nicolson) so work done by authors/ 7089 editors of these documents is appreciated. Note that editors of this 7090 document were redacted from the above list. 7092 Index 7094 $ 7095 $Forwarded (predefined flag) 12 7096 $Junk (predefined flag) 12 7097 $MDNSent (predefined flag) 12 7098 $NotJunk (predefined flag) 12 7099 $Phishing (predefined flag) 12 7101 + 7102 +FLAGS 91 7103 +FLAGS.SILENT 91 7105 - 7106 -FLAGS 91 7107 -FLAGS.SILENT 91 7109 A 7110 ALERT (response code) 98 7111 ALL (fetch item) 87 7112 ALL (search key) 77 7113 ALL (search result option) 75 7114 ALREADYEXISTS (response code) 98 7115 ANSWERED (search key) 77 7116 APPEND (command) 67 7117 APPENDUID (response code) 98 7118 AUTHENTICATE (command) 29 7119 AUTHENTICATIONFAILED (response code) 99 7120 AUTHORIZATIONFAILED (response code) 99 7122 B 7123 BAD (response) 106 7124 BADCHARSET (response code) 100 7125 BCC (search key) 77 7126 BEFORE (search key) 77 7127 BINARY.PEEK[]<> (fetch item) 87 7128 BINARY.SIZE[] (fetch item) 87 7129 BINARY.SIZE[] (fetch result) 117 7130 BINARY[]<> (fetch result) 116 7131 BINARY[]<> (fetch item) 87 7132 BODY (fetch item) 88 7133 BODY (fetch result) 117 7134 BODY (search key) 77 7135 BODY.PEEK[
]<> (fetch item) 90 7136 BODYSTRUCTURE (fetch item) 90 7137 BODYSTRUCTURE (fetch result) 117 7138 BODY[
]<> (fetch result) 117 7139 BODY[
]<> (fetch item) 88 7140 BYE (response) 107 7141 Body Structure (message attribute) 14 7143 C 7144 CANNOT (response code) 100 7145 CAPABILITY (command) 25 7146 CAPABILITY (response code) 100 7147 CAPABILITY (response) 108 7148 CC (search key) 77 7149 CLIENTBUG (response code) 100 7150 CLOSE (command) 72 7151 CLOSED (response code) 100 7152 CONTACTADMIN (response code) 101 7153 COPY (command) 91 7154 COPYUID (response code) 101 7155 CORRUPTION (response code) 101 7156 COUNT (search result option) 75 7157 CREATE (command) 38 7159 D 7160 DELETE (command) 39 7161 DELETED (search key) 77 7162 DELETED (status item) 67 7163 DRAFT (search key) 77 7165 E 7166 ENABLE (command) 33 7167 ENVELOPE (fetch item) 90 7168 ENVELOPE (fetch result) 120 7169 ESEARCH (response) 113 7170 EXAMINE (command) 37 7171 EXPIRED (response code) 102 7172 EXPUNGE (command) 73 7173 EXPUNGE (response) 115 7174 EXPUNGEISSUED (response code) 102 7175 Envelope Structure (message attribute) 14 7177 F 7178 FAST (fetch item) 87 7179 FETCH (command) 86 7180 FETCH (response) 116 7181 FLAGGED (search key) 77 7182 FLAGS (fetch item) 90 7183 FLAGS (fetch result) 121 7184 FLAGS (response) 114 7185 FLAGS (store command data item) 91 7186 FLAGS.SILENT (store command data item) 91 7187 FROM (search key) 77 7188 FULL (fetch item) 87 7189 Flags (message attribute) 11 7191 H 7192 HEADER (part specifier) 88 7193 HEADER (search key) 77 7194 HEADER.FIELDS (part specifier) 88 7195 HEADER.FIELDS.NOT (part specifier) 88 7197 I 7198 IDLE (command) 70 7199 INTERNALDATE (fetch item) 90 7200 INTERNALDATE (fetch result) 121 7201 INUSE (response code) 102 7202 Internal Date (message attribute) 13 7204 K 7205 KEYWORD (search key) 78 7206 Keyword (type of flag) 12 7208 L 7209 LARGER (search key) 78 7210 LIMIT (response code) 102 7211 LIST (command) 43 7212 LIST (response) 109 7213 LOGOUT (command) 27 7215 M 7216 MAX (search result option) 75 7217 MAY (specification requirement term) 5 7218 MESSAGES (status item) 67 7219 MIME (part specifier) 89 7220 MIN (search result option) 75 7221 MOVE (command) 92 7222 MUST (specification requirement term) 5 7223 MUST NOT (specification requirement term) 5 7224 Message Sequence Number (message attribute) 11 7226 N 7227 NAMESPACE (command) 61 7228 NAMESPACE (response) 113 7229 NO (response) 106 7230 NONEXISTENT (response code) 103 7231 NOOP (command) 26 7232 NOPERM (response code) 103 7233 NOT (search key) 78 7234 NOT RECOMMENDED (specification requirement term) 5 7236 O 7237 OK (response) 106 7238 ON (search key) 78 7239 OPTIONAL (specification requirement term) 5 7240 OR (search key) 78 7241 OVERQUOTA (response code) 103 7243 P 7244 PARSE (response code) 103 7245 PERMANENTFLAGS (response code) 103 7246 PREAUTH (response) 107 7247 PRIVACYREQUIRED (response code) 104 7248 Permanent Flag (class of flag) 13 7249 Predefined keywords 12 7251 R 7252 READ-ONLY (response code) 104 7253 READ-WRITE (response code) 104 7254 RECOMMENDED (specification requirement term) 5 7255 RENAME (command) 40 7256 REQUIRED (specification requirement term) 5 7257 RFC822.SIZE (fetch item) 90 7258 RFC822.SIZE (fetch result) 121 7260 S 7261 SAVE (search result option) 75 7262 SEARCH (command) 74 7263 SEEN (search key) 78 7264 SELECT (command) 35 7265 SENTBEFORE (search key) 78 7266 SENTON (search key) 78 7267 SENTSINCE (search key) 78 7268 SERVERBUG (response code) 104 7269 SHOULD (specification requirement term) 5 7270 SHOULD NOT (specification requirement term) 5 7271 SINCE (search key) 78 7272 SIZE (status item) 67 7273 SMALLER (search key) 78 7274 STARTTLS (command) 28 7275 STATUS (command) 66 7276 STATUS (response) 113 7277 STORE (command) 90 7278 SUBJECT (search key) 78 7279 SUBSCRIBE (command) 42 7280 Session Flag (class of flag) 13 7281 System Flag (type of flag) 11 7283 T 7284 TEXT (part specifier) 88 7285 TEXT (search key) 78 7286 TO (search key) 78 7287 TRYCREATE (response code) 104 7289 U 7290 UID (command) 94 7291 UID (fetch item) 90 7292 UID (fetch result) 121 7293 UID (search key) 79 7294 UIDNEXT (response code) 105 7295 UIDNEXT (status item) 67 7296 UIDNOTSTICKY (response code) 105 7297 UIDVALIDITY (response code) 105 7298 UIDVALIDITY (status item) 67 7299 UNANSWERED (search key) 79 7300 UNAVAILABLE (response code) 105 7301 UNDELETED (search key) 79 7302 UNDRAFT (search key) 79 7303 UNFLAGGED (search key) 79 7304 UNKEYWORD (search key) 79 7305 UNKNOWN-CTE (response code) 105 7306 UNSEEN (search key) 79 7307 UNSEEN (status item) 67 7308 UNSELECT (command) 73 7309 UNSUBSCRIBE (command) 43 7310 Unique Identifier (UID) (message attribute) 9 7312 X 7313 X (command) 96 7315 [ 7316 [RFC-5322] Size (message attribute) 13 7318 \ 7319 \All (mailbox name attribute) 111 7320 \Answered (system flag) 11 7321 \Archive (mailbox name attribute) 111 7322 \Deleted (system flag) 12 7323 \Draft (system flag) 12 7324 \Drafts (mailbox name attribute) 111 7325 \Flagged (mailbox name attribute) 111 7326 \Flagged (system flag) 11 7327 \HasChildren (mailbox name attribute) 110 7328 \HasNoChildren (mailbox name attribute) 110 7329 \Junk (mailbox name attribute) 112 7330 \Marked (mailbox name attribute) 110 7331 \Noinferiors (mailbox name attribute) 110 7332 \NonExistent (mailbox name attribute) 109 7333 \Noselect (mailbox name attribute) 110 7334 \Recent (system flag) 12 7335 \Remote (mailbox name attribute) 111 7336 \Seen (system flag) 11 7337 \Sent (mailbox name attribute) 112 7338 \Subscribed (mailbox name attribute) 111 7339 \Trash (mailbox name attribute) 112 7340 \Unmarked (mailbox name attribute) 110 7342 Authors' Addresses 7344 Alexey Melnikov (editor) 7345 Isode Ltd 7346 14 Castle Mews 7347 Hampton, Middlesex TW12 2NP 7348 UK 7350 Email: Alexey.Melnikov@isode.com 7352 Barry Leiba (editor) 7353 Huawei Technologies 7355 Phone: +1 646 827 0648 7356 Email: barryleiba@computer.org 7357 URI: http://internetmessagingtechnology.org/