idnits 2.17.1 draft-ietf-extra-imap4rev2-16.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 3 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 (July 13, 2020) is 1382 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 7001, but not defined == Missing Reference: 'IMAP-OBSOLETE' is mentioned on line 6996, but not defined == Missing Reference: 'IMAP-COMPAT' is mentioned on line 6986, but not defined == Missing Reference: 'IMAP-HISTORICAL' is mentioned on line 6991, but not defined == Missing Reference: 'RFC-822' is mentioned on line 7005, but not defined ** Obsolete undefined reference: RFC 822 (Obsoleted by RFC 2822) == Missing Reference: 'IMAP-MODEL' is mentioned on line 6935, but not defined == Missing Reference: 'IMAP-DISC' is mentioned on line 6924, but not defined == Missing Reference: 'RFC3503' is mentioned on line 6897, but not defined == Missing Reference: 'IMAP-KEYWORDS-REG' is mentioned on line 6964, but not defined == Missing Reference: 'SMTP' is mentioned on line 6945, but not defined == Missing Reference: 'RFC7888' is mentioned on line 6920, but not defined -- Looks like a reference, but probably isn't: '1' on line 886 == Missing Reference: 'IMAP-URL' is mentioned on line 6959, but not defined == Missing Reference: 'UIDVALIDITY 3857529045' is mentioned on line 5721, but not defined == Missing Reference: 'UIDNEXT 4392' is mentioned on line 1726, but not defined == Missing Reference: 'RFC2193' is mentioned on line 6907, but not defined == Missing Reference: 'RFC3348' is mentioned on line 6911, but not defined ** Obsolete undefined reference: RFC 3348 (Obsoleted by RFC 5258) == Missing Reference: 'RFC4314' is mentioned on line 6952, but not defined == Missing Reference: 'RFC3501' is mentioned on line 6982, but not defined ** Obsolete undefined reference: RFC 3501 (Obsoleted by RFC 9051) == Missing Reference: 'UIDNEXT 2' is mentioned on line 3244, but not defined == Missing Reference: 'UIDVALIDITY 1' is mentioned on line 3315, but not defined == Missing Reference: 'CHARSET-REG' is mentioned on line 6974, but not defined == Missing Reference: 'IMAP-I18N' is mentioned on line 6929, but not defined == Missing Reference: 'HEADER' is mentioned on line 5738, but not defined == Missing Reference: 'BADCHARSET UTF-8' is mentioned on line 3892, but not defined == Missing Reference: 'UID' is mentioned on line 4302, but not defined == Missing Reference: 'RFC2087' is mentioned on line 6956, but not defined ** Obsolete undefined reference: RFC 2087 (Obsoleted by RFC 9208) == Missing Reference: 'IMAP-MAILBOX-NAME-ATTRS-REG' is mentioned on line 6969, but not defined == Missing Reference: 'READ-WRITE' is mentioned on line 5722, but not defined == Missing Reference: 'RFC4422' is mentioned on line 6064, but not defined == Missing Reference: 'IMAP4' is mentioned on line 6149, but not defined == Missing Reference: 'Namespace-Response-Extensions' is mentioned on line 6217, but not defined == Missing Reference: 'IMAP-TLS' is mentioned on line 7009, but not defined == Missing Reference: 'RFCXXXX' is mentioned on line 6741, but not defined == Missing Reference: 'RFC5465' is mentioned on line 6916, but not defined == Missing Reference: 'RFC5256' is mentioned on line 6902, but not defined == Missing Reference: 'IMAP-UTF-8' is mentioned on line 7027, but not defined == Missing Reference: 'RFC3516' is mentioned on line 7117, 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: 10 errors (**), 0 flaws (~~), 39 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 Futurewei Technologies 6 Expires: January 14, 2021 July 13, 2020 8 Internet Message Access Protocol (IMAP) - Version 4rev2 9 draft-ietf-extra-imap4rev2-16 11 Abstract 13 The Internet Message Access Protocol, Version 4rev2 (IMAP4rev2) 14 allows a client to access and manipulate electronic mail messages on 15 a server. IMAP4rev2 permits manipulation of mailboxes (remote 16 message folders) in a way that is functionally equivalent to local 17 folders. IMAP4rev2 also provides the capability for an offline 18 client to resynchronize with the server. 20 IMAP4rev2 includes operations for creating, deleting, and renaming 21 mailboxes, checking for new messages, permanently removing messages, 22 setting and clearing flags, RFC 5322, RFC 2045 and RFC 2231 parsing, 23 searching, and selective fetching of message attributes, texts, and 24 portions thereof. Messages in IMAP4rev2 are accessed by the use of 25 numbers. These numbers are either message sequence numbers or unique 26 identifiers. 28 IMAP4rev2 does not specify a means of posting mail; this function is 29 handled by a mail submission protocol such as RFC 6409. 31 Status of This Memo 33 This Internet-Draft is submitted in full conformance with the 34 provisions of BCP 78 and BCP 79. 36 Internet-Drafts are working documents of the Internet Engineering 37 Task Force (IETF). Note that other groups may also distribute 38 working documents as Internet-Drafts. The list of current Internet- 39 Drafts is at https://datatracker.ietf.org/drafts/current/. 41 Internet-Drafts are draft documents valid for a maximum of six months 42 and may be updated, replaced, or obsoleted by other documents at any 43 time. It is inappropriate to use Internet-Drafts as reference 44 material or to cite them other than as "work in progress." 46 This Internet-Draft will expire on January 14, 2021. 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 . . . . . . . . . . . . . . . . . . . 41 131 6.3.7. SUBSCRIBE Command . . . . . . . . . . . . . . . . . . 43 132 6.3.8. UNSUBSCRIBE Command . . . . . . . . . . . . . . . . . 44 133 6.3.9. LIST Command . . . . . . . . . . . . . . . . . . . . 44 134 6.3.10. NAMESPACE Command . . . . . . . . . . . . . . . . . . 62 135 6.3.11. STATUS Command . . . . . . . . . . . . . . . . . . . 67 136 6.3.12. APPEND Command . . . . . . . . . . . . . . . . . . . 68 137 6.3.13. IDLE Command . . . . . . . . . . . . . . . . . . . . 71 138 6.4. Client Commands - Selected State . . . . . . . . . . . . 73 139 6.4.1. CLOSE Command . . . . . . . . . . . . . . . . . . . . 73 140 6.4.2. UNSELECT Command . . . . . . . . . . . . . . . . . . 74 141 6.4.3. EXPUNGE Command . . . . . . . . . . . . . . . . . . . 74 142 6.4.4. SEARCH Command . . . . . . . . . . . . . . . . . . . 75 143 6.4.5. FETCH Command . . . . . . . . . . . . . . . . . . . . 87 144 6.4.6. STORE Command . . . . . . . . . . . . . . . . . . . . 91 145 6.4.7. COPY Command . . . . . . . . . . . . . . . . . . . . 92 146 6.4.8. MOVE Command . . . . . . . . . . . . . . . . . . . . 93 147 6.4.9. UID Command . . . . . . . . . . . . . . . . . . . . . 95 148 6.5. Client Commands - Experimental/Expansion . . . . . . . . 97 149 6.5.1. X Command . . . . . . . . . . . . . . . . . . . 97 150 7. Server Responses . . . . . . . . . . . . . . . . . . . . . . 98 151 7.1. Server Responses - Status Responses . . . . . . . . . . . 99 152 7.1.1. OK Response . . . . . . . . . . . . . . . . . . . . . 107 153 7.1.2. NO Response . . . . . . . . . . . . . . . . . . . . . 107 154 7.1.3. BAD Response . . . . . . . . . . . . . . . . . . . . 107 155 7.1.4. PREAUTH Response . . . . . . . . . . . . . . . . . . 108 156 7.1.5. BYE Response . . . . . . . . . . . . . . . . . . . . 108 157 7.2. Server Responses - Server and Mailbox Status . . . . . . 109 158 7.2.1. The ENABLED Response . . . . . . . . . . . . . . . . 109 159 7.2.2. CAPABILITY Response . . . . . . . . . . . . . . . . . 109 160 7.2.3. LIST Response . . . . . . . . . . . . . . . . . . . . 110 161 7.2.4. NAMESPACE Response . . . . . . . . . . . . . . . . . 114 162 7.2.5. STATUS Response . . . . . . . . . . . . . . . . . . . 114 163 7.2.6. ESEARCH Response . . . . . . . . . . . . . . . . . . 115 164 7.2.7. FLAGS Response . . . . . . . . . . . . . . . . . . . 115 165 7.3. Server Responses - Mailbox Size . . . . . . . . . . . . . 116 166 7.3.1. EXISTS Response . . . . . . . . . . . . . . . . . . . 116 167 7.4. Server Responses - Message Status . . . . . . . . . . . . 116 168 7.4.1. EXPUNGE Response . . . . . . . . . . . . . . . . . . 116 169 7.4.2. FETCH Response . . . . . . . . . . . . . . . . . . . 117 170 7.5. Server Responses - Command Continuation Request . . . . . 123 171 8. Sample IMAP4rev2 connection . . . . . . . . . . . . . . . . . 123 172 9. Formal Syntax . . . . . . . . . . . . . . . . . . . . . . . . 124 173 10. Author's Note . . . . . . . . . . . . . . . . . . . . . . . . 142 174 11. Security Considerations . . . . . . . . . . . . . . . . . . . 142 175 11.1. STARTTLS Security Considerations . . . . . . . . . . . . 142 176 11.2. COPYUID and APPENDUID response codes . . . . . . . . . . 143 177 11.3. LIST command and Other Users' namespace . . . . . . . . 143 178 11.4. Other Security Considerations . . . . . . . . . . . . . 143 179 12. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 144 180 12.1. Updates to IMAP4 Capabilities registry . . . . . . . . . 144 181 12.2. GSSAPI/SASL service name . . . . . . . . . . . . . . . . 145 182 12.3. LIST Selection Options, LIST Return Options, LIST 183 extended data items . . . . . . . . . . . . . . . . . . 145 184 13. References . . . . . . . . . . . . . . . . . . . . . . . . . 145 185 13.1. Normative References . . . . . . . . . . . . . . . . . . 145 186 13.2. Informative References (related protocols) . . . . . . . 148 187 13.3. Informative References (historical aspects of IMAP and 188 related protocols) . . . . . . . . . . . . . . . . . . . 150 189 Appendix A. Backward compatibility with IMAP4rev1 . . . . . . . 151 190 A.1. Mailbox International Naming Convention for compatibility 191 with IMAP4rev1 . . . . . . . . . . . . . . . . . . . . . 151 193 Appendix B. Backward compatibility with BINARY extension . . . . 153 194 Appendix C. Backward compatibility with LIST-EXTENDED extension 153 195 Appendix D. Changes from RFC 3501 / IMAP4rev1 . . . . . . . . . 153 196 Appendix E. Acknowledgement . . . . . . . . . . . . . . . . . . 155 197 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 198 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 161 200 1. How to Read This Document 202 1.1. Organization of This Document 204 This document is written from the point of view of the implementor of 205 an IMAP4rev2 client or server. Beyond the protocol overview in 206 section 2, it is not optimized for someone trying to understand the 207 operation of the protocol. The material in sections 3 through 5 208 provides the general context and definitions with which IMAP4rev2 209 operates. 211 Sections 6, 7, and 9 describe the IMAP commands, responses, and 212 syntax, respectively. The relationships among these are such that it 213 is almost impossible to understand any of them separately. In 214 particular, do not attempt to deduce command syntax from the command 215 section alone; instead refer to the Formal Syntax section. 217 1.2. Conventions Used in This Document 219 "Conventions" are basic principles or procedures. Document 220 conventions are noted in this section. 222 In examples, "C:" and "S:" indicate lines sent by the client and 223 server respectively. 225 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 226 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 227 "OPTIONAL" in this document are to be interpreted as described in BCP 228 14 [RFC2119] [RFC8174] when, and only when, they appear in all 229 capitals, as shown here. 231 The word "can" (not "may") is used to refer to a possible 232 circumstance or situation, as opposed to an optional facility of the 233 protocol. 235 "User" is used to refer to a human user, whereas "client" refers to 236 the software being run by the user. 238 "Connection" refers to the entire sequence of client/server 239 interaction from the initial establishment of the network connection 240 until its termination. 242 "Session" refers to the sequence of client/server interaction from 243 the time that a mailbox is selected (SELECT or EXAMINE command) until 244 the time that selection ends (SELECT or EXAMINE of another mailbox, 245 CLOSE command, UNSELECT command, or connection termination). 247 Characters are 8-bit UTF-8 (of which 7-bit US-ASCII is a subset) 248 unless otherwise specified. Other character sets are indicated using 249 a "CHARSET", as described in [MIME-IMT] and defined in [CHARSET]. 250 CHARSETs have important additional semantics in addition to defining 251 character set; refer to these documents for more detail. 253 There are several protocol conventions in IMAP. These refer to 254 aspects of the specification which are not strictly part of the IMAP 255 protocol, but reflect generally-accepted practice. Implementations 256 need to be aware of these conventions, and avoid conflicts whether or 257 not they implement the convention. For example, "&" may not be used 258 as a hierarchy delimiter since it conflicts with the Mailbox 259 International Naming Convention, and other uses of "&" in mailbox 260 names are impacted as well. 262 1.3. Special Notes to Implementors 264 Implementors of the IMAP protocol are strongly encouraged to read the 265 IMAP implementation recommendations document [IMAP-IMPLEMENTATION] in 266 conjunction with this document, to help understand the intricacies of 267 this protocol and how best to build an interoperable product. 269 IMAP4rev2 is designed to be upwards compatible from the [IMAP2] and 270 unpublished IMAP2bis protocols. IMAP4rev2 is largely compatible with 271 the IMAP4rev1 protocol described in RFC 3501 and the IMAP4 protocol 272 described in RFC 1730; the exception being in certain facilities 273 added in RFC 1730 that proved problematic and were subsequently 274 removed. In the course of the evolution of IMAP4rev2, some aspects 275 in the earlier protocols have become obsolete. Obsolete commands, 276 responses, and data formats which an IMAP4rev2 implementation can 277 encounter when used with an earlier implementation are described in 278 Appendix D and [IMAP-OBSOLETE]. 280 Other compatibility issues with IMAP2bis, the most common variant of 281 the earlier protocol, are discussed in [IMAP-COMPAT]. A full 282 discussion of compatibility issues with rare (and presumed extinct) 283 variants of [IMAP2] is in [IMAP-HISTORICAL]; this document is 284 primarily of historical interest. 286 IMAP was originally developed for the older [RFC-822] standard, and 287 as a consequence several fetch items in IMAP incorporate "RFC822" in 288 their name. In all cases, "RFC822" should be interpreted as a 289 reference to the updated [RFC-5322] standard. 291 2. Protocol Overview 293 2.1. Link Level 295 The IMAP4rev2 protocol assumes a reliable data stream such as that 296 provided by TCP. When TCP is used, an IMAP4rev2 server listens on 297 port 143 or port 993 (IMAP-over-TLS). 299 2.2. Commands and Responses 301 An IMAP4rev2 connection consists of the establishment of a client/ 302 server network connection, an initial greeting from the server, and 303 client/server interactions. These client/server interactions consist 304 of a client command, server data, and a server completion result 305 response. 307 All interactions transmitted by client and server are in the form of 308 lines, that is, strings that end with a CRLF. The protocol receiver 309 of an IMAP4rev2 client or server is either reading a line, or is 310 reading a sequence of octets with a known count followed by a line. 312 2.2.1. Client Protocol Sender and Server Protocol Receiver 314 The client command begins an operation. Each client command is 315 prefixed with an identifier (typically a short alphanumeric string, 316 e.g., A0001, A0002, etc.) called a "tag". A different tag is 317 generated by the client for each command. (More formally: the client 318 SHOULD generate a unique tag for every command, but a server MUST 319 accept tag reuse.) 321 Clients MUST follow the syntax outlined in this specification 322 strictly. It is a syntax error to send a command with missing or 323 extraneous spaces or arguments. 325 There are two cases in which a line from the client does not 326 represent a complete command. In one case, a command argument is 327 quoted with an octet count (see the description of literal in String 328 under Data Formats); in the other case, the command arguments require 329 server feedback (see the AUTHENTICATE command). In either case, the 330 server sends a command continuation request response if it is ready 331 for the octets (if appropriate) and the remainder of the command. 332 This response is prefixed with the token "+". 334 Note: If instead, the server detected an error in the command, it 335 sends a BAD completion response with a tag matching the command 336 (as described below) to reject the command and prevent the client 337 from sending any more of the command. 339 It is also possible for the server to send a completion response 340 for some other command (if multiple commands are in progress), or 341 untagged data. In either case, the command continuation request 342 is still pending; the client takes the appropriate action for the 343 response, and reads another response from the server. In all 344 cases, the client MUST send a complete command (including 345 receiving all command continuation request responses and command 346 continuations for the command) before initiating a new command. 348 The protocol receiver of an IMAP4rev2 server reads a command line 349 from the client, parses the command and its arguments, and transmits 350 server data and a server command completion result response. 352 2.2.2. Server Protocol Sender and Client Protocol Receiver 354 Data transmitted by the server to the client and status responses 355 that do not indicate command completion are prefixed with the token 356 "*", and are called untagged responses. 358 Server data MAY be sent as a result of a client command, or MAY be 359 sent unilaterally by the server. There is no syntactic difference 360 between server data that resulted from a specific command and server 361 data that were sent unilaterally. 363 The server completion result response indicates the success or 364 failure of the operation. It is tagged with the same tag as the 365 client command which began the operation. Thus, if more than one 366 command is in progress, the tag in a server completion response 367 identifies the command to which the response applies. There are 368 three possible server completion responses: OK (indicating success), 369 NO (indicating failure), or BAD (indicating a protocol error such as 370 unrecognized command or command syntax error). 372 Servers SHOULD enforce the syntax outlined in this specification 373 strictly. Any client command with a protocol syntax error, including 374 (but not limited to) missing or extraneous spaces or arguments, 375 SHOULD be rejected, and the client given a BAD server completion 376 response. 378 The protocol receiver of an IMAP4rev2 client reads a response line 379 from the server. It then takes action on the response based upon the 380 first token of the response, which can be a tag, a "*", or a "+". 382 A client MUST be prepared to accept any server response at all times. 383 This includes server data that was not requested. Server data SHOULD 384 be recorded, so that the client can reference its recorded copy 385 rather than sending a command to the server to request the data. In 386 the case of certain server data, the data MUST be recorded. 388 This topic is discussed in greater detail in the Server Responses 389 section. 391 2.3. Message Attributes 393 In addition to message text, each message has several attributes 394 associated with it. These attributes can be retrieved individually 395 or in conjunction with other attributes or message texts. 397 2.3.1. Message Numbers 399 Messages in IMAP4rev2 are accessed by one of two numbers; the unique 400 identifier or the message sequence number. 402 2.3.1.1. Unique Identifier (UID) Message Attribute 404 An unsigned non-zero 32-bit value assigned to each message, which 405 when used with the unique identifier validity value (see below) forms 406 a 64-bit value that MUST NOT refer to any other message in the 407 mailbox or any subsequent mailbox with the same name forever. Unique 408 identifiers are assigned in a strictly ascending fashion in the 409 mailbox; as each message is added to the mailbox it is assigned a 410 higher UID than the message(s) which were added previously. Unlike 411 message sequence numbers, unique identifiers are not necessarily 412 contiguous. 414 The unique identifier of a message MUST NOT change during the 415 session, and SHOULD NOT change between sessions. Any change of 416 unique identifiers between sessions MUST be detectable using the 417 UIDVALIDITY mechanism discussed below. Persistent unique identifiers 418 are required for a client to resynchronize its state from a previous 419 session with the server (e.g., disconnected or offline access clients 420 [IMAP-MODEL]); this is discussed further in [IMAP-DISC]. 422 Associated with every mailbox are two 32-bit unsigned non-zero values 423 which aid in unique identifier handling: the next unique identifier 424 value (UIDNEXT) and the unique identifier validity value 425 (UIDVALIDITY). 427 The next unique identifier value is the predicted value that will be 428 assigned to a new message in the mailbox. Unless the unique 429 identifier validity also changes (see below), the next unique 430 identifier value MUST have the following two characteristics. First, 431 the next unique identifier value MUST NOT change unless new messages 432 are added to the mailbox; and second, the next unique identifier 433 value MUST change whenever new messages are added to the mailbox, 434 even if those new messages are subsequently expunged. 436 Note: The next unique identifier value is intended to provide a 437 means for a client to determine whether any messages have been 438 delivered to the mailbox since the previous time it checked this 439 value. It is not intended to provide any guarantee that any 440 message will have this unique identifier. A client can only 441 assume, at the time that it obtains the next unique identifier 442 value, that messages arriving after that time will have a UID 443 greater than or equal to that value. 445 The unique identifier validity value is sent in a UIDVALIDITY 446 response code in an OK untagged response at mailbox selection time. 447 If unique identifiers from an earlier session fail to persist in this 448 session, the unique identifier validity value MUST be greater than 449 the one used in the earlier session. A good UIDVALIDITY value to use 450 is a 32-bit representation of the current date/time when the value is 451 assigned: this ensures that the value is unique and always increases. 452 Another possible alternative is a global counter that gets 453 incremented every time a mailbox is created. 455 Note: Ideally, unique identifiers SHOULD persist at all times. 456 Although this specification recognizes that failure to persist can 457 be unavoidable in certain server environments, it STRONGLY 458 ENCOURAGES message store implementation techniques that avoid this 459 problem. For example: 461 1. Unique identifiers MUST be strictly ascending in the mailbox 462 at all times. If the physical message store is re-ordered by 463 a non-IMAP agent, this requires that the unique identifiers in 464 the mailbox be regenerated, since the former unique 465 identifiers are no longer strictly ascending as a result of 466 the re-ordering. 468 2. If the message store has no mechanism to store unique 469 identifiers, it must regenerate unique identifiers at each 470 session, and each session must have a unique UIDVALIDITY 471 value. 473 3. If the mailbox is deleted/renamed and a new mailbox with the 474 same name is created at a later date, the server must either 475 keep track of unique identifiers from the previous instance of 476 the mailbox, or it must assign a new UIDVALIDITY value to the 477 new instance of the mailbox. 479 4. The combination of mailbox name, UIDVALIDITY, and UID must 480 refer to a single immutable (or expunged) message on that 481 server forever. In particular, the internal date, [RFC-5322] 482 size, envelope, body structure, and message texts (all 483 BODY[...] fetch data items) must never change. This does not 484 include message numbers, nor does it include attributes that 485 can be set by a STORE command (e.g., FLAGS). When a message 486 is expunged, its UID MUST NOT be reused under the same 487 UIDVALIDITY value. 489 2.3.1.2. Message Sequence Number Message Attribute 491 A relative position from 1 to the number of messages in the mailbox. 492 This position MUST be ordered by ascending unique identifier. As 493 each new message is added, it is assigned a message sequence number 494 that is 1 higher than the number of messages in the mailbox before 495 that new message was added. 497 Message sequence numbers can be reassigned during the session. For 498 example, when a message is permanently removed (expunged) from the 499 mailbox, the message sequence number for all subsequent messages is 500 decremented. The number of messages in the mailbox is also 501 decremented. Similarly, a new message can be assigned a message 502 sequence number that was once held by some other message prior to an 503 expunge. 505 In addition to accessing messages by relative position in the 506 mailbox, message sequence numbers can be used in mathematical 507 calculations. For example, if an untagged "11 EXISTS" is received, 508 and previously an untagged "8 EXISTS" was received, three new 509 messages have arrived with message sequence numbers of 9, 10, and 11. 510 Another example, if message 287 in a 523 message mailbox has UID 511 12345, there are exactly 286 messages which have lesser UIDs and 236 512 messages which have greater UIDs. 514 2.3.2. Flags Message Attribute 516 A list of zero or more named tokens associated with the message. A 517 flag is set by its addition to this list, and is cleared by its 518 removal. There are two types of flags in IMAP4rev2. A flag of 519 either type can be permanent or session-only. 521 A system flag is a flag name that is pre-defined in this 522 specification and begin with "\". Certain system flags (\Deleted and 523 \Seen) have special semantics described elsewhere in this document. 524 The currently-defined system flags are: 526 \Seen Message has been read 528 \Answered Message has been answered 530 \Flagged Message is "flagged" for urgent/special attention 531 \Deleted Message is "deleted" for removal by later EXPUNGE 533 \Draft Message has not completed composition (marked as a draft). 535 \Recent This flag was in used in IMAP4rev1 and is now deprecated. 537 A keyword is defined by the server implementation. Keywords do not 538 begin with "\". Servers MAY permit the client to define new keywords 539 in the mailbox (see the description of the PERMANENTFLAGS response 540 code for more information). Some keywords that start with "$" are 541 also defined in this specification. 543 This document defines several keywords that were not originally 544 defined in RFC 3501, but which were found to be useful by client 545 implementations. These keywords SHOULD be supported (i.e. allowed in 546 SEARCH, allowed and preserved in APPEND, COPY, MOVE commands) by 547 server implementations: 549 $Forwarded Message has been forwarded to another email address, 550 embedded within or attached to a new message. An email client 551 sets this keyword when it successfully forwards the message to 552 another email address. Typical usage of this keyword is to show a 553 different (or additional) icon for a message that has been 554 forwarded. Once set, the flag SHOULD NOT be cleared. 556 $MDNSent Message Disposition Notification [RFC8098] was generated 557 and sent for this message. See [RFC3503] for more details on how 558 this keyword is used. 560 $Junk The user (or a delivery agent on behalf of the user) may 561 choose to mark a message as definitely containing junk ($Junk; see 562 also the related keyword $NotJunk). The $Junk keyword can be used 563 to mark (and potentially move/delete messages later), group or 564 hide undesirable messages. See [IMAP-KEYWORDS-REG] for more 565 information. 567 $NotJunk The user (or a delivery agent on behalf of the user) may 568 choose to mark a message as definitely not containing junk 569 ($NotJunk; see also the related keyword $Junk). The $NotJunk 570 keyword can be used to mark, group or show messages that the user 571 wants to see. See [IMAP-KEYWORDS-REG] for more information. 573 $Phishing The $Phishing keyword can be used by a delivery agent to 574 mark a message as highly likely to be a phishing email. An email 575 that's determined to be a phishing email by the delivery agent 576 should also be considered a junk email and have the appropriate 577 junk filtering applied, including setting the $Junk flag and 578 placing in the \Junk special-use mailbox if available. 580 If both the $Phishing flag and the $Junk flag are set, the user 581 agent should display an additional warning message to the user. 582 User agents should not use the term "phishing" in their warning 583 message as most users do not understand this term. Phrasing of 584 the form "this message may be trying to steal your personal 585 information" is recommended. Additionally the user agent may 586 display a warning when clicking on any hyperlinks within the 587 message. 588 The requirement for both $Phishing and $Junk to be set before a 589 user agent displays a warning is for better backwards 590 compatibility with existing clients that understand the $Junk flag 591 but not the $Phishing flag. This so that when an unextended 592 client removes the $Junk flag, an extended client will also show 593 the correct state. See [IMAP-KEYWORDS-REG] for more information. 595 $Junk and $NotJunk are mutually exclusive. If more than one of them 596 is set for a message, the client MUST treat this as if none of them 597 is set and SHOULD unset both of them on the IMAP server. 599 Other registered keywords can be found in the "IMAP and JMAP 600 Keywords" registry [IMAP-KEYWORDS-REG]. New keywords SHOULD be 601 registered in this registry using the procedure specified in 602 [RFC5788]. 604 A flag can be permanent or session-only on a per-flag basis. 605 Permanent flags are those which the client can add or remove from the 606 message flags permanently; that is, concurrent and subsequent 607 sessions will see any change in permanent flags. Changes to session 608 flags are valid only in that session. 610 2.3.3. Internal Date Message Attribute 612 The internal date and time of the message on the server. This is not 613 the date and time in the [RFC-5322] header, but rather a date and 614 time which reflects when the message was received. In the case of 615 messages delivered via [SMTP], this SHOULD be the date and time of 616 final delivery of the message as defined by [SMTP]. In the case of 617 messages delivered by the IMAP4rev2 COPY or MOVE command, this SHOULD 618 be the internal date and time of the source message. In the case of 619 messages delivered by the IMAP4rev2 APPEND command, this SHOULD be 620 the date and time as specified in the APPEND command description. 621 All other cases are implementation defined. 623 2.3.4. [RFC-5322] Size Message Attribute 625 The number of octets in the message, as expressed in [RFC-5322] 626 format. 628 2.3.5. Envelope Structure Message Attribute 630 A parsed representation of the [RFC-5322] header of the message. 631 Note that the IMAP Envelope structure is not the same as an [SMTP] 632 envelope. 634 2.3.6. Body Structure Message Attribute 636 A parsed representation of the [MIME-IMB] body structure information 637 of the message. 639 2.4. Message Texts 641 In addition to being able to fetch the full [RFC-5322] text of a 642 message, IMAP4rev2 permits the fetching of portions of the full 643 message text. Specifically, it is possible to fetch the [RFC-5322] 644 message header, [RFC-5322] message body, a [MIME-IMB] body part, or a 645 [MIME-IMB] header. 647 3. State and Flow Diagram 649 Once the connection between client and server is established, an 650 IMAP4rev2 connection is in one of four states. The initial state is 651 identified in the server greeting. Most commands are only valid in 652 certain states. It is a protocol error for the client to attempt a 653 command while the connection is in an inappropriate state, and the 654 server will respond with a BAD or NO (depending upon server 655 implementation) command completion result. 657 3.1. Not Authenticated State 659 In the not authenticated state, the client MUST supply authentication 660 credentials before most commands will be permitted. This state is 661 entered when a connection starts unless the connection has been pre- 662 authenticated. 664 3.2. Authenticated State 666 In the authenticated state, the client is authenticated and MUST 667 select a mailbox to access before commands that affect messages will 668 be permitted. This state is entered when a pre-authenticated 669 connection starts, when acceptable authentication credentials have 670 been provided, after an error in selecting a mailbox, or after a 671 successful CLOSE command. 673 3.3. Selected State 675 In a selected state, a mailbox has been selected to access. This 676 state is entered when a mailbox has been successfully selected. 678 3.4. Logout State 680 In the logout state, the connection is being terminated. This state 681 can be entered as a result of a client request (via the LOGOUT 682 command) or by unilateral action on the part of either the client or 683 server. 685 If the client requests the logout state, the server MUST send an 686 untagged BYE response and a tagged OK response to the LOGOUT command 687 before the server closes the connection; and the client MUST read the 688 tagged OK response to the LOGOUT command before the client closes the 689 connection. 691 A server SHOULD NOT unilaterally close the connection without sending 692 an untagged BYE response that contains the reason for having done so. 693 A client SHOULD NOT unilaterally close the connection, and instead 694 SHOULD issue a LOGOUT command. If the server detects that the client 695 has unilaterally closed the connection, the server MAY omit the 696 untagged BYE response and simply close its connection. 698 +----------------------+ 699 |connection established| 700 +----------------------+ 701 || 702 \/ 703 +--------------------------------------+ 704 | server greeting | 705 +--------------------------------------+ 706 || (1) || (2) || (3) 707 \/ || || 708 +-----------------+ || || 709 |Not Authenticated| || || 710 +-----------------+ || || 711 || (7) || (4) || || 712 || \/ \/ || 713 || +----------------+ || 714 || | Authenticated |<=++ || 715 || +----------------+ || || 716 || || (7) || (5) || (6) || 717 || || \/ || || 718 || || +--------+ || || 719 || || |Selected|==++ || 720 || || +--------+ || 721 || || || (7) || 722 \/ \/ \/ \/ 723 +--------------------------------------+ 724 | Logout | 725 +--------------------------------------+ 726 || 727 \/ 728 +-------------------------------+ 729 |both sides close the connection| 730 +-------------------------------+ 732 (1) connection without pre-authentication (OK greeting) 733 (2) pre-authenticated connection (PREAUTH greeting) 734 (3) rejected connection (BYE greeting) 735 (4) successful LOGIN or AUTHENTICATE command 736 (5) successful SELECT or EXAMINE command 737 (6) CLOSE command, unsolicited CLOSED response code or 738 failed SELECT or EXAMINE command 739 (7) LOGOUT command, server shutdown, or connection closed 741 4. Data Formats 743 IMAP4rev2 uses textual commands and responses. Data in IMAP4rev2 can 744 be in one of several forms: atom, number, string, parenthesized list, 745 or NIL. Note that a particular data item may take more than one 746 form; for example, a data item defined as using "astring" syntax may 747 be either an atom or a string. 749 4.1. Atom 751 An atom consists of one or more non-special characters. 753 4.1.1. Sequence set and UID set 755 A set of messages can be referenced by a sequence set containing 756 either message sequence numbers or unique identifiers. See Section 9 757 for details. Sequence sets can contain ranges (e.g. "5:50"), an 758 enumeration of specific message/UID numbers, a special symbol "*", or 759 a combination of the above. 761 A "UID set" is similar to the sequence set of unique identifiers; 762 however, the "*" value for a sequence number is not permitted. 764 4.2. Number 766 A number consists of one or more digit characters, and represents a 767 numeric value. 769 4.3. String 771 A string is in one of three forms: synchonizing literal, non- 772 synchronizing literal or quoted string. The synchronizing literal 773 form is the general form of string. The non-synchronizing literal 774 form is also the general form, but has length limitation. The quoted 775 string form is an alternative that avoids the overhead of processing 776 a literal at the cost of limitations of characters which may be used. 778 When the distinction between synchronizing and non-synchronizing 779 literals is not important, this document just uses the term 780 "literal". 782 A synchronizing literal is a sequence of zero or more octets 783 (including CR and LF), prefix-quoted with an octet count in the form 784 of an open brace ("{"), the number of octets, close brace ("}"), and 785 CRLF. In the case of synchronizing literals transmitted from server 786 to client, the CRLF is immediately followed by the octet data. In 787 the case of synchronizing literals transmitted from client to server, 788 the client MUST wait to receive a command continuation request 789 (described later in this document) before sending the octet data (and 790 the remainder of the command). 792 The non-synchronizing literal is an alternate form of synchronizing 793 literal, and it may appear in communication from client to server 794 instead of the synchonizing form of literal. The non-synchronizing 795 literal form MUST NOT be sent from server to client. The non- 796 synchronizing literal is distinguished from the synchronizing literal 797 by having a plus ("+") between the octet count and the closing brace 798 ("}"). The server does not generate a command continuation request 799 in response to a non-synchronizing literal, and clients are not 800 required to wait before sending the octets of a non- synchronizing 801 literal. Non-synchronizing literals MUST NOT be larger than 4096 802 octets. Any literal larger than 4096 bytes MUST be sent as a 803 synchronizing literal. (Non-synchronizing literals defined in this 804 document are the same as non-synchronizing literals defined by the 805 LITERAL- extension from [RFC7888]. See that document for details on 806 how to handle invalid non-synchronizing literals longer than 4096 807 octets and for interaction with other IMAP extensions.) 809 A quoted string is a sequence of zero or more Unicode characters, 810 excluding CR and LF, encoded in UTF-8, with double quote (<">) 811 characters at each end. 813 The empty string is represented as "" (a quoted string with zero 814 characters between double quotes), as {0} followed by CRLF (a 815 synchronizing literal with an octet count of 0) or as {0+} followed 816 by CRLF (a non-synchronizing literal with an octet count of 0). 818 Note: Even if the octet count is 0, a client transmitting a 819 synchronizing literal MUST wait to receive a command continuation 820 request. 822 4.3.1. 8-bit and Binary Strings 824 8-bit textual and binary mail is supported through the use of a 825 [MIME-IMB] content transfer encoding. IMAP4rev2 implementations MAY 826 transmit 8-bit or multi-octet characters in literals, but SHOULD do 827 so only when the [CHARSET] is identified. 829 IMAP4rev2 is compatible with [I18N-HDRS]. As a result, the 830 identified charset for header-field values with 8-bit content is 831 UTF-8 [UTF-8]. IMAP4rev2 implementations MUST accept and MAY 832 transmit [UTF-8] text in quoted-strings as long as the string does 833 not contain NUL, CR, or LF. This differs from IMAP4rev1 834 implementations. 836 Although a BINARY content transfer encoding is defined, unencoded 837 binary strings are not permitted, unless returned in a in 838 response to BINARY.PEEK[]<> or 839 BINARY[]<> FETCH data item. A "binary 840 string" is any string with NUL characters. A string with an 841 excessive amount of CTL characters MAY also be considered to be 842 binary. Unless returned in response to BINARY.PEEK[...]/BINARY[...] 843 FETCH, client and server implementations MUST encode binary data into 844 a textual form, such as BASE64, before transmitting the data. 846 4.4. Parenthesized List 848 Data structures are represented as a "parenthesized list"; a sequence 849 of data items, delimited by space, and bounded at each end by 850 parentheses. A parenthesized list can contain other parenthesized 851 lists, using multiple levels of parentheses to indicate nesting. 853 The empty list is represented as () -- a parenthesized list with no 854 members. 856 4.5. NIL 858 The special form "NIL" represents the non-existence of a particular 859 data item that is represented as a string or parenthesized list, as 860 distinct from the empty string "" or the empty parenthesized list (). 862 Note: NIL is never used for any data item which takes the form of 863 an atom. For example, a mailbox name of "NIL" is a mailbox named 864 NIL as opposed to a non-existent mailbox name. This is because 865 mailbox uses "astring" syntax which is an atom or a string. 866 Conversely, an addr-name of NIL is a non-existent personal name, 867 because addr-name uses "nstring" syntax which is NIL or a string, 868 but never an atom. 870 Examples: 872 The following LIST response: 874 * LIST () "/" NIL 876 is equivalent to: 877 * LIST () "/" "NIL" 879 as LIST response ABNF is using astring for mailbox name. 881 However, the following response 883 * FETCH 1 (BODY[1] NIL) 885 is not equivalent to: 886 * FETCH 1 (BODY[1] "NIL") 887 The former means absence of the body part, while the latter 888 means that it contains literal sequence of characters "NIL". 890 5. Operational Considerations 892 The following rules are listed here to ensure that all IMAP4rev2 893 implementations interoperate properly. 895 5.1. Mailbox Naming 897 In IMAP4rev2, Mailbox names are encoded in Net-Unicode [NET-UNICODE] 898 (this differs from IMAP4rev1). Client implementations MAY attempt to 899 create Net-Unicode mailbox names, and MUST interpret any 8-bit 900 mailbox names returned by LIST as [NET-UNICODE]. Server 901 implementations MUST prohibit the creation of 8-bit mailbox names 902 that do not comply with Net-Unicode. However, servers MAY accept a 903 de-normalized UTF-8 mailbox name and convert it to Unicode 904 normalization form "NFC" (as per Net-Unicode requirements) prior to 905 mailbox creation. Servers that choose to accept such de-normalized 906 UTF-8 mailbox names MUST accept them in all IMAP commands that have a 907 mailbox name parameter. In particular SELECT must open the 908 same mailbox that was successfully created with CREATE , even 909 if is a de-normalized UTF-8 mailbox name. 911 The case-insensitive mailbox name INBOX is a special name reserved to 912 mean "the primary mailbox for this user on this server". (Note that 913 this special name may not exist on some servers for some users, for 914 example if the user has no access to personal namespace.) The 915 interpretation of all other names is implementation-dependent. 917 In particular, this specification takes no position on case 918 sensitivity in non-INBOX mailbox names. Some server implementations 919 are fully case-sensitive in ASCII range; others preserve case of a 920 newly-created name but otherwise are case-insensitive; and yet others 921 coerce names to a particular case. Client implementations must be 922 able to interact with any of these. 924 There are certain client considerations when creating a new mailbox 925 name: 927 1. Any character which is one of the atom-specials (see the Formal 928 Syntax) will require that the mailbox name be represented as a 929 quoted string or literal. 931 2. CTL and other non-graphic characters are difficult to represent 932 in a user interface and are best avoided. Servers MAY refuse to 933 create mailbox names containing Unicode CTL characters. 935 3. Although the list-wildcard characters ("%" and "*") are valid in 936 a mailbox name, it is difficult to use such mailbox names with 937 the LIST command due to the conflict with wildcard 938 interpretation. 940 4. Usually, a character (determined by the server implementation) is 941 reserved to delimit levels of hierarchy. 943 5. Two characters, "#" and "&", have meanings by convention, and 944 should be avoided except when used in that convention. 946 5.1.1. Mailbox Hierarchy Naming 948 If it is desired to export hierarchical mailbox names, mailbox names 949 MUST be left-to-right hierarchical using a single character to 950 separate levels of hierarchy. The same hierarchy separator character 951 is used for all levels of hierarchy within a single name. 953 5.1.2. Namespaces 955 Personal Namespace: A namespace that the server considers within the 956 personal scope of the authenticated user on a particular connection. 957 Typically, only the authenticated user has access to mailboxes in 958 their Personal Namespace. It is the part of the namespace that 959 belongs to the user that is allocated for mailboxes. If an INBOX 960 exists for a user, it MUST appear within the user's personal 961 namespace. In the typical case, there SHOULD be only one Personal 962 Namespace on a server. 964 Other Users' Namespace: A namespace that consists of mailboxes from 965 the Personal Namespaces of other users. To access mailboxes in the 966 Other Users' Namespace, the currently authenticated user MUST be 967 explicitly granted access rights. For example, it is common for a 968 manager to grant to their secretary access rights to their mailbox. 969 In the typical case, there SHOULD be only one Other Users' Namespace 970 on a server. 972 Shared Namespace: A namespace that consists of mailboxes that are 973 intended to be shared amongst users and do not exist within a user's 974 Personal Namespace. 976 The namespaces a server uses MAY differ on a per-user basis. 978 5.1.2.1. Historic Mailbox Namespace Naming Convention 980 By convention, the first hierarchical element of any mailbox name 981 which begins with "#" identifies the "namespace" of the remainder of 982 the name. This makes it possible to disambiguate between different 983 types of mailbox stores, each of which have their own namespaces. 985 For example, implementations which offer access to USENET 986 newsgroups MAY use the "#news" namespace to partition the USENET 987 newsgroup namespace from that of other mailboxes. Thus, the 988 comp.mail.misc newsgroup would have a mailbox name of 989 "#news.comp.mail.misc", and the name "comp.mail.misc" can refer to 990 a different object (e.g., a user's private mailbox). 992 Namespaces that include the "#" character are not IMAP URL [IMAP-URL] 993 friendly requiring the "#" character to be represented as %23 when 994 within URLs. As such, server implementers MAY instead consider using 995 namespace prefixes that do not contain the "#" character. 997 5.1.2.2. Common namespace models 999 Previous version of this protocol does not define a default server 1000 namespace. Two common namespace models have evolved: 1002 The "Personal Mailbox" model, in which the default namespace that is 1003 presented consists of only the user's personal mailboxes. To access 1004 shared mailboxes, the user must use an escape mechanism to reach 1005 another namespace. 1007 The "Complete Hierarchy" model, in which the default namespace that 1008 is presented includes the user's personal mailboxes along with any 1009 other mailboxes they have access to. 1011 5.2. Mailbox Size and Message Status Updates 1013 At any time, a server can send data that the client did not request. 1014 Sometimes, such behavior is REQUIRED. For example, agents other than 1015 the server MAY add messages to the mailbox (e.g., new message 1016 delivery), change the flags of the messages in the mailbox (e.g., 1017 simultaneous access to the same mailbox by multiple agents), or even 1018 remove messages from the mailbox. A server MUST send mailbox size 1019 updates automatically if a mailbox size change is observed during the 1020 processing of a command. A server SHOULD send message flag updates 1021 automatically, without requiring the client to request such updates 1022 explicitly. 1024 Special rules exist for server notification of a client about the 1025 removal of messages to prevent synchronization errors; see the 1026 description of the EXPUNGE response for more detail. In particular, 1027 it is NOT permitted to send an EXISTS response that would reduce the 1028 number of messages in the mailbox; only the EXPUNGE response can do 1029 this. 1031 Regardless of what implementation decisions a client makes on 1032 remembering data from the server, a client implementation MUST record 1033 mailbox size updates. It MUST NOT assume that any command after the 1034 initial mailbox selection will return the size of the mailbox. 1036 5.3. Response when no Command in Progress 1038 Server implementations are permitted to send an untagged response 1039 (except for EXPUNGE) while there is no command in progress. Server 1040 implementations that send such responses MUST deal with flow control 1041 considerations. Specifically, they MUST either (1) verify that the 1042 size of the data does not exceed the underlying transport's available 1043 window size, or (2) use non-blocking writes. 1045 5.4. Autologout Timer 1047 If a server has an inactivity autologout timer that applies to 1048 sessions after authentication, the duration of that timer MUST be at 1049 least 30 minutes. The receipt of ANY command from the client during 1050 that interval SHOULD suffice to reset the autologout timer. 1052 5.5. Multiple Commands in Progress (Command Pipelining) 1054 The client MAY send another command without waiting for the 1055 completion result response of a command, subject to ambiguity rules 1056 (see below) and flow control constraints on the underlying data 1057 stream. Similarly, a server MAY begin processing another command 1058 before processing the current command to completion, subject to 1059 ambiguity rules. However, any command continuation request responses 1060 and command continuations MUST be negotiated before any subsequent 1061 command is initiated. 1063 The exception is if an ambiguity would result because of a command 1064 that would affect the results of other commands. If the server 1065 detects a possible ambiguity, it MUST execute commands to completion 1066 in the order given by the client. 1068 The most obvious example of ambiguity is when a command would affect 1069 the results of another command, e.g., a FETCH of a message's flags 1070 and a STORE of that same message's flags. 1072 A non-obvious ambiguity occurs with commands that permit an untagged 1073 EXPUNGE response (commands other than FETCH, STORE, and SEARCH), 1074 since an untagged EXPUNGE response can invalidate sequence numbers in 1075 a subsequent command. This is not a problem for FETCH, STORE, or 1076 SEARCH commands because servers are prohibited from sending EXPUNGE 1077 responses while any of those commands are in progress. Therefore, if 1078 the client sends any command other than FETCH, STORE, or SEARCH, it 1079 MUST wait for the completion result response before sending a command 1080 with message sequence numbers. 1082 Note: EXPUNGE responses are permitted while UID FETCH, UID STORE, 1083 and UID SEARCH are in progress. If the client sends a UID 1084 command, it MUST wait for a completion result response before 1085 sending a command which uses message sequence numbers (this may 1086 include UID SEARCH). Any message sequence numbers in an argument 1087 to UID SEARCH are associated with messages prior to the effect of 1088 any untagged EXPUNGE returned by the UID SEARCH. 1090 For example, the following non-waiting command sequences are invalid: 1092 FETCH + NOOP + STORE 1094 STORE + COPY + FETCH 1096 COPY + COPY 1098 The following are examples of valid non-waiting command sequences: 1100 FETCH + STORE + SEARCH + NOOP 1102 STORE + COPY + EXPUNGE 1104 UID SEARCH + UID SEARCH may be valid or invalid as a non-waiting 1105 command sequence, depending upon whether or not the second UID 1106 SEARCH contains message sequence numbers. 1108 Use of SEARCH result variable (see Section 6.4.4.1) creates direct 1109 dependency between two commands. See Section 6.4.4.2 for more 1110 considerations about pipelining such dependent commands. 1112 6. Client Commands 1114 IMAP4rev2 commands are described in this section. Commands are 1115 organized by the state in which the command is permitted. Commands 1116 which are permitted in multiple states are listed in the minimum 1117 permitted state (for example, commands valid in authenticated and 1118 selected state are listed in the authenticated state commands). 1120 Command arguments, identified by "Arguments:" in the command 1121 descriptions below, are described by function, not by syntax. The 1122 precise syntax of command arguments is described in the Formal Syntax 1123 (Section 9). 1125 Some commands cause specific server responses to be returned; these 1126 are identified by "Responses:" in the command descriptions below. 1127 See the response descriptions in the Responses section for 1128 information on these responses, and the Formal Syntax section for the 1129 precise syntax of these responses. It is possible for server data to 1130 be transmitted as a result of any command. Thus, commands that do 1131 not specifically require server data specify "no specific responses 1132 for this command" instead of "none". 1134 The "Result:" in the command description refers to the possible 1135 tagged status responses to a command, and any special interpretation 1136 of these status responses. 1138 The state of a connection is only changed by successful commands 1139 which are documented as changing state. A rejected command (BAD 1140 response) never changes the state of the connection or of the 1141 selected mailbox. A failed command (NO response) generally does not 1142 change the state of the connection or of the selected mailbox; the 1143 exception being the SELECT and EXAMINE commands. 1145 6.1. Client Commands - Any State 1147 The following commands are valid in any state: CAPABILITY, NOOP, and 1148 LOGOUT. 1150 6.1.1. CAPABILITY Command 1152 Arguments: none 1154 Responses: REQUIRED untagged response: CAPABILITY 1155 Result: OK - capability completed 1156 BAD - command unknown or arguments invalid 1158 The CAPABILITY command requests a listing of capabilities that the 1159 server supports. The server MUST send a single untagged CAPABILITY 1160 response with "IMAP4rev2" as one of the listed capabilities before 1161 the (tagged) OK response. 1163 A capability name which begins with "AUTH=" indicates that the server 1164 supports that particular authentication mechanism. All such names 1165 are, by definition, part of this specification. For example, the 1166 authorization capability for an experimental "blurdybloop" 1167 authenticator would be "AUTH=XBLURDYBLOOP" and not 1168 "XAUTH=BLURDYBLOOP" or "XAUTH=XBLURDYBLOOP". 1170 Other capability names refer to extensions, revisions, or amendments 1171 to this specification. See the documentation of the CAPABILITY 1172 response for additional information. No capabilities, beyond the 1173 base IMAP4rev2 set defined in this specification, are enabled without 1174 explicit client action to invoke the capability. 1176 Client and server implementations MUST implement the STARTTLS, 1177 LOGINDISABLED, and AUTH=PLAIN (described in [PLAIN]) capabilities. 1178 See the Security Considerations section for important information. 1180 See the section entitled "Client Commands - Experimental/Expansion" 1181 for information about the form of site or implementation-specific 1182 capabilities. 1184 Example: C: abcd CAPABILITY 1185 S: * CAPABILITY IMAP4rev2 STARTTLS AUTH=GSSAPI 1186 LOGINDISABLED 1187 S: abcd OK CAPABILITY completed 1188 C: efgh STARTTLS 1189 S: efgh OK STARTLS completed 1190 1191 C: ijkl CAPABILITY 1192 S: * CAPABILITY IMAP4rev2 AUTH=GSSAPI AUTH=PLAIN 1193 S: ijkl OK CAPABILITY completed 1195 6.1.2. NOOP Command 1197 Arguments: none 1199 Responses: no specific responses for this command (but see below) 1201 Result: OK - noop completed 1202 BAD - command unknown or arguments invalid 1204 The NOOP command always succeeds. It does nothing. 1206 Since any command can return a status update as untagged data, the 1207 NOOP command can be used as a periodic poll for new messages or 1208 message status updates during a period of inactivity (the IDLE 1209 command Section 6.3.13 should be used instead of NOOP if real-time 1210 updates to mailbox state are desirable). The NOOP command can also 1211 be used to reset any inactivity autologout timer on the server. 1213 Example: C: a002 NOOP 1214 S: a002 OK NOOP completed 1215 . . . 1216 C: a047 NOOP 1217 S: * 22 EXPUNGE 1218 S: * 23 EXISTS 1219 S: * 14 FETCH (UID 1305 FLAGS (\Seen \Deleted)) 1220 S: a047 OK NOOP completed 1222 6.1.3. LOGOUT Command 1224 Arguments: none 1226 Responses: REQUIRED untagged response: BYE 1228 Result: OK - logout completed 1229 BAD - command unknown or arguments invalid 1231 The LOGOUT command informs the server that the client is done with 1232 the connection. The server MUST send a BYE untagged response before 1233 the (tagged) OK response, and then close the network connection. 1235 Example: C: A023 LOGOUT 1236 S: * BYE IMAP4rev2 Server logging out 1237 S: A023 OK LOGOUT completed 1238 (Server and client then close the connection) 1240 6.2. Client Commands - Not Authenticated State 1242 In the not authenticated state, the AUTHENTICATE or LOGIN command 1243 establishes authentication and enters the authenticated state. The 1244 AUTHENTICATE command provides a general mechanism for a variety of 1245 authentication techniques, privacy protection, and integrity 1246 checking; whereas the LOGIN command uses a traditional user name and 1247 plaintext password pair and has no means of establishing privacy 1248 protection or integrity checking. 1250 The STARTTLS command is an alternate form of establishing session 1251 privacy protection and integrity checking, but does not by itself 1252 establish authentication or enter the authenticated state. 1254 Server implementations MAY allow access to certain mailboxes without 1255 establishing authentication. This can be done by means of the 1256 ANONYMOUS [SASL] authenticator described in [ANONYMOUS]. An older 1257 convention is a LOGIN command using the userid "anonymous"; in this 1258 case, a password is required although the server may choose to accept 1259 any password. The restrictions placed on anonymous users are 1260 implementation-dependent. 1262 Once authenticated (including as anonymous), it is not possible to 1263 re-enter not authenticated state. 1265 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 1266 the following commands are valid in the not authenticated state: 1267 STARTTLS, AUTHENTICATE and LOGIN. See the Security Considerations 1268 section for important information about these commands. 1270 6.2.1. STARTTLS Command 1272 Arguments: none 1274 Responses: no specific response for this command 1276 Result: OK - starttls completed, begin TLS negotiation 1277 BAD - command unknown or arguments invalid 1279 A [TLS] negotiation begins immediately after the CRLF at the end of 1280 the tagged OK response from the server. Once a client issues a 1281 STARTTLS command, it MUST NOT issue further commands until a server 1282 response is seen and the [TLS] negotiation is complete. 1284 The server remains in the non-authenticated state, even if client 1285 credentials are supplied during the [TLS] negotiation. This does not 1286 preclude an authentication mechanism such as EXTERNAL (defined in 1287 [SASL]) from using client identity determined by the [TLS] 1288 negotiation. 1290 Once [TLS] has been started, the client MUST discard cached 1291 information about server capabilities and SHOULD re-issue the 1292 CAPABILITY command. This is necessary to protect against man-in- 1293 the-middle attacks which alter the capabilities list prior to 1294 STARTTLS. The server MAY advertise different capabilities, and in 1295 particular SHOULD NOT advertise the STARTTLS capability, after a 1296 successful STARTTLS command. 1298 Example: C: a001 CAPABILITY 1299 S: * CAPABILITY IMAP4rev2 STARTTLS LOGINDISABLED 1300 S: a001 OK CAPABILITY completed 1301 C: a002 STARTTLS 1302 S: a002 OK Begin TLS negotiation now 1303 1304 C: a003 CAPABILITY 1305 S: * CAPABILITY IMAP4rev2 AUTH=PLAIN 1306 S: a003 OK CAPABILITY completed 1307 C: a004 LOGIN joe password 1308 S: a004 OK LOGIN completed 1310 6.2.2. AUTHENTICATE Command 1312 Arguments: SASL authentication mechanism name 1313 OPTIONAL initial response 1315 Responses: continuation data can be requested 1317 Result: OK - authenticate completed, now in authenticated state 1318 NO - authenticate failure: unsupported authentication 1319 mechanism, credentials rejected 1320 BAD - command unknown or arguments invalid, 1321 authentication exchange cancelled 1323 The AUTHENTICATE command indicates a [SASL] authentication mechanism 1324 to the server. If the server supports the requested authentication 1325 mechanism, it performs an authentication protocol exchange to 1326 authenticate and identify the client. It MAY also negotiate an 1327 OPTIONAL security layer for subsequent protocol interactions. If the 1328 requested authentication mechanism is not supported, the server 1329 SHOULD reject the AUTHENTICATE command by sending a tagged NO 1330 response. 1332 The AUTHENTICATE command supports the optional "initial response" 1333 feature defined in Section 5.1 of [SASL]. The client doesn't need to 1334 use it. If a SASL mechanism supports "initial response", but it is 1335 not specified by the client, the server handles this as specified in 1336 Section 3 of [SASL]. 1338 The service name specified by this protocol's profile of [SASL] is 1339 "imap". 1341 The authentication protocol exchange consists of a series of server 1342 challenges and client responses that are specific to the 1343 authentication mechanism. A server challenge consists of a command 1344 continuation request response with the "+" token followed by a BASE64 1345 encoded (see Section 4 of [RFC4648]) string. The client response 1346 consists of a single line consisting of a BASE64 encoded string. If 1347 the client wishes to cancel an authentication exchange, it issues a 1348 line consisting of a single "*". If the server receives such a 1349 response, or if it receives an invalid BASE64 string (e.g. 1350 characters outside the BASE64 alphabet, or non-terminal "="), it MUST 1351 reject the AUTHENTICATE command by sending a tagged BAD response. 1353 As with any other client response, this initial response MUST be 1354 encoded as BASE64. It also MUST be transmitted outside of a quoted 1355 string or literal. To send a zero-length initial response, the 1356 client MUST send a single pad character ("="). This indicates that 1357 the response is present, but is a zero-length string. 1359 When decoding the BASE64 data in the initial response, decoding 1360 errors MUST be treated as in any normal SASL client response, i.e. 1361 with a tagged BAD response. In particular, the server should check 1362 for any characters not explicitly allowed by the BASE64 alphabet, as 1363 well as any sequence of BASE64 characters that contains the pad 1364 character ('=') anywhere other than the end of the string (e.g., 1365 "=AAA" and "AAA=BBB" are not allowed). 1367 If the client uses an initial response with a SASL mechanism that 1368 does not support an initial response, the server MUST reject the 1369 command with a tagged BAD response. 1371 If a security layer is negotiated through the [SASL] authentication 1372 exchange, it takes effect immediately following the CRLF that 1373 concludes the authentication exchange for the client, and the CRLF of 1374 the tagged OK response for the server. 1376 While client and server implementations MUST implement the 1377 AUTHENTICATE command itself, it is not required to implement any 1378 authentication mechanisms other than the PLAIN mechanism described in 1379 [PLAIN]. Also, an authentication mechanism is not required to 1380 support any security layers. 1382 Note: a server implementation MUST implement a configuration in 1383 which it does NOT permit any plaintext password mechanisms, unless 1384 either the STARTTLS command has been negotiated or some other 1385 mechanism that protects the session from password snooping has 1386 been provided. Server sites SHOULD NOT use any configuration 1387 which permits a plaintext password mechanism without such a 1388 protection mechanism against password snooping. Client and server 1389 implementations SHOULD implement additional [SASL] mechanisms that 1390 do not use plaintext passwords, such the GSSAPI mechanism 1391 described in [SASL] and/or the SCRAM-SHA-256/SCRAM-SHA-256-PLUS 1392 [SCRAM-SHA-256] mechanisms. 1394 Servers and clients can support multiple authentication mechanisms. 1395 The server SHOULD list its supported authentication mechanisms in the 1396 response to the CAPABILITY command so that the client knows which 1397 authentication mechanisms to use. 1399 A server MAY include a CAPABILITY response code in the tagged OK 1400 response of a successful AUTHENTICATE command in order to send 1401 capabilities automatically. It is unnecessary for a client to send a 1402 separate CAPABILITY command if it recognizes these automatic 1403 capabilities. This should only be done if a security layer was not 1404 negotiated by the AUTHENTICATE command, because the tagged OK 1405 response as part of an AUTHENTICATE command is not protected by 1406 encryption/integrity checking. [SASL] requires the client to re- 1407 issue a CAPABILITY command in this case. The server MAY advertise 1408 different capabilities after a successful AUTHENTICATE command. 1410 If an AUTHENTICATE command fails with a NO response, the client MAY 1411 try another authentication mechanism by issuing another AUTHENTICATE 1412 command. It MAY also attempt to authenticate by using the LOGIN 1413 command (see Section 6.2.3 for more detail). In other words, the 1414 client MAY request authentication types in decreasing order of 1415 preference, with the LOGIN command as a last resort. 1417 The authorization identity passed from the client to the server 1418 during the authentication exchange is interpreted by the server as 1419 the user name whose privileges the client is requesting. 1421 Example: S: * OK IMAP4rev2 Server 1422 C: A001 AUTHENTICATE GSSAPI 1423 S: + 1424 C: YIIB+wYJKoZIhvcSAQICAQBuggHqMIIB5qADAgEFoQMCAQ6iBw 1425 MFACAAAACjggEmYYIBIjCCAR6gAwIBBaESGxB1Lndhc2hpbmd0 1426 b24uZWR1oi0wK6ADAgEDoSQwIhsEaW1hcBsac2hpdmFtcy5jYW 1427 Mud2FzaGluZ3Rvbi5lZHWjgdMwgdCgAwIBAaEDAgEDooHDBIHA 1428 cS1GSa5b+fXnPZNmXB9SjL8Ollj2SKyb+3S0iXMljen/jNkpJX 1429 AleKTz6BQPzj8duz8EtoOuNfKgweViyn/9B9bccy1uuAE2HI0y 1430 C/PHXNNU9ZrBziJ8Lm0tTNc98kUpjXnHZhsMcz5Mx2GR6dGknb 1431 I0iaGcRerMUsWOuBmKKKRmVMMdR9T3EZdpqsBd7jZCNMWotjhi 1432 vd5zovQlFqQ2Wjc2+y46vKP/iXxWIuQJuDiisyXF0Y8+5GTpAL 1433 pHDc1/pIGmMIGjoAMCAQGigZsEgZg2on5mSuxoDHEA1w9bcW9n 1434 FdFxDKpdrQhVGVRDIzcCMCTzvUboqb5KjY1NJKJsfjRQiBYBdE 1435 NKfzK+g5DlV8nrw81uOcP8NOQCLR5XkoMHC0Dr/80ziQzbNqhx 1436 O6652Npft0LQwJvenwDI13YxpwOdMXzkWZN/XrEqOWp6GCgXTB 1437 vCyLWLlWnbaUkZdEYbKHBPjd8t/1x5Yg== 1438 S: + YGgGCSqGSIb3EgECAgIAb1kwV6ADAgEFoQMCAQ+iSzBJoAMC 1439 AQGiQgRAtHTEuOP2BXb9sBYFR4SJlDZxmg39IxmRBOhXRKdDA0 1440 uHTCOT9Bq3OsUTXUlk0CsFLoa8j+gvGDlgHuqzWHPSQg== 1441 C: 1442 S: + YDMGCSqGSIb3EgECAgIBAAD/////6jcyG4GE3KkTzBeBiVHe 1443 ceP2CWY0SR0fAQAgAAQEBAQ= 1444 C: YDMGCSqGSIb3EgECAgIBAAD/////3LQBHXTpFfZgrejpLlLImP 1445 wkhbfa2QteAQAgAG1yYwE= 1446 S: A001 OK GSSAPI authentication successful 1448 Note: The line breaks within server challenges and client responses 1449 are for editorial clarity and are not in real authenticators. 1451 6.2.3. LOGIN Command 1453 Arguments: user name 1454 password 1456 Responses: no specific responses for this command 1458 Result: OK - login completed, now in authenticated state 1459 NO - login failure: user name or password rejected 1460 BAD - command unknown or arguments invalid 1462 The LOGIN command identifies the client to the server and carries the 1463 plaintext password authenticating this user. 1465 A server MAY include a CAPABILITY response code in the tagged OK 1466 response to a successful LOGIN command in order to send capabilities 1467 automatically. It is unnecessary for a client to send a separate 1468 CAPABILITY command if it recognizes these automatic capabilities. 1470 Example: C: a001 LOGIN SMITH SESAME 1471 S: a001 OK LOGIN completed 1473 Note: Use of the LOGIN command over an insecure network (such as the 1474 Internet) is a security risk, because anyone monitoring network 1475 traffic can obtain plaintext passwords. The LOGIN command SHOULD NOT 1476 be used except as a last resort, and it is recommended that client 1477 implementations have a means to disable any automatic use of the 1478 LOGIN command. 1480 Unless either the client is accessing IMAP service on IMAPS port 1481 [RFC8314], the STARTTLS command has been negotiated or some other 1482 mechanism that protects the session from password snooping has been 1483 provided, a server implementation MUST implement a configuration in 1484 which it advertises the LOGINDISABLED capability and does NOT permit 1485 the LOGIN command. Server sites SHOULD NOT use any configuration 1486 which permits the LOGIN command without such a protection mechanism 1487 against password snooping. A client implementation MUST NOT send a 1488 LOGIN command if the LOGINDISABLED capability is advertised. 1490 6.3. Client Commands - Authenticated State 1492 In the authenticated state, commands that manipulate mailboxes as 1493 atomic entities are permitted. Of these commands, the SELECT and 1494 EXAMINE commands will select a mailbox for access and enter the 1495 selected state. 1497 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 1498 the following commands are valid in the authenticated state: ENABLE, 1499 SELECT, EXAMINE, NAMESPACE, CREATE, DELETE, RENAME, SUBSCRIBE, 1500 UNSUBSCRIBE, LIST, STATUS, APPEND and IDLE. 1502 6.3.1. ENABLE Command 1504 Arguments: capability names 1506 Responses: no specific responses for this command 1508 Result: OK - Relevant capabilities enabled 1509 BAD - No arguments, or syntax error in an argument 1511 Several IMAP extensions allow the server to return unsolicited 1512 responses specific to these extensions in certain circumstances. 1513 However, servers cannot send those unsolicited responses (with the 1514 exception of response codes (see Section 7.1) included in tagged or 1515 untagged OK/NO/BAD responses, which can always be sent) until they 1516 know that the clients support such extensions and thus won't choke on 1517 the extension response data. 1519 The ENABLE command provides an explicit indication from the client 1520 that it supports particular extensions. It is designed such that the 1521 client can send a simple constant string with the extensions it 1522 supports, and the server will enable the shared subset that both 1523 support. 1525 The ENABLE command takes a list of capability names, and requests the 1526 server to enable the named extensions. Once enabled using ENABLE, 1527 each extension remains active until the IMAP connection is closed. 1528 For each argument, the server does the following: 1530 o If the argument is not an extension known to the server, the 1531 server MUST ignore the argument. 1533 o If the argument is an extension known to the server, and it is not 1534 specifically permitted to be enabled using ENABLE, the server MUST 1535 ignore the argument. (Note that knowing about an extension 1536 doesn't necessarily imply supporting that extension.) 1538 o If the argument is an extension that is supported by the server 1539 and that needs to be enabled, the server MUST enable the extension 1540 for the duration of the connection. Note that once an extension 1541 is enabled, there is no way to disable it. 1543 If the ENABLE command is successful, the server MUST send an untagged 1544 ENABLED response Section 7.2.1. 1546 Clients SHOULD only include extensions that need to be enabled by the 1547 server. For example, a client can enable IMAP4rev2 specific 1548 behaviour when both IMAP4rev1 and IMAP4rev2 are advertised in the 1549 CAPABILITY response. Future RFCs may add to this list. 1551 The ENABLE command is only valid in the authenticated state, before 1552 any mailbox is selected. Clients MUST NOT issue ENABLE once they 1553 SELECT/EXAMINE a mailbox; however, server implementations don't have 1554 to check that no mailbox is selected or was previously selected 1555 during the duration of a connection. 1557 The ENABLE command can be issued multiple times in a session. It is 1558 additive; i.e., "ENABLE a b", followed by "ENABLE c" is the same as a 1559 single command "ENABLE a b c". When multiple ENABLE commands are 1560 issued, each corresponding ENABLED response SHOULD only contain 1561 extensions enabled by the corresponding ENABLE command, i.e. for the 1562 above example, the ENABLED response to "ENABLE c" should not contain 1563 "a" or "b". 1565 There are no limitations on pipelining ENABLE. For example, it is 1566 possible to send ENABLE and then immediately SELECT, or a LOGIN 1567 immediately followed by ENABLE. 1569 The server MUST NOT change the CAPABILITY list as a result of 1570 executing ENABLE; i.e., a CAPABILITY command issued right after an 1571 ENABLE command MUST list the same capabilities as a CAPABILITY 1572 command issued before the ENABLE command. This is demonstrated in 1573 the following example: 1575 C: t1 CAPABILITY 1576 S: * CAPABILITY IMAP4rev2 ID LITERAL+ X-GOOD-IDEA 1577 S: t1 OK foo 1578 C: t2 ENABLE CONDSTORE X-GOOD-IDEA 1579 S: * ENABLED X-GOOD-IDEA 1580 S: t2 OK foo 1581 C: t3 CAPABILITY 1582 S: * CAPABILITY IMAP4rev2 ID LITERAL+ X-GOOD-IDEA 1583 S: t3 OK foo again 1585 In the following example, the client enables CONDSTORE: 1587 C: a1 ENABLE CONDSTORE 1588 S: * ENABLED CONDSTORE 1589 S: a1 OK Conditional Store enabled 1591 6.3.1.1. Note to Designers of Extensions That May Use the ENABLE 1592 Command 1594 Designers of IMAP extensions are discouraged from creating extensions 1595 that require ENABLE unless there is no good alternative design. 1596 Specifically, extensions that cause potentially incompatible behavior 1597 changes to deployed server responses (and thus benefit from ENABLE) 1598 have a higher complexity cost than extensions that do not. 1600 6.3.2. SELECT Command 1602 Arguments: mailbox name 1604 Responses: REQUIRED untagged responses: FLAGS, EXISTS 1605 REQUIRED OK untagged responses: PERMANENTFLAGS, 1606 UIDNEXT, UIDVALIDITY 1607 OPTIONAL untagged response: LIST 1609 Result: OK - select completed, now in selected state 1610 NO - select failure, now in authenticated state: no 1611 such mailbox, can't access mailbox 1612 BAD - command unknown or arguments invalid 1614 The SELECT command selects a mailbox so that messages in the mailbox 1615 can be accessed. Before returning an OK to the client, the server 1616 MUST send the following untagged data to the client. (The order of 1617 individual responses is not important.) Note that earlier versions 1618 of this protocol only required the FLAGS and EXISTS untagged data; 1619 consequently, client implementations SHOULD implement default 1620 behavior for missing data as discussed with the individual item. 1622 FLAGS Defined flags in the mailbox. See the description of the 1623 FLAGS response for more detail. 1625 EXISTS The number of messages in the mailbox. See the 1626 description of the EXISTS response for more detail. 1628 LIST If the server allows de-normalized UTF-8 mailbox names (see 1629 Section 5.1) and the supplied mailbox name differs from the 1630 normalized version, the server SHOULD return LIST with OLDNAME 1631 extended data item. See Section 6.3.9.7 for more details. 1633 OK [PERMANENTFLAGS ()] A list of message flags that 1634 the client can change permanently. If this is missing, the client 1635 should assume that all flags can be changed permanently. 1637 OK [UIDNEXT ] The next unique identifier value. Refer to 1638 Section 2.3.1.1 for more information. If this is missing, the 1639 client can not make any assumptions about the next unique 1640 identifier value. 1642 OK [UIDVALIDITY ] The unique identifier validity value. Refer to 1643 Section 2.3.1.1 for more information. If this is missing, the 1644 server does not support unique identifiers. 1646 Only one mailbox can be selected at a time in a connection; 1647 simultaneous access to multiple mailboxes requires multiple 1648 connections. The SELECT command automatically deselects any 1649 currently selected mailbox before attempting the new selection. 1650 Consequently, if a mailbox is selected and a SELECT command that 1651 fails is attempted, no mailbox is selected. When deselecting a 1652 selected mailbox, the server MUST return an untagged OK response with 1653 the "[CLOSED]" response code when the currently selected mailbox is 1654 closed (see Paragraph 10). 1656 If the client is permitted to modify the mailbox, the server SHOULD 1657 prefix the text of the tagged OK response with the "[READ-WRITE]" 1658 response code. 1660 If the client is not permitted to modify the mailbox but is permitted 1661 read access, the mailbox is selected as read-only, and the server 1662 MUST prefix the text of the tagged OK response to SELECT with the 1663 "[READ-ONLY]" response code. Read-only access through SELECT differs 1664 from the EXAMINE command in that certain read-only mailboxes MAY 1665 permit the change of permanent state on a per-user (as opposed to 1666 global) basis. Netnews messages marked in a server-based .newsrc 1667 file are an example of such per-user permanent state that can be 1668 modified with read-only mailboxes. 1670 Example: C: A142 SELECT INBOX 1671 S: * 172 EXISTS 1672 S: * OK [UIDVALIDITY 3857529045] UIDs valid 1673 S: * OK [UIDNEXT 4392] Predicted next UID 1674 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1675 S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited 1676 S: A142 OK [READ-WRITE] SELECT completed 1678 Example: C: A142 SELECT INBOX 1679 S: * 172 EXISTS 1680 S: * OK [UIDVALIDITY 3857529045] UIDs valid 1681 S: * OK [UIDNEXT 4392] Predicted next UID 1682 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1683 S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited 1684 S: A142 OK [READ-WRITE] SELECT completed 1685 [...some time later...] 1686 C: A143 SELECT Drafts 1687 S: * OK [CLOSED] Previous mailbox is now closed 1688 S: * 5 EXISTS 1689 S: * OK [UIDVALIDITY 9877410381] UIDs valid 1690 S: * OK [UIDNEXT 102] Predicted next UID 1691 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1692 S: * OK [PERMANENTFLAGS (\Deleted \Seen \Answered 1693 \Flagged \Draft \*)] System flags and keywords allowed 1694 S: A143 OK [READ-WRITE] SELECT completed 1696 Note that IMAP4rev1 compliant servers can also send the untagged 1697 RECENT response which was deprecated in IMAP4rev2. E.g. "* 0 1698 RECENT". Pure IMAP4rev2 clients are advised to ignore the untagged 1699 RECENT response. 1701 6.3.3. EXAMINE Command 1703 Arguments: mailbox name 1705 Responses: REQUIRED untagged responses: FLAGS, EXISTS 1706 REQUIRED OK untagged responses: PERMANENTFLAGS, 1707 UIDNEXT, UIDVALIDITY 1708 OPTIONAL untagged response: LIST 1710 Result: OK - examine completed, now in selected state 1711 NO - examine failure, now in authenticated state: no 1712 such mailbox, can't access mailbox BAD - command unknown 1713 or arguments invalid 1715 The EXAMINE command is identical to SELECT and returns the same 1716 output; however, the selected mailbox is identified as read-only. No 1717 changes to the permanent state of the mailbox, including per-user 1718 state, are permitted. 1720 The text of the tagged OK response to the EXAMINE command MUST begin 1721 with the "[READ-ONLY]" response code. 1723 Example: C: A932 EXAMINE blurdybloop 1724 S: * 17 EXISTS 1725 S: * OK [UIDVALIDITY 3857529045] UIDs valid 1726 S: * OK [UIDNEXT 4392] Predicted next UID 1727 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1728 S: * OK [PERMANENTFLAGS ()] No permanent flags permitted 1729 S: A932 OK [READ-ONLY] EXAMINE completed 1731 6.3.4. CREATE Command 1733 Arguments: mailbox name 1735 Responses: OPTIONAL untagged response: LIST 1737 Result: OK - create completed 1738 NO - create failure: can't create mailbox with that name 1739 BAD - command unknown or arguments invalid 1741 The CREATE command creates a mailbox with the given name. An OK 1742 response is returned only if a new mailbox with that name has been 1743 created. It is an error to attempt to create INBOX or a mailbox with 1744 a name that refers to an extant mailbox. Any error in creation will 1745 return a tagged NO response. If a client attempts to create a UTF-8 1746 mailbox name that is not a valid Net-Unicode name, the server MUST 1747 reject the creation or convert the name to Net-Unicode prior to 1748 creating the mailbox. If the server decides to convert (normalize) 1749 the name, it SHOULD return an untagged LIST with OLDNAME extended 1750 data item, with the OLDNAME value being the supplied mailbox name and 1751 the name parameter being the normalized mailbox name. (See 1752 Section 6.3.9.7 for more details.) 1754 Mailboxes created in one IMAP session MAY be announced to other IMAP 1755 sessions using unsolicited LIST response. If the server 1756 automatically subscribes a mailbox when it is created, then the 1757 unsolicited LIST response for each affected subscribed mailbox name 1758 MUST include the \Subscribed attribute. 1760 If the mailbox name is suffixed with the server's hierarchy separator 1761 character (as returned from the server by a LIST command), this is a 1762 declaration that the client intends to create mailbox names under 1763 this name in the hierarchy. Server implementations that do not 1764 require this declaration MUST ignore the declaration. In any case, 1765 the name created is without the trailing hierarchy delimiter. 1767 If the server's hierarchy separator character appears elsewhere in 1768 the name, the server SHOULD create any superior hierarchical names 1769 that are needed for the CREATE command to be successfully completed. 1770 In other words, an attempt to create "foo/bar/zap" on a server in 1771 which "/" is the hierarchy separator character SHOULD create foo/ and 1772 foo/bar/ if they do not already exist. 1774 If a new mailbox is created with the same name as a mailbox which was 1775 deleted, its unique identifiers MUST be greater than any unique 1776 identifiers used in the previous incarnation of the mailbox UNLESS 1777 the new incarnation has a different unique identifier validity value. 1778 See the description of the UID command for more detail. 1780 Example: C: A003 CREATE owatagusiam/ 1781 S: A003 OK CREATE completed 1782 C: A004 CREATE owatagusiam/blurdybloop 1783 S: A004 OK CREATE completed 1784 C: A005 CREATE NonNormalized 1785 S: * LIST () "/" "Normalized" ("OLDNAME" ("NonNormalized")) 1786 S: A005 OK CREATE completed 1788 (in the last example imagine that "NonNormalized" is 1789 a non NFC normalized Unicode mailbox name and that 1790 "Normalized" is its NFC normalized version.) 1792 Note: The interpretation of this example depends on whether "/" 1793 was returned as the hierarchy separator from LIST. If "/" is the 1794 hierarchy separator, a new level of hierarchy named "owatagusiam" 1795 with a member called "blurdybloop" is created. Otherwise, two 1796 mailboxes at the same hierarchy level are created. 1798 6.3.5. DELETE Command 1800 Arguments: mailbox name 1802 Responses: OPTIONAL untagged response: LIST 1804 Result: OK - delete completed 1805 NO - delete failure: can't delete mailbox with that name 1806 BAD - command unknown or arguments invalid 1808 The DELETE command permanently removes the mailbox with the given 1809 name. A tagged OK response is returned only if the mailbox has been 1810 deleted. It is an error to attempt to delete INBOX or a mailbox name 1811 that does not exist. 1813 The DELETE command MUST NOT remove inferior hierarchical names. For 1814 example, if a mailbox "foo" has an inferior "foo.bar" (assuming "." 1815 is the hierarchy delimiter character), removing "foo" MUST NOT remove 1816 "foo.bar". It is an error to attempt to delete a name that has 1817 inferior hierarchical names and also has the \Noselect mailbox name 1818 attribute (see the description of the LIST response for more 1819 details). 1821 It is permitted to delete a name that has inferior hierarchical names 1822 and does not have the \Noselect mailbox name attribute. If the 1823 server implementation does not permit deleting the name while 1824 inferior hierarchical names exists then it SHOULD disallow the DELETE 1825 command by returning a tagged NO response. The NO response SHOULD 1826 include the HASCHILDREN response code. Alternatively the server MAY 1827 allow the DELETE command, but sets the \Noselect mailbox name 1828 attribute for that name. 1830 If the server returns OK response, all messages in that mailbox are 1831 removed by the DELETE command. 1833 The value of the highest-used unique identifier of the deleted 1834 mailbox MUST be preserved so that a new mailbox created with the same 1835 name will not reuse the identifiers of the former incarnation, UNLESS 1836 the new incarnation has a different unique identifier validity value. 1837 See the description of the UID command for more detail. 1839 Mailboxes deleted in one IMAP session MAY be announced to other IMAP 1840 sessions using unsolicited LIST response, containing the 1841 "\NonExistent" attribute. 1843 Examples: C: A682 LIST "" * 1844 S: * LIST () "/" blurdybloop 1845 S: * LIST (\Noselect) "/" foo 1846 S: * LIST () "/" foo/bar 1847 S: A682 OK LIST completed 1848 C: A683 DELETE blurdybloop 1849 S: A683 OK DELETE completed 1850 C: A684 DELETE foo 1851 S: A684 NO Name "foo" has inferior hierarchical names 1852 C: A685 DELETE foo/bar 1853 S: A685 OK DELETE Completed 1854 C: A686 LIST "" * 1855 S: * LIST (\Noselect) "/" foo 1856 S: A686 OK LIST completed 1857 C: A687 DELETE foo 1858 S: A687 OK DELETE Completed 1859 C: A82 LIST "" * 1860 S: * LIST () "." blurdybloop 1861 S: * LIST () "." foo 1862 S: * LIST () "." foo.bar 1863 S: A82 OK LIST completed 1864 C: A83 DELETE blurdybloop 1865 S: A83 OK DELETE completed 1866 C: A84 DELETE foo 1867 S: A84 OK DELETE Completed 1868 C: A85 LIST "" * 1869 S: * LIST () "." foo.bar 1870 S: A85 OK LIST completed 1871 C: A86 LIST "" % 1872 S: * LIST (\Noselect) "." foo 1873 S: A86 OK LIST completed 1875 6.3.6. RENAME Command 1877 Arguments: existing mailbox name 1878 new mailbox name 1880 Responses: OPTIONAL untagged response: LIST 1882 Result: OK - rename completed 1883 NO - rename failure: can't rename mailbox with that name, 1884 can't rename to mailbox with that name 1885 BAD - command unknown or arguments invalid 1887 The RENAME command changes the name of a mailbox. A tagged OK 1888 response is returned only if the mailbox has been renamed. It is an 1889 error to attempt to rename from a mailbox name that does not exist or 1890 to a mailbox name that already exists. Any error in renaming will 1891 return a tagged NO response. 1893 If the name has inferior hierarchical names, then the inferior 1894 hierarchical names MUST also be renamed. For example, a rename of 1895 "foo" to "zap" will rename "foo/bar" (assuming "/" is the hierarchy 1896 delimiter character) to "zap/bar". 1898 If the server's hierarchy separator character appears in the name, 1899 the server SHOULD create any superior hierarchical names that are 1900 needed for the RENAME command to complete successfully. In other 1901 words, an attempt to rename "foo/bar/zap" to baz/rag/zowie on a 1902 server in which "/" is the hierarchy separator character in the 1903 corresponding namespace SHOULD create baz/ and baz/rag/ if they do 1904 not already exist. 1906 The value of the highest-used unique identifier of the old mailbox 1907 name MUST be preserved so that a new mailbox created with the same 1908 name will not reuse the identifiers of the former incarnation, UNLESS 1909 the new incarnation has a different unique identifier validity value. 1910 See the description of the UID command for more detail. 1912 Renaming INBOX is permitted, and has special behavior. (Note that 1913 some servers disallow renaming INBOX, so clients need to be able to 1914 handle such RENAME failing). It moves all messages in INBOX to a new 1915 mailbox with the given name, leaving INBOX empty. If the server 1916 implementation supports inferior hierarchical names of INBOX, these 1917 are unaffected by a rename of INBOX. 1919 If the server allows creation of mailboxes with names that are not 1920 valid Net-Unicode names, the server normalizes both the existing 1921 mailbox name parameter and the new mailbox name parameter. If the 1922 normalized version of any of these 2 parameters differs from the 1923 corresponding supplied version, the server SHOULD return an untagged 1924 LIST response with OLDNAME extended data item, with the OLDNAME value 1925 being the supplied existing mailbox name and the name parameter being 1926 the normalized new mailbox name (see Section 6.3.9.7). This would 1927 allow the client to correlate supplied name with the normalized name. 1929 Mailboxes renamed in one IMAP session MAY be announced to other IMAP 1930 sessions using unsolicited LIST response with OLDNAME extended data 1931 item. 1933 In both of the above cases: if the server automatically subscribes a 1934 mailbox when it is renamed, then the unsolicited LIST response for 1935 each affected subscribed mailbox name MUST include the \Subscribed 1936 attribute. No unsolicited LIST responses need to be sent for 1937 children mailboxes, if any. When INBOX is successfully renamed, a 1938 new INBOX is assumed to be created. No unsolicited LIST responses 1939 need to be sent for INBOX in this case. 1941 Examples: C: A682 LIST "" * 1942 S: * LIST () "/" blurdybloop 1943 S: * LIST (\Noselect) "/" foo 1944 S: * LIST () "/" foo/bar 1945 S: A682 OK LIST completed 1946 C: A683 RENAME blurdybloop sarasoop 1947 S: A683 OK RENAME completed 1948 C: A684 RENAME foo zowie 1949 S: A684 OK RENAME Completed 1950 C: A685 LIST "" * 1951 S: * LIST () "/" sarasoop 1952 S: * LIST (\Noselect) "/" zowie 1953 S: * LIST () "/" zowie/bar 1954 S: A685 OK LIST completed 1956 C: Z432 LIST "" * 1957 S: * LIST () "." INBOX 1958 S: * LIST () "." INBOX.bar 1959 S: Z432 OK LIST completed 1960 C: Z433 RENAME INBOX old-mail 1961 S: Z433 OK RENAME completed 1962 C: Z434 LIST "" * 1963 S: * LIST () "." INBOX 1964 S: * LIST () "." INBOX.bar 1965 S: * LIST () "." old-mail 1966 S: Z434 OK LIST completed 1968 Note that renaming a mailbox doesn't update subscription information 1969 on the original name. To keep subscription information in sync, the 1970 following sequence of commands can be used: 1972 C: 1001 RENAME X Y 1973 C: 1002 SUBSCRIBE Y 1974 C: 1003 UNSUBSCRIBE X 1976 Note that the above sequence of commands doesn't account for updating 1977 subscription for any children mailboxes of mailbox X. 1979 6.3.7. SUBSCRIBE Command 1981 Arguments: mailbox 1983 Responses: no specific responses for this command 1985 Result: OK - subscribe completed 1986 NO - subscribe failure: can't subscribe to that name 1987 BAD - command unknown or arguments invalid 1989 The SUBSCRIBE command adds the specified mailbox name to the server's 1990 set of "active" or "subscribed" mailboxes as returned by the LIST 1991 (SUBSCRIBED) command. This command returns a tagged OK response if 1992 the subscription is successful or if the mailbox is already 1993 subscribed. 1995 A server MAY validate the mailbox argument to SUBSCRIBE to verify 1996 that it exists. However, it SHOULD NOT unilaterally remove an 1997 existing mailbox name from the subscription list even if a mailbox by 1998 that name no longer exists. 2000 Note: This requirement is because a server site can choose to 2001 routinely remove a mailbox with a well-known name (e.g., "system- 2002 alerts") after its contents expire, with the intention of 2003 recreating it when new contents are appropriate. 2005 Example: C: A002 SUBSCRIBE #news.comp.mail.mime 2006 S: A002 OK SUBSCRIBE completed 2008 6.3.8. UNSUBSCRIBE Command 2010 Arguments: mailbox name 2012 Responses: no specific responses for this command 2014 Result: OK - unsubscribe completed 2015 NO - unsubscribe failure: can't unsubscribe that name 2016 BAD - command unknown or arguments invalid 2018 The UNSUBSCRIBE command removes the specified mailbox name from the 2019 server's set of "active" or "subscribed" mailboxes as returned by the 2020 LIST (SUBSCRIBED) command. This command returns a tagged OK response 2021 if the unsubscription is successful or if the mailbox is not 2022 subscribed. 2024 Example: C: A002 UNSUBSCRIBE #news.comp.mail.mime 2025 S: A002 OK UNSUBSCRIBE completed 2027 6.3.9. LIST Command 2029 Arguments (basic): reference name 2030 mailbox name with possible wildcards 2032 Arguments (extended): selection options (OPTIONAL) 2033 reference name 2034 mailbox patterns 2035 return options (OPTIONAL) 2037 Responses: untagged responses: LIST 2039 Result: OK - list completed 2040 NO - list failure: can't list that reference or name 2041 BAD - command unknown or arguments invalid 2043 The LIST command returns a subset of names from the complete set of 2044 all names available to the client. Zero or more untagged LIST 2045 replies are returned, containing the name attributes, hierarchy 2046 delimiter, name, and possible extension information; see the 2047 description of the LIST reply for more detail. 2049 The LIST command SHOULD return its data quickly, without undue delay. 2050 For example, it SHOULD NOT go to excess trouble to calculate the 2051 \Marked or \Unmarked status or perform other processing; if each name 2052 requires 1 second of processing, then a list of 1200 names would take 2053 20 minutes! 2055 The extended LIST command, originally introduced in [RFC5258], 2056 provides capabilities beyond that of the original IMAP LIST command. 2057 The extended syntax is being used if one or more of the following 2058 conditions is true: 2060 1. if the first word after the command name begins with a 2061 parenthesis ("LIST selection options"); 2063 2. if the second word after the command name begins with a 2064 parenthesis; 2066 3. if the LIST command has more than 2 parameters ("LIST return 2067 options") 2069 An empty ("" string) reference name argument indicates that the 2070 mailbox name is interpreted as by SELECT. The returned mailbox names 2071 MUST match the supplied mailbox name pattern(s). A non-empty 2072 reference name argument is the name of a mailbox or a level of 2073 mailbox hierarchy, and indicates the context in which the mailbox 2074 name is interpreted. Clients SHOULD use the empty reference 2075 argument. 2077 In the basic syntax only, an empty ("" string) mailbox name argument 2078 is a special request to return the hierarchy delimiter and the root 2079 name of the name given in the reference. The value returned as the 2080 root MAY be the empty string if the reference is non-rooted or is an 2081 empty string. In all cases, a hierarchy delimiter (or NIL if there 2082 is no hierarchy) is returned. This permits a client to get the 2083 hierarchy delimiter (or find out that the mailbox names are flat) 2084 even when no mailboxes by that name currently exist. 2086 In the extended syntax, any mailbox name arguments that are empty 2087 strings are ignored. There is no special meaning for empty mailbox 2088 names when the extended syntax is used. 2090 The reference and mailbox name arguments are interpreted into a 2091 canonical form that represents an unambiguous left-to-right 2092 hierarchy. The returned mailbox names will be in the interpreted 2093 form, that we call "canonical LIST pattern" later in this document. 2094 To define the term "canonical LIST pattern" formally: it refers to 2095 the canonical pattern constructed internally by the server from the 2096 reference and mailbox name arguments. 2098 Note: The interpretation of the reference argument is 2099 implementation-defined. It depends upon whether the server 2100 implementation has a concept of the "current working directory" 2101 and leading "break out characters", which override the current 2102 working directory. 2104 For example, on a server which exports a UNIX or NT filesystem, 2105 the reference argument contains the current working directory, and 2106 the mailbox name argument would contain the name as interpreted in 2107 the current working directory. 2109 If a server implementation has no concept of break out characters, 2110 the canonical form is normally the reference name appended with 2111 the mailbox name. Note that if the server implements the 2112 namespace convention (Section 5.1.2.1), "#" is a break out 2113 character and must be treated as such. 2115 If the reference argument is not a level of mailbox hierarchy 2116 (that is, it is a \NoInferiors name), and/or the reference 2117 argument does not end with the hierarchy delimiter, it is 2118 implementation-dependent how this is interpreted. For example, a 2119 reference of "foo/bar" and mailbox name of "rag/baz" could be 2120 interpreted as "foo/bar/rag/baz", "foo/barrag/baz", or "foo/rag/ 2121 baz". A client SHOULD NOT use such a reference argument except at 2122 the explicit request of the user. A hierarchical browser MUST NOT 2123 make any assumptions about server interpretation of the reference 2124 unless the reference is a level of mailbox hierarchy AND ends with 2125 the hierarchy delimiter. 2127 Any part of the reference argument that is included in the 2128 interpreted form SHOULD prefix the interpreted form. It SHOULD also 2129 be in the same form as the reference name argument. This rule 2130 permits the client to determine if the returned mailbox name is in 2131 the context of the reference argument, or if something about the 2132 mailbox argument overrode the reference argument. Without this rule, 2133 the client would have to have knowledge of the server's naming 2134 semantics including what characters are "breakouts" that override a 2135 naming context. 2137 For example, here are some examples of how references 2138 and mailbox names might be interpreted on a UNIX-based 2139 server: 2141 Reference Mailbox Name Interpretation 2142 ------------ ------------ -------------- 2143 ~smith/Mail/ foo.* ~smith/Mail/foo.* 2144 archive/ % archive/% 2145 #news. comp.mail.* #news.comp.mail.* 2146 ~smith/Mail/ /usr/doc/foo /usr/doc/foo 2147 archive/ ~fred/Mail/* ~fred/Mail/* 2149 The first three examples demonstrate interpretations in 2150 the context of the reference argument. Note that 2151 "~smith/Mail" SHOULD NOT be transformed into something 2152 like "/u2/users/smith/Mail", or it would be impossible 2153 for the client to determine that the interpretation was 2154 in the context of the reference. 2156 The character "*" is a wildcard, and matches zero or more characters 2157 at this position. The character "%" is similar to "*", but it does 2158 not match a hierarchy delimiter. If the "%" wildcard is the last 2159 character of a mailbox name argument, matching levels of hierarchy 2160 are also returned. If these levels of hierarchy are not also 2161 selectable mailboxes, they are returned with the \Noselect mailbox 2162 name attribute (see the description of the LIST response for more 2163 details). 2165 Any syntactically valid pattern that is not accepted by a server for 2166 any reason MUST be silently ignored. I.e. it results in no LIST 2167 responses and the LIST command still returns tagged OK response. 2169 Selection options tell the server to limit the mailbox names that are 2170 selected by the LIST operation. If selection options are used, the 2171 mailboxes returned are those that match both the list of canonical 2172 LIST patterns and the selection options. Unless a particular 2173 selection option provides special rules, the selection options are 2174 cumulative: a mailbox that matches the mailbox patterns is selected 2175 only if it also matches all of the selection options. (An example of 2176 a selection option with special rules is the RECURSIVEMATCH option.) 2177 Return options control what information is returned for each matched 2178 mailbox. Return options MUST NOT cause the server to report 2179 information about additional mailbox names other than those that 2180 match the canonical LIST patterns and selection options. If no 2181 return options are specified, the client is only expecting 2182 information about mailbox attributes. The server MAY return other 2183 information about the matched mailboxes, and clients MUST be able to 2184 handle that situation. 2186 Initial selection options and return options are defined in the 2187 following subsections, and new ones will also be defined in 2188 extensions. Initial options defined in this document MUST be 2189 supported. Each non-initial option will be enabled by a capability 2190 string (one capability may enable multiple options), and a client 2191 MUST NOT send an option for which the server has not advertised 2192 support. A server MUST respond to options it does not recognize with 2193 a BAD response. The client SHOULD NOT specify any option more than 2194 once; however, if the client does this, the server MUST act as if it 2195 received the option only once. The order in which options are 2196 specified by the client is not significant. 2198 In general, each selection option except RECURSIVEMATCH will have a 2199 corresponding return option. The REMOTE selection option is an 2200 anomaly in this regard, and does not have a corresponding return 2201 option. That is because it expands, rather than restricts, the set 2202 of mailboxes that are returned. Future extensions to this 2203 specification should keep parallelism in mind and define a pair of 2204 corresponding options. 2206 Server implementations are permitted to "hide" otherwise accessible 2207 mailboxes from the wildcard characters, by preventing certain 2208 characters or names from matching a wildcard in certain situations. 2209 For example, a UNIX-based server might restrict the interpretation of 2210 "*" so that an initial "/" character does not match. 2212 The special name INBOX is included in the output from LIST, if INBOX 2213 is supported by this server for this user and if the uppercase string 2214 "INBOX" matches the interpreted reference and mailbox name arguments 2215 with wildcards as described above. The criteria for omitting INBOX 2216 is whether SELECT INBOX will return failure; it is not relevant 2217 whether the user's real INBOX resides on this or some other server. 2219 6.3.9.1. LIST Selection Options 2221 The selection options defined in this specification are as follows: 2223 SUBSCRIBED - causes the LIST command to list subscribed names, 2224 rather than the existing mailboxes. This will often be a subset 2225 of the actual mailboxes. It's also possible for this list to 2226 contain the names of mailboxes that don't exist. In any case, the 2227 list MUST include exactly those mailbox names that match the 2228 canonical list pattern and are subscribed to. 2230 This option defines a mailbox attribute, "\Subscribed", that 2231 indicates that a mailbox name is subscribed to. The "\Subscribed" 2232 attribute MUST be supported and MUST be accurately computed when 2233 the SUBSCRIBED selection option is specified. 2235 Note that the SUBSCRIBED selection option implies the SUBSCRIBED 2236 return option (see below). 2238 REMOTE - causes the LIST command to show remote mailboxes as well as 2239 local ones, as described in [RFC2193]. This option is intended to 2240 replace the RLIST command and, in conjunction with the SUBSCRIBED 2241 selection option, the RLSUB command. Servers that don't support 2242 remote mailboxes just ignore this option. 2244 This option defines a mailbox attribute, "\Remote", that indicates 2245 that a mailbox is a remote mailbox. The "\Remote" attribute MUST 2246 be accurately computed when the REMOTE option is specified. 2248 The REMOTE selection option has no interaction with other options. 2249 Its effect is to tell the server to apply the other options, if 2250 any, to remote mailboxes, in addition to local ones. In 2251 particular, it has no interaction with RECURSIVEMATCH (see below). 2252 A request for (REMOTE RECURSIVEMATCH) is invalid, because a 2253 request for (RECURSIVEMATCH) is also invalid. A request for 2254 (REMOTE RECURSIVEMATCH SUBSCRIBED) is asking for all subscribed 2255 mailboxes, both local and remote. 2257 RECURSIVEMATCH - this option forces the server to return information 2258 about parent mailboxes that don't match other selection options, 2259 but have some submailboxes that do. Information about children is 2260 returned in the CHILDINFO extended data item, as described in 2261 Section 6.3.9.6. 2263 Note 1: In order for a parent mailbox to be returned, it still has 2264 to match the canonical LIST pattern. 2266 Note 2: When returning the CHILDINFO extended data item, it 2267 doesn't matter whether or not the submailbox matches the canonical 2268 LIST pattern. See also example 9 in Section 6.3.9.8. 2270 The RECURSIVEMATCH option MUST NOT occur as the only selection 2271 option (or only with REMOTE), as it only makes sense when other 2272 selection options are also used. The server MUST return BAD 2273 tagged response in such case. 2275 Note that even if the RECURSIVEMATCH option is specified, the 2276 client MUST still be able to handle a case when a CHILDINFO 2277 extended data item is returned and there are no submailboxes that 2278 meet the selection criteria of the subsequent LIST command, as 2279 they can be deleted/renamed after the LIST response was sent, but 2280 before the client had a chance to access them. 2282 6.3.9.2. LIST Return Options 2284 The return options defined in this specification are as follows: 2286 SUBSCRIBED - causes the LIST command to return subscription state 2287 for all matching mailbox names. The "\Subscribed" attribute MUST 2288 be supported and MUST be accurately computed when the SUBSCRIBED 2289 return option is specified. Further, all mailbox flags MUST be 2290 accurately computed (this differs from the behavior of the 2291 obsolete LSUB command from IMAP4rev1). 2293 CHILDREN - requests mailbox child information as originally proposed 2294 in [RFC3348]. See Section 6.3.9.5, below, for details. This 2295 option MUST be supported by all servers. 2297 STATUS - requests STATUS response for each matching mailbox. 2299 This option takes STATUS data items as parameters. For each 2300 selectable mailbox matching the list pattern and selection 2301 options, the server MUST return an untagged LIST response 2302 followed by an untagged STATUS response containing the 2303 information requested in the STATUS return option. 2305 If an attempted STATUS for a listed mailbox fails because the 2306 mailbox can't be selected (e.g., if the "l" ACL right [RFC4314] 2307 is granted to the mailbox and the "r" right is not granted, or 2308 due to a race condition between LIST and STATUS changing the 2309 mailbox to \NoSelect), the STATUS response MUST NOT be returned 2310 and the LIST response MUST include the \NoSelect attribute. 2311 This means the server may have to buffer the LIST reply until 2312 it has successfully looked up the necessary STATUS information. 2314 If the server runs into unexpected problems while trying to 2315 look up the STATUS information, it MAY drop the corresponding 2316 STATUS reply. In such a situation, the LIST command would 2317 still return a tagged OK reply. 2319 6.3.9.3. General Principles for Returning LIST Responses 2321 This section outlines several principles that can be used by server 2322 implementations of this document to decide whether a LIST response 2323 should be returned, as well as how many responses and what kind of 2324 information they may contain. 2326 1. At most one LIST response should be returned for each mailbox 2327 name that matches the canonical LIST pattern. Server 2328 implementors must not assume that clients will be able to 2329 assemble mailbox attributes and other information returned in 2330 multiple LIST responses. 2332 2. There are only two reasons for including a matching mailbox name 2333 in the responses to the LIST command (note that the server is 2334 allowed to return unsolicited responses at any time, and such 2335 responses are not governed by this rule): 2337 A. The mailbox name also satisfies the selection criteria. 2339 B. The mailbox name doesn't satisfy the selection criteria, but 2340 it has at least one descendant mailbox name that satisfies 2341 the selection criteria and that doesn't match the canonical 2342 LIST pattern. 2344 For more information on this case, see the CHILDINFO extended 2345 data item described in Section 6.3.9.6. Note that the 2346 CHILDINFO extended data item can only be returned when the 2347 RECURSIVEMATCH selection option is specified. 2349 3. Attributes returned in the same LIST response must be treated 2350 additively. For example, the following response 2352 S: * LIST (\Subscribed \NonExistent) "/" "Fruit/Peach" 2354 means that the "Fruit/Peach" mailbox doesn't exist, but it is 2355 subscribed. 2357 6.3.9.4. Additional LIST-related Requirements on Clients 2359 All clients MUST treat a LIST attribute with a stronger meaning as 2360 implying any attribute that can be inferred from it. (See 2361 Section 7.2.3 for the list of currently defined attributes). For 2362 example, the client must treat the presence of the \NoInferiors 2363 attribute as if the \HasNoChildren attribute was also sent by the 2364 server. 2366 The following table summarizes inference rules. 2368 +--------------------+-------------------+ 2369 | returned attribute | implied attribute | 2370 +--------------------+-------------------+ 2371 | \NoInferiors | \HasNoChildren | 2372 | \NonExistent | \NoSelect | 2373 +--------------------+-------------------+ 2375 6.3.9.5. The CHILDREN Return Option 2377 The CHILDREN return option implements the Child Mailbox Extension, 2378 originally proposed by Mike Gahrns and Raymond Cheng, of Microsoft 2379 Corporation. Most of the information in this section is taken 2380 directly from their original specification [RFC3348]. The CHILDREN 2381 return option is simply an indication that the client wants this 2382 information; a server MAY provide it even if the option is not 2383 specified. 2385 Many IMAP4 clients present to the user a hierarchical view of the 2386 mailboxes that a user has access to. Rather than initially 2387 presenting to the user the entire mailbox hierarchy, it is often 2388 preferable to show to the user a collapsed outline list of the 2389 mailbox hierarchy (particularly if there is a large number of 2390 mailboxes). The user can then expand the collapsed outline hierarchy 2391 as needed. It is common to include within the collapsed hierarchy a 2392 visual clue (such as a ''+'') to indicate that there are child 2393 mailboxes under a particular mailbox. When the visual clue is 2394 clicked, the hierarchy list is expanded to show the child mailboxes. 2395 The CHILDREN return option provides a mechanism for a client to 2396 efficiently determine whether a particular mailbox has children, 2397 without issuing a LIST "" * or a LIST "" % for each mailbox name. 2398 The CHILDREN return option defines two new attributes that MUST be 2399 returned within a LIST response: \HasChildren and \HasNoChildren. 2400 Although these attributes MAY be returned in response to any LIST 2401 command, the CHILDREN return option is provided to indicate that the 2402 client particularly wants this information. If the CHILDREN return 2403 option is present, the server MUST return these attributes even if 2404 their computation is expensive. 2406 \HasChildren 2408 The presence of this attribute indicates that the mailbox has 2409 child mailboxes. A server SHOULD NOT set this attribute if 2410 there are child mailboxes and the user does not have permission 2411 to access any of them. In this case, \HasNoChildren SHOULD be 2412 used. In many cases, however, a server may not be able to 2413 efficiently compute whether a user has access to any child 2414 mailbox. Note that even though the \HasChildren attribute for a 2415 mailbox must be correct at the time of processing of the 2416 mailbox, a client must be prepared to deal with a situation when 2417 a mailbox is marked with the \HasChildren attribute, but no 2418 child mailbox appears in the response to the LIST command. This 2419 might happen, for example, due to children mailboxes being 2420 deleted or made inaccessible to the user (using access control) 2421 by another client before the server is able to list them. 2423 \HasNoChildren 2425 The presence of this attribute indicates that the mailbox has NO 2426 child mailboxes that are accessible to the currently 2427 authenticated user. 2429 It is an error for the server to return both a \HasChildren and a 2430 \HasNoChildren attribute in the same LIST response. 2432 Note: the \HasNoChildren attribute should not be confused with the 2433 the \NoInferiors attribute, which indicates that no child mailboxes 2434 exist now and none can be created in the future. 2436 6.3.9.6. CHILDINFO Extended Data Item 2438 The CHILDINFO extended data item MUST NOT be returned unless the 2439 client has specified the RECURSIVEMATCH selection option. 2441 The CHILDINFO extended data item in a LIST response describes the 2442 selection criteria that has caused it to be returned and indicates 2443 that the mailbox has at least one descendant mailbox that matches the 2444 selection criteria. 2446 Note: Some servers allow for mailboxes to exist without requiring 2447 their parent to exist. For example, a mailbox "Customers/ABC" can 2448 exist while the mailbox "Customers" does not. As CHILDINFO extended 2449 data item is not allowed if the RECURSIVEMATCH selection option is 2450 not specified, such servers SHOULD use the "\NonExistent 2451 \HasChildren" attribute pair to signal to the client that there is a 2452 descendant mailbox that matches the selection criteria. See example 2453 11 in Section 6.3.9.8. 2455 The returned selection criteria allow the client to distinguish a 2456 solicited response from an unsolicited one, as well as to distinguish 2457 among solicited responses caused by multiple pipelined LIST commands 2458 that specify different criteria. 2460 Servers SHOULD ONLY return a non-matching mailbox name along with 2461 CHILDINFO if at least one matching child is not also being returned. 2462 That is, servers SHOULD suppress redundant CHILDINFO responses. 2464 Examples 8 and 10 in Section 6.3.9.8 demonstrate the difference 2465 between present CHILDINFO extended data item and the "\HasChildren" 2466 attribute. 2468 The following table summarizes interaction between the "\NonExistent" 2469 attribute and CHILDINFO (the first column indicates whether the 2470 parent mailbox exists): 2472 +--------+-------------+------------------+-------------------------+ 2473 | exists | meets the | has a child that | returned IMAP4rev2 | 2474 | | selection | meets the | /LIST-EXTENDED | 2475 | | criteria | selection | attributes and | 2476 | | | criteria | CHILDINFO | 2477 +--------+-------------+------------------+-------------------------+ 2478 | no | no | no | no LIST response | 2479 | | | | returned | 2480 | yes | no | no | no LIST response | 2481 | | | | returned | 2482 | no | yes | no | (\NonExistent ) | 2483 | yes | yes | no | () | 2484 | no | no | yes | (\NonExistent) + | 2485 | | | | CHILDINFO | 2486 | yes | no | yes | () + CHILDINFO | 2487 | no | yes | yes | (\NonExistent ) + | 2488 | | | | CHILDINFO | 2489 | yes | yes | yes | () + CHILDINFO | 2490 +--------+-------------+------------------+-------------------------+ 2492 where is one or more attributes that correspond to the 2493 selection criteria; for example, for the SUBSCRIBED option the 2494 is \Subscribed. 2496 6.3.9.7. OLDNAME Extended Data Item 2498 The OLDNAME extended data item is included when a mailbox name is 2499 created (with CREATE command), renamed (with RENAME command) or 2500 deleted (with DELETE command). (When a mailbox is deleted the 2501 "\NonExistent" attribute is also included.) IMAP extensions can 2502 specify other conditions when OLDNAME extended data item should be 2503 included. 2505 If the server allows de-normalized mailbox names (see Section 5.1) in 2506 SELECT/EXAMINE, CREATE, RENAME or DELETE, it SHOULD return an 2507 unsolicited LIST response that includes OLDNAME extended data item, 2508 whenever the supplied mailbox name differs from the resulting 2509 normalized mailbox name. From the client point of view this is 2510 indistinguishable from another user renaming of deleting the mailbox, 2511 as specified in the previous paragraph. 2513 A deleted mailbox can be announced like this: 2515 S: * LIST (\NonExistent) "." "INBOX.DeletedMailbox" 2517 Example of a renamed mailbox: 2519 S: * LIST () "/" "NewMailbox" ("OLDNAME" ("OldMailbox")) 2521 6.3.9.8. LIST Command Examples 2523 This example shows some uses of the basic LIST command: 2525 Example: C: A101 LIST "" "" 2526 S: * LIST (\Noselect) "/" "" 2527 S: A101 OK LIST Completed 2528 C: A102 LIST #news.comp.mail.misc "" 2529 S: * LIST (\Noselect) "." #news. 2530 S: A102 OK LIST Completed 2531 C: A103 LIST /usr/staff/jones "" 2532 S: * LIST (\Noselect) "/" / 2533 S: A103 OK LIST Completed 2534 C: A202 LIST ~/Mail/ % 2535 S: * LIST (\Noselect) "/" ~/Mail/foo 2536 S: * LIST () "/" ~/Mail/meetings 2537 S: A202 OK LIST completed 2539 Extended examples: 2541 1: The first example shows the complete local hierarchy that will 2542 be used for the other examples. 2544 C: A01 LIST "" "*" 2545 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2546 S: * LIST () "/" "Fruit" 2547 S: * LIST () "/" "Fruit/Apple" 2548 S: * LIST () "/" "Fruit/Banana" 2549 S: * LIST () "/" "Tofu" 2550 S: * LIST () "/" "Vegetable" 2551 S: * LIST () "/" "Vegetable/Broccoli" 2552 S: * LIST () "/" "Vegetable/Corn" 2553 S: A01 OK done 2555 2: In the next example, we will see the subscribed mailboxes. This 2556 is similar to, but not equivalent with now deprecated, (see [RFC3501] for more details on LSUB command). Note 2558 that the mailbox called "Fruit/Peach" is subscribed to, but does 2559 not actually exist (perhaps it was deleted while still 2560 subscribed). The "Fruit" mailbox is not subscribed to, but it 2561 has two subscribed children. The "Vegetable" mailbox is 2562 subscribed and has two children; one of them is subscribed as 2563 well. 2565 C: A02 LIST (SUBSCRIBED) "" "*" 2566 S: * LIST (\Marked \NoInferiors \Subscribed) "/" "inbox" 2567 S: * LIST (\Subscribed) "/" "Fruit/Banana" 2568 S: * LIST (\Subscribed \NonExistent) "/" "Fruit/Peach" 2569 S: * LIST (\Subscribed) "/" "Vegetable" 2570 S: * LIST (\Subscribed) "/" "Vegetable/Broccoli" 2571 S: A02 OK done 2573 3: The next example shows the use of the CHILDREN option. The 2574 client, without having to list the second level of hierarchy, 2575 now knows which of the top-level mailboxes have submailboxes 2576 (children) and which do not. Note that it's not necessary for 2577 the server to return the \HasNoChildren attribute for the inbox, 2578 because the \NoInferiors attribute already implies that, and has 2579 a stronger meaning. 2581 C: A03 LIST () "" "%" RETURN (CHILDREN) 2582 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2583 S: * LIST (\HasChildren) "/" "Fruit" 2584 S: * LIST (\HasNoChildren) "/" "Tofu" 2585 S: * LIST (\HasChildren) "/" "Vegetable" 2586 S: A03 OK done 2588 4: In this example, we see more mailboxes that reside on another 2589 server. This is similar to the command . 2591 C: A04 LIST (REMOTE) "" "%" RETURN (CHILDREN) 2592 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2593 S: * LIST (\HasChildren) "/" "Fruit" 2594 S: * LIST (\HasNoChildren) "/" "Tofu" 2595 S: * LIST (\HasChildren) "/" "Vegetable" 2596 S: * LIST (\Remote) "/" "Bread" 2597 S: * LIST (\HasChildren \Remote) "/" "Meat" 2598 S: A04 OK done 2600 5: The following example also requests the server to include 2601 mailboxes that reside on another server. The server returns 2602 information about all mailboxes that are subscribed. This is 2603 similar to the command (see [RFC2193] for more 2604 details on RLSUB). We also see the use of two selection 2605 options. 2607 C: A05 LIST (REMOTE SUBSCRIBED) "" "*" 2608 S: * LIST (\Marked \NoInferiors \Subscribed) "/" "inbox" 2609 S: * LIST (\Subscribed) "/" "Fruit/Banana" 2610 S: * LIST (\Subscribed \NonExistent) "/" "Fruit/Peach" 2611 S: * LIST (\Subscribed) "/" "Vegetable" 2612 S: * LIST (\Subscribed) "/" "Vegetable/Broccoli" 2613 S: * LIST (\Remote \Subscribed) "/" "Bread" 2614 S: A05 OK done 2616 6: The following example requests the server to include mailboxes 2617 that reside on another server. The server is asked to return 2618 subscription information for all returned mailboxes. This is 2619 different from the example above. 2621 Note that the output of this command is not a superset of the 2622 output in the previous example, as it doesn't include LIST 2623 response for the non-existent "Fruit/Peach". 2625 C: A06 LIST (REMOTE) "" "*" RETURN (SUBSCRIBED) 2626 S: * LIST (\Marked \NoInferiors \Subscribed) "/" "inbox" 2627 S: * LIST () "/" "Fruit" 2628 S: * LIST () "/" "Fruit/Apple" 2629 S: * LIST (\Subscribed) "/" "Fruit/Banana" 2630 S: * LIST () "/" "Tofu" 2631 S: * LIST (\Subscribed) "/" "Vegetable" 2632 S: * LIST (\Subscribed) "/" "Vegetable/Broccoli" 2633 S: * LIST () "/" "Vegetable/Corn" 2634 S: * LIST (\Remote \Subscribed) "/" "Bread" 2635 S: * LIST (\Remote) "/" "Meat" 2636 S: A06 OK done 2638 7: The following example demonstrates the difference between the 2639 \HasChildren attribute and the CHILDINFO extended data item. 2641 Let's assume there is the following hierarchy: 2643 C: C01 LIST "" "*" 2644 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2645 S: * LIST () "/" "Foo" 2646 S: * LIST () "/" "Foo/Bar" 2647 S: * LIST () "/" "Foo/Baz" 2648 S: * LIST () "/" "Moo" 2649 S: C01 OK done 2650 If the client asks RETURN (CHILDREN), it will get this: 2652 C: CA3 LIST "" "%" RETURN (CHILDREN) 2653 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2654 S: * LIST (\HasChildren) "/" "Foo" 2655 S: * LIST (\HasNoChildren) "/" "Moo" 2656 S: CA3 OK done 2658 A) Let's also assume that the mailbox "Foo/Baz" is the only 2659 subscribed mailbox. Then we get this result: 2661 C: C02 LIST (SUBSCRIBED) "" "*" 2662 S: * LIST (\Subscribed) "/" "Foo/Baz" 2663 S: C02 OK done 2665 Now, if the client issues , the server 2666 will return no mailboxes (as the mailboxes "Moo", "Foo", and 2667 "Inbox" are NOT subscribed). However, if the client issues 2668 this: 2670 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2671 S: * LIST () "/" "Foo" ("CHILDINFO" ("SUBSCRIBED")) 2672 S: C04 OK done 2674 (i.e., the mailbox "Foo" is not subscribed, but it has a child 2675 that is.) 2677 A1) If the mailbox "Foo" had also been subscribed, the last 2678 command would return this: 2680 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2681 S: * LIST (\Subscribed) "/" "Foo" ("CHILDINFO" ("SUBSCRIBED")) 2682 S: C04 OK done 2684 or even this: 2686 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2687 S: * LIST (\Subscribed \HasChildren) "/" "Foo" ("CHILDINFO" 2688 ("SUBSCRIBED")) 2689 S: C04 OK done 2691 A2) If we assume instead that the mailbox "Foo" is not part of 2692 the original hierarchy and is not subscribed, the last command 2693 will give this result: 2695 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2696 S: * LIST (\NonExistent) "/" "Foo" ("CHILDINFO" ("SUBSCRIBED")) 2697 S: C04 OK done 2698 B) Now, let's assume that no mailbox is subscribed. In this 2699 case, the command will 2700 return no responses, as there are no subscribed children (even 2701 though "Foo" has children). 2703 C) And finally, suppose that only the mailboxes "Foo" and "Moo" 2704 are subscribed. In that case, we see this result: 2706 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" RETURN (CHILDREN) 2707 S: * LIST (\HasChildren \Subscribed) "/" "Foo" 2708 S: * LIST (\HasNoChildren \Subscribed) "/" "Moo" 2709 S: C04 OK done 2711 (which means that the mailbox "Foo" has children, but none of 2712 them is subscribed). 2714 8: The following example demonstrates that the CHILDINFO extended 2715 data item is returned whether or not children mailboxes match 2716 the canonical LIST pattern. 2718 Let's assume there is the following hierarchy: 2720 C: D01 LIST "" "*" 2721 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2722 S: * LIST () "/" "foo2" 2723 S: * LIST () "/" "foo2/bar1" 2724 S: * LIST () "/" "foo2/bar2" 2725 S: * LIST () "/" "baz2" 2726 S: * LIST () "/" "baz2/bar2" 2727 S: * LIST () "/" "baz2/bar22" 2728 S: * LIST () "/" "baz2/bar222" 2729 S: * LIST () "/" "eps2" 2730 S: * LIST () "/" "eps2/mamba" 2731 S: * LIST () "/" "qux2/bar2" 2732 S: D01 OK done 2734 And that the following mailboxes are subscribed: 2736 C: D02 LIST (SUBSCRIBED) "" "*" 2737 S: * LIST (\Subscribed) "/" "foo2/bar1" 2738 S: * LIST (\Subscribed) "/" "foo2/bar2" 2739 S: * LIST (\Subscribed) "/" "baz2/bar2" 2740 S: * LIST (\Subscribed) "/" "baz2/bar22" 2741 S: * LIST (\Subscribed) "/" "baz2/bar222" 2742 S: * LIST (\Subscribed) "/" "eps2" 2743 S: * LIST (\Subscribed) "/" "eps2/mamba" 2744 S: * LIST (\Subscribed) "/" "qux2/bar2" 2745 S: D02 OK done 2746 The client issues the following command first: 2748 C: D03 LIST (RECURSIVEMATCH SUBSCRIBED) "" "*2" 2749 S: * LIST () "/" "foo2" ("CHILDINFO" ("SUBSCRIBED")) 2750 S: * LIST (\Subscribed) "/" "foo2/bar2" 2751 S: * LIST (\Subscribed) "/" "baz2/bar2" 2752 S: * LIST (\Subscribed) "/" "baz2/bar22" 2753 S: * LIST (\Subscribed) "/" "baz2/bar222" 2754 S: * LIST (\Subscribed) "/" "eps2" ("CHILDINFO" ("SUBSCRIBED")) 2755 S: * LIST (\Subscribed) "/" "qux2/bar2" 2756 S: D03 OK done 2758 and the server may also include (but this would violate a SHOULD 2759 NOT in Section 3.5, because CHILDINFO is redundant) 2761 S: * LIST () "/" "baz2" ("CHILDINFO" ("SUBSCRIBED")) 2762 S: * LIST (\NonExistent) "/" "qux2" ("CHILDINFO" ("SUBSCRIBED")) 2764 The CHILDINFO extended data item is returned for mailboxes 2765 "foo2", "baz2", and "eps2", because all of them have subscribed 2766 children, even though for the mailbox "foo2" only one of the two 2767 subscribed children matches the pattern, for the mailbox "baz2" 2768 all the subscribed children match the pattern, and for the 2769 mailbox "eps2" none of the subscribed children matches the 2770 pattern. 2772 Note that if the client issues 2774 C: D03 LIST (RECURSIVEMATCH SUBSCRIBED) "" "*" 2775 S: * LIST () "/" "foo2" ("CHILDINFO" ("SUBSCRIBED")) 2776 S: * LIST (\Subscribed) "/" "foo2/bar1" 2777 S: * LIST (\Subscribed) "/" "foo2/bar2" 2778 S: * LIST () "/" "baz2" ("CHILDINFO" ("SUBSCRIBED")) 2779 S: * LIST (\Subscribed) "/" "baz2/bar2" 2780 S: * LIST (\Subscribed) "/" "baz2/bar22" 2781 S: * LIST (\Subscribed) "/" "baz2/bar222" 2782 S: * LIST (\Subscribed) "/" "eps2" ("CHILDINFO" ("SUBSCRIBED")) 2783 S: * LIST (\Subscribed) "/" "eps2/mamba" 2784 S: * LIST (\Subscribed) "/" "qux2/bar2" 2785 S: D03 OK done 2787 The LIST responses for mailboxes "foo2", "baz2", and "eps2" 2788 still have the CHILDINFO extended data item, even though this 2789 information is redundant and the client can determine it by 2790 itself. 2792 9: The following example shows usage of extended syntax for mailbox 2793 pattern. It also demonstrates that the presence of the 2794 CHILDINFO extended data item doesn't necessarily imply 2795 \HasChildren. 2797 C: a1 LIST "" ("foo") 2798 S: * LIST () "/" foo 2799 S: a1 OK done 2801 C: a2 LIST (SUBSCRIBED) "" "foo/*" 2802 S: * LIST (\Subscribed \NonExistent) "/" foo/bar 2803 S: a2 OK done 2805 C: a3 LIST (SUBSCRIBED RECURSIVEMATCH) "" foo RETURN (CHILDREN) 2806 S: * LIST (\HasNoChildren) "/" foo ("CHILDINFO" ("SUBSCRIBED")) 2807 S: a3 OK done 2809 10: The following example shows how a server that supports missing 2810 mailbox hierarchy elements can signal to a client that didn't 2811 specify the RECURSIVEMATCH selection option that there is a 2812 child mailbox that matches the selection criteria. 2814 C: a1 LIST (REMOTE) "" * 2815 S: * LIST () "/" music/rock 2816 S: * LIST (\Remote) "/" also/jazz 2817 S: a1 OK done 2819 C: a2 LIST () "" % 2820 S: * LIST (\NonExistent \HasChildren) "/" music 2821 S: a2 OK done 2823 C: a3 LIST (REMOTE) "" % 2824 S: * LIST (\NonExistent \HasChildren) "/" music 2825 S: * LIST (\NonExistent \HasChildren) "/" also 2826 S: a3 OK done 2828 C: a3.1 LIST "" (% music/rock) 2829 S: * LIST () "/" music/rock 2830 S: a3.1 OK done 2832 Because "music/rock" is the only mailbox under "music", there's 2833 no need for the server to also return "music". However clients 2834 must handle both cases. 2836 11: The following examples show use of STATUS return option. 2838 C: A01 LIST "" % RETURN (STATUS (MESSAGES UNSEEN)) 2839 S: * LIST () "." "INBOX" 2840 S: * STATUS "INBOX" (MESSAGES 17 UNSEEN 16) 2841 S: * LIST () "." "foo" 2842 S: * STATUS "foo" (MESSAGES 30 UNSEEN 29) 2843 S: * LIST (\NoSelect) "." "bar" 2844 S: A01 OK List completed. 2846 The "bar" mailbox isn't selectable, so it has no STATUS reply. 2848 C: A02 LIST (SUBSCRIBED RECURSIVEMATCH) "" % RETURN (STATUS 2849 (MESSAGES)) 2850 S: * LIST (\Subscribed) "." "INBOX" 2851 S: * STATUS "INBOX" (MESSAGES 17) 2852 S: * LIST () "." "foo" (CHILDINFO ("SUBSCRIBED")) 2853 S: A02 OK List completed. 2855 The LIST reply for "foo" is returned because it has matching 2856 children, but no STATUS reply is returned because "foo" itself 2857 doesn't match the selection criteria. 2859 6.3.10. NAMESPACE Command 2861 Arguments: none 2863 Responses: REQUIRED untagged responses: NAMESPACE 2865 Result: OK - command completed 2866 NO - Can't complete the command 2867 BAD - arguments invalid 2869 The NAMESPACE command causes a single ungagged NAMESPACE response to 2870 be returned. The untagged NAMESPACE response contains the prefix and 2871 hierarchy delimiter to the server's Personal Namespace(s), Other 2872 Users' Namespace(s), and Shared Namespace(s) that the server wishes 2873 to expose. The response will contain a NIL for any namespace class 2874 that is not available. Namespace-Response-Extensions ABNF non 2875 terminal is defined for extensibility and MAY be included in the 2876 response. 2878 Example 1: 2880 In this example a server supports a single personal namespace. No 2881 leading prefix is used on personal mailboxes and "/" is the hierarchy 2882 delimiter. 2884 C: A001 NAMESPACE 2885 S: * NAMESPACE (("" "/")) NIL NIL 2886 S: A001 OK NAMESPACE command completed 2888 Example 2: 2890 A user logged on anonymously to a server. No personal mailboxes are 2891 associated with the anonymous user and the user does not have access 2892 to the Other Users' Namespace. No prefix is required to access 2893 shared mailboxes and the hierarchy delimiter is "." 2895 C: A001 NAMESPACE 2896 S: * NAMESPACE NIL NIL (("" ".")) 2897 S: A001 OK NAMESPACE command completed 2899 Example 3: 2901 A server that contains a Personal Namespace and a single Shared 2902 Namespace. 2904 C: A001 NAMESPACE 2905 S: * NAMESPACE (("" "/")) NIL (("Public Folders/" "/")) 2906 S: A001 OK NAMESPACE command completed 2908 Example 4: 2910 A server that contains a Personal Namespace, Other Users' Namespace 2911 and multiple Shared Namespaces. Note that the hierarchy delimiter 2912 used within each namespace can be different. 2914 C: A001 NAMESPACE 2915 S: * NAMESPACE (("" "/")) (("~" "/")) (("#shared/" "/") 2916 ("#public/" "/")("#ftp/" "/")("#news." ".")) 2917 S: A001 OK NAMESPACE command completed 2919 The prefix string allows a client to do things such as automatically 2920 creating personal mailboxes or LISTing all available mailboxes within 2921 a namespace. 2923 Example 5: 2925 A server that supports only the Personal Namespace, with a leading 2926 prefix of INBOX to personal mailboxes and a hierarchy delimiter of 2927 "." 2928 C: A001 NAMESPACE 2929 S: * NAMESPACE (("INBOX." ".")) NIL NIL 2930 S: A001 OK NAMESPACE command completed 2932 < Automatically create a mailbox to store sent items.> 2934 C: A002 CREATE "INBOX.Sent Mail" 2935 S: A002 OK CREATE command completed 2937 Although typically a server will support only a single Personal 2938 Namespace, and a single Other User's Namespace, circumstances exist 2939 where there MAY be multiples of these, and a client MUST be prepared 2940 for them. If a client is configured such that it is required to 2941 create a certain mailbox, there can be circumstances where it is 2942 unclear which Personal Namespaces it should create the mailbox in. 2943 In these situations a client SHOULD let the user select which 2944 namespaces to create the mailbox in or just use the first personal 2945 namespace. 2947 Example 6: 2949 In this example, a server supports 2 Personal Namespaces. In 2950 addition to the regular Personal Namespace, the user has an 2951 additional personal namespace to allow access to mailboxes in an MH 2952 format mailstore. 2954 The client is configured to save a copy of all mail sent by the user 2955 into a mailbox called 'Sent Mail'. Furthermore, after a message is 2956 deleted from a mailbox, the client is configured to move that message 2957 to a mailbox called 'Deleted Items'. 2959 Note that this example demonstrates how some extension flags can be 2960 passed to further describe the #mh namespace. 2962 C: A001 NAMESPACE 2963 S: * NAMESPACE (("" "/")("#mh/" "/" "X-PARAM" 2964 ("FLAG1" "FLAG2"))) NIL NIL 2965 S: A001 OK NAMESPACE command completed 2967 < It is desired to keep only one copy of sent mail. 2968 It is unclear which Personal Namespace the client 2969 should use to create the 'Sent Mail' mailbox. 2970 The user is prompted to select a namespace and only 2971 one 'Sent Mail' mailbox is created. > 2973 C: A002 CREATE "Sent Mail" 2974 S: A002 OK CREATE command completed 2976 < The client is designed so that it keeps two 2977 'Deleted Items' mailboxes, one for each namespace. > 2979 C: A003 CREATE "Delete Items" 2980 S: A003 OK CREATE command completed 2982 C: A004 CREATE "#mh/Deleted Items" 2983 S: A004 OK CREATE command completed 2985 The next level of hierarchy following the Other Users' Namespace 2986 prefix SHOULD consist of , where is a user name 2987 as per the LOGIN or AUTHENTICATE command. 2989 A client can construct a LIST command by appending a "%" to the Other 2990 Users' Namespace prefix to discover the Personal Namespaces of other 2991 users that are available to the currently authenticated user. 2993 In response to such a LIST command, a server SHOULD NOT return user 2994 names that have not granted access to their personal mailboxes to the 2995 user in question. 2997 A server MAY return a LIST response containing only the names of 2998 users that have explicitly granted access to the user in question. 3000 Alternatively, a server MAY return NO to such a LIST command, 3001 requiring that a user name be included with the Other Users' 3002 Namespace prefix before listing any other user's mailboxes. 3004 Example 7: 3006 A server that supports providing a list of other user's mailboxes 3007 that are accessible to the currently logged on user. 3009 C: A001 NAMESPACE 3010 S: * NAMESPACE (("" "/")) (("Other Users/" "/")) NIL 3011 S: A001 OK NAMESPACE command completed 3013 C: A002 LIST "" "Other Users/%" 3014 S: * LIST () "/" "Other Users/Mike" 3015 S: * LIST () "/" "Other Users/Karen" 3016 S: * LIST () "/" "Other Users/Matthew" 3017 S: * LIST () "/" "Other Users/Tesa" 3018 S: A002 OK LIST command completed 3020 Example 8: 3022 A server that does not support providing a list of other user's 3023 mailboxes that are accessible to the currently logged on user. The 3024 mailboxes are listable if the client includes the name of the other 3025 user with the Other Users' Namespace prefix. 3027 C: A001 NAMESPACE 3028 S: * NAMESPACE (("" "/")) (("#Users/" "/")) NIL 3029 S: A001 OK NAMESPACE command completed 3031 < In this example, the currently logged on user has access to 3032 the Personal Namespace of user Mike, but the server chose to 3033 suppress this information in the LIST response. However, 3034 by appending the user name Mike (received through user input) 3035 to the Other Users' Namespace prefix, the client is able 3036 to get a listing of the personal mailboxes of user Mike. > 3038 C: A002 LIST "" "#Users/%" 3039 S: A002 NO The requested item could not be found. 3041 C: A003 LIST "" "#Users/Mike/%" 3042 S: * LIST () "/" "#Users/Mike/INBOX" 3043 S: * LIST () "/" "#Users/Mike/Foo" 3044 S: A003 OK LIST command completed. 3046 A prefix string might not contain a hierarchy delimiter, because in 3047 some cases it is not needed as part of the prefix. 3049 Example 9: 3051 A server that allows access to the Other Users' Namespace by 3052 prefixing the others' mailboxes with a '~' followed by , 3053 where is a user name as per the LOGIN or AUTHENTICATE 3054 command. 3056 C: A001 NAMESPACE 3057 S: * NAMESPACE (("" "/")) (("~" "/")) NIL 3058 S: A001 OK NAMESPACE command completed 3060 < List the mailboxes for user mark > 3062 C: A002 LIST "" "~mark/%" 3063 S: * LIST () "/" "~mark/INBOX" 3064 S: * LIST () "/" "~mark/foo" 3065 S: A002 OK LIST command completed 3067 6.3.11. STATUS Command 3069 Arguments: mailbox name 3070 status data item names 3072 Responses: REQUIRED untagged responses: STATUS 3074 Result: OK - status completed 3075 NO - status failure: no status for that name 3076 BAD - command unknown or arguments invalid 3078 The STATUS command requests the status of the indicated mailbox. It 3079 does not change the currently selected mailbox, nor does it affect 3080 the state of any messages in the queried mailbox. 3082 The STATUS command provides an alternative to opening a second 3083 IMAP4rev2 connection and doing an EXAMINE command on a mailbox to 3084 query that mailbox's status without deselecting the current mailbox 3085 in the first IMAP4rev2 connection. 3087 Unlike the LIST command, the STATUS command is not guaranteed to be 3088 fast in its response. Under certain circumstances, it can be quite 3089 slow. In some implementations, the server is obliged to open the 3090 mailbox read-only internally to obtain certain status information. 3091 Also unlike the LIST command, the STATUS command does not accept 3092 wildcards. 3094 Note: The STATUS command is intended to access the status of 3095 mailboxes other than the currently selected mailbox. Because the 3096 STATUS command can cause the mailbox to be opened internally, and 3097 because this information is available by other means on the 3098 selected mailbox, the STATUS command SHOULD NOT be used on the 3099 currently selected mailbox. However, servers MUST be able to 3100 execute STATUS command on the selected mailbox. (This might also 3101 implicitly happen when STATUS return option is used in a LIST 3102 command). 3104 The STATUS command MUST NOT be used as a "check for new messages 3105 in the selected mailbox" operation (refer to sections Section 7, 3106 Section 7.3.1 for more information about the proper method for new 3107 message checking). 3109 STATUS SIZE (see below) can take a significant amount of time, 3110 depending upon server implementation. Clients should use STATUS 3111 SIZE cautiously. 3113 The currently defined status data items that can be requested are: 3115 MESSAGES The number of messages in the mailbox. 3117 UIDNEXT The next unique identifier value of the mailbox. Refer to 3118 Section 2.3.1.1 for more information. 3120 UIDVALIDITY The unique identifier validity value of the mailbox. 3121 Refer to Section 2.3.1.1 for more information. 3123 UNSEEN The number of messages which do not have the \Seen flag set. 3125 DELETED The number of messages which have the \Deleted flag set. 3127 SIZE The total size of the mailbox in octets. This is not strictly 3128 required to be an exact value, but it MUST be equal to or greater 3129 than the sum of the values of the RFC822.SIZE FETCH message data 3130 items (see Section 6.4.5) of all messages in the mailbox. 3132 Example: C: A042 STATUS blurdybloop (UIDNEXT MESSAGES) 3133 S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) 3134 S: A042 OK STATUS completed 3136 6.3.12. APPEND Command 3138 Arguments: mailbox name 3139 OPTIONAL flag parenthesized list 3140 OPTIONAL date/time string 3141 message literal 3143 Responses: no specific responses for this command 3145 Result: OK - append completed 3146 NO - append error: can't append to that mailbox, error 3147 in flags or date/time or message text 3148 BAD - command unknown or arguments invalid 3150 The APPEND command appends the literal argument as a new message to 3151 the end of the specified destination mailbox. This argument SHOULD 3152 be in the format of an [RFC-5322] or [I18N-HDRS] message. 8-bit 3153 characters are permitted in the message. A server implementation 3154 that is unable to preserve 8-bit data properly MUST be able to 3155 reversibly convert 8-bit APPEND data to 7-bit using a [MIME-IMB] 3156 content transfer encoding. 3158 Note: There may be exceptions, e.g., draft messages, in which 3159 required [RFC-5322] header lines are omitted in the message 3160 literal argument to APPEND. The full implications of doing so 3161 must be understood and carefully weighed. 3163 If a flag parenthesized list is specified, the flags SHOULD be set in 3164 the resulting message; otherwise, the flag list of the resulting 3165 message is set to empty by default. 3167 If a date-time is specified, the internal date SHOULD be set in the 3168 resulting message; otherwise, the internal date of the resulting 3169 message is set to the current date and time by default. 3171 If the append is unsuccessful for any reason, the mailbox MUST be 3172 restored to its state before the APPEND attempt (other than possibly 3173 keeping the changed mailbox's UIDNEXT value); no partial appending is 3174 permitted. 3176 If the destination mailbox does not exist, a server MUST return an 3177 error, and MUST NOT automatically create the mailbox. Unless it is 3178 certain that the destination mailbox can not be created, the server 3179 MUST send the response code "[TRYCREATE]" as the prefix of the text 3180 of the tagged NO response. This gives a hint to the client that it 3181 can attempt a CREATE command and retry the APPEND if the CREATE is 3182 successful. 3184 On successful completion of an APPEND, the server SHOULD return an 3185 APPENDUID response code. 3187 In the case of a mailbox that has permissions set so that the client 3188 can APPEND to the mailbox, but not SELECT or EXAMINE it, the server 3189 SHOULD NOT send an APPENDUID response code as it would disclose 3190 information about the mailbox. 3192 In the case of a mailbox that has UIDNOTSTICKY status (see 3193 UIDNOTSTICKY response code definition), the server MAY omit the 3194 APPENDUID response code as it is not meaningful. 3196 If the server does not return the APPENDUID response codes, the 3197 client can discover this information by selecting the destination 3198 mailbox. The location of messages placed in the destination mailbox 3199 by APPEND can be determined by using FETCH and/or SEARCH commands 3200 (e.g., for Message-ID or some unique marker placed in the message in 3201 an APPEND). 3203 If the mailbox is currently selected, the normal new message actions 3204 SHOULD occur. Specifically, the server SHOULD notify the client 3205 immediately via an untagged EXISTS response. If the server does not 3206 do so, the client MAY issue a NOOP command after one or more APPEND 3207 commands. 3209 Example: C: A003 APPEND saved-messages (\Seen) {310} 3210 S: + Ready for literal data 3211 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST) 3212 C: From: Fred Foobar 3213 C: Subject: afternoon meeting 3214 C: To: mooch@owatagu.siam.edu 3215 C: Message-Id: 3216 C: MIME-Version: 1.0 3217 C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 3218 C: 3219 C: Hello Joe, do you think we can meet at 3:30 tomorrow? 3220 C: 3221 S: A003 OK APPEND completed 3223 Example: C: A003 APPEND saved-messages (\Seen) {297} 3224 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST) 3225 C: From: Fred Foobar 3226 C: Subject: afternoon meeting 3227 C: To: mooch@example.com 3228 C: Message-Id: 3229 C: MIME-Version: 1.0 3230 C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 3231 C: 3232 C: Hello Joe, do you think we can meet at 3:30 tomorrow? 3233 C: 3234 S: A003 OK [APPENDUID 38505 3955] APPEND completed 3235 C: A004 COPY 2:4 meeting 3236 S: A004 OK [COPYUID 38505 304,319:320 3956:3958] Done 3237 C: A005 UID COPY 305:310 meeting 3238 S: A005 OK No matching messages, so nothing copied 3239 C: A006 COPY 2 funny 3240 S: A006 OK Done 3241 C: A007 SELECT funny 3242 S: * 1 EXISTS 3243 S: * OK [UIDVALIDITY 3857529045] Validity session-only 3244 S: * OK [UIDNEXT 2] Predicted next UID 3245 S: * NO [UIDNOTSTICKY] Non-persistent UIDs 3246 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 3247 S: * OK [PERMANENTFLAGS (\Deleted \Seen)] Limited 3248 S: A007 OK [READ-WRITE] SELECT completed 3250 In this example, A003 and A004 demonstrate successful appending and 3251 copying to a mailbox that returns the UIDs assigned to the messages. 3252 A005 is an example in which no messages were copied; this is because 3253 in A003, we see that message 2 had UID 304, and message 3 had UID 3254 319; therefore, UIDs 305 through 310 do not exist (refer to 3255 Section 2.3.1.1 for further explanation). A006 is an example of a 3256 message being copied that did not return a COPYUID; and, as expected, 3257 A007 shows that the mail store containing that mailbox does not 3258 support persistent UIDs. 3260 Note: The APPEND command is not used for message delivery, because 3261 it does not provide a mechanism to transfer [SMTP] envelope 3262 information. 3264 6.3.13. IDLE Command 3266 Arguments: none 3268 Responses: continuation data will be requested; the client sends the 3269 continuation data "DONE" to end the command 3271 Result: OK - IDLE completed after client sent "DONE" 3272 NO - failure: the server will not allow the IDLE command 3273 at this time 3274 BAD - command unknown or arguments invalid 3276 Without the IDLE command a client requires to poll the server for 3277 changes to the selected mailbox (new mail, deletions, flag changes). 3278 It's often more desirable to have the server transmit updates to the 3279 client in real time. This allows a user to see new mail immediately. 3280 The IDLE command allows a client to tell the server that it's ready 3281 to accept such real-time updates. 3283 The IDLE command is sent from the client to the server when the 3284 client is ready to accept unsolicited update messages. The server 3285 requests a response to the IDLE command using the continuation ("+") 3286 response. The IDLE command remains active until the client responds 3287 to the continuation, and as long as an IDLE command is active, the 3288 server is now free to send untagged EXISTS, EXPUNGE, FETCH, and other 3289 responses at any time. If the server choose to send unsolicited 3290 FETCH responses, they MUST include UID FETCH item. 3292 The IDLE command is terminated by the receipt of a "DONE" 3293 continuation from the client; such response satisfies the server's 3294 continuation request. At that point, the server MAY send any 3295 remaining queued untagged responses and then MUST immediately send 3296 the tagged response to the IDLE command and prepare to process other 3297 commands. As for other commands, the processing of any new command 3298 may cause the sending of unsolicited untagged responses, subject to 3299 the ambiguity limitations. The client MUST NOT send a command while 3300 the server is waiting for the DONE, since the server will not be able 3301 to distinguish a command from a continuation. 3303 The server MAY consider a client inactive if it has an IDLE command 3304 running, and if such a server has an inactivity timeout it MAY log 3305 the client off implicitly at the end of its timeout period. Because 3306 of that, clients using IDLE are advised to terminate the IDLE and re- 3307 issue it at least every 29 minutes to avoid being logged off. This 3308 still allows a client to receive immediate mailbox updates even 3309 though it need only "poll" at half hour intervals. 3311 Example: C: A001 SELECT INBOX 3312 S: * FLAGS (\Deleted \Seen \Flagged) 3313 S: * OK [PERMANENTFLAGS (\Deleted \Seen \Flagged)] Limited 3314 S: * 3 EXISTS 3315 S: * OK [UIDVALIDITY 1] 3316 S: A001 OK [READ-WRITE] SELECT completed 3317 C: A002 IDLE 3318 S: + idling 3319 ...time passes; new mail arrives... 3320 S: * 4 EXISTS 3321 C: DONE 3322 S: A002 OK IDLE terminated 3323 ...another client expunges message 2 now... 3324 C: A003 FETCH 4 ALL 3325 S: * 4 FETCH (...) 3326 S: A003 OK FETCH completed 3327 C: A004 IDLE 3328 S: * 2 EXPUNGE 3329 S: * 3 EXISTS 3330 S: + idling 3331 ...time passes; another client expunges message 3... 3332 S: * 3 EXPUNGE 3333 S: * 2 EXISTS 3334 ...time passes; new mail arrives... 3335 S: * 3 EXISTS 3336 C: DONE 3337 S: A004 OK IDLE terminated 3338 C: A005 FETCH 3 ALL 3339 S: * 3 FETCH (...) 3340 S: A005 OK FETCH completed 3341 C: A006 IDLE 3343 6.4. Client Commands - Selected State 3345 In the selected state, commands that manipulate messages in a mailbox 3346 are permitted. 3348 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 3349 and the authenticated state commands (SELECT, EXAMINE, NAMESPACE, 3350 CREATE, DELETE, RENAME, SUBSCRIBE, UNSUBSCRIBE, LIST, STATUS, and 3351 APPEND), the following commands are valid in the selected state: 3352 CLOSE, UNSELECT, EXPUNGE, SEARCH, FETCH, STORE, COPY, MOVE, and UID. 3354 6.4.1. CLOSE Command 3356 Arguments: none 3358 Responses: no specific responses for this command 3359 Result: OK - close completed, now in authenticated state 3360 BAD - command unknown or arguments invalid 3362 The CLOSE command permanently removes all messages that have the 3363 \Deleted flag set from the currently selected mailbox, and returns to 3364 the authenticated state from the selected state. No untagged EXPUNGE 3365 responses are sent. 3367 No messages are removed, and no error is given, if the mailbox is 3368 selected by an EXAMINE command or is otherwise selected read-only. 3370 Even if a mailbox is selected, a SELECT, EXAMINE, or LOGOUT command 3371 MAY be issued without previously issuing a CLOSE command. The 3372 SELECT, EXAMINE, and LOGOUT commands implicitly close the currently 3373 selected mailbox without doing an expunge. However, when many 3374 messages are deleted, a CLOSE-LOGOUT or CLOSE-SELECT sequence is 3375 considerably faster than an EXPUNGE-LOGOUT or EXPUNGE-SELECT because 3376 no untagged EXPUNGE responses (which the client would probably 3377 ignore) are sent. 3379 Example: C: A341 CLOSE 3380 S: A341 OK CLOSE completed 3382 6.4.2. UNSELECT Command 3384 Arguments: none 3386 Responses: no specific responses for this command 3388 Result: OK - unselect completed, now in authenticated state 3389 BAD - no mailbox selected, or argument supplied but none 3390 permitted 3392 The UNSELECT command frees server's resources associated with the 3393 selected mailbox and returns the server to the authenticated state. 3394 This command performs the same actions as CLOSE, except that no 3395 messages are permanently removed from the currently selected mailbox. 3397 Example: C: A342 UNSELECT 3398 S: A342 OK Unselect completed 3400 6.4.3. EXPUNGE Command 3402 Arguments: none 3404 Responses: untagged responses: EXPUNGE 3406 Result: OK - expunge completed 3407 NO - expunge failure: can't expunge (e.g., permission 3408 denied) 3409 BAD - command unknown or arguments invalid 3411 The EXPUNGE command permanently removes all messages that have the 3412 \Deleted flag set from the currently selected mailbox. Before 3413 returning an OK to the client, an untagged EXPUNGE response is sent 3414 for each message that is removed. 3416 Example: C: A202 EXPUNGE 3417 S: * 3 EXPUNGE 3418 S: * 3 EXPUNGE 3419 S: * 5 EXPUNGE 3420 S: * 8 EXPUNGE 3421 S: A202 OK EXPUNGE completed 3423 Note: In this example, messages 3, 4, 7, and 11 had the \Deleted flag 3424 set. See the description of the EXPUNGE response for further 3425 explanation. 3427 6.4.4. SEARCH Command 3429 Arguments: OPTIONAL result specifier 3430 OPTIONAL [CHARSET] specification 3431 searching criteria (one or more) 3433 Responses: OPTIONAL untagged response: ESEARCH 3435 Result: OK - search completed 3436 NO - search error: can't search that [CHARSET] or 3437 criteria 3438 BAD - command unknown or arguments invalid 3440 The SEARCH command searches the mailbox for messages that match the 3441 given searching criteria. 3443 The SEARCH command may contain result options. Result options 3444 control what kind of information is returned about messages matching 3445 the search criteria in an untagged ESEARCH response. If no result 3446 option is specified or empty list of options is specified "()", ALL 3447 is assumed (see below). The order of individual options is 3448 arbitrary. Individual options may contain parameters enclosed in 3449 parentheses (*). If an option has parameters, they consist of atoms 3450 and/or strings and/or lists in a specific order. Any options not 3451 defined by extensions that the server supports must be rejected with 3452 a BAD response. 3454 (*) - if an option has a mandatory parameter, which can always be 3455 represented as a number or a sequence-set, the option parameter does 3456 not need the enclosing (). See the ABNF for more details. 3458 This document specifies the following result options: 3460 MIN 3462 Return the lowest message number/UID that satisfies the SEARCH 3463 criteria. 3465 If the SEARCH results in no matches, the server MUST NOT 3466 include the MIN result option in the ESEARCH response; however, 3467 it still MUST send the ESEARCH response. 3469 MAX 3471 Return the highest message number/UID that satisfies the SEARCH 3472 criteria. 3474 If the SEARCH results in no matches, the server MUST NOT 3475 include the MAX result option in the ESEARCH response; however, 3476 it still MUST send the ESEARCH response. 3478 ALL 3480 Return all message numbers/UIDs that satisfy the SEARCH 3481 criteria using the sequence-set syntax. Note, the client MUST 3482 NOT assume that messages/UIDs will be listed in any particular 3483 order. 3485 If the SEARCH results in no matches, the server MUST NOT 3486 include the ALL result option in the ESEARCH response; however, 3487 it still MUST send the ESEARCH response. 3489 COUNT Return number of the messages that satisfy the SEARCH 3490 criteria. This result option MUST always be included in the 3491 ESEARCH response. 3493 SAVE 3495 This option tells the server to remember the result of the 3496 SEARCH or UID SEARCH command (as well as any command based on 3497 SEARCH, e.g., SORT and THREAD [RFC5256]>) and store it in an 3498 internal variable that we will reference as the "search result 3499 variable". The client can use the "$" marker to reference the 3500 content of this internal variable. The "$" marker can be used 3501 instead of message sequence or UID sequence in order to 3502 indicate that the server should substitute it with the list of 3503 messages from the search result variable. Thus, the client can 3504 use the result of the latest remembered SEARCH command as a 3505 parameter to another command. See Section 6.4.4.1 for details 3506 on how the value of the search result variable is determined, 3507 how it is affected by other commands executed, and how SAVE 3508 return option interacts with other return options. 3510 In absence of any other SEARCH result option, the SAVE result 3511 option also suppresses any ESEARCH response that would have 3512 been otherwise returned by the SEARCH command. 3514 Note: future extensions to this document can allow servers to return 3515 multiple ESEARCH responses for a single extended SEARCH command. 3516 However all options specified above MUST result in a single ESEARCH 3517 response. These extensions will have to describe how results from 3518 multiple ESEARCH responses are to be amalgamated. 3520 Searching criteria consist of one or more search keys. 3522 When multiple keys are specified, the result is the intersection (AND 3523 function) of all the messages that match those keys. For example, 3524 the criteria DELETED FROM "SMITH" SINCE 1-Feb-1994 refers to all 3525 deleted messages from Smith with INTERNALDATE greater than February 3526 1, 1994. A search key can also be a parenthesized list of one or 3527 more search keys (e.g., for use with the OR and NOT keys). 3529 Server implementations MAY exclude [MIME-IMB] body parts with 3530 terminal content media types other than TEXT and MESSAGE from 3531 consideration in SEARCH matching. 3533 The OPTIONAL [CHARSET] specification consists of the word "CHARSET" 3534 followed by a registered [CHARSET] [CHARSET-REG]. It indicates the 3535 [CHARSET] of the strings that appear in the search criteria. 3536 [MIME-IMB] content transfer encodings, and [MIME-HDRS] strings in 3537 [RFC-5322]/[MIME-IMB] headers, MUST be decoded before comparing text. 3538 Servers MUST support US-ASCII and UTF-8 charsets; other [CHARSET]s 3539 MAY be supported. Clients SHOULD use UTF-8. Note that if "CHARSET" 3540 is not provided IMAP4rev2 server MUST assume UTF-8, so selecting 3541 CHARSET UTF-8 is redundant. It is permitted for improved 3542 compatibility with existing IMAP4rev1 clients. 3544 If the server does not support the specified [CHARSET], it MUST 3545 return a tagged NO response (not a BAD). This response SHOULD 3546 contain the BADCHARSET response code, which MAY list the [CHARSET]s 3547 supported by the server. 3549 In all search keys that use strings and unless specified otherwise, a 3550 message matches the key if the string is a substring of the 3551 associated text. The matching SHOULD be case-insensitive for 3552 characters within ASCII range. Consider using [IMAP-I18N] for 3553 language-sensitive case-insensitive searching. Note that the empty 3554 string is a substring; this is useful when doing a HEADER search in 3555 order to test for a header field presence in the message. 3557 The defined search keys are as follows. Refer to the Formal Syntax 3558 section for the precise syntactic definitions of the arguments. 3560 Messages with message sequence numbers corresponding 3561 to the specified message sequence number set. 3563 ALL All messages in the mailbox; the default initial key for ANDing. 3565 ANSWERED Messages with the \Answered flag set. 3567 BCC Messages that contain the specified string in the 3568 envelope structure's BCC field. 3570 BEFORE Messages whose internal date (disregarding time and 3571 timezone) is earlier than the specified date. 3573 BODY Messages that contain the specified string in the body 3574 of the message. Unlike TEXT (see below), this doesn't match any 3575 header fields. Servers are allowed to implement flexible matching 3576 for this search key, for example matching "swim" to both "swam" 3577 and "swum" in English language text or only doing full word 3578 matching (where "swim" will not match "swimming"). 3580 CC Messages that contain the specified string in the 3581 envelope structure's CC field. 3583 DELETED Messages with the \Deleted flag set. 3585 DRAFT Messages with the \Draft flag set. 3587 FLAGGED Messages with the \Flagged flag set. 3589 FROM Messages that contain the specified string in the 3590 envelope structure's FROM field. 3592 HEADER Messages that have a header with the 3593 specified field-name (as defined in [RFC-5322]) and that contains 3594 the specified string in the text of the header (what comes after 3595 the colon). If the string to search is zero-length, this matches 3596 all messages that have a header line with the specified field-name 3597 regardless of the contents. Servers should use substring search 3598 for this SEARCH item, as clients can use it for automatic 3599 processing not initiated by end users. For example this can be 3600 used for searching for Message-ID or Content-Type header field 3601 values that need to be exact, or for searches in header fields 3602 that the IMAP server might not know anything about. 3604 KEYWORD Messages with the specified keyword flag set. 3606 LARGER Messages with an [RFC-5322] size larger than the 3607 specified number of octets. 3609 NOT Messages that do not match the specified search 3610 key. 3612 ON Messages whose internal date (disregarding time and 3613 timezone) is within the specified date. 3615 OR Messages that match either search 3616 key. 3618 SEEN Messages that have the \Seen flag set. 3620 SENTBEFORE Messages whose [RFC-5322] Date: header 3621 (disregarding time and timezone) is earlier than the specified 3622 date. 3624 SENTON Messages whose [RFC-5322] Date: header (disregarding 3625 time and timezone) is within the specified date. 3627 SENTSINCE Messages whose [RFC-5322] Date: header 3628 (disregarding time and timezone) is within or later than the 3629 specified date. 3631 SINCE Messages whose internal date (disregarding time and 3632 timezone) is within or later than the specified date. 3634 SMALLER Messages with an [RFC-5322] size smaller than the 3635 specified number of octets. 3637 SUBJECT Messages that contain the specified string in the 3638 envelope structure's SUBJECT field. 3640 TEXT Messages that contain the specified string in the 3641 header (including MIME header fields) or body of the message. 3642 Servers are allowed to implement flexible matching for this search 3643 key, for example matching "swim" to both "swam" and "swum" in 3644 English language text or only doing full word matching (where 3645 "swim" will not match "swimming"). 3647 TO Messages that contain the specified string in the 3648 envelope structure's TO field. 3650 UID Messages with unique identifiers corresponding to 3651 the specified unique identifier set. Sequence set ranges are 3652 permitted. 3654 UNANSWERED Messages that do not have the \Answered flag set. 3656 UNDELETED Messages that do not have the \Deleted flag set. 3658 UNDRAFT Messages that do not have the \Draft flag set. 3660 UNFLAGGED Messages that do not have the \Flagged flag set. 3662 UNKEYWORD Messages that do not have the specified keyword 3663 flag set. 3665 UNSEEN Messages that do not have the \Seen flag set. 3667 Example: C: A282 SEARCH RETURN (MIN COUNT) FLAGGED 3668 SINCE 1-Feb-1994 NOT FROM "Smith" 3669 S: * ESEARCH (TAG "A282") MIN 2 COUNT 3 3670 S: A282 OK SEARCH completed 3672 Example: C: A283 SEARCH RETURN () FLAGGED 3673 SINCE 1-Feb-1994 NOT FROM "Smith" 3674 S: * ESEARCH (TAG "A283") ALL 2,10:11 3675 S: A283 OK SEARCH completed 3677 Example: C: A284 SEARCH TEXT "string not in mailbox" 3678 S: * ESEARCH (TAG "A284") 3679 S: A284 OK SEARCH completed 3680 C: A285 SEARCH CHARSET UTF-8 TEXT {6} 3681 S: + Ready for literal text 3682 C: XXXXXX 3683 S: * ESEARCH (TAG "A285") ALL 43 3684 S: A285 OK SEARCH completed 3686 Note: Since this document is restricted to 7-bit ASCII text, it is 3687 not possible to show actual UTF-8 data. The "XXXXXX" is a 3688 placeholder for what would be 6 octets of 8-bit data in an actual 3689 transaction. 3691 The following example demonstrates finding the first unseen message 3692 in the mailbox: 3694 Example: C: A284 SEARCH RETURN (MIN) UNSEEN 3695 S: * ESEARCH (TAG "A284") MIN 4 3696 S: A284 OK SEARCH completed 3698 The following example demonstrates that if the ESEARCH UID indicator 3699 is present, all data in the ESEARCH response is referring to UIDs; 3700 for example, the MIN result specifier will be followed by a UID. 3702 Example: C: A285 UID SEARCH RETURN (MIN MAX) 1:5000 3703 S: * ESEARCH (TAG "A285") UID MIN 7 MAX 3800 3704 S: A285 OK SEARCH completed 3706 The following example demonstrates returning the number of deleted 3707 messages: 3709 Example: C: A286 SEARCH RETURN (COUNT) DELETED 3710 S: * ESEARCH (TAG "A286") COUNT 15 3711 S: A286 OK SEARCH completed 3713 6.4.4.1. SAVE result option and SEARCH result variable 3715 Upon successful completion of a SELECT or an EXAMINE command (after 3716 the tagged OK response), the current search result variable is reset 3717 to the empty sequence. 3719 A successful SEARCH command with the SAVE result option sets the 3720 value of the search result variable to the list of messages found in 3721 the SEARCH command. For example, if no messages were found, the 3722 search result variable will contain the empty sequence. 3724 Any of the following SEARCH commands MUST NOT change the search 3725 result variable: 3727 a SEARCH command that caused the server to return the BAD tagged 3728 response, 3730 a SEARCH command with no SAVE result option that caused the server 3731 to return NO tagged response, 3733 a successful SEARCH command with no SAVE result option. 3735 A SEARCH command with the SAVE result option that caused the server 3736 to return the NO tagged response sets the value of the search result 3737 variable to the empty sequence. 3739 When a message listed in the search result variable is EXPUNGEd, it 3740 is automatically removed from the list. Implementors are reminded 3741 that if the server stores the list as a list of message numbers, it 3742 MUST automatically adjust them when notifying the client about 3743 expunged messages, as described in Section 7.4.1. 3745 If the server decides to send a new UIDVALIDITY value while the 3746 mailbox is opened, this causes resetting of the search variable to 3747 the empty sequence. 3749 Note that even if the "$" marker contains the empty sequence of 3750 messages, it must be treated by all commands accepting message sets 3751 as parameters as a valid, but non-matching list of messages. For 3752 example, the "FETCH $" command would return a tagged OK response and 3753 no FETCH responses. See also the Example 5 in Section 6.4.4.4. 3755 The SAVE result option doesn't change whether the server would return 3756 items corresponding to MIN, MAX, ALL, or COUNT result options. 3758 When the SAVE result option is combined with the MIN or MAX result 3759 option, and both ALL and COUNT result options are absent, the 3760 corresponding MIN/MAX is returned (if the search result is not 3761 empty), but the "$" marker would contain a single message as returned 3762 in the MIN/MAX return item. 3764 If the SAVE result option is combined with both MIN and MAX result 3765 options, and both ALL and COUNT result options are absent, the "$" 3766 marker would contain zero, one or two messages as returned in the 3767 MIN/MAX return items. 3769 If the SAVE result option is combined with the ALL and/or COUNT 3770 result option(s), the "$" marker would always contain all messages 3771 found by the SEARCH or UID SEARCH command. 3773 The following table summarizes the additional requirement on ESEARCH 3774 server implementations described in this section. 3776 +------------------------------+--------------------+ 3777 | Combination of Result option | "$" marker value | 3778 +------------------------------+--------------------+ 3779 | SAVE MIN | MIN | 3780 | SAVE MAX | MAX | 3781 | SAVE MIN MAX | MIN & MAX | 3782 | SAVE * [m] | all found messages | 3783 +------------------------------+--------------------+ 3785 where '*' means "ALL" and/or "COUNT", and '[m]' means optional "MIN" 3786 and/or "MAX" 3788 Implementation note: server implementors should note that "$" can 3789 reference IMAP message sequences or UID sequences, depending on the 3790 context where it is used. For example, the "$" marker can be set as 3791 a result of a SEARCH (SAVE) command and used as a parameter to a UID 3792 FETCH command (which accepts a UID sequence, not a message sequence), 3793 or the "$" marker can be set as a result of a UID SEARCH (SAVE) 3794 command and used as a parameter to a FETCH command (which accepts a 3795 message sequence, not a UID sequence). Server implementations need 3796 to automatically map the "$" marker value to message numbers or UIDs, 3797 depending on context where the "$" marker is used. 3799 6.4.4.2. Multiple Commands in Progress 3801 Use of a SEARCH RETURN (SAVE) command followed by a command using the 3802 "$" marker creates direct dependency between the two commands. As 3803 directed by Section 5.5, a server MUST execute the two commands in 3804 the order they were received. 3806 A client MAY pipeline a SEARCH RETURN (SAVE) command with one or more 3807 command using the "$" marker, as long as this doesn't create an 3808 ambiguity, as described in by Section 5.5. Examples 7-9 in 3809 Section 6.4.4.4 explain this in more details. 3811 6.4.4.3. Refusing to Save Search Results 3813 In some cases, the server MAY refuse to save a SEARCH (SAVE) result, 3814 for example, if an internal limit on the number of saved results is 3815 reached. In this case, the server MUST return a tagged NO response 3816 containing the NOTSAVED response code and set the search result 3817 variable to the empty sequence, as described in Section 6.4.4.1. 3819 6.4.4.4. Examples showing use of SAVE result option 3821 Only in this section: explanatory comments in examples that start 3822 with // are not part of the protocol. 3824 1) The following example demonstrates how the client can use the 3825 result of a SEARCH command to FETCH headers of interesting messages: 3827 Example 1: 3828 C: A282 SEARCH RETURN (SAVE) FLAGGED SINCE 1-Feb-1994 3829 NOT FROM "Smith" 3830 S: A282 OK SEARCH completed, result saved 3831 C: A283 FETCH $ (UID INTERNALDATE FLAGS BODY.PEEK[HEADER]) 3832 S: * 2 FETCH (UID 14 ... 3833 S: * 84 FETCH (UID 100 ... 3834 S: * 882 FETCH (UID 1115 ... 3835 S: A283 OK completed 3837 The client can also pipeline the two commands: 3839 Example 2: 3840 C: A282 SEARCH RETURN (SAVE) FLAGGED SINCE 1-Feb-1994 3841 NOT FROM "Smith" 3842 C: A283 FETCH $ (UID INTERNALDATE FLAGS BODY.PEEK[HEADER]) 3843 S: A282 OK SEARCH completed 3844 S: * 2 FETCH (UID 14 ... 3845 S: * 84 FETCH (UID 100 ... 3846 S: * 882 FETCH (UID 1115 ... 3847 S: A283 OK completed 3849 2) The following example demonstrates that the result of one SEARCH 3850 command can be used as input to another SEARCH command: 3852 Example 3: 3853 C: A300 SEARCH RETURN (SAVE) SINCE 1-Jan-2004 3854 NOT FROM "Smith" 3855 S: A300 OK SEARCH completed 3856 C: A301 UID SEARCH UID $ SMALLER 4096 3857 S: * ESEARCH (TAG "A301") UID ALL 17,900,901 3858 S: A301 OK completed 3860 Note that the second command in Example 3 can be replaced with: 3861 C: A301 UID SEARCH $ SMALLER 4096 3862 and the result of the command would be the same. 3864 3) The following example shows that the "$" marker can be combined 3865 with other message numbers using the OR SEARCH criterion. 3867 Example 4: 3868 C: P282 SEARCH RETURN (SAVE) SINCE 1-Feb-1994 3869 NOT FROM "Smith" 3870 S: P282 OK SEARCH completed 3871 C: P283 SEARCH CHARSET UTF-8 (OR $ 1,3000:3021) TEXT {8} 3872 C: YYYYYYYY 3873 S: * ESEARCH (TAG "P283") ALL 882,1102,3003,3005:3006 3874 S: P283 OK completed 3876 Note: Since this document format is restricted to 7-bit ASCII text, 3877 it is not possible to show actual UTF-8 data. The "YYYYYYYY" is a 3878 placeholder for what would be 8 octets of 8-bit data in an actual 3879 transaction. 3881 4) The following example demonstrates that a failed SEARCH sets the 3882 search result variable to the empty list. The server doesn't 3883 implement the KOI8-R charset. 3885 Example 5: 3886 C: B282 SEARCH RETURN (SAVE) SINCE 1-Feb-1994 3887 NOT FROM "Smith" 3888 S: B282 OK SEARCH completed 3889 C: B283 SEARCH RETURN (SAVE) CHARSET KOI8-R 3890 (OR $ 1,3000:3021) TEXT {4} 3891 C: XXXX 3892 S: B283 NO [BADCHARSET UTF-8] KOI8-R is not supported 3893 //After this command the saved result variable contains 3894 //no messages. A client that wants to reissue the B283 3895 //SEARCH command with another CHARSET would have to reissue 3896 //the B282 command as well. One possible workaround for 3897 //this is to include the desired CHARSET parameter 3898 //in the earliest SEARCH RETURN (SAVE) command in a 3899 //sequence of related SEARCH commands, to cause 3900 //the earliest SEARCH in the sequence to fail. 3901 //A better approach might be to always use CHARSET UTF-8 3902 //instead. 3904 Note: Since this document format is restricted to 7-bit ASCII text, 3905 it is not possible to show actual KOI8-R data. The "XXXX" is a 3906 placeholder for what would be 4 octets of 8-bit data in an actual 3907 transaction. 3909 5) The following example demonstrates that it is not an error to use 3910 the "$" marker when it contains no messages. 3912 Example 6: 3913 C: E282 SEARCH RETURN (SAVE) SINCE 28-Oct-2006 3914 NOT FROM "Eric" 3915 C: E283 COPY $ "Other Messages" 3916 //The "$" contains no messages 3917 S: E282 OK SEARCH completed 3918 S: E283 OK COPY completed, nothing copied 3920 Example 7: 3921 C: F282 SEARCH RETURN (SAVE) KEYWORD $Junk 3922 C: F283 COPY $ "Junk" 3923 C: F284 STORE $ +FLAGS.Silent (\Deleted) 3924 S: F282 OK SEARCH completed 3925 S: F283 OK COPY completed 3926 S: F284 OK STORE completed 3928 Example 8: 3929 C: G282 SEARCH RETURN (SAVE) KEYWORD $Junk 3930 C: G283 SEARCH RETURN (ALL) SINCE 28-Oct-2006 3931 FROM "Eric" 3932 // The server can execute the two SEARCH commands 3933 // in any order, as they don't have any dependency. 3934 // For example, it may return: 3935 S: * ESEARCH (TAG "G283") ALL 3:15,27,29:103 3936 S: G283 OK SEARCH completed 3937 S: G282 OK SEARCH completed 3939 The following example demonstrates that the result of the second 3940 SEARCH RETURN (SAVE) always overrides the result of the first. 3942 Example 9: 3943 C: H282 SEARCH RETURN (SAVE) KEYWORD $Junk 3944 C: H283 SEARCH RETURN (SAVE) SINCE 28-Oct-2006 3945 FROM "Eric" 3946 S: H282 OK SEARCH completed 3947 S: H283 OK SEARCH completed 3948 // At this point "$" would contain results of H283 3950 The following example demonstrates behavioral difference for 3951 different combinations of ESEARCH result options. 3953 Example 10: 3954 C: C282 SEARCH RETURN (ALL) SINCE 12-Feb-2006 3955 NOT FROM "Smith" 3956 S: * ESEARCH (TAG "C283") ALL 2,10:15,21 3957 //$ value hasn't changed 3958 S: C282 OK SEARCH completed 3960 C: C283 SEARCH RETURN (ALL SAVE) SINCE 12-Feb-2006 3961 NOT FROM "Smith" 3962 S: * ESEARCH (TAG "C283") ALL 2,10:15,21 3963 //$ value is 2,10:15,21 3964 S: C283 OK SEARCH completed 3966 C: C284 SEARCH RETURN (SAVE MIN) SINCE 12-Feb-2006 3967 NOT FROM "Smith" 3968 S: * ESEARCH (TAG "C284") MIN 2 3969 //$ value is 2 3970 S: C284 OK SEARCH completed 3972 C: C285 SEARCH RETURN (MAX SAVE MIN) SINCE 3973 12-Feb-2006 NOT FROM "Smith" 3974 S: * ESEARCH (TAG "C285") MIN 2 MAX 21 3975 //$ value is 2,21 3976 S: C285 OK SEARCH completed 3978 C: C286 SEARCH RETURN (MAX SAVE MIN COUNT) 3979 SINCE 12-Feb-2006 NOT FROM "Smith" 3980 S: * ESEARCH (TAG "C286") MIN 2 MAX 21 COUNT 8 3981 //$ value is 2,10:15,21 3982 S: C286 OK SEARCH completed 3984 C: C286 SEARCH RETURN (ALL SAVE MIN) SINCE 3985 12-Feb-2006 NOT FROM "Smith" 3986 S: * ESEARCH (TAG "C286") MIN 2 ALL 2,10:15,21 3987 //$ value is 2,10:15,21 3988 S: C286 OK SEARCH completed 3990 6.4.5. FETCH Command 3992 Arguments: sequence set 3993 message data item names or macro 3995 Responses: untagged responses: FETCH 3997 Result: OK - fetch completed 3998 NO - fetch error: can't fetch that data 3999 BAD - command unknown or arguments invalid 4001 The FETCH command retrieves data associated with a message in the 4002 mailbox. The data items to be fetched can be either a single atom or 4003 a parenthesized list. 4005 Most data items, identified in the formal syntax under the msg-att- 4006 static rule, are static and MUST NOT change for any particular 4007 message. Other data items, identified in the formal syntax under the 4008 msg-att-dynamic rule, MAY change, either as a result of a STORE 4009 command or due to external events. 4011 For example, if a client receives an ENVELOPE for a message when 4012 it already knows the envelope, it can safely ignore the newly 4013 transmitted envelope. 4015 There are three macros which specify commonly-used sets of data 4016 items, and can be used instead of data items. A macro must be used 4017 by itself, and not in conjunction with other macros or data items. 4019 ALL Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE) 4021 FAST Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE) 4023 FULL Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE 4024 BODY) 4026 The currently defined data items that can be fetched are: 4028 BINARY[]<> 4030 Requests that the specified section be transmitted after 4031 performing Content-Transfer-Encoding-related decoding. 4033 The argument, if present, requests that a subset of 4034 the data be returned. The semantics of a partial FETCH BINARY 4035 command are the same as for a partial FETCH BODY command, with 4036 the exception that the arguments refer to the DECODED 4037 section data. 4039 BINARY.PEEK[]<> An alternate form of 4040 BINARY[] that does not implicitly set the \Seen 4041 flag. 4043 BINARY.SIZE[] 4045 Requests the decoded size of the section (i.e., the size to 4046 expect in response to the corresponding FETCH BINARY request). 4048 Note: client authors are cautioned that this might be an 4049 expensive operation for some server implementations. 4050 Needlessly issuing this request could result in degraded 4051 performance due to servers having to calculate the value every 4052 time the request is issued. 4054 BODY Non-extensible form of BODYSTRUCTURE. 4056 BODY[
]<> 4058 The text of a particular body section. The section 4059 specification is a set of zero or more part specifiers 4060 delimited by periods. A part specifier is either a part number 4061 or one of the following: HEADER, HEADER.FIELDS, 4062 HEADER.FIELDS.NOT, MIME, and TEXT. An empty section 4063 specification refers to the entire message, including the 4064 header. 4066 Every message has at least one part number. Non-[MIME-IMB] 4067 messages, and non-multipart [MIME-IMB] messages with no 4068 encapsulated message, only have a part 1. 4070 Multipart messages are assigned consecutive part numbers, as 4071 they occur in the message. If a particular part is of type 4072 message or multipart, its parts MUST be indicated by a period 4073 followed by the part number within that nested multipart part. 4075 A part of type MESSAGE/RFC822 or MESSAGE/GLOBAL also has nested 4076 part numbers, referring to parts of the MESSAGE part's body. 4078 The HEADER, HEADER.FIELDS, HEADER.FIELDS.NOT, and TEXT part 4079 specifiers can be the sole part specifier or can be prefixed by 4080 one or more numeric part specifiers, provided that the numeric 4081 part specifier refers to a part of type MESSAGE/RFC822 or 4082 MESSAGE/GLOBAL. The MIME part specifier MUST be prefixed by 4083 one or more numeric part specifiers. 4085 The HEADER, HEADER.FIELDS, and HEADER.FIELDS.NOT part 4086 specifiers refer to the [RFC-5322] header of the message or of 4087 an encapsulated [MIME-IMT] MESSAGE/RFC822 or MESSAGE/GLOBAL 4088 message. HEADER.FIELDS and HEADER.FIELDS.NOT are followed by a 4089 list of field-name (as defined in [RFC-5322]) names, and return 4090 a subset of the header. The subset returned by HEADER.FIELDS 4091 contains only those header fields with a field-name that 4092 matches one of the names in the list; similarly, the subset 4093 returned by HEADER.FIELDS.NOT contains only the header fields 4094 with a non-matching field-name. The field-matching is ASCII 4095 range case-insensitive but otherwise exact. Subsetting does 4096 not exclude the [RFC-5322] delimiting blank line between the 4097 header and the body; the blank line is included in all header 4098 fetches, except in the case of a message which has no body and 4099 no blank line. 4101 The MIME part specifier refers to the [MIME-IMB] header for 4102 this part. 4104 The TEXT part specifier refers to the text body of the message, 4105 omitting the [RFC-5322] header. 4107 Here is an example of a complex message with some of its 4108 part specifiers: 4110 HEADER ([RFC-5322] header of the message) 4111 TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 4112 1 TEXT/PLAIN 4113 2 APPLICATION/OCTET-STREAM 4114 3 MESSAGE/RFC822 4115 3.HEADER ([RFC-5322] header of the message) 4116 3.TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 4117 3.1 TEXT/PLAIN 4118 3.2 APPLICATION/OCTET-STREAM 4119 4 MULTIPART/MIXED 4120 4.1 IMAGE/GIF 4121 4.1.MIME ([MIME-IMB] header for the IMAGE/GIF) 4122 4.2 MESSAGE/RFC822 4123 4.2.HEADER ([RFC-5322] header of the message) 4124 4.2.TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 4125 4.2.1 TEXT/PLAIN 4126 4.2.2 MULTIPART/ALTERNATIVE 4127 4.2.2.1 TEXT/PLAIN 4128 4.2.2.2 TEXT/RICHTEXT 4130 It is possible to fetch a substring of the designated text. 4131 This is done by appending an open angle bracket ("<"), the 4132 octet position of the first desired octet, a period, the 4133 maximum number of octets desired, and a close angle bracket 4134 (">") to the part specifier. If the starting octet is beyond 4135 the end of the text, an empty string is returned. 4137 Any partial fetch that attempts to read beyond the end of the 4138 text is truncated as appropriate. A partial fetch that starts 4139 at octet 0 is returned as a partial fetch, even if this 4140 truncation happened. 4142 Note: This means that BODY[]<0.2048> of a 1500-octet message 4143 will return BODY[]<0> with a literal of size 1500, not 4144 BODY[]. 4146 Note: A substring fetch of a HEADER.FIELDS or 4147 HEADER.FIELDS.NOT part specifier is calculated after 4148 subsetting the header. 4150 The \Seen flag is implicitly set; if this causes the flags to 4151 change, they SHOULD be included as part of the FETCH responses. 4153 BODY.PEEK[
]<> An alternate form of BODY[
] 4154 that does not implicitly set the \Seen flag. 4156 BODYSTRUCTURE The [MIME-IMB] body structure of the message. This is 4157 computed by the server by parsing the [MIME-IMB] header fields in 4158 the [RFC-5322] header and [MIME-IMB] headers. 4160 ENVELOPE The envelope structure of the message. This is computed by 4161 the server by parsing the [RFC-5322] header into the component 4162 parts, defaulting various fields as necessary. 4164 FLAGS The flags that are set for this message. 4166 INTERNALDATE The internal date of the message. 4168 RFC822.SIZE The [RFC-5322] size of the message. 4170 UID The unique identifier for the message. 4172 Example: C: A654 FETCH 2:4 (FLAGS BODY[HEADER.FIELDS (DATE FROM)]) 4173 S: * 2 FETCH .... 4174 S: * 3 FETCH .... 4175 S: * 4 FETCH .... 4176 S: A654 OK FETCH completed 4178 6.4.6. STORE Command 4180 Arguments: sequence set 4181 message data item name 4182 value for message data item 4184 Responses: untagged responses: FETCH 4186 Result: OK - store completed 4187 NO - store error: can't store that data 4188 BAD - command unknown or arguments invalid 4190 The STORE command alters data associated with a message in the 4191 mailbox. Normally, STORE will return the updated value of the data 4192 with an untagged FETCH response. A suffix of ".SILENT" in the data 4193 item name prevents the untagged FETCH, and the server SHOULD assume 4194 that the client has determined the updated value itself or does not 4195 care about the updated value. 4197 Note: Regardless of whether or not the ".SILENT" suffix was used, 4198 the server SHOULD send an untagged FETCH response if a change to a 4199 message's flags from an external source is observed. The intent 4200 is that the status of the flags is determinate without a race 4201 condition. 4203 The currently defined data items that can be stored are: 4205 FLAGS Replace the flags for the message with the 4206 argument. The new value of the flags is returned as if a FETCH of 4207 those flags was done. 4209 FLAGS.SILENT Equivalent to FLAGS, but without returning 4210 a new value. 4212 +FLAGS Add the argument to the flags for the message. 4213 The new value of the flags is returned as if a FETCH of those 4214 flags was done. 4216 +FLAGS.SILENT Equivalent to +FLAGS, but without 4217 returning a new value. 4219 -FLAGS Remove the argument from the flags for the 4220 message. The new value of the flags is returned as if a FETCH of 4221 those flags was done. 4223 -FLAGS.SILENT Equivalent to -FLAGS, but without 4224 returning a new value. 4226 Example: C: A003 STORE 2:4 +FLAGS (\Deleted) 4227 S: * 2 FETCH (FLAGS (\Deleted \Seen)) 4228 S: * 3 FETCH (FLAGS (\Deleted)) 4229 S: * 4 FETCH (FLAGS (\Deleted \Flagged \Seen)) 4230 S: A003 OK STORE completed 4232 6.4.7. COPY Command 4234 Arguments: sequence set 4235 mailbox name 4237 Responses: no specific responses for this command 4238 Result: OK - copy completed 4239 NO - copy error: can't copy those messages or to that 4240 name 4241 BAD - command unknown or arguments invalid 4243 The COPY command copies the specified message(s) to the end of the 4244 specified destination mailbox. The flags and internal date of the 4245 message(s) SHOULD be preserved in the copy. 4247 If the destination mailbox does not exist, a server SHOULD return an 4248 error. It SHOULD NOT automatically create the mailbox. Unless it is 4249 certain that the destination mailbox can not be created, the server 4250 MUST send the response code "[TRYCREATE]" as the prefix of the text 4251 of the tagged NO response. This gives a hint to the client that it 4252 can attempt a CREATE command and retry the COPY if the CREATE is 4253 successful. 4255 If the COPY command is unsuccessful for any reason, server 4256 implementations MUST restore the destination mailbox to its state 4257 before the COPY attempt. 4259 On successful completion of a COPY, the server SHOULD return a 4260 COPYUID response code. 4262 In the case of a mailbox that has permissions set so that the client 4263 can COPY to the mailbox, but not SELECT or EXAMINE it, the server 4264 SHOULD NOT send an COPYUID response code as it would disclose 4265 information about the mailbox. 4267 In the case of a mailbox that has UIDNOTSTICKY status (see the 4268 UIDNOTSTICKY response code), the server MAY omit the COPYUID response 4269 code as it is not meaningful. 4271 If the server does not return the COPYUID response code, the client 4272 can discover this information by selecting the destination mailbox. 4273 The location of messages placed in the destination mailbox by COPY 4274 can be determined by using FETCH and/or SEARCH commands (e.g., for 4275 Message-ID). 4277 Example: C: A003 COPY 2:4 MEETING 4278 S: A003 OK COPY completed 4280 6.4.8. MOVE Command 4282 Arguments: sequence set 4283 mailbox name 4285 Responses: no specific responses for this command 4286 Result: OK - move completed 4287 NO - move error: can't move those messages or to that 4288 name 4289 BAD - command unknown or arguments invalid 4291 The MOVE command moves the specified message(s) to the end of the 4292 specified destination mailbox. The flags and internal date of the 4293 message(s) SHOULD be preserved. 4295 This means that a new message is created in the target mailbox with a 4296 new UID, the original message is removed from the source mailbox, and 4297 it appears to the client as a single action. This has the same 4298 effect for each message as this sequence: 4300 1. [UID] COPY 4302 2. [UID] STORE +FLAGS.SILENT \DELETED 4304 3. UID EXPUNGE 4306 Although the effect of the MOVE is the same as the preceding steps, 4307 the semantics are not identical: The intermediate states produced by 4308 those steps do not occur, and the response codes are different. In 4309 particular, though the COPY and EXPUNGE response codes will be 4310 returned, response codes for a STORE MUST NOT be generated and the 4311 \Deleted flag MUST NOT be set for any message. 4313 Because a MOVE applies to a set of messages, it might fail partway 4314 through the set. Regardless of whether the command is successful in 4315 moving the entire set, each individual message SHOULD either be moved 4316 or unaffected. The server MUST leave each message in a state where 4317 it is in at least one of the source or target mailboxes (no message 4318 can be lost or orphaned). The server SHOULD NOT leave any message in 4319 both mailboxes (it would be bad for a partial failure to result in a 4320 bunch of duplicate messages). This is true even if the server 4321 returns a tagged NO response to the command. 4323 Because of the similarity of MOVE to COPY, extensions that affect 4324 COPY affect MOVE in the same way. Response codes such as TRYCREATE 4325 (see Section 7.1), as well as those defined by extensions, are sent 4326 as appropriate. 4328 Servers SHOULD send COPYUID in response to a UID MOVE (see 4329 Section 6.4.9) command. For additional information see Section 7.1. 4331 Servers are also advised to send the COPYUID response code in an 4332 untagged OK before sending EXPUNGE or moved responses. (Sending 4333 COPYUID in the tagged OK, as described in the UIDPLUS specification, 4334 means that clients first receive an EXPUNGE for a message and 4335 afterwards COPYUID for the same message. It can be unnecessarily 4336 difficult to process that sequence usefully.) 4338 An example: 4339 C: a UID MOVE 42:69 foo 4340 S: * OK [COPYUID 432432 42:69 1202:1229] 4341 S: * 22 EXPUNGE 4342 S: (more expunges) 4343 S: a OK Done 4345 Note that the server may send unrelated EXPUNGE responses as well, if 4346 any happen to have been expunged at the same time; this is normal 4347 IMAP operation. 4349 Note that moving a message to the currently selected mailbox (that 4350 is, where the source and target mailboxes are the same) is allowed 4351 when copying the message to the currently selected mailbox is 4352 allowed. 4354 The server may send EXPUNGE responses before the tagged response, so 4355 the client cannot safely send more commands with message sequence 4356 number arguments while the server is processing MOVE. 4358 MOVE and UID MOVE can be pipelined with other commands, but care has 4359 to be taken. Both commands modify sequence numbers and also allow 4360 unrelated EXPUNGE responses. The renumbering of other messages in 4361 the source mailbox following any EXPUNGE response can be surprising 4362 and makes it unsafe to pipeline any command that relies on message 4363 sequence numbers after a MOVE or UID MOVE. Similarly, MOVE cannot be 4364 pipelined with a command that might cause message renumbering. See 4365 Section 5.5, for more information about ambiguities as well as 4366 handling requirements for both clients and servers. 4368 6.4.9. UID Command 4370 Arguments: command name 4371 command arguments 4373 Responses: untagged responses: FETCH, ESEARCH, EXPUNGE 4375 Result: OK - UID command completed 4376 NO - UID command error 4377 BAD - command unknown or arguments invalid 4379 The UID command has three forms. In the first form, it takes as its 4380 arguments a COPY, MOVE, FETCH, or STORE command with arguments 4381 appropriate for the associated command. However, the numbers in the 4382 sequence set argument are unique identifiers instead of message 4383 sequence numbers. Sequence set ranges are permitted, but there is no 4384 guarantee that unique identifiers will be contiguous. 4386 A non-existent unique identifier is ignored without any error message 4387 generated. Thus, it is possible for a UID FETCH command to return an 4388 OK without any data or a UID COPY, UID MOVE or UID STORE to return an 4389 OK without performing any operations. 4391 In the second form, the UID command takes an EXPUNGE command with an 4392 extra parameter the specified a sequence set of UIDs to operate on. 4393 The UID EXPUNGE command permanently removes all messages that both 4394 have the \Deleted flag set and have a UID that is included in the 4395 specified sequence set from the currently selected mailbox. If a 4396 message either does not have the \Deleted flag set or has a UID that 4397 is not included in the specified sequence set, it is not affected. 4399 UID EXPUNGE is particularly useful for disconnected use clients. 4400 By using UID EXPUNGE instead of EXPUNGE when resynchronizing with 4401 the server, the client can ensure that it does not inadvertantly 4402 remove any messages that have been marked as \Deleted by other 4403 clients between the time that the client was last connected and 4404 the time the client resynchronizes. 4406 Example: C: A003 UID EXPUNGE 3000:3002 4407 S: * 3 EXPUNGE 4408 S: * 3 EXPUNGE 4409 S: * 3 EXPUNGE 4410 S: A003 OK UID EXPUNGE completed 4412 In the third form, the UID command takes a SEARCH command with SEARCH 4413 command arguments. The interpretation of the arguments is the same 4414 as with SEARCH; however, the numbers returned in a ESEARCH response 4415 for a UID SEARCH command are unique identifiers instead of message 4416 sequence numbers. Also, the corresponding ESEARCH response MUST 4417 include the UID indicator. For example, the command UID SEARCH 1:100 4418 UID 443:557 returns the unique identifiers corresponding to the 4419 intersection of two sequence sets, the message sequence number range 4420 1:100 and the UID range 443:557. 4422 Note: in the above example, the UID range 443:557 appears. The 4423 same comment about a non-existent unique identifier being ignored 4424 without any error message also applies here. Hence, even if 4425 neither UID 443 or 557 exist, this range is valid and would 4426 include an existing UID 495. 4428 Also note that a UID range of 559:* always includes the UID of the 4429 last message in the mailbox, even if 559 is higher than any 4430 assigned UID value. This is because the contents of a range are 4431 independent of the order of the range endpoints. Thus, any UID 4432 range with * as one of the endpoints indicates at least one 4433 message (the message with the highest numbered UID), unless the 4434 mailbox is empty. 4436 The number after the "*" in an untagged FETCH or EXPUNGE response is 4437 always a message sequence number, not a unique identifier, even for a 4438 UID command response. However, server implementations MUST 4439 implicitly include the UID message data item as part of any FETCH 4440 response caused by a UID command, regardless of whether a UID was 4441 specified as a message data item to the FETCH. 4443 Note: The rule about including the UID message data item as part of a 4444 FETCH response primarily applies to the UID FETCH and UID STORE 4445 commands, including a UID FETCH command that does not include UID as 4446 a message data item. Although it is unlikely that the other UID 4447 commands will cause an untagged FETCH, this rule applies to these 4448 commands as well. 4450 Example: C: A999 UID FETCH 4827313:4828442 FLAGS 4451 S: * 23 FETCH (FLAGS (\Seen) UID 4827313) 4452 S: * 24 FETCH (FLAGS (\Seen) UID 4827943) 4453 S: * 25 FETCH (FLAGS (\Seen) UID 4828442) 4454 S: A999 OK UID FETCH completed 4456 6.5. Client Commands - Experimental/Expansion 4458 6.5.1. X Command 4460 Arguments: implementation defined 4462 Responses: implementation defined 4464 Result: OK - command completed 4465 NO - failure 4466 BAD - command unknown or arguments invalid 4468 Any command prefixed with an X is an experimental command. Commands 4469 which are not part of this specification, a standard or standards- 4470 track revision of this specification, or an IESG-approved 4471 experimental protocol, MUST use the X prefix. 4473 Any added untagged responses issued by an experimental command MUST 4474 also be prefixed with an X. Server implementations MUST NOT send any 4475 such untagged responses, unless the client requested it by issuing 4476 the associated experimental command. 4478 Example: C: a441 CAPABILITY 4479 S: * CAPABILITY IMAP4rev2 XPIG-LATIN 4480 S: a441 OK CAPABILITY completed 4481 C: A442 XPIG-LATIN 4482 S: * XPIG-LATIN ow-nay eaking-spay ig-pay atin-lay 4483 S: A442 OK XPIG-LATIN ompleted-cay 4485 7. Server Responses 4487 Server responses are in three forms: status responses, server data, 4488 and command continuation request. The information contained in a 4489 server response, identified by "Contents:" in the response 4490 descriptions below, is described by function, not by syntax. The 4491 precise syntax of server responses is described in the Formal Syntax 4492 section. 4494 The client MUST be prepared to accept any response at all times. 4496 Status responses can be tagged or untagged. Tagged status responses 4497 indicate the completion result (OK, NO, or BAD status) of a client 4498 command, and have a tag matching the command. 4500 Some status responses, and all server data, are untagged. An 4501 untagged response is indicated by the token "*" instead of a tag. 4502 Untagged status responses indicate server greeting, or server status 4503 that does not indicate the completion of a command (for example, an 4504 impending system shutdown alert). For historical reasons, untagged 4505 server data responses are also called "unsolicited data", although 4506 strictly speaking, only unilateral server data is truly 4507 "unsolicited". 4509 Certain server data MUST be recorded by the client when it is 4510 received; this is noted in the description of that data. Such data 4511 conveys critical information which affects the interpretation of all 4512 subsequent commands and responses (e.g., updates reflecting the 4513 creation or destruction of messages). 4515 Other server data SHOULD be recorded for later reference; if the 4516 client does not need to record the data, or if recording the data has 4517 no obvious purpose (e.g., a SEARCH response when no SEARCH command is 4518 in progress), the data SHOULD be ignored. 4520 An example of unilateral untagged server data occurs when the IMAP 4521 connection is in the selected state. In the selected state, the 4522 server checks the mailbox for new messages as part of command 4523 execution. Normally, this is part of the execution of every command; 4524 hence, a NOOP command suffices to check for new messages. If new 4525 messages are found, the server sends untagged EXISTS response 4526 reflecting the new size of the mailbox. Server implementations that 4527 offer multiple simultaneous access to the same mailbox SHOULD also 4528 send appropriate unilateral untagged FETCH and EXPUNGE responses if 4529 another agent changes the state of any message flags or expunges any 4530 messages. 4532 Command continuation request responses use the token "+" instead of a 4533 tag. These responses are sent by the server to indicate acceptance 4534 of an incomplete client command and readiness for the remainder of 4535 the command. 4537 7.1. Server Responses - Status Responses 4539 Status responses are OK, NO, BAD, PREAUTH and BYE. OK, NO, and BAD 4540 can be tagged or untagged. PREAUTH and BYE are always untagged. 4542 Status responses MAY include an OPTIONAL "response code". A response 4543 code consists of data inside square brackets in the form of an atom, 4544 possibly followed by a space and arguments. The response code 4545 contains additional information or status codes for client software 4546 beyond the OK/NO/BAD condition, and are defined when there is a 4547 specific action that a client can take based upon the additional 4548 information. 4550 The currently defined response codes are: 4552 ALERT 4554 The human-readable text contains a special alert that MUST be 4555 presented to the user in a fashion that calls the user's 4556 attention to the message. 4558 ALREADYEXISTS 4560 The operation attempts to create something that already exists, 4561 such as when the CREATE or RENAME directories attempt to create 4562 a mailbox and there is already one of that name. 4564 C: o356 RENAME this that 4565 S: o356 NO [ALREADYEXISTS] Mailbox "that" already exists 4567 APPENDUID 4569 Followed by the UIDVALIDITY of the destination mailbox and the 4570 UID assigned to the appended message in the destination 4571 mailbox, indicates that the message has been appended to the 4572 destination mailbox with that UID. 4574 If the server also supports the [MULTIAPPEND] extension, and if 4575 multiple messages were appended in the APPEND command, then the 4576 second value is a UID set containing the UIDs assigned to the 4577 appended messages, in the order they were transmitted in the 4578 APPEND command. This UID set may not contain extraneous UIDs 4579 or the symbol "*". 4581 Note: the UID set form of the APPENDUID response code MUST 4582 NOT be used if only a single message was appended. In 4583 particular, a server MUST NOT send a range such as 123:123. 4584 This is because a client that does not support [MULTIAPPEND] 4585 expects only a single UID and not a UID set. 4587 UIDs are assigned in strictly ascending order in the mailbox 4588 (refer to Section 2.3.1.1); note that a range of 12:10 is 4589 exactly equivalent to 10:12 and refers to the sequence 4590 10,11,12. 4592 This response code is returned in a tagged OK response to the 4593 APPEND command. 4595 AUTHENTICATIONFAILED 4597 Authentication failed for some reason on which the server is 4598 unwilling to elaborate. Typically, this includes "unknown 4599 user" and "bad password". 4601 This is the same as not sending any response code, except that 4602 when a client sees AUTHENTICATIONFAILED, it knows that the 4603 problem wasn't, e.g., UNAVAILABLE, so there's no point in 4604 trying the same login/password again later. 4606 C: b LOGIN "fred" "foo" 4607 S: b NO [AUTHENTICATIONFAILED] Authentication failed 4609 AUTHORIZATIONFAILED 4611 Authentication succeeded in using the authentication identity, 4612 but the server cannot or will not allow the authentication 4613 identity to act as the requested authorization identity. This 4614 is only applicable when the authentication and authorization 4615 identities are different. 4617 C: c1 AUTHENTICATE PLAIN 4618 [...] 4619 S: c1 NO [AUTHORIZATIONFAILED] No such authorization-ID 4620 C: c2 AUTHENTICATE PLAIN 4621 [...] 4622 S: c2 NO [AUTHORIZATIONFAILED] Authenticator is not an admin 4624 BADCHARSET 4626 Optionally followed by a parenthesized list of charsets. A 4627 SEARCH failed because the given charset is not supported by 4628 this implementation. If the optional list of charsets is 4629 given, this lists the charsets that are supported by this 4630 implementation. 4632 CANNOT 4634 The operation violates some invariant of the server and can 4635 never succeed. 4637 C: l create "///////" 4638 S: l NO [CANNOT] Adjacent slashes are not supported 4640 CAPABILITY 4642 Followed by a list of capabilities. This can appear in the 4643 initial OK or PREAUTH response to transmit an initial 4644 capabilities list. It can also appear in tagged responses to 4645 LOGIN or AUTHENTICATE commands. This makes it unnecessary for 4646 a client to send a separate CAPABILITY command if it recognizes 4647 this response. 4649 CLIENTBUG 4651 The server has detected a client bug. This can accompany all 4652 of OK, NO, and BAD, depending on what the client bug is. 4654 C: k1 select "/archive/projects/experiment-iv" 4655 [...] 4656 S: k1 OK [READ-ONLY] Done 4657 C: k2 status "/archive/projects/experiment-iv" (messages) 4658 [...] 4659 S: k2 OK [CLIENTBUG] Done 4661 CLOSED 4663 The CLOSED response code has no parameters. A server return 4664 the CLOSED response code when the currently selected mailbox is 4665 closed implicitly using the SELECT/EXAMINE command on another 4666 mailbox. The CLOSED response code serves as a boundary between 4667 responses for the previously opened mailbox (which was closed) 4668 and the newly selected mailbox; all responses before the CLOSED 4669 response code relate to the mailbox that was closed, and all 4670 subsequent responses relate to the newly opened mailbox. 4672 There is no need to return the CLOSED response code on 4673 completion of the CLOSE or the UNSELECT command (or similar), 4674 whose purpose is to close the currently selected mailbox 4675 without opening a new one. 4677 CONTACTADMIN 4679 The user should contact the system administrator or support 4680 desk. 4682 C: e login "fred" "foo" 4683 S: e OK [CONTACTADMIN] 4685 COPYUID 4687 Followed by the UIDVALIDITY of the destination mailbox, a UID 4688 set containing the UIDs of the message(s) in the source mailbox 4689 that were copied to the destination mailbox and containing the 4690 UIDs assigned to the copied message(s) in the destination 4691 mailbox, indicates that the message(s) have been copied to the 4692 destination mailbox with the stated UID(s). 4694 The source UID set is in the order the message(s) were copied; 4695 the destination UID set corresponds to the source UID set and 4696 is in the same order. Neither of the UID sets may contain 4697 extraneous UIDs or the symbol "*". 4699 UIDs are assigned in strictly ascending order in the mailbox 4700 (refer to Section 2.3.1.1); note that a range of 12:10 is 4701 exactly equivalent to 10:12 and refers to the sequence 4702 10,11,12. 4704 This response code is returned in a tagged OK response to the 4705 COPY command. 4707 CORRUPTION 4709 The server discovered that some relevant data (e.g., the 4710 mailbox) are corrupt. This response code does not include any 4711 information about what's corrupt, but the server can write that 4712 to its logfiles. 4714 C: i select "/archive/projects/experiment-iv" 4715 S: i NO [CORRUPTION] Cannot open mailbox 4717 EXPIRED 4719 Either authentication succeeded or the server no longer had the 4720 necessary data; either way, access is no longer permitted using 4721 that passphrase. The client or user should get a new 4722 passphrase. 4724 C: d login "fred" "foo" 4725 S: d NO [EXPIRED] That password isn't valid any more 4727 EXPUNGEISSUED 4729 Someone else has issued an EXPUNGE for the same mailbox. The 4730 client may want to issue NOOP soon. [IMAP-MULTIACCESS] 4731 discusses this subject in depth. 4733 C: h search from fred@example.com 4734 S: * ESEARCH (TAG "h") ALL 1:3,5,8,13,21,42 4735 S: h OK [EXPUNGEISSUED] Search completed 4737 HASCHILDREN 4739 The mailbox delete operation failed because the mailbox has one 4740 or more children and the server doesn't allow deletion of 4741 mailboxes with children. 4743 C: m356 DELETE Notes 4744 S: o356 NO [HASCHILDREN] Mailbox "Notes" has children that need 4745 to be deleted first 4747 INUSE 4749 An operation has not been carried out because it involves 4750 sawing off a branch someone else is sitting on. Someone else 4751 may be holding an exclusive lock needed for this operation, or 4752 the operation may involve deleting a resource someone else is 4753 using, typically a mailbox. 4755 The operation may succeed if the client tries again later. 4757 C: g delete "/archive/projects/experiment-iv" 4758 S: g NO [INUSE] Mailbox in use 4760 LIMIT 4762 The operation ran up against an implementation limit of some 4763 kind, such as the number of flags on a single message or the 4764 number of flags used in a mailbox. 4766 C: m STORE 42 FLAGS f1 f2 f3 f4 f5 ... f250 4767 S: m NO [LIMIT] At most 32 flags in one mailbox supported 4769 NONEXISTENT 4771 The operation attempts to delete something that does not exist. 4772 Similar to ALREADYEXISTS. 4774 C: p RENAME this that 4775 S: p NO [NONEXISTENT] No such mailbox 4777 NOPERM 4779 The access control system (e.g., Access Control List (ACL), see 4780 [RFC4314] does not permit this user to carry out an operation, 4781 such as selecting or creating a mailbox. 4783 C: f select "/archive/projects/experiment-iv" 4784 S: f NO [NOPERM] Access denied 4786 OVERQUOTA 4788 The user would be over quota after the operation. (The user 4789 may or may not be over quota already.) 4791 Note that if the server sends OVERQUOTA but doesn't support the 4792 IMAP QUOTA extension defined by [RFC2087], then there is a 4793 quota, but the client cannot find out what the quota is. 4795 C: n1 uid copy 1:* oldmail 4796 S: n1 NO [OVERQUOTA] Sorry 4798 C: n2 uid copy 1:* oldmail 4799 S: n2 OK [OVERQUOTA] You are now over your soft quota 4801 PARSE 4803 The human-readable text represents an error in parsing the 4804 [RFC-5322] header or [MIME-IMB] headers of a message in the 4805 mailbox. 4807 PERMANENTFLAGS 4809 Followed by a parenthesized list of flags, indicates which of 4810 the known flags the client can change permanently. Any flags 4811 that are in the FLAGS untagged response, but not the 4812 PERMANENTFLAGS list, can not be set permanently. The 4813 PERMANENTFLAGS list can also include the special flag \*, which 4814 indicates that it is possible to create new keywords by 4815 attempting to store those keywords in the mailbox. If the 4816 client attempts to STORE a flag that is not in the 4817 PERMANENTFLAGS list, the server will either ignore the change 4818 or store the state change for the remainder of the current 4819 session only. 4821 There is no need for a server that included the special flag \* 4822 to return a new PERMANENTFLAGS response code when a new keyword 4823 was successfully set on a message upon client request. However 4824 if the server has a limit on the number of different keywords 4825 that can be stored in a mailbox and that limit is reached, the 4826 server MUST send a new PERMANENTFLAGS response code without the 4827 special flag \*. 4829 PRIVACYREQUIRED 4831 The operation is not permitted due to a lack of privacy. If 4832 Transport Layer Security (TLS) is not in use, the client could 4833 try STARTTLS (see Section 6.2.1) and then repeat the operation. 4835 C: d login "fred" "foo" 4836 S: d NO [PRIVACYREQUIRED] Connection offers no privacy 4838 C: d select inbox 4839 S: d NO [PRIVACYREQUIRED] Connection offers no privacy 4841 READ-ONLY 4843 The mailbox is selected read-only, or its access while selected 4844 has changed from read-write to read-only. 4846 READ-WRITE 4848 The mailbox is selected read-write, or its access while 4849 selected has changed from read-only to read-write. 4851 SERVERBUG 4853 The server encountered a bug in itself or violated one of its 4854 own invariants. 4856 C: j select "/archive/projects/experiment-iv" 4857 S: j NO [SERVERBUG] This should not happen 4859 TRYCREATE 4860 An APPEND or COPY attempt is failing because the target mailbox 4861 does not exist (as opposed to some other reason). This is a 4862 hint to the client that the operation can succeed if the 4863 mailbox is first created by the CREATE command. 4865 UIDNEXT 4867 Followed by a decimal number, indicates the next unique 4868 identifier value. Refer to Section 2.3.1.1 for more 4869 information. 4871 UIDNOTSTICKY 4873 The selected mailbox is supported by a mail store that does not 4874 support persistent UIDs; that is, UIDVALIDITY will be different 4875 each time the mailbox is selected. Consequently, APPEND or 4876 COPY to this mailbox will not return an APPENDUID or COPYUID 4877 response code. 4879 This response code is returned in an untagged NO response to 4880 the SELECT command. 4882 Note: servers SHOULD NOT have any UIDNOTSTICKY mail stores. 4883 This facility exists to support legacy mail stores in which 4884 it is technically infeasible to support persistent UIDs. 4885 This should be avoided when designing new mail stores. 4887 UIDVALIDITY 4889 Followed by a decimal number, indicates the unique identifier 4890 validity value. Refer to Section 2.3.1.1 for more information. 4892 UNAVAILABLE 4894 Temporary failure because a subsystem is down. For example, an 4895 IMAP server that uses a Lightweight Directory Access Protocol 4896 (LDAP) or Radius server for authentication might use this 4897 response code when the LDAP/Radius server is down. 4899 C: a LOGIN "fred" "foo" 4900 S: a NO [UNAVAILABLE] User's backend down for maintenance 4902 UNKNOWN-CTE 4904 The server does not know how to decode the section's Content- 4905 Transfer-Encoding. 4907 Client implementations MUST ignore response codes that they do not 4908 recognize. 4910 7.1.1. OK Response 4912 Contents: OPTIONAL response code 4913 human-readable text 4915 The OK response indicates an information message from the server. 4916 When tagged, it indicates successful completion of the associated 4917 command. The human-readable text MAY be presented to the user as an 4918 information message. The untagged form indicates an information-only 4919 message; the nature of the information MAY be indicated by a response 4920 code. 4922 The untagged form is also used as one of three possible greetings at 4923 connection startup. It indicates that the connection is not yet 4924 authenticated and that a LOGIN or an AUTHENTICATE command is needed. 4926 Example: S: * OK IMAP4rev2 server ready 4927 C: A001 LOGIN fred blurdybloop 4928 S: * OK [ALERT] System shutdown in 10 minutes 4929 S: A001 OK LOGIN Completed 4931 7.1.2. NO Response 4933 Contents: OPTIONAL response code 4934 human-readable text 4936 The NO response indicates an operational error message from the 4937 server. When tagged, it indicates unsuccessful completion of the 4938 associated command. The untagged form indicates a warning; the 4939 command can still complete successfully. The human-readable text 4940 describes the condition. 4942 Example: C: A222 COPY 1:2 owatagusiam 4943 S: * NO Disk is 98% full, please delete unnecessary data 4944 S: A222 OK COPY completed 4945 C: A223 COPY 3:200 blurdybloop 4946 S: * NO Disk is 98% full, please delete unnecessary data 4947 S: * NO Disk is 99% full, please delete unnecessary data 4948 S: A223 NO COPY failed: disk is full 4950 7.1.3. BAD Response 4952 Contents: OPTIONAL response code 4953 human-readable text 4955 The BAD response indicates an error message from the server. When 4956 tagged, it reports a protocol-level error in the client's command; 4957 the tag indicates the command that caused the error. The untagged 4958 form indicates a protocol-level error for which the associated 4959 command can not be determined; it can also indicate an internal 4960 server failure. The human-readable text describes the condition. 4962 Example: C: ...very long command line... 4963 S: * BAD Command line too long 4964 C: ...empty line... 4965 S: * BAD Empty command line 4966 C: A443 EXPUNGE 4967 S: * BAD Disk crash, attempting salvage to a new disk! 4968 S: * OK Salvage successful, no data lost 4969 S: A443 OK Expunge completed 4971 7.1.4. PREAUTH Response 4973 Contents: OPTIONAL response code 4974 human-readable text 4976 The PREAUTH response is always untagged, and is one of three possible 4977 greetings at connection startup. It indicates that the connection 4978 has already been authenticated by external means; thus no LOGIN/ 4979 AUTHENTICATE command is needed. 4981 Example: S: * PREAUTH IMAP4rev2 server logged in as Smith 4983 7.1.5. BYE Response 4985 Contents: OPTIONAL response code 4986 human-readable text 4988 The BYE response is always untagged, and indicates that the server is 4989 about to close the connection. The human-readable text MAY be 4990 displayed to the user in a status report by the client. The BYE 4991 response is sent under one of four conditions: 4993 1. as part of a normal logout sequence. The server will close the 4994 connection after sending the tagged OK response to the LOGOUT 4995 command. 4997 2. as a panic shutdown announcement. The server closes the 4998 connection immediately. 5000 3. as an announcement of an inactivity autologout. The server 5001 closes the connection immediately. 5003 4. as one of three possible greetings at connection startup, 5004 indicating that the server is not willing to accept a connection 5005 from this client. The server closes the connection immediately. 5007 The difference between a BYE that occurs as part of a normal LOGOUT 5008 sequence (the first case) and a BYE that occurs because of a failure 5009 (the other three cases) is that the connection closes immediately in 5010 the failure case. In all cases the client SHOULD continue to read 5011 response data from the server until the connection is closed; this 5012 will ensure that any pending untagged or completion responses are 5013 read and processed. 5015 Example: S: * BYE Autologout; idle for too long 5017 7.2. Server Responses - Server and Mailbox Status 5019 These responses are always untagged. This is how server and mailbox 5020 status data are transmitted from the server to the client. Many of 5021 these responses typically result from a command with the same name. 5023 7.2.1. The ENABLED Response 5025 Contents: capability listing 5027 The ENABLED response occurs as a result of an ENABLE command. The 5028 capability listing contains a space-separated listing of capability 5029 names that the server supports and that were successfully enabled. 5030 The ENABLED response may contain no capabilities, which means that no 5031 extensions listed by the client were successfully enabled. 5033 7.2.2. CAPABILITY Response 5035 Contents: capability listing 5037 The CAPABILITY response occurs as a result of a CAPABILITY command. 5038 The capability listing contains a space-separated listing of 5039 capability names that the server supports. The capability listing 5040 MUST include the atom "IMAP4rev2". 5042 In addition, client and server implementations MUST implement the 5043 STARTTLS, LOGINDISABLED, and AUTH=PLAIN (described in [PLAIN]) 5044 capabilities. See the Security Considerations section for important 5045 information. 5047 A capability name which begins with "AUTH=" indicates that the server 5048 supports that particular authentication mechanism. 5050 The LOGINDISABLED capability indicates that the LOGIN command is 5051 disabled, and that the server will respond with a tagged NO response 5052 to any attempt to use the LOGIN command even if the user name and 5053 password are valid. An IMAP client MUST NOT issue the LOGIN command 5054 if the server advertises the LOGINDISABLED capability. 5056 Other capability names indicate that the server supports an 5057 extension, revision, or amendment to the IMAP4rev2 protocol. Server 5058 responses MUST conform to this document until the client issues a 5059 command that uses the associated capability. 5061 Capability names MUST either begin with "X" or be informational, 5062 experimental or standards-track IMAP4rev2 extensions, revisions, or 5063 amendments registered with IANA. A server SHOULD NOT offer 5064 unregistered or non-standard capability names, unless such names are 5065 prefixed with an "X". 5067 Client implementations SHOULD NOT require any capability name other 5068 than "IMAP4rev2", and MUST ignore any unknown capability names. 5070 A server MAY send capabilities automatically, by using the CAPABILITY 5071 response code in the initial PREAUTH or OK responses, and by sending 5072 an updated CAPABILITY response code in the tagged OK response as part 5073 of a successful authentication. It is unnecessary for a client to 5074 send a separate CAPABILITY command if it recognizes these automatic 5075 capabilities. 5077 Example: S: * CAPABILITY IMAP4rev2 STARTTLS AUTH=GSSAPI XPIG-LATIN 5079 7.2.3. LIST Response 5081 Contents: name attributes 5082 hierarchy delimiter 5083 name 5084 OPTIONAL extension data 5086 The LIST response occurs as a result of a LIST command. It returns a 5087 single name that matches the LIST specification. There can be 5088 multiple LIST responses for a single LIST command. 5090 The following base mailbox name attributes are defined: 5092 \NonExistent The "\NonExistent" attribute indicates that a mailbox 5093 name does not refer to an existing mailbox. Note that this 5094 attribute is not meaningful by itself, as mailbox names that match 5095 the canonical LIST pattern but don't exist must not be returned 5096 unless one of the two conditions listed below is also satisfied: 5098 1. The mailbox name also satisfies the selection criteria (for 5099 example, it is subscribed and the "SUBSCRIBED" selection 5100 option has been specified). 5102 2. "RECURSIVEMATCH" has been specified, and the mailbox name has 5103 at least one descendant mailbox name that does not match the 5104 LIST pattern and does match the selection criteria. 5106 In practice, this means that the "\NonExistent" attribute is 5107 usually returned with one or more of "\Subscribed", "\Remote", 5108 "\HasChildren", or the CHILDINFO extended data item. 5110 The "\NonExistent" attribute implies "\NoSelect". 5112 \Noinferiors It is not possible for any child levels of hierarchy to 5113 exist under this name; no child levels exist now and none can be 5114 created in the future. 5116 \Noselect It is not possible to use this name as a selectable 5117 mailbox. 5119 \HasChildren The presence of this attribute indicates that the 5120 mailbox has child mailboxes. A server SHOULD NOT set this 5121 attribute if there are child mailboxes and the user does not have 5122 permission to access any of them. In this case, \HasNoChildren 5123 SHOULD be used. In many cases, however, a server may not be able 5124 to efficiently compute whether a user has access to any child 5125 mailbox. Note that even though the \HasChildren attribute for a 5126 mailbox must be correct at the time of processing of the mailbox, 5127 a client must be prepared to deal with a situation when a mailbox 5128 is marked with the \HasChildren attribute, but no child mailbox 5129 appears in the response to the LIST command. This might happen, 5130 for example, due to children mailboxes being deleted or made 5131 inaccessible to the user (using access control) by another client 5132 before the server is able to list them. 5134 \HasNoChildren The presence of this attribute indicates that the 5135 mailbox has NO child mailboxes that are accessible to the 5136 currently authenticated user. 5138 \Marked The mailbox has been marked "interesting" by the server; the 5139 mailbox probably contains messages that have been added since the 5140 last time the mailbox was selected. 5142 \Unmarked The mailbox does not contain any additional messages since 5143 the last time the mailbox was selected. 5145 \Subscribed The mailbox name was subscribed to using the SUBSCRIBE 5146 command. 5148 \Remote The mailbox is a remote mailbox. 5150 It is an error for the server to return both a \HasChildren and a 5151 \HasNoChildren attribute in the same LIST response. 5153 Note: the \HasNoChildren attribute should not be confused with the 5154 \NoInferiors attribute, which indicates that no child mailboxes 5155 exist now and none can be created in the future. 5157 If it is not feasible for the server to determine whether or not the 5158 mailbox is "interesting", the server SHOULD NOT send either \Marked 5159 or \Unmarked. The server MUST NOT send more than one of \Marked, 5160 \Unmarked, and \Noselect for a single mailbox, and MAY send none of 5161 these. 5163 In addition to the base mailbox name attributes defined above, an 5164 IMAP server MAY also include any or all of the following attributes 5165 that denote "role" (or "special-use") of a mailbox. These attributes 5166 are included along with base attributes defined above. A given 5167 mailbox may have none, one, or more than one of these attributes. In 5168 some cases, a special use is advice to a client about what to put in 5169 that mailbox. In other cases, it's advice to a client about what to 5170 expect to find there. 5172 \All This mailbox presents all messages in the user's message store. 5173 Implementations MAY omit some messages, such as, perhaps, those in 5174 \Trash and \Junk. When this special use is supported, it is 5175 almost certain to represent a virtual mailbox. 5177 \Archive This mailbox is used to archive messages. The meaning of 5178 an "archival" mailbox is server-dependent; typically, it will be 5179 used to get messages out of the inbox, or otherwise keep them out 5180 of the user's way, while still making them accessible. 5182 \Drafts This mailbox is used to hold draft messages -- typically, 5183 messages that are being composed but have not yet been sent. In 5184 some server implementations, this might be a virtual mailbox, 5185 containing messages from other mailboxes that are marked with the 5186 "\Draft" message flag. Alternatively, this might just be advice 5187 that a client put drafts here. 5189 \Flagged This mailbox presents all messages marked in some way as 5190 "important". When this special use is supported, it is likely to 5191 represent a virtual mailbox collecting messages (from other 5192 mailboxes) that are marked with the "\Flagged" message flag. 5194 \Junk This mailbox is where messages deemed to be junk mail are 5195 held. Some server implementations might put messages here 5196 automatically. Alternatively, this might just be advice to a 5197 client-side spam filter. 5199 \Sent This mailbox is used to hold copies of messages that have been 5200 sent. Some server implementations might put messages here 5201 automatically. Alternatively, this might just be advice that a 5202 client save sent messages here. 5204 \Trash This mailbox is used to hold messages that have been deleted 5205 or marked for deletion. In some server implementations, this 5206 might be a virtual mailbox, containing messages from other 5207 mailboxes that are marked with the "\Deleted" message flag. 5208 Alternatively, this might just be advice that a client that 5209 chooses not to use the IMAP "\Deleted" model should use this as 5210 its trash location. In server implementations that strictly 5211 expect the IMAP "\Deleted" model, this special use is likely not 5212 to be supported. 5214 All of special-use attributes are OPTIONAL, and any given server or 5215 message store may support any combination of the attributes, or none 5216 at all. In most cases, there will likely be at most one mailbox with 5217 a given attribute for a given user, but in some server or message 5218 store implementations it might be possible for multiple mailboxes to 5219 have the same special-use attribute. 5221 Special-use attributes are likely to be user-specific. User Adam 5222 might share his \Sent mailbox with user Barb, but that mailbox is 5223 unlikely to also serve as Barb's \Sent mailbox. 5225 Other mailbox name attributes can be found in the "IMAP Mailbox Name 5226 Attributes" registry [IMAP-MAILBOX-NAME-ATTRS-REG]. 5228 The hierarchy delimiter is a character used to delimit levels of 5229 hierarchy in a mailbox name. A client can use it to create child 5230 mailboxes, and to search higher or lower levels of naming hierarchy. 5231 All children of a top-level hierarchy node MUST use the same 5232 separator character. A NIL hierarchy delimiter means that no 5233 hierarchy exists; the name is a "flat" name. 5235 The name represents an unambiguous left-to-right hierarchy, and MUST 5236 be valid for use as a reference in LIST command. Unless \Noselect or 5237 \NonExistent is indicated, the name MUST also be valid as an argument 5238 for commands, such as SELECT, that accept mailbox names. 5240 The name might be followed by an OPTIONAL series of extended fields, 5241 a parenthesized list of tagged data (also referred to as "extended 5242 data item"). The first element of an extended field is a string, 5243 which identifies the type of data. [RFC5258] specified requirements 5244 on string registration (which are called "tags" there; such tags are 5245 not to be confused with IMAP command tags), in particular it said 5246 that "Tags MUST be registered with IANA". This document doesn't 5247 change that. See Section 9.5 of [RFC5258] for the registration 5248 template. The server MAY return data in the extended fields that was 5249 not directly solicited by the client in the corresponding LIST 5250 command. For example, the client can enable extra extended fields by 5251 using another IMAP extension that make use of the extended LIST 5252 responses. The client MUST ignore all extended fields it doesn't 5253 recognize. 5255 Example: S: * LIST (\Noselect) "/" ~/Mail/foo 5257 Example: S: * LIST (\Marked) ":" Tables (tablecloth (("edge" "lacy") 5258 ("color" "red")) Sample "text") 5259 S: * LIST () ":" Tables:new (tablecloth ("edge" "lacy") 5260 Sample ("text" "more text")) 5262 7.2.4. NAMESPACE Response 5264 Contents: the prefix and hierarchy delimiter to the server's 5265 Personal Namespace(s), Other Users' Namespace(s), and 5266 Shared Namespace(s) 5268 The NAMESPACE response occurs as a result of a NAMESPACE command. It 5269 contains the prefix and hierarchy delimiter to the server's Personal 5270 Namespace(s), Other Users' Namespace(s), and Shared Namespace(s) that 5271 the server wishes to expose. The response will contain a NIL for any 5272 namespace class that is not available. Namespace-Response-Extensions 5273 ABNF non terminal is defined for extensibility and MAY be included in 5274 the response. 5276 Example: S: * NAMESPACE (("" "/")) (("~" "/")) NIL 5278 7.2.5. STATUS Response 5280 Contents: name 5281 status parenthesized list 5283 The STATUS response occurs as a result of an STATUS command. It 5284 returns the mailbox name that matches the STATUS specification and 5285 the requested mailbox status information. 5287 Example: S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) 5289 7.2.6. ESEARCH Response 5291 Contents: one or more search-return-data pairs 5293 The ESEARCH response occurs as a result of a SEARCH or UID SEARCH 5294 command. 5296 The ESEARCH response starts with an optional search correlator. If 5297 it is missing, then the response was not caused by a particular IMAP 5298 command, whereas if it is present, it contains the tag of the command 5299 that caused the response to be returned. 5301 The search correlator is followed by an optional UID indicator. If 5302 this indicator is present, all data in the ESEARCH response refers to 5303 UIDs, otherwise all returned data refers to message numbers. 5305 The rest of the ESEARCH response contains one or more search data 5306 pairs. Each pair starts with unique return item name, followed by a 5307 space and the corresponding data. Search data pairs may be returned 5308 in any order. Unless specified otherwise by an extension, any return 5309 item name SHOULD appear only once in an ESEARCH response. 5311 [[TBD: describe the most common search data pairs returned.]] 5313 Example: S: * ESEARCH UID COUNT 5 ALL 4:19,21,28 5315 Example: S: * ESEARCH (TAG "a567") UID COUNT 5 ALL 4:19,21,28 5317 Example: S: * ESEARCH COUNT 5 ALL 1:17,21 5319 7.2.7. FLAGS Response 5321 Contents: flag parenthesized list 5323 The FLAGS response occurs as a result of a SELECT or EXAMINE command. 5324 The flag parenthesized list identifies the flags (at a minimum, the 5325 system-defined flags) that are applicable for this mailbox. Flags 5326 other than the system flags can also exist, depending on server 5327 implementation. 5329 The update from the FLAGS response MUST be recorded by the client. 5331 Example: S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 5333 7.3. Server Responses - Mailbox Size 5335 These responses are always untagged. This is how changes in the size 5336 of the mailbox are transmitted from the server to the client. 5337 Immediately following the "*" token is a number that represents a 5338 message count. 5340 7.3.1. EXISTS Response 5342 Contents: none 5344 The EXISTS response reports the number of messages in the mailbox. 5345 This response occurs as a result of a SELECT or EXAMINE command, and 5346 if the size of the mailbox changes (e.g., new messages). 5348 The update from the EXISTS response MUST be recorded by the client. 5350 Example: S: * 23 EXISTS 5352 7.4. Server Responses - Message Status 5354 These responses are always untagged. This is how message data are 5355 transmitted from the server to the client, often as a result of a 5356 command with the same name. Immediately following the "*" token is a 5357 number that represents a message sequence number. 5359 7.4.1. EXPUNGE Response 5361 Contents: none 5363 The EXPUNGE response reports that the specified message sequence 5364 number has been permanently removed from the mailbox. The message 5365 sequence number for each successive message in the mailbox is 5366 immediately decremented by 1, and this decrement is reflected in 5367 message sequence numbers in subsequent responses (including other 5368 untagged EXPUNGE responses). 5370 The EXPUNGE response also decrements the number of messages in the 5371 mailbox; it is not necessary to send an EXISTS response with the new 5372 value. 5374 As a result of the immediate decrement rule, message sequence numbers 5375 that appear in a set of successive EXPUNGE responses depend upon 5376 whether the messages are removed starting from lower numbers to 5377 higher numbers, or from higher numbers to lower numbers. For 5378 example, if the last 5 messages in a 9-message mailbox are expunged, 5379 a "lower to higher" server will send five untagged EXPUNGE responses 5380 for message sequence number 5, whereas a "higher to lower server" 5381 will send successive untagged EXPUNGE responses for message sequence 5382 numbers 9, 8, 7, 6, and 5. 5384 An EXPUNGE response MUST NOT be sent when no command is in progress, 5385 nor while responding to a FETCH, STORE, or SEARCH command. This rule 5386 is necessary to prevent a loss of synchronization of message sequence 5387 numbers between client and server. A command is not "in progress" 5388 until the complete command has been received; in particular, a 5389 command is not "in progress" during the negotiation of command 5390 continuation. 5392 Note: UID FETCH, UID STORE, and UID SEARCH are different commands 5393 from FETCH, STORE, and SEARCH. An EXPUNGE response MAY be sent 5394 during a UID command. 5396 The update from the EXPUNGE response MUST be recorded by the client. 5398 Example: S: * 44 EXPUNGE 5400 7.4.2. FETCH Response 5402 Contents: message data 5404 The FETCH response returns data about a message to the client. The 5405 data are pairs of data item names and their values in parentheses. 5406 This response occurs as the result of a FETCH or STORE command, as 5407 well as by unilateral server decision (e.g., flag updates). 5409 The current data items are: 5411 BINARY[]<> 5413 An or expressing the content of the 5414 specified section after removing any Content-Transfer-Encoding- 5415 related encoding. If is present it refers to the 5416 offset within the DECODED section data. 5418 If the domain of the decoded data is "8bit" and the data does 5419 not contain the NUL octet, the server SHOULD return the data in 5420 a instead of a ; this allows the client to 5421 determine if the "8bit" data contains the NUL octet without 5422 having to explicitly scan the data stream for for NULs. 5424 Messaging clients and servers have been notoriously lax in 5425 their adherence to the Internet CRLF convention for terminating 5426 lines of textual data (text/* media types) in Internet 5427 protocols. When sending data in BINARY[...] FETCH data item, 5428 servers MUST ensure that textual line-oriented sections are 5429 always transmitted using the IMAP4 CRLF line termination 5430 syntax, regardless of the underlying storage representation of 5431 the data on the server. 5433 If the server does not know how to decode the section's 5434 Content-Transfer-Encoding, it MUST fail the request and issue a 5435 "NO" response that contains the "UNKNOWN-CTE" response code. 5437 BINARY.SIZE[] 5439 The size of the section after removing any Content-Transfer- 5440 Encoding-related encoding. The value returned MUST match the 5441 size of the or that will be returned by 5442 the corresponding FETCH BINARY request. 5444 If the server does not know how to decode the section's 5445 Content-Transfer-Encoding, it MUST fail the request and issue a 5446 "NO" response that contains the "UNKNOWN-CTE" response code. 5448 BODY A form of BODYSTRUCTURE without extension data. 5450 BODY[
]<> 5452 A string expressing the body contents of the specified section. 5453 The string SHOULD be interpreted by the client according to the 5454 content transfer encoding, body type, and subtype. 5456 If the origin octet is specified, this string is a substring of 5457 the entire body contents, starting at that origin octet. This 5458 means that BODY[]<0> MAY be truncated, but BODY[] is NEVER 5459 truncated. 5461 Note: The origin octet facility MUST NOT be used by a server 5462 in a FETCH response unless the client specifically requested 5463 it by means of a FETCH of a BODY[
]<> data 5464 item. 5466 8-bit textual data is permitted if a [CHARSET] identifier is 5467 part of the body parameter parenthesized list for this section. 5468 Note that headers (part specifiers HEADER or MIME, or the 5469 header portion of a MESSAGE/RFC822 or MESSAGE/GLOBAL part), MAY 5470 be in UTF-8. Note also that the [RFC-5322] delimiting blank 5471 line between the header and the body is not affected by header 5472 line subsetting; the blank line is always included as part of 5473 header data, except in the case of a message which has no body 5474 and no blank line. 5476 Non-textual data such as binary data MUST be transfer encoded 5477 into a textual form, such as BASE64, prior to being sent to the 5478 client. To derive the original binary data, the client MUST 5479 decode the transfer encoded string. 5481 BODYSTRUCTURE 5483 A parenthesized list that describes the [MIME-IMB] body 5484 structure of a message. This is computed by the server by 5485 parsing the [MIME-IMB] header fields, defaulting various fields 5486 as necessary. 5488 For example, a simple text message of 48 lines and 2279 octets 5489 can have a body structure of: ("TEXT" "PLAIN" ("CHARSET" "US- 5490 ASCII") NIL NIL "7BIT" 2279 48) 5492 Multiple parts are indicated by parenthesis nesting. Instead 5493 of a body type as the first element of the parenthesized list, 5494 there is a sequence of one or more nested body structures. The 5495 second element of the parenthesized list is the multipart 5496 subtype (mixed, digest, parallel, alternative, etc.). 5498 For example, a two part message consisting of a text and a 5499 BASE64-encoded text attachment can have a body structure of: 5500 (("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 1152 5501 23)("TEXT" "PLAIN" ("CHARSET" "US-ASCII" "NAME" "cc.diff") 5502 "<960723163407.20117h@cac.washington.edu>" "Compiler diff" 5503 "BASE64" 4554 73) "MIXED") 5505 Extension data follows the multipart subtype. Extension data 5506 is never returned with the BODY fetch, but can be returned with 5507 a BODYSTRUCTURE fetch. Extension data, if present, MUST be in 5508 the defined order. The extension data of a multipart body part 5509 are in the following order: 5511 body parameter parenthesized list A parenthesized list of 5512 attribute/value pairs [e.g., ("foo" "bar" "baz" "rag") where 5513 "bar" is the value of "foo", and "rag" is the value of 5514 "baz"] as defined in [MIME-IMB]. Servers SHOULD decode 5515 parameter value continuations and parameter value character 5516 sets as described in [RFC2231], for example, if the message 5517 contains parameters "baz*0", "baz*1" and "baz*2", the server 5518 should RFC2231-decode them, concatenate and return the 5519 resulting value as a parameter "baz". Similarly, if the 5520 message contains parameters "foo*0*" and "foo*1*", the 5521 server should RFC2231-decode them, convert to UTF-8, 5522 concatenate and return the resulting value as a parameter 5523 "foo*". 5525 body disposition A parenthesized list, consisting of a 5526 disposition type string, followed by a parenthesized list of 5527 disposition attribute/value pairs as defined in 5528 [DISPOSITION]. Servers SHOULD decode parameter value 5529 continuations as described in [RFC2231]. 5531 body language A string or parenthesized list giving the body 5532 language value as defined in [LANGUAGE-TAGS]. 5534 body location A string giving the body content URI as defined 5535 in [LOCATION]. 5537 Any following extension data are not yet defined in this 5538 version of the protocol. Such extension data can consist of 5539 zero or more NILs, strings, numbers, or potentially nested 5540 parenthesized lists of such data. Client implementations that 5541 do a BODYSTRUCTURE fetch MUST be prepared to accept such 5542 extension data. Server implementations MUST NOT send such 5543 extension data until it has been defined by a revision of this 5544 protocol. 5546 The basic fields of a non-multipart body part are in the 5547 following order: 5549 body type A string giving the content media type name as 5550 defined in [MIME-IMB]. 5552 body subtype A string giving the content subtype name as 5553 defined in [MIME-IMB]. 5555 body parameter parenthesized list A parenthesized list of 5556 attribute/value pairs [e.g., ("foo" "bar" "baz" "rag") where 5557 "bar" is the value of "foo" and "rag" is the value of "baz"] 5558 as defined in [MIME-IMB]. 5560 body id A string giving the Content-ID header field value as 5561 defined in Section 7 of [MIME-IMB]. 5563 body description A string giving the Content-Description 5564 header field value as defined in Section 8 of [MIME-IMB]. 5566 body encoding A string giving the content transfer encoding as 5567 defined in Section 6 of [MIME-IMB]. 5569 body size A number giving the size of the body in octets. 5570 Note that this size is the size in its transfer encoding and 5571 not the resulting size after any decoding. 5573 A body type of type MESSAGE and subtype RFC822 contains, 5574 immediately after the basic fields, the envelope structure, 5575 body structure, and size in text lines of the encapsulated 5576 message. 5578 A body type of type TEXT contains, immediately after the basic 5579 fields, the size of the body in text lines. Note that this 5580 size is the size in its content transfer encoding and not the 5581 resulting size after any decoding. 5583 Extension data follows the basic fields and the type-specific 5584 fields listed above. Extension data is never returned with the 5585 BODY fetch, but can be returned with a BODYSTRUCTURE fetch. 5586 Extension data, if present, MUST be in the defined order. 5588 The extension data of a non-multipart body part are in the 5589 following order: 5591 body MD5 A string giving the body MD5 value as defined in 5592 [MD5]. 5594 body disposition A parenthesized list with the same content 5595 and function as the body disposition for a multipart body 5596 part. 5598 body language A string or parenthesized list giving the body 5599 language value as defined in [LANGUAGE-TAGS]. 5601 body location A string giving the body content URI as defined 5602 in [LOCATION]. 5604 Any following extension data are not yet defined in this 5605 version of the protocol, and would be as described above under 5606 multipart extension data. 5608 ENVELOPE 5610 A parenthesized list that describes the envelope structure of a 5611 message. This is computed by the server by parsing the 5612 [RFC-5322] header into the component parts, defaulting various 5613 fields as necessary. 5615 The fields of the envelope structure are in the following 5616 order: date, subject, from, sender, reply-to, to, cc, bcc, in- 5617 reply-to, and message-id. The date, subject, in-reply-to, and 5618 message-id fields are strings. The from, sender, reply-to, to, 5619 cc, and bcc fields are parenthesized lists of address 5620 structures. 5622 An address structure is a parenthesized list that describes an 5623 electronic mail address. The fields of an address structure 5624 are in the following order: personal name, [SMTP] at-domain- 5625 list (source route, obs-route), mailbox name, and host name. 5627 [RFC-5322] group syntax is indicated by a special form of 5628 address structure in which the host name field is NIL. If the 5629 mailbox name field is also NIL, this is an end of group marker 5630 (semi-colon in RFC 822 syntax). If the mailbox name field is 5631 non-NIL, this is a start of group marker, and the mailbox name 5632 field holds the group name phrase. 5634 If the Date, Subject, In-Reply-To, and Message-ID header lines 5635 are absent in the [RFC-5322] header, the corresponding member 5636 of the envelope is NIL; if these header lines are present but 5637 empty the corresponding member of the envelope is the empty 5638 string. 5640 Note: some servers may return a NIL envelope member in the 5641 "present but empty" case. Clients SHOULD treat NIL and 5642 empty string as identical. 5644 Note: [RFC-5322] requires that all messages have a valid 5645 Date header. Therefore, the date member in the envelope can 5646 not be NIL or the empty string. 5648 Note: [RFC-5322] requires that the In-Reply-To and Message- 5649 ID headers, if present, have non-empty content. Therefore, 5650 the in-reply-to and message-id members in the envelope can 5651 not be the empty string. 5653 If the From, To, Cc, and Bcc header lines are absent in the 5654 [RFC-5322] header, or are present but empty, the corresponding 5655 member of the envelope is NIL. 5657 If the Sender or Reply-To lines are absent in the [RFC-5322] 5658 header, or are present but empty, the server sets the 5659 corresponding member of the envelope to be the same value as 5660 the from member (the client is not expected to know to do 5661 this). 5663 Note: [RFC-5322] requires that all messages have a valid 5664 From header. Therefore, the from, sender, and reply-to 5665 members in the envelope can not be NIL. 5667 FLAGS A parenthesized list of flags that are set for this message. 5669 INTERNALDATE A string representing the internal date of the message. 5671 RFC822.SIZE A number expressing the [RFC-5322] size of the message. 5673 UID A number expressing the unique identifier of the message. 5675 If the server chooses to send unsolicited FETCH responses, they MUST 5676 include UID FETCH item. Note that this is a new requirement when 5677 compared to RFC 3501. 5679 Example: S: * 23 FETCH (FLAGS (\Seen) RFC822.SIZE 44827) 5681 7.5. Server Responses - Command Continuation Request 5683 The command continuation request response is indicated by a "+" token 5684 instead of a tag. This form of response indicates that the server is 5685 ready to accept the continuation of a command from the client. The 5686 remainder of this response is a line of text. 5688 This response is used in the AUTHENTICATE command to transmit server 5689 data to the client, and request additional client data. This 5690 response is also used if an argument to any command is a 5691 synchronizing literal. 5693 The client is not permitted to send the octets of the synchronizing 5694 literal unless the server indicates that it is expected. This 5695 permits the server to process commands and reject errors on a line- 5696 by-line basis. The remainder of the command, including the CRLF that 5697 terminates a command, follows the octets of the literal. If there 5698 are any additional command arguments, the literal octets are followed 5699 by a space and those arguments. 5701 Example: C: A001 LOGIN {11} 5702 S: + Ready for additional command text 5703 C: FRED FOOBAR {7} 5704 S: + Ready for additional command text 5705 C: fat man 5706 S: A001 OK LOGIN completed 5707 C: A044 BLURDYBLOOP {102856} 5708 S: A044 BAD No such command as "BLURDYBLOOP" 5710 8. Sample IMAP4rev2 connection 5712 The following is a transcript of an IMAP4rev2 connection. A long 5713 line in this sample is broken for editorial clarity. 5715 S: * OK IMAP4rev2 Service Ready 5716 C: a001 login mrc secret 5717 S: a001 OK LOGIN completed 5718 C: a002 select inbox 5719 S: * 18 EXISTS 5720 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 5721 S: * OK [UIDVALIDITY 3857529045] UIDs valid 5722 S: a002 OK [READ-WRITE] SELECT completed 5723 C: a003 fetch 12 full 5724 S: * 12 FETCH (FLAGS (\Seen) INTERNALDATE "17-Jul-1996 02:44:25 -0700" 5725 RFC822.SIZE 4286 ENVELOPE ("Wed, 17 Jul 1996 02:23:25 -0700 (PDT)" 5726 "IMAP4rev2 WG mtg summary and minutes" 5727 (("Terry Gray" NIL "gray" "cac.washington.edu")) 5728 (("Terry Gray" NIL "gray" "cac.washington.edu")) 5729 (("Terry Gray" NIL "gray" "cac.washington.edu")) 5730 ((NIL NIL "imap" "cac.washington.edu")) 5731 ((NIL NIL "minutes" "CNRI.Reston.VA.US") 5732 ("John Klensin" NIL "KLENSIN" "MIT.EDU")) NIL NIL 5733 "") 5734 BODY ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 3028 5735 92)) 5736 S: a003 OK FETCH completed 5737 C: a004 fetch 12 body[header] 5738 S: * 12 FETCH (BODY[HEADER] {342} 5739 S: Date: Wed, 17 Jul 1996 02:23:25 -0700 (PDT) 5740 S: From: Terry Gray 5741 S: Subject: IMAP4rev2 WG mtg summary and minutes 5742 S: To: imap@cac.washington.edu 5743 S: cc: minutes@CNRI.Reston.VA.US, John Klensin 5744 S: Message-Id: 5745 S: MIME-Version: 1.0 5746 S: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 5747 S: 5748 S: ) 5749 S: a004 OK FETCH completed 5750 C: a005 store 12 +flags \deleted 5751 S: * 12 FETCH (FLAGS (\Seen \Deleted)) 5752 S: a005 OK +FLAGS completed 5753 C: a006 logout 5754 S: * BYE IMAP4rev2 server terminating connection 5755 S: a006 OK LOGOUT completed 5757 9. Formal Syntax 5759 The following syntax specification uses the Augmented Backus-Naur 5760 Form (ABNF) notation as specified in [ABNF]. 5762 In the case of alternative or optional rules in which a later rule 5763 overlaps an earlier rule, the rule which is listed earlier MUST take 5764 priority. For example, "\Seen" when parsed as a flag is the \Seen 5765 flag name and not a flag-extension, even though "\Seen" can be parsed 5766 as a flag-extension. Some, but not all, instances of this rule are 5767 noted below. 5769 Note: [ABNF] rules MUST be followed strictly; in particular: 5771 (1) Except as noted otherwise, all alphabetic characters are case- 5772 insensitive. The use of upper or lower case characters to define 5773 token strings is for editorial clarity only. Implementations MUST 5774 accept these strings in a case-insensitive fashion. 5776 (2) In all cases, SP refers to exactly one space. It is NOT 5777 permitted to substitute TAB, insert additional spaces, or 5778 otherwise treat SP as being equivalent to LWSP. 5780 (3) The ASCII NUL character, %x00, MUST NOT be used at any time. 5782 address = "(" addr-name SP addr-adl SP addr-mailbox SP 5783 addr-host ")" 5785 addr-adl = nstring 5786 ; Holds route from [RFC-5322] obs-route if 5787 ; non-NIL 5789 addr-host = nstring 5790 ; NIL indicates [RFC-5322] group syntax. 5791 ; Otherwise, holds [RFC-5322] domain name 5793 addr-mailbox = nstring 5794 ; NIL indicates end of [RFC-5322] group; if 5795 ; non-NIL and addr-host is NIL, holds 5796 ; [RFC-5322] group name. 5797 ; Otherwise, holds [RFC-5322] local-part 5798 ; after removing [RFC-5322] quoting 5800 addr-name = nstring 5801 ; If non-NIL, holds phrase from [RFC-5322] 5802 ; mailbox after removing [RFC-5322] quoting 5804 append = "APPEND" SP mailbox [SP flag-list] [SP date-time] SP 5805 literal 5807 append-uid = uniqueid 5809 astring = 1*ASTRING-CHAR / string 5810 ASTRING-CHAR = ATOM-CHAR / resp-specials 5812 atom = 1*ATOM-CHAR 5814 ATOM-CHAR = 5816 atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards / 5817 quoted-specials / resp-specials 5819 authenticate = "AUTHENTICATE" SP auth-type [SP initial-resp] 5820 *(CRLF base64) 5822 auth-type = atom 5823 ; Defined by [SASL] 5825 base64 = *(4base64-char) [base64-terminal] 5827 base64-char = ALPHA / DIGIT / "+" / "/" 5828 ; Case-sensitive 5830 base64-terminal = (2base64-char "==") / (3base64-char "=") 5832 body = "(" (body-type-1part / body-type-mpart) ")" 5834 body-extension = nstring / number / 5835 "(" body-extension *(SP body-extension) ")" 5836 ; Future expansion. Client implementations 5837 ; MUST accept body-extension fields. Server 5838 ; implementations MUST NOT generate 5839 ; body-extension fields except as defined by 5840 ; future standard or standards-track 5841 ; revisions of this specification. 5843 body-ext-1part = body-fld-md5 [SP body-fld-dsp [SP body-fld-lang 5844 [SP body-fld-loc *(SP body-extension)]]] 5845 ; MUST NOT be returned on non-extensible 5846 ; "BODY" fetch 5848 body-ext-mpart = body-fld-param [SP body-fld-dsp [SP body-fld-lang 5849 [SP body-fld-loc *(SP body-extension)]]] 5850 ; MUST NOT be returned on non-extensible 5851 ; "BODY" fetch 5853 body-fields = body-fld-param SP body-fld-id SP body-fld-desc SP 5854 body-fld-enc SP body-fld-octets 5856 body-fld-desc = nstring 5857 body-fld-dsp = "(" string SP body-fld-param ")" / nil 5859 body-fld-enc = (DQUOTE ("7BIT" / "8BIT" / "BINARY" / "BASE64"/ 5860 "QUOTED-PRINTABLE") DQUOTE) / string 5862 body-fld-id = nstring 5864 body-fld-lang = nstring / "(" string *(SP string) ")" 5866 body-fld-loc = nstring 5868 body-fld-lines = number 5870 body-fld-md5 = nstring 5872 body-fld-octets = number 5874 body-fld-param = "(" string SP string *(SP string SP string) ")" / nil 5876 body-type-1part = (body-type-basic / body-type-msg / body-type-text) 5877 [SP body-ext-1part] 5879 body-type-basic = media-basic SP body-fields 5880 ; MESSAGE subtype MUST NOT be "RFC822" or "GLOBAL" 5882 body-type-mpart = 1*body SP media-subtype 5883 [SP body-ext-mpart] 5884 ; MULTIPART body part 5886 body-type-msg = media-message SP body-fields SP envelope 5887 SP body SP body-fld-lines 5889 body-type-text = media-text SP body-fields SP body-fld-lines 5891 capability = ("AUTH=" auth-type) / atom 5892 ; New capabilities MUST begin with "X" or be 5893 ; registered with IANA in 5894 ; a standards-track, an experimental 5895 ; or an informational RFC. 5897 capability-data = "CAPABILITY" *(SP capability) SP "IMAP4rev2" 5898 *(SP capability) 5899 ; Servers MUST implement the STARTTLS, AUTH=PLAIN, 5900 ; and LOGINDISABLED capabilities. 5901 ; Servers which offer RFC 1730 compatibility MUST 5902 ; list "IMAP4" as the first capability. 5903 ; Servers which offer RFC 3501 compatibility MUST 5904 ; list "IMAP4rev1" as one of capabilities. 5906 CHAR = 5908 CHAR8 = %x01-ff 5909 ; any OCTET except NUL, %x00 5911 charset = atom / quoted 5913 childinfo-extended-item = "CHILDINFO" SP "(" 5914 list-select-base-opt-quoted 5915 *(SP list-select-base-opt-quoted) ")" 5916 ; Extended data item (mbox-list-extended-item) 5917 ; returned when the RECURSIVEMATCH 5918 ; selection option is specified. 5919 ; Note 1: the CHILDINFO extended data item tag can be 5920 ; returned with and without surrounding quotes, as per 5921 ; mbox-list-extended-item-tag production. 5922 ; Note 2: The selection options are always returned 5923 ; quoted, unlike their specification in 5924 ; the extended LIST command. 5926 child-mbox-flag = "\HasChildren" / "\HasNoChildren" 5927 ; attributes for CHILDREN return option, at most one 5928 ; possible per LIST response 5930 command = tag SP (command-any / command-auth / command-nonauth / 5931 command-select) CRLF 5932 ; Modal based on state 5934 command-any = "CAPABILITY" / "LOGOUT" / "NOOP" / enable / x-command 5935 ; Valid in all states 5937 command-auth = append / create / delete / examine / list / 5938 Namespace-Command / 5939 rename / select / status / subscribe / unsubscribe / 5940 idle 5941 ; Valid only in Authenticated or Selected state 5943 command-nonauth = login / authenticate / "STARTTLS" 5944 ; Valid only when in Not Authenticated state 5946 command-select = "CLOSE" / "UNSELECT" / "EXPUNGE" / copy / 5947 move / fetch / store / search / uid 5948 ; Valid only when in Selected state 5950 continue-req = "+" SP (resp-text / base64) CRLF 5952 copy = "COPY" SP sequence-set SP mailbox 5953 create = "CREATE" SP mailbox 5954 ; Use of INBOX gives a NO error 5956 date = date-text / DQUOTE date-text DQUOTE 5958 date-day = 1*2DIGIT 5959 ; Day of month 5961 date-day-fixed = (SP DIGIT) / 2DIGIT 5962 ; Fixed-format version of date-day 5964 date-month = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / 5965 "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec" 5967 date-text = date-day "-" date-month "-" date-year 5969 date-year = 4DIGIT 5971 date-time = DQUOTE date-day-fixed "-" date-month "-" date-year 5972 SP time SP zone DQUOTE 5974 delete = "DELETE" SP mailbox 5975 ; Use of INBOX gives a NO error 5977 digit-nz = %x31-39 5978 ; 1-9 5980 eitem-standard-tag = atom 5981 ; a tag for LIST extended data item defined in a Standard 5982 ; Track or Experimental RFC. 5984 eitem-vendor-tag = vendor-token "-" atom 5985 ; a vendor-specific tag for LIST extended data item 5987 enable = "ENABLE" 1*(SP capability) 5989 enable-data = "ENABLED" *(SP capability) 5991 envelope = "(" env-date SP env-subject SP env-from SP 5992 env-sender SP env-reply-to SP env-to SP env-cc SP 5993 env-bcc SP env-in-reply-to SP env-message-id ")" 5995 env-bcc = "(" 1*address ")" / nil 5997 env-cc = "(" 1*address ")" / nil 5999 env-date = nstring 6000 env-from = "(" 1*address ")" / nil 6002 env-in-reply-to = nstring 6004 env-message-id = nstring 6006 env-reply-to = "(" 1*address ")" / nil 6008 env-sender = "(" 1*address ")" / nil 6010 env-subject = nstring 6012 env-to = "(" 1*address ")" / nil 6014 esearch-response = "ESEARCH" [search-correlator] [SP "UID"] 6015 *(SP search-return-data) 6016 ; ESEARCH response replaces SEARCH response 6017 ; from IMAP4rev1. 6019 examine = "EXAMINE" SP mailbox 6021 fetch = "FETCH" SP sequence-set SP ("ALL" / "FULL" / "FAST" / 6022 fetch-att / "(" fetch-att *(SP fetch-att) ")") 6024 fetch-att = "ENVELOPE" / "FLAGS" / "INTERNALDATE" / 6025 "RFC822.SIZE" / 6026 "BODY" ["STRUCTURE"] / "UID" / 6027 "BODY" section [partial] / 6028 "BODY.PEEK" section [partial] / 6029 "BINARY" [".PEEK"] section-binary [partial] / 6030 "BINARY.SIZE" section-binary 6032 flag = "\Answered" / "\Flagged" / "\Deleted" / 6033 "\Seen" / "\Draft" / flag-keyword / flag-extension 6034 ; Does not include "\Recent" 6036 flag-extension = "\" atom 6037 ; Future expansion. Client implementations 6038 ; MUST accept flag-extension flags. Server 6039 ; implementations MUST NOT generate 6040 ; flag-extension flags except as defined by 6041 ; future standard or standards-track 6042 ; revisions of this specification. 6043 ; "\Recent" was defined in RFC 3501 6044 ; and is now deprecated. 6046 flag-fetch = flag 6047 flag-keyword = "$MDNSent" / "$Forwarded" / "$Junk" / 6048 "$NotJunk" / "$Phishing" / atom 6050 flag-list = "(" [flag *(SP flag)] ")" 6052 flag-perm = flag / "\*" 6054 greeting = "*" SP (resp-cond-auth / resp-cond-bye) CRLF 6056 header-fld-name = astring 6058 header-list = "(" header-fld-name *(SP header-fld-name) ")" 6060 idle = "IDLE" CRLF "DONE" 6062 initial-resp = (base64 / "=") 6063 ; "initial response" defined in 6064 ; Section 5.1 of [RFC4422] 6066 list = "LIST" [SP list-select-opts] SP mailbox SP mbox-or-pat 6067 [SP list-return-opts] 6069 list-mailbox = 1*list-char / string 6071 list-char = ATOM-CHAR / list-wildcards / resp-specials 6073 list-return-opts = "RETURN" SP 6074 "(" [return-option *(SP return-option)] ")" 6075 ; list return options, e.g., CHILDREN 6077 list-select-base-opt = "SUBSCRIBED" / option-extension 6078 ; options that can be used by themselves 6080 list-select-base-opt-quoted = DQUOTE list-select-base-opt DQUOTE 6082 list-select-independent-opt = "REMOTE" / option-extension 6083 ; options that do not syntactically interact with 6084 ; other options 6086 list-select-mod-opt = "RECURSIVEMATCH" / option-extension 6087 ; options that require a list-select-base-opt 6088 ; to also be present 6090 list-select-opt = list-select-base-opt / list-select-independent-opt 6091 / list-select-mod-opt 6092 ; An option registration template is described in 6093 ; Section 9.3 of this document. 6095 list-select-opts = "(" [ 6096 (*(list-select-opt SP) list-select-base-opt 6097 *(SP list-select-opt)) 6098 / (list-select-independent-opt 6099 *(SP list-select-independent-opt)) 6100 ] ")" 6101 ; Any number of options may be in any order. 6102 ; If a list-select-mod-opt appears, then a 6103 ; list-select-base-opt must also appear. 6104 ; This allows these: 6105 ; () 6106 ; (REMOTE) 6107 ; (SUBSCRIBED) 6108 ; (SUBSCRIBED REMOTE) 6109 ; (SUBSCRIBED RECURSIVEMATCH) 6110 ; (SUBSCRIBED REMOTE RECURSIVEMATCH) 6111 ; But does NOT allow these: 6112 ; (RECURSIVEMATCH) 6113 ; (REMOTE RECURSIVEMATCH) 6115 list-wildcards = "%" / "*" 6117 literal = "{" number ["+"] "}" CRLF *CHAR8 6118 ; represents the number of CHAR8s. 6119 ; A non-synchronizing literal is distinguished from 6120 ; a synchronizing literal by presence of the "+" 6121 ; before the closing "}". 6122 ; Non synchronizing literals are not allowed when 6123 ; sent from server to the client. 6125 literal8 = "~{" number "}" CRLF *OCTET 6126 ; represents the number of OCTETs 6127 ; in the response string. 6129 login = "LOGIN" SP userid SP password 6131 mailbox = "INBOX" / astring 6132 ; INBOX is case-insensitive. All case variants of 6133 ; INBOX (e.g., "iNbOx") MUST be interpreted as INBOX 6134 ; not as an astring. An astring which consists of 6135 ; the case-insensitive sequence "I" "N" "B" "O" "X" 6136 ; is considered to be INBOX and not an astring. 6137 ; Refer to section 5.1 for further 6138 ; semantic details of mailbox names. 6140 mailbox-data = "FLAGS" SP flag-list / "LIST" SP mailbox-list / 6141 esearch-response / 6142 "STATUS" SP mailbox SP "(" [status-att-list] ")" / 6143 number SP "EXISTS" / Namespace-Response 6145 mailbox-list = "(" [mbx-list-flags] ")" SP 6146 (DQUOTE QUOTED-CHAR DQUOTE / nil) SP mailbox 6147 [SP mbox-list-extended] 6148 ; This is the list information pointed to by the ABNF 6149 ; item "mailbox-data", which is defined in [IMAP4] 6151 mbox-list-extended = "(" [mbox-list-extended-item 6152 *(SP mbox-list-extended-item)] ")" 6154 mbox-list-extended-item = mbox-list-extended-item-tag SP 6155 tagged-ext-val 6157 mbox-list-extended-item-tag = astring 6158 ; The content MUST conform to either "eitem-vendor-tag" 6159 ; or "eitem-standard-tag" ABNF productions. 6161 mbox-or-pat = list-mailbox / patterns 6163 mbx-list-flags = *(mbx-list-oflag SP) mbx-list-sflag 6164 *(SP mbx-list-oflag) / 6165 mbx-list-oflag *(SP mbx-list-oflag) 6167 mbx-list-oflag = "\Noinferiors" / child-mbox-flag / 6168 "\Subscribed" / "\Remote" / flag-extension 6169 ; Other flags; multiple possible per LIST response 6171 mbx-list-sflag = "\NonExistent" / "\Noselect" / "\Marked" / "\Unmarked" 6172 ; Selectability flags; only one per LIST response 6174 media-basic = ((DQUOTE ("APPLICATION" / "AUDIO" / "IMAGE" / 6175 "MESSAGE" / "VIDEO" / "FONT") DQUOTE) / string) SP 6176 media-subtype 6177 ; Defined in [MIME-IMT]. 6178 ; FONT defined in RFC YYYY. 6180 media-message = DQUOTE "MESSAGE" DQUOTE SP 6181 DQUOTE ("RFC822" / "GLOBAL") DQUOTE 6182 ; Defined in [MIME-IMT] 6184 media-subtype = string 6185 ; Defined in [MIME-IMT] 6187 media-text = DQUOTE "TEXT" DQUOTE SP media-subtype 6188 ; Defined in [MIME-IMT] 6190 message-data = nz-number SP ("EXPUNGE" / ("FETCH" SP msg-att)) 6191 move = "MOVE" SP sequence-set SP mailbox 6193 msg-att = "(" (msg-att-dynamic / msg-att-static) 6194 *(SP (msg-att-dynamic / msg-att-static)) ")" 6196 msg-att-dynamic = "FLAGS" SP "(" [flag-fetch *(SP flag-fetch)] ")" 6197 ; MAY change for a message 6199 msg-att-static = "ENVELOPE" SP envelope / "INTERNALDATE" SP date-time / 6200 "RFC822.SIZE" SP number / 6201 "BODY" ["STRUCTURE"] SP body / 6202 "BODY" section ["<" number ">"] SP nstring / 6203 "BINARY" section-binary SP (nstring / literal8) / 6204 "BINARY.SIZE" section-binary SP number / 6205 "UID" SP uniqueid 6206 ; MUST NOT change for a message 6208 name-component = 1*UTF8-CHAR 6209 ; MUST NOT contain ".", "/", "%", or "*" 6211 Namespace = nil / "(" 1*Namespace-Descr ")" 6213 Namespace-Command = "NAMESPACE" 6215 Namespace-Descr = "(" string SP 6216 (DQUOTE QUOTED-CHAR DQUOTE / nil) 6217 [Namespace-Response-Extensions] ")" 6219 Namespace-Response-Extensions = *Namespace-Response-Extension 6221 Namespace-Response-Extension = SP string SP 6222 "(" string *(SP string) ")" 6224 Namespace-Response = "NAMESPACE" SP Namespace 6225 SP Namespace SP Namespace 6226 ; The first Namespace is the Personal Namespace(s). 6227 ; The second Namespace is the Other Users' 6228 ; Namespace(s). 6229 ; The third Namespace is the Shared Namespace(s). 6231 nil = "NIL" 6233 nstring = string / nil 6235 number = 1*DIGIT 6236 ; Unsigned 32-bit integer 6237 ; (0 <= n < 4,294,967,296) 6239 number64 = 1*DIGIT 6240 ; Unsigned 63-bit integer 6241 ; (0 <= n <= 9,223,372,036,854,775,807) 6243 nz-number = digit-nz *DIGIT 6244 ; Non-zero unsigned 32-bit integer 6245 ; (0 < n < 4,294,967,296) 6247 oldname-extended-item = "OLDNAME" SP "(" mailbox ")" 6248 ; Extended data item (mbox-list-extended-item) 6249 ; returned in a LIST response when a mailbox is 6250 ; renamed or deleted. Also returned when 6251 ; the server canonicalized the provided mailbox 6252 ; name. 6253 ; Note 1: the OLDNAME tag can be returned 6254 ; with or without surrounding quotes, as per 6255 ; mbox-list-extended-item-tag production. 6257 option-extension = (option-standard-tag / option-vendor-tag) 6258 [SP option-value] 6260 option-standard-tag = atom 6261 ; an option defined in a Standards Track or 6262 ; Experimental RFC 6264 option-val-comp = astring / 6265 option-val-comp *(SP option-val-comp) / 6266 "(" option-val-comp ")" 6268 option-value = "(" option-val-comp ")" 6270 option-vendor-tag = vendor-token "-" atom 6271 ; a vendor-specific option, non-standard 6273 partial-range = number ["." nz-number] 6274 ; Copied from RFC 5092 (IMAP URL) 6276 partial = "<" number "." nz-number ">" 6277 ; Partial FETCH request. 0-based offset of 6278 ; the first octet, followed by the number of octets 6279 ; in the fragment. 6281 password = astring 6283 patterns = "(" list-mailbox ")" 6284 ; [RFC5258] supports multiple patterns, 6285 ; but this document only requires one 6286 ; to be supported. 6288 ; If the server is also implementing 6289 ; [RFC5258], "patterns" syntax from that 6290 ; document must be followed. 6292 quoted = DQUOTE *QUOTED-CHAR DQUOTE 6294 QUOTED-CHAR = / 6295 "\" quoted-specials / UTF8-2 / UTF8-3 / UTF8-4 6297 quoted-specials = DQUOTE / "\" 6299 rename = "RENAME" SP mailbox SP mailbox 6300 ; Use of INBOX as a destination gives a NO error 6302 response = *(continue-req / response-data) response-done 6304 response-data = "*" SP (resp-cond-state / resp-cond-bye / 6305 mailbox-data / message-data / capability-data / 6306 enable-data) CRLF 6308 response-done = response-tagged / response-fatal 6310 response-fatal = "*" SP resp-cond-bye CRLF 6311 ; Server closes connection immediately 6313 response-tagged = tag SP resp-cond-state CRLF 6315 resp-code-apnd = "APPENDUID" SP nz-number SP append-uid 6317 resp-code-copy = "COPYUID" SP nz-number SP uid-set SP uid-set 6319 resp-cond-auth = ("OK" / "PREAUTH") SP resp-text 6320 ; Authentication condition 6322 resp-cond-bye = "BYE" SP resp-text 6324 resp-cond-state = ("OK" / "NO" / "BAD") SP resp-text 6325 ; Status condition 6327 resp-specials = "]" 6329 resp-text = ["[" resp-text-code "]" SP] [text] 6331 resp-text-code = "ALERT" / 6332 "BADCHARSET" [SP "(" charset *(SP charset) ")" ] / 6333 capability-data / "PARSE" / 6334 "PERMANENTFLAGS" SP 6335 "(" [flag-perm *(SP flag-perm)] ")" / 6337 "READ-ONLY" / "READ-WRITE" / "TRYCREATE" / 6338 "UIDNEXT" SP nz-number / "UIDVALIDITY" SP nz-number / 6339 resp-code-apnd / resp-code-copy / "UIDNOTSTICKY" / 6340 "UNAVAILABLE" / "AUTHENTICATIONFAILED" / 6341 "AUTHORIZATIONFAILED" / "EXPIRED" / 6342 "PRIVACYREQUIRED" / "CONTACTADMIN" / "NOPERM" / 6343 "INUSE" / "EXPUNGEISSUED" / "CORRUPTION" / 6344 "SERVERBUG" / "CLIENTBUG" / "CANNOT" / 6345 "LIMIT" / "OVERQUOTA" / "ALREADYEXISTS" / 6346 "NONEXISTENT" / "NOTSAVED" / "HASCHILDREN" / 6347 "CLOSED" / 6348 "UNKNOWN-CTE" / 6349 atom [SP 1*] 6351 return-option = "SUBSCRIBED" / "CHILDREN" / status-option / 6352 option-extension 6354 search = "SEARCH" [search-return-opts] 6355 SP search-program 6357 search-correlator = SP "(" "TAG" SP tag-string ")" 6359 search-key = "ALL" / "ANSWERED" / "BCC" SP astring / 6360 "BEFORE" SP date / "BODY" SP astring / 6361 "CC" SP astring / "DELETED" / "FLAGGED" / 6362 "FROM" SP astring / "KEYWORD" SP flag-keyword / 6363 "ON" SP date / "SEEN" / 6364 "SINCE" SP date / "SUBJECT" SP astring / 6365 "TEXT" SP astring / "TO" SP astring / 6366 "UNANSWERED" / "UNDELETED" / "UNFLAGGED" / 6367 "UNKEYWORD" SP flag-keyword / "UNSEEN" / 6368 ; Above this line were in [IMAP2] 6369 "DRAFT" / "HEADER" SP header-fld-name SP astring / 6370 "LARGER" SP number / "NOT" SP search-key / 6371 "OR" SP search-key SP search-key / 6372 "SENTBEFORE" SP date / "SENTON" SP date / 6373 "SENTSINCE" SP date / "SMALLER" SP number / 6374 "UID" SP sequence-set / "UNDRAFT" / sequence-set / 6375 "(" search-key *(SP search-key) ")" 6377 search-modifier-name = tagged-ext-label 6379 search-mod-params = tagged-ext-val 6380 ; This non-terminal shows recommended syntax 6381 ; for future extensions. 6383 search-program = ["CHARSET" SP charset SP] 6384 search-key *(SP search-key) 6385 ; CHARSET argument to SEARCH MUST be 6386 ; registered with IANA. 6388 search-ret-data-ext = search-modifier-name SP search-return-value 6389 ; Note that not every SEARCH return option 6390 ; is required to have the corresponding 6391 ; ESEARCH return data. 6393 search-return-data = "MIN" SP nz-number / 6394 "MAX" SP nz-number / 6395 "ALL" SP sequence-set / 6396 "COUNT" SP number / 6397 search-ret-data-ext 6398 ; All return data items conform to 6399 ; search-ret-data-ext syntax. 6400 ; Note that "$" marker is not allowed 6401 ; after the ALL return data item. 6403 search-return-opts = SP "RETURN" SP "(" [search-return-opt 6404 *(SP search-return-opt)] ")" 6406 search-return-opt = "MIN" / "MAX" / "ALL" / "COUNT" / 6407 "SAVE" / 6408 search-ret-opt-ext 6409 ; conforms to generic search-ret-opt-ext 6410 ; syntax 6412 search-ret-opt-ext = search-modifier-name [SP search-mod-params] 6414 search-return-value = tagged-ext-val 6415 ; Data for the returned search option. 6416 ; A single "nz-number"/"number"/"number64" value 6417 ; can be returned as an atom (i.e., without 6418 ; quoting). A sequence-set can be returned 6419 ; as an atom as well. 6421 section = "[" [section-spec] "]" 6423 section-binary = "[" [section-part] "]" 6425 section-msgtext = "HEADER" / "HEADER.FIELDS" [".NOT"] SP header-list / 6426 "TEXT" 6427 ; top-level or MESSAGE/RFC822 or MESSAGE/GLOBAL part 6429 section-part = nz-number *("." nz-number) 6430 ; body part reference. 6431 ; Allows for accessing nested body parts. 6433 section-spec = section-msgtext / (section-part ["." section-text]) 6435 section-text = section-msgtext / "MIME" 6436 ; text other than actual body part (headers, etc.) 6438 select = "SELECT" SP mailbox 6440 seq-number = nz-number / "*" 6441 ; message sequence number (COPY, FETCH, STORE 6442 ; commands) or unique identifier (UID COPY, 6443 ; UID FETCH, UID STORE commands). 6444 ; * represents the largest number in use. In 6445 ; the case of message sequence numbers, it is 6446 ; the number of messages in a non-empty mailbox. 6447 ; In the case of unique identifiers, it is the 6448 ; unique identifier of the last message in the 6449 ; mailbox or, if the mailbox is empty, the 6450 ; mailbox's current UIDNEXT value. 6451 ; The server should respond with a tagged BAD 6452 ; response to a command that uses a message 6453 ; sequence number greater than the number of 6454 ; messages in the selected mailbox. This 6455 ; includes "*" if the selected mailbox is empty. 6457 seq-range = seq-number ":" seq-number 6458 ; two seq-number values and all values between 6459 ; these two regardless of order. 6460 ; Example: 2:4 and 4:2 are equivalent and indicate 6461 ; values 2, 3, and 4. 6462 ; Example: a unique identifier sequence range of 6463 ; 3291:* includes the UID of the last message in 6464 ; the mailbox, even if that value is less than 3291. 6466 sequence-set = (seq-number / seq-range) ["," sequence-set] 6467 ; set of seq-number values, regardless of order. 6468 ; Servers MAY coalesce overlaps and/or execute the 6469 ; sequence in any order. 6470 ; Example: a message sequence number set of 6471 ; 2,4:7,9,12:* for a mailbox with 15 messages is 6472 ; equivalent to 2,4,5,6,7,9,12,13,14,15 6473 ; Example: a message sequence number set of *:4,5:7 6474 ; for a mailbox with 10 messages is equivalent to 6475 ; 10,9,8,7,6,5,4,5,6,7 and MAY be reordered and 6476 ; overlap coalesced to be 4,5,6,7,8,9,10. 6478 sequence-set =/ seq-last-command 6479 ; Allow for "result of the last command" indicator. 6481 seq-last-command = "$" 6483 status = "STATUS" SP mailbox SP 6484 "(" status-att *(SP status-att) ")" 6486 status-att = "MESSAGES" / "UIDNEXT" / "UIDVALIDITY" / 6487 "UNSEEN" / "DELETED" / "SIZE" 6489 status-att-val = ("MESSAGES" SP number) / 6490 ("UIDNEXT" SP nz-number) / 6491 ("UIDVALIDITY" SP nz-number) / 6492 ("UNSEEN" SP number) / 6493 ("DELETED" SP number) / 6494 ("SIZE" SP number64) 6495 ; Extensions to the STATUS responses 6496 ; should extend this production. 6497 ; Extensions should use the generic 6498 ; syntax defined by tagged-ext. 6500 status-att-list = status-att-val *(SP status-att-val) 6502 status-option = "STATUS" SP "(" status-att *(SP status-att) ")" 6503 ; This ABNF production complies with 6504 ; syntax. 6506 store = "STORE" SP sequence-set SP store-att-flags 6508 store-att-flags = (["+" / "-"] "FLAGS" [".SILENT"]) SP 6509 (flag-list / (flag *(SP flag))) 6511 string = quoted / literal 6513 subscribe = "SUBSCRIBE" SP mailbox 6515 tag = 1* 6517 tag-string = astring 6518 ; represented as 6520 tagged-ext-label = tagged-label-fchar *tagged-label-char 6521 ;; Is a valid RFC 3501 "atom". 6523 tagged-label-fchar = ALPHA / "-" / "_" / "." 6525 tagged-label-char = tagged-label-fchar / DIGIT / ":" 6527 tagged-ext-comp = astring / 6528 tagged-ext-comp *(SP tagged-ext-comp) / 6529 "(" tagged-ext-comp ")" 6530 ;; Extensions that follow this general 6531 ;; syntax should use nstring instead of 6532 ;; astring when appropriate in the context 6533 ;; of the extension. 6534 ;; Note that a message set or a "number" 6535 ;; can always be represented as an "atom". 6536 ;; An URL should be represented as 6537 ;; a "quoted" string. 6539 tagged-ext-simple = sequence-set / number / number64 6541 tagged-ext-val = tagged-ext-simple / 6542 "(" [tagged-ext-comp] ")" 6544 text = 1*TEXT-CHAR 6546 TEXT-CHAR = 6548 time = 2DIGIT ":" 2DIGIT ":" 2DIGIT 6549 ; Hours minutes seconds 6551 uid = "UID" SP 6552 (copy / move / fetch / search / store / uid-expunge) 6553 ; Unique identifiers used instead of message 6554 ; sequence numbers 6556 uid-expunge = "EXPUNGE" SP sequence-set 6557 ; Unique identifiers used instead of message 6558 ; sequence numbers 6560 uid-set = (uniqueid / uid-range) *("," uid-set) 6562 uid-range = (uniqueid ":" uniqueid) 6563 ; two uniqueid values and all values 6564 ; between these two regards of order. 6565 ; Example: 2:4 and 4:2 are equivalent. 6567 uniqueid = nz-number 6568 ; Strictly ascending 6570 unsubscribe = "UNSUBSCRIBE" SP mailbox 6572 userid = astring 6574 UTF8-2 = 6576 UTF8-3 = 6577 UTF8-4 = 6579 vendor-token = "vendor." name-component 6580 ; Definition copied from RFC 2244. 6581 ; MUST be registered with IANA 6583 x-command = "X" atom 6585 zone = ("+" / "-") 4DIGIT 6586 ; Signed four-digit value of hhmm representing 6587 ; hours and minutes east of Greenwich (that is, 6588 ; the amount that the given time differs from 6589 ; Universal Time). Subtracting the timezone 6590 ; from the given time will give the UT form. 6591 ; The Universal Time zone is "+0000". 6593 10. Author's Note 6595 This document is a revision or rewrite of earlier documents, and 6596 supercedes the protocol specification in those documents: RFC 2060, 6597 RFC 1730, unpublished IMAP2bis.TXT document, RFC 1176, and RFC 1064. 6599 11. Security Considerations 6601 IMAP4rev2 protocol transactions, including electronic mail data, are 6602 sent in the clear over the network unless protection from snooping is 6603 negotiated. This can be accomplished either by the use of IMAPS 6604 service, STARTTLS command, negotiated privacy protection in the 6605 AUTHENTICATE command, or some other protection mechanism. 6607 11.1. STARTTLS Security Considerations 6609 IMAP client and server implementations MUST comply with relevant TLS 6610 recommendations from [RFC8314]. Additionally, when using TLS 1.2, 6611 IMAP implementations MUST implement 6612 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 cipher suite, and SHOULD 6613 implement the TLS_RSA_WITH_AES_128_CBC_SHA [TLS] cipher suite. This 6614 is important as it assures that any two compliant implementations can 6615 be configured to interoperate. Other TLS cipher suites recommended 6616 in RFC 7525 are RECOMMENDED: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 6617 TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 and 6618 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384. All other cipher suites are 6619 OPTIONAL. Note that this is a change from section 2.1 of [IMAP-TLS]. 6621 During the [TLS] negotiation, the client MUST check its understanding 6622 of the server hostname against the server's identity as presented in 6623 the server Certificate message, in order to prevent man-in-the-middle 6624 attacks. This procedure is described in [RFC7817]. 6626 Both the client and server MUST check the result of the STARTTLS 6627 command and subsequent [TLS] negotiation to see whether acceptable 6628 authentication and/or privacy was achieved. 6630 11.2. COPYUID and APPENDUID response codes 6632 The COPYUID and APPENDUID response codes return information about the 6633 mailbox, which may be considered sensitive if the mailbox has 6634 permissions set that permit the client to COPY or APPEND to the 6635 mailbox, but not SELECT or EXAMINE it. 6637 Consequently, these response codes SHOULD NOT be issued if the client 6638 does not have access to SELECT or EXAMINE the mailbox. 6640 11.3. LIST command and Other Users' namespace 6642 In response to a LIST command containing an argument of the Other 6643 Users' Namespace prefix, a server SHOULD NOT list users that have not 6644 granted list access to their personal mailboxes to the currently 6645 authenticated user. Providing such a list, could compromise security 6646 by potentially disclosing confidential information of who is located 6647 on the server, or providing a starting point of a list of user 6648 accounts to attack. 6650 11.4. Other Security Considerations 6652 A server error message for an AUTHENTICATE command which fails due to 6653 invalid credentials SHOULD NOT detail why the credentials are 6654 invalid. 6656 Use of the LOGIN command sends passwords in the clear. This can be 6657 avoided by using the AUTHENTICATE command with a [SASL] mechanism 6658 that does not use plaintext passwords, by first negotiating 6659 encryption via STARTTLS or some other protection mechanism. 6661 A server implementation MUST implement a configuration that, at the 6662 time of authentication, requires: 6663 (1) The STARTTLS command has been negotiated. 6664 OR 6665 (2) Some other mechanism that protects the session from password 6666 snooping has been provided. 6667 OR 6668 (3) The following measures are in place: 6669 (a) The LOGINDISABLED capability is advertised, and [SASL] mechanisms 6670 (such as PLAIN) using plaintext passwords are NOT advertised in the 6671 CAPABILITY list. 6672 AND 6673 (b) The LOGIN command returns an error even if the password is 6674 correct. 6675 AND 6676 (c) The AUTHENTICATE command returns an error with all [SASL] 6677 mechanisms that use plaintext passwords, even if the password is 6678 correct. 6680 A server error message for a failing LOGIN command SHOULD NOT specify 6681 that the user name, as opposed to the password, is invalid. 6683 A server SHOULD have mechanisms in place to limit or delay failed 6684 AUTHENTICATE/LOGIN attempts. 6686 Additional security considerations are discussed in the section 6687 discussing the AUTHENTICATE and LOGIN commands. 6689 12. IANA Considerations 6691 IANA is requested to update "Service Names and Transport Protocol 6692 Port Numbers" registry as follows: 6694 1. Registration for TCP port 143 and the corresponding "imap" 6695 service name should be updated to point to this document and RFC 6696 3501. 6698 2. Registration for TCP port 993 and the corresponding "imaps" 6699 service name should be updated to point to this document, RFC 6700 8314 and RFC 3501. 6702 3. Both UDP port 143 and UDP port 993 should be marked as "Reserved" 6703 in the registry. 6705 Additional IANA actions are specified in subsection of this section. 6707 12.1. Updates to IMAP4 Capabilities registry 6709 IMAP4 capabilities are registered by publishing a standards track or 6710 IESG approved informational or experimental RFC. The registry is 6711 currently located at: https://www.iana.org/assignments/ 6712 imap4-capabilities 6714 As this specification revises the AUTH= prefix, STARTTLS and 6715 LOGINDISABLED extensions previously defined in [IMAP-TLS], IANA is 6716 requested to update registry entries for these 3 extensions to point 6717 to this document. 6719 12.2. GSSAPI/SASL service name 6721 GSSAPI/Kerberos/SASL service names are registered by publishing a 6722 standards track or IESG approved experimental RFC. The registry is 6723 currently located at: https://www.iana.org/assignments/gssapi- 6724 service-names 6726 IANA is requested to update the "imap" service name previously 6727 registered in RFC 3501, to point to this document. 6729 12.3. LIST Selection Options, LIST Return Options, LIST extended data 6730 items 6732 [RFC5258] specifies IANA registration procedures for LIST Selection 6733 Options, LIST Return Options, LIST extended data items. This 6734 document doesn't change these registration procedures. In particular 6735 LIST selection options Section 6.3.9.1 and LIST return options 6736 Section 6.3.9.2 are registered using the procedure specified in 6737 Section 9 of [RFC5258] (and using the registration template from 6738 Section 9.3 of [RFC5258]). LIST Extended Data Items are registered 6739 using the registration template from Section 9.6 of [RFC5258]). 6741 IANA is requested to add a reference to [RFCXXXX] for the "OLDNAME" 6742 LIST-EXTENDED extended data item entry. This is in addition to the 6743 existing reference to [RFC5465]. 6745 13. References 6747 13.1. Normative References 6749 [RFC5258] Leiba, B. and A. Melnikov, "Internet Message Access 6750 Protocol version 4 - LIST Command Extensions", RFC 5258, 6751 DOI 10.17487/RFC5258, June 2008, 6752 . 6754 [RFC5788] Melnikov, A. and D. Cridland, "IMAP4 Keyword Registry", 6755 RFC 5788, DOI 10.17487/RFC5788, March 2010, 6756 . 6758 [ABNF] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 6759 Specifications: ABNF", STD 68, RFC 5234, January 2008, 6760 . 6762 [ANONYMOUS] 6763 Zeilenga, K., "Anonymous Simple Authentication and 6764 Security Layer (SASL) Mechanism", RFC 4505, June 2006, 6765 . 6767 [CHARSET] Freed, N. and J. Postel, "IANA Charset Registration 6768 Procedures", BCP 19, RFC 2978, October 2000, 6769 . 6771 [SCRAM-SHA-256] 6772 Hansen, T., "SCRAM-SHA-256 and SCRAM-SHA-256-PLUS Simple 6773 Authentication and Security Layer (SASL) Mechanisms", 6774 RFC 7677, DOI 10.17487/RFC7677, November 2015, 6775 . 6777 [DISPOSITION] 6778 Troost, R., Dorner, S., and K. Moore, Ed., "Communicating 6779 Presentation Information in Internet Messages: The 6780 Content-Disposition Header Field", RFC 2183, August 1997, 6781 . 6783 [PLAIN] Zeilenga, K., Ed., "The PLAIN Simple Authentication and 6784 Security Layer (SASL) Mechanism", RFC 4616, August 2006, 6785 . 6787 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 6788 Requirement Levels", BCP 14, RFC 2119, 6789 DOI 10.17487/RFC2119, March 1997, 6790 . 6792 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 6793 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 6794 May 2017, . 6796 [LANGUAGE-TAGS] 6797 Alvestrand, H., "Content Language Headers", RFC 3282, May 6798 2002, . 6800 [LOCATION] 6801 Palme, J., Hopmann, A., and N. Shelness, "MIME 6802 Encapsulation of Aggregate Documents, such as HTML 6803 (MHTML)", RFC 2557, March 1999, 6804 . 6806 [MD5] Myers, J. and M. Rose, "The Content-MD5 Header Field", 6807 RFC 1864, October 1995, 6808 . 6810 [MIME-HDRS] 6811 Moore, K., "MIME (Multipurpose Internet Mail Extensions) 6812 Part Three: Message Header Extensions for Non-ASCII Text", 6813 RFC 2047, November 1996, 6814 . 6816 [MIME-IMB] 6817 Freed, N. and N. Borenstein, "Multipurpose Internet Mail 6818 Extensions (MIME) Part One: Format of Internet Message 6819 Bodies", RFC 2045, November 1996, 6820 . 6822 [MIME-IMT] 6823 Freed, N. and N. Borenstein, "Multipurpose Internet Mail 6824 Extensions (MIME) Part Two: Media Types", RFC 2046, 6825 November 1996, . 6827 [RFC2231] Freed, N. and K. Moore, "MIME Parameter Value and Encoded 6828 Word Extensions: Character Sets, Languages, and 6829 Continuations", RFC 2231, DOI 10.17487/RFC2231, November 6830 1997, . 6832 [RFC-5322] 6833 Resnick, P., Ed., "Internet Message Format", RFC 5322, 6834 October 2008, . 6836 [SASL] Melnikov, A., Ed. and K. Zeilenga, Ed., "Simple 6837 Authentication and Security Layer (SASL)", RFC 4422, June 6838 2006, . 6840 [TLS] Dierks, T. and E. Rescorla, "The Transport Layer Security 6841 (TLS) Protocol Version 1.2", RFC 5246, August 2008, 6842 . 6844 [UTF-7] Goldsmith, D. and M. Davis, "UTF-7 A Mail-Safe 6845 Transformation Format of Unicode", RFC 2152, May 1997, 6846 . 6848 [UTF-8] Yergeau, F., "UTF-8, a transformation format of ISO 6849 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 6850 2003, . 6852 [MULTIAPPEND] 6853 Crispin, M., "Internet Message Access Protocol (IMAP) - 6854 MULTIAPPEND Extension", RFC 3502, March 2003, 6855 . 6857 [NET-UNICODE] 6858 Klensin, J. and M. Padlipsky, "Unicode Format for Network 6859 Interchange", RFC 5198, DOI 10.17487/RFC5198, March 2008, 6860 . 6862 [I18N-HDRS] 6863 Yang, A., Steele, S., and N. Freed, "Internationalized 6864 Email Headers", RFC 6532, DOI 10.17487/RFC6532, February 6865 2012, . 6867 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 6868 Encodings", RFC 4648, DOI 10.17487/RFC4648, October 2006, 6869 . 6871 [RFC7817] Melnikov, A., "Updated Transport Layer Security (TLS) 6872 Server Identity Check Procedure for Email-Related 6873 Protocols", RFC 7817, DOI 10.17487/RFC7817, March 2016, 6874 . 6876 [RFC8098] Hansen, T., Ed. and A. Melnikov, Ed., "Message Disposition 6877 Notification", STD 85, RFC 8098, DOI 10.17487/RFC8098, 6878 February 2017, . 6880 [RFC8314] Moore, K. and C. Newman, "Cleartext Considered Obsolete: 6881 Use of Transport Layer Security (TLS) for Email Submission 6882 and Access", RFC 8314, DOI 10.17487/RFC8314, January 2018, 6883 . 6885 [IMAP-IMPLEMENTATION] 6886 Leiba, B., "IMAP4 Implementation Recommendations", 6887 RFC 2683, September 1999, 6888 . 6890 [IMAP-MULTIACCESS] 6891 Gahrns, M., "IMAP4 Multi-Accessed Mailbox Practice", 6892 RFC 2180, July 1997, 6893 . 6895 13.2. Informative References (related protocols) 6897 [RFC3503] Melnikov, A., "Message Disposition Notification (MDN) 6898 profile for Internet Message Access Protocol (IMAP)", 6899 RFC 3503, DOI 10.17487/RFC3503, March 2003, 6900 . 6902 [RFC5256] Crispin, M. and K. Murchison, "Internet Message Access 6903 Protocol - SORT and THREAD Extensions", RFC 5256, 6904 DOI 10.17487/RFC5256, June 2008, 6905 . 6907 [RFC2193] Gahrns, M., "IMAP4 Mailbox Referrals", RFC 2193, 6908 DOI 10.17487/RFC2193, September 1997, 6909 . 6911 [RFC3348] Gahrns, M. and R. Cheng, "The Internet Message Action 6912 Protocol (IMAP4) Child Mailbox Extension", RFC 3348, 6913 DOI 10.17487/RFC3348, July 2002, 6914 . 6916 [RFC5465] Gulbrandsen, A., King, C., and A. Melnikov, "The IMAP 6917 NOTIFY Extension", RFC 5465, DOI 10.17487/RFC5465, 6918 February 2009, . 6920 [RFC7888] Melnikov, A., Ed., "IMAP4 Non-synchronizing Literals", 6921 RFC 7888, DOI 10.17487/RFC7888, May 2016, 6922 . 6924 [IMAP-DISC] 6925 Melnikov, A., Ed., "Synchronization Operations for 6926 Disconnected IMAP4 Clients", RFC 4549, June 2006, 6927 . 6929 [IMAP-I18N] 6930 Newman, C., Gulbrandsen, A., and A. Melnikov, "Internet 6931 Message Access Protocol Internationalization", RFC 5255, 6932 DOI 10.17487/RFC5255, June 2008, 6933 . 6935 [IMAP-MODEL] 6936 Crispin, M., "Distributed Electronic Mail Models in 6937 IMAP4", RFC 1733, December 1994, 6938 . 6940 [IMAP-UTF-8] 6941 Resnick, P., Ed., Newman, C., Ed., and S. Shen, Ed., "IMAP 6942 Support for UTF-8", RFC 6855, DOI 10.17487/RFC6855, March 6943 2013, . 6945 [SMTP] Klensin, J., "Simple Mail Transfer Protocol", RFC 5321, 6946 October 2008, . 6948 [RFC3516] Nerenberg, L., "IMAP4 Binary Content Extension", RFC 3516, 6949 DOI 10.17487/RFC3516, April 2003, 6950 . 6952 [RFC4314] Melnikov, A., "IMAP4 Access Control List (ACL) Extension", 6953 RFC 4314, December 2005, 6954 . 6956 [RFC2087] Myers, J., "IMAP4 QUOTA extension", RFC 2087, January 6957 1997, . 6959 [IMAP-URL] 6960 Melnikov, A., Ed. and C. Newman, "IMAP URL Scheme", 6961 RFC 5092, DOI 10.17487/RFC5092, November 2007, 6962 . 6964 [IMAP-KEYWORDS-REG] 6965 IANA, "IMAP and JMAP Keywords", December 2009, 6966 . 6969 [IMAP-MAILBOX-NAME-ATTRS-REG] 6970 IANA, "IMAP Mailbox Name Attributes", June 2018, 6971 . 6974 [CHARSET-REG] 6975 IANA, "Character Set Registrations", May 2015, 6976 . 6979 13.3. Informative References (historical aspects of IMAP and related 6980 protocols) 6982 [RFC3501] Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - VERSION 6983 4rev1", RFC 3501, DOI 10.17487/RFC3501, March 2003, 6984 . 6986 [IMAP-COMPAT] 6987 Crispin, M., "IMAP4 Compatibility with IMAP2bis", 6988 RFC 2061, December 1996, 6989 . 6991 [IMAP-HISTORICAL] 6992 Crispin, M., "IMAP4 Compatibility with IMAP2 and 6993 IMAP2bis", RFC 1732, December 1994, 6994 . 6996 [IMAP-OBSOLETE] 6997 Crispin, M., "Internet Message Access Protocol - Obsolete 6998 Syntax", RFC 2062, December 1996, 6999 . 7001 [IMAP2] Crispin, M., "Interactive Mail Access Protocol: Version 7002 2", RFC 1176, August 1990, 7003 . 7005 [RFC-822] Crocker, D., "STANDARD FOR THE FORMAT OF ARPA INTERNET 7006 TEXT MESSAGES", STD 11, RFC 822, August 1982, 7007 . 7009 [IMAP-TLS] 7010 Newman, C., "Using TLS with IMAP, POP3 and ACAP", 7011 RFC 2595, June 1999, 7012 . 7014 Appendix A. Backward compatibility with IMAP4rev1 7016 An implementation that wants to remain compatible with IMAP4rev1 can 7017 advertise both IMAP4rev1 and IMAP4rev2 in its CAPABILITY response/ 7018 response code. While some IMAP4rev1 responses were removed in 7019 IMAP4rev2, their presence will not break IMAP4rev2-only clients. 7021 If both IMAP4rev1 and IMAP4rev2 are advertised, an IMAP client that 7022 wants to use IMAP4rev2 MUST issue an "ENABLE IMAP4rev2" command. 7024 Servers advertising both IMAP4rev1 and IMAP4rev2 MUST NOT generate 7025 UTF-8 quoted strings unless the client has issued "ENABLE IMAP4rev2". 7026 Consider implementation of mechanisms described or referenced in 7027 [IMAP-UTF-8] to achieve this goal. 7029 Servers advertising both IMAP4rev1 and IMAP4rev2, and clients 7030 intending to be compatible with IMAP4rev1 servers MUST be compatible 7031 with the international mailbox naming convention described in the 7032 following subsection. 7034 A.1. Mailbox International Naming Convention for compatibility with 7035 IMAP4rev1 7037 Support for the Mailbox International Naming Convention described in 7038 this section is not required for IMAP4rev2-only clients and servers. 7040 By convention, international mailbox names in IMAP4rev1 are specified 7041 using a modified version of the UTF-7 encoding described in [UTF-7]. 7042 Modified UTF-7 may also be usable in servers that implement an 7043 earlier version of this protocol. 7045 In modified UTF-7, printable US-ASCII characters, except for "&", 7046 represent themselves; that is, characters with octet values 0x20-0x25 7047 and 0x27-0x7e. The character "&" (0x26) is represented by the two- 7048 octet sequence "&-". 7050 All other characters (octet values 0x00-0x1f and 0x7f-0xff) are 7051 represented in modified BASE64, with a further modification from 7052 [UTF-7] that "," is used instead of "/". Modified BASE64 MUST NOT be 7053 used to represent any printing US-ASCII character which can represent 7054 itself. Only characters inside the modified BASE64 alphabet are 7055 permitted in modified BASE64 text. 7057 "&" is used to shift to modified BASE64 and "-" to shift back to US- 7058 ASCII. There is no implicit shift from BASE64 to US-ASCII, and null 7059 shifts ("-&" while in BASE64; note that "&-" while in US-ASCII means 7060 "&") are not permitted. However, all names start in US-ASCII, and 7061 MUST end in US-ASCII; that is, a name that ends with a non-ASCII 7062 ISO-10646 character MUST end with a "-"). 7064 The purpose of these modifications is to correct the following 7065 problems with UTF-7: 7067 1. UTF-7 uses the "+" character for shifting; this conflicts with 7068 the common use of "+" in mailbox names, in particular USENET 7069 newsgroup names. 7071 2. UTF-7's encoding is BASE64 which uses the "/" character; this 7072 conflicts with the use of "/" as a popular hierarchy delimiter. 7074 3. UTF-7 prohibits the unencoded usage of "\"; this conflicts with 7075 the use of "\" as a popular hierarchy delimiter. 7077 4. UTF-7 prohibits the unencoded usage of "~"; this conflicts with 7078 the use of "~" in some servers as a home directory indicator. 7080 5. UTF-7 permits multiple alternate forms to represent the same 7081 string; in particular, printable US-ASCII characters can be 7082 represented in encoded form. 7084 Although modified UTF-7 is a convention, it establishes certain 7085 requirements on server handling of any mailbox name with an embedded 7086 "&" character. In particular, server implementations MUST preserve 7087 the exact form of the modified BASE64 portion of a modified UTF-7 7088 name and treat that text as case-sensitive, even if names are 7089 otherwise case-insensitive or case-folded. 7091 Server implementations SHOULD verify that any mailbox name with an 7092 embedded "&" character, used as an argument to CREATE, is: in the 7093 correctly modified UTF-7 syntax, has no superfluous shifts, and has 7094 no encoding in modified BASE64 of any printing US-ASCII character 7095 which can represent itself. However, client implementations MUST NOT 7096 depend upon the server doing this, and SHOULD NOT attempt to create a 7097 mailbox name with an embedded "&" character unless it complies with 7098 the modified UTF-7 syntax. 7100 Server implementations which export a mail store that does not follow 7101 the modified UTF-7 convention MUST convert to modified UTF-7 any 7102 mailbox name that contains either non-ASCII characters or the "&" 7103 character. 7105 For example, here is a mailbox name which mixes English, Chinese, 7106 and Japanese text: ~peter/mail/&U,BTFw-/&ZeVnLIqe- 7108 For example, the string "&Jjo!" is not a valid mailbox name 7109 because it does not contain a shift to US-ASCII before the "!". 7110 The correct form is "&Jjo-!". The string "&U,BTFw-&ZeVnLIqe-" is 7111 not permitted because it contains a superfluous shift. The 7112 correct form is "&U,BTF2XlZyyKng-". 7114 Appendix B. Backward compatibility with BINARY extension 7116 IMAP4rev2 is incorporates subset of functionality provided by the 7117 BINARY extension [RFC3516], in particular it includes additional 7118 FETCH items (BINARY, BINARY.PEEK and BINARY.SIZE), but not extensions 7119 to the APPEND command. IMAP4rev2 implementations that supports full 7120 RFC 3516 functionality need to also advertise the BINARY token in the 7121 CAPABILITY response. 7123 Appendix C. Backward compatibility with LIST-EXTENDED extension 7125 IMAP4rev2 is incorporates most of functionality provided by the LIST- 7126 EXTENDED extension [RFC5258]. In particular, multiple mailbox 7127 patterns syntax is not supported in IMAP4rev2, unless LIST-EXTENDED 7128 capability is also advertised in CAPABILITY response/response code. 7130 Appendix D. Changes from RFC 3501 / IMAP4rev1 7132 The following is the plan for remaining changes. The plan might 7133 change over time. 7135 1. Revise IANA registration of IMAP extensions and give advice on 7136 use of "X-" convention. 7138 2. Add a section on other recommended extensions? 7140 The following changes were already done: 7142 1. Fold in the following extensions/RFC: RFC 5530 (IMAP Response 7143 Codes), UIDPLUS, ENABLE, ESEARCH, SPECIAL-USE (list of new 7144 mailbox attributes), LITERAL-, NAMESPACE, SASL-IR, LIST-STATUS, 7145 SEARCHRES, IDLE, MOVE. 7147 2. Add CLOSED response code (from CONDSTORE). 7149 3. Add support for $Phishing, $Junk, $NonJunk, $MDNSent and 7150 $Forwarded IMAP keywords. Add more examples showing their use? 7152 4. Require all unsolicited FETCH updates to include UID. 7154 5. Update recommendations on TLS ciphers to match UTA WG work (as 7155 per RFC 8314, RFC 7525 and RFC 7817). 7157 6. Fold in the following extensions/RFC: Base LIST-EXTENDED syntax 7158 plus deprecate LSUB (replace it with LIST \Subscribed) minus the 7159 requirement to support multiple list patterns, BINARY (only the 7160 FETCH changes on leaf body part and make APPEND related ones 7161 optional. See the mailing list discussion). 7163 7. Add STATUS SIZE (total mailbox size). Add STATUS DELETED (number 7164 of messages with \Deleted flag set). 7166 8. Drop UTF-7, all mailboxes are always in UTF-8. 7168 The following changes since RFC 3501 were done so far: 7170 1. Folded in IMAP UNSELECT (RFC 3691), UIDPLUS (RFC 4315), ESEARCH 7171 (RFC 4731), SEARCHRES (RFC 5182), ENABLE (RFC 5161), IDLE (RFC 7172 2177), SASL-IR (RFC 4959), LIST-STATUS (RFC 5819) and MOVE (RFC 7173 6851) extensions. Also folded RFC 5530 and FETCH side of the 7174 BINARY extension (RFC 3516). 7176 2. Clarified that server should decode parameter value 7177 continuations as described in [RFC2231]. This requirement was 7178 hidden in RFC 2231 itself. 7180 3. SEARCH command now requires to return ESEARCH response (SEARCH 7181 response is now deprecated). 7183 4. Clarified which SEARCH keys has to use substring match and which 7184 don't. 7186 5. Added CLOSED response code from RFC 7162. SELECT/EXAMINE when a 7187 mailbox is already selected now require for the CLOSED response 7188 code to be returned. 7190 6. Updated to use modern TLS-related recommendations as per RFC 7191 8314, RFC 7817, RFC 7525. 7193 7. For future extensibility extended ABNF for tagged-ext-simple to 7194 allow for bare number64. 7196 8. Added SHOULD level requirement on IMAP servers to support 7197 $MDNSent, $Forwarded, $Junk, $NonJunk and $Phishing keywords. 7199 9. Added STATUS SIZE (RFC 8438) and STATUS DELETED. 7201 10. Mailbox names and message headers now allow for UTF-8. Support 7202 for Modified UTF-7 in mailbox names is not required, unless 7203 compatibility with IMAP4rev1 is desired. 7205 11. UNSEEN response code on SELECT/EXAMINE is now deprecated. 7207 12. RECENT response on SELECT/EXAMINE, \Recent flag, RECENT STATUS, 7208 SEARCH NEW items are now deprecated. 7210 13. Clarified that the server doesn't need to send a new 7211 PERMANENTFLAGS response code when a new keyword was successfully 7212 added and the server advertised \* earlier for the same mailbox. 7214 14. Removed the CHECK command. Clients should use NOOP instead. 7216 15. RFC822, RFC822.HEADER and RFC822.TEXT FETCH data items were 7217 deprecated. Clients should use the corresponding BODY[] 7218 variants instead. 7220 16. Replaced DIGEST-MD5 SASL mechanism with SCRAM-SHA-256. DIGEST- 7221 MD5 was deprecated. 7223 17. LSUB command was deprecated. Clients should use LIST 7224 (SUBSCRIBED) instead. 7226 18. resp-text ABNF non terminal was updated to allow for empty text. 7228 19. IDLE command can now return updates not related to the currently 7229 selected mailbox state. 7231 20. All unsolicited FETCH updates are required to include UID. 7233 21. Clarified that client implementations MUST ignore response codes 7234 that they do not recognize. (Change from a SHOULD to a MUST.) 7236 Appendix E. Acknowledgement 7238 Earlier versions of this document were edited by Mark Crispin. 7239 Sadly, he is no longer available to help with this work. Editors of 7240 this revisions are hoping that Mark would have approved. 7242 Chris Newman has contributed text on I18N and use of UTF-8 in 7243 messages and mailbox names. 7245 Thank you to Tony Hansen for helping with the index generation. 7246 Thank you to Timo Sirainen, Bron Gondwana and Arnt Gulbrandsen for 7247 extensive feedback. 7249 This document incorporate text from RFC 4315 (by Mark Crispin), RFC 7250 4466 (by Cyrus Daboo), RFC 4731 (by Dave Cridland), RFC 5161 (by Arnt 7251 Gulbrandsen), RFC 5465 (by Arnt Gulbrandsen and Curtis King), RFC 7252 5530 (by Arnt Gulbrandsen), RFC 5819 (by Timo Sirainen), RFC 6154 (by 7253 Jamie Nicolson), RFC 8438 (by Stephan Bosch) so work done by authors/ 7254 editors of these documents is appreciated. Note that editors of this 7255 document were redacted from the above list. 7257 Index 7259 $ 7260 $Forwarded (predefined flag) 12 7261 $Junk (predefined flag) 12 7262 $MDNSent (predefined flag) 12 7263 $NotJunk (predefined flag) 12 7264 $Phishing (predefined flag) 12 7266 + 7267 +FLAGS 92 7268 +FLAGS.SILENT 92 7270 - 7271 -FLAGS 92 7272 -FLAGS.SILENT 92 7274 A 7275 ALERT (response code) 99 7276 ALL (fetch item) 88 7277 ALL (search key) 78 7278 ALL (search result option) 76 7279 ALREADYEXISTS (response code) 99 7280 ANSWERED (search key) 78 7281 APPEND (command) 68 7282 APPENDUID (response code) 99 7283 AUTHENTICATE (command) 29 7284 AUTHENTICATIONFAILED (response code) 100 7285 AUTHORIZATIONFAILED (response code) 100 7287 B 7288 BAD (response) 107 7289 BADCHARSET (response code) 101 7290 BCC (search key) 78 7291 BEFORE (search key) 78 7292 BINARY.PEEK[]<> (fetch item) 88 7293 BINARY.SIZE[] (fetch item) 88 7294 BINARY.SIZE[] (fetch result) 118 7295 BINARY[]<> (fetch result) 117 7296 BINARY[]<> (fetch item) 88 7297 BODY (fetch item) 89 7298 BODY (fetch result) 118 7299 BODY (search key) 78 7300 BODY.PEEK[
]<> (fetch item) 91 7301 BODYSTRUCTURE (fetch item) 91 7302 BODYSTRUCTURE (fetch result) 119 7303 BODY[
]<> (fetch result) 118 7304 BODY[
]<> (fetch item) 89 7305 BYE (response) 108 7306 Body Structure (message attribute) 14 7308 C 7309 CANNOT (response code) 101 7310 CAPABILITY (command) 25 7311 CAPABILITY (response code) 101 7312 CAPABILITY (response) 109 7313 CC (search key) 78 7314 CLIENTBUG (response code) 101 7315 CLOSE (command) 73 7316 CLOSED (response code) 101 7317 CONTACTADMIN (response code) 102 7318 COPY (command) 92 7319 COPYUID (response code) 102 7320 CORRUPTION (response code) 102 7321 COUNT (search result option) 76 7322 CREATE (command) 38 7324 D 7325 DELETE (command) 39 7326 DELETED (search key) 78 7327 DELETED (status item) 68 7328 DRAFT (search key) 78 7330 E 7331 ENABLE (command) 33 7332 ENVELOPE (fetch item) 91 7333 ENVELOPE (fetch result) 121 7334 ESEARCH (response) 115 7335 EXAMINE (command) 37 7336 EXPIRED (response code) 103 7337 EXPUNGE (command) 74 7338 EXPUNGE (response) 116 7339 EXPUNGEISSUED (response code) 103 7340 Envelope Structure (message attribute) 14 7342 F 7343 FAST (fetch item) 88 7344 FETCH (command) 87 7345 FETCH (response) 117 7346 FLAGGED (search key) 78 7347 FLAGS (fetch item) 91 7348 FLAGS (fetch result) 122 7349 FLAGS (response) 115 7350 FLAGS (store command data item) 92 7351 FLAGS.SILENT (store command data item) 92 7352 FROM (search key) 78 7353 FULL (fetch item) 88 7354 Flags (message attribute) 11 7356 H 7357 HASCHILDREN (response code) 103 7358 HEADER (part specifier) 89 7359 HEADER (search key) 78 7360 HEADER.FIELDS (part specifier) 89 7361 HEADER.FIELDS.NOT (part specifier) 89 7363 I 7364 IDLE (command) 71 7365 INTERNALDATE (fetch item) 91 7366 INTERNALDATE (fetch result) 122 7367 INUSE (response code) 103 7368 Internal Date (message attribute) 13 7370 K 7371 KEYWORD (search key) 79 7372 Keyword (type of flag) 12 7374 L 7375 LARGER (search key) 79 7376 LIMIT (response code) 103 7377 LIST (command) 44 7378 LIST (response) 110 7379 LOGOUT (command) 27 7381 M 7382 MAX (search result option) 76 7383 MAY (specification requirement term) 5 7384 MESSAGES (status item) 68 7385 MIME (part specifier) 90 7386 MIN (search result option) 76 7387 MOVE (command) 93 7388 MUST (specification requirement term) 5 7389 MUST NOT (specification requirement term) 5 7390 Message Sequence Number (message attribute) 11 7392 N 7393 NAMESPACE (command) 62 7394 NAMESPACE (response) 114 7395 NO (response) 107 7396 NONEXISTENT (response code) 104 7397 NOOP (command) 26 7398 NOPERM (response code) 104 7399 NOT (search key) 79 7400 NOT RECOMMENDED (specification requirement term) 5 7402 O 7403 OK (response) 107 7404 ON (search key) 79 7405 OPTIONAL (specification requirement term) 5 7406 OR (search key) 79 7407 OVERQUOTA (response code) 104 7409 P 7410 PARSE (response code) 104 7411 PERMANENTFLAGS (response code) 104 7412 PREAUTH (response) 108 7413 PRIVACYREQUIRED (response code) 105 7414 Permanent Flag (class of flag) 13 7415 Predefined keywords 12 7417 R 7418 READ-ONLY (response code) 105 7419 READ-WRITE (response code) 105 7420 RECOMMENDED (specification requirement term) 5 7421 RENAME (command) 41 7422 REQUIRED (specification requirement term) 5 7423 RFC822.SIZE (fetch item) 91 7424 RFC822.SIZE (fetch result) 123 7426 S 7427 SAVE (search result option) 76 7428 SEARCH (command) 75 7429 SEEN (search key) 79 7430 SELECT (command) 35 7431 SENTBEFORE (search key) 79 7432 SENTON (search key) 79 7433 SENTSINCE (search key) 79 7434 SERVERBUG (response code) 105 7435 SHOULD (specification requirement term) 5 7436 SHOULD NOT (specification requirement term) 5 7437 SINCE (search key) 79 7438 SIZE (status item) 68 7439 SMALLER (search key) 79 7440 STARTTLS (command) 28 7441 STATUS (command) 67 7442 STATUS (response) 114 7443 STORE (command) 91 7444 SUBJECT (search key) 79 7445 SUBSCRIBE (command) 43 7446 Session Flag (class of flag) 13 7447 System Flag (type of flag) 11 7449 T 7450 TEXT (part specifier) 89 7451 TEXT (search key) 79 7452 TO (search key) 80 7453 TRYCREATE (response code) 105 7455 U 7456 UID (command) 95 7457 UID (fetch item) 91 7458 UID (fetch result) 123 7459 UID (search key) 80 7460 UIDNEXT (response code) 106 7461 UIDNEXT (status item) 68 7462 UIDNOTSTICKY (response code) 106 7463 UIDVALIDITY (response code) 106 7464 UIDVALIDITY (status item) 68 7465 UNANSWERED (search key) 80 7466 UNAVAILABLE (response code) 106 7467 UNDELETED (search key) 80 7468 UNDRAFT (search key) 80 7469 UNFLAGGED (search key) 80 7470 UNKEYWORD (search key) 80 7471 UNKNOWN-CTE (response code) 106 7472 UNSEEN (search key) 80 7473 UNSEEN (status item) 68 7474 UNSELECT (command) 74 7475 UNSUBSCRIBE (command) 44 7476 Unique Identifier (UID) (message attribute) 9 7478 X 7479 X (command) 97 7481 [ 7482 [RFC-5322] Size (message attribute) 13 7484 \ 7485 \All (mailbox name attribute) 112 7486 \Answered (system flag) 11 7487 \Archive (mailbox name attribute) 112 7488 \Deleted (system flag) 12 7489 \Draft (system flag) 12 7490 \Drafts (mailbox name attribute) 112 7491 \Flagged (mailbox name attribute) 112 7492 \Flagged (system flag) 11 7493 \HasChildren (mailbox name attribute) 111 7494 \HasNoChildren (mailbox name attribute) 111 7495 \Junk (mailbox name attribute) 113 7496 \Marked (mailbox name attribute) 111 7497 \Noinferiors (mailbox name attribute) 111 7498 \NonExistent (mailbox name attribute) 110 7499 \Noselect (mailbox name attribute) 111 7500 \Recent (system flag) 12 7501 \Remote (mailbox name attribute) 112 7502 \Seen (system flag) 11 7503 \Sent (mailbox name attribute) 113 7504 \Subscribed (mailbox name attribute) 112 7505 \Trash (mailbox name attribute) 113 7506 \Unmarked (mailbox name attribute) 111 7508 Authors' Addresses 7510 Alexey Melnikov (editor) 7511 Isode Ltd 7512 14 Castle Mews 7513 Hampton, Middlesex TW12 2NP 7514 UK 7516 Email: Alexey.Melnikov@isode.com 7518 Barry Leiba (editor) 7519 Futurewei Technologies 7521 Phone: +1 646 827 0648 7522 Email: barryleiba@computer.org 7523 URI: http://internetmessagingtechnology.org/