idnits 2.17.00 (12 Aug 2021) /tmp/idnits51488/draft-ietf-extra-imap4rev2-01.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 14 instances of too long lines in the document, the longest one being 9 characters in excess of 72. -- The draft header indicates that this document obsoletes RFC3501, but the abstract doesn't seem to mention this, which it should. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == The document seems to contain a disclaimer for pre-RFC5378 work, but was first submitted on or after 10 November 2008. The disclaimer is usually necessary only for documents that revise or obsolete older RFCs, and that take significant amounts of text from those RFCs. If you can contact all authors of the source material and they are willing to grant the BCP78 rights to the IETF Trust, you can and should remove the disclaimer. Otherwise, the disclaimer is needed and you can ignore this comment. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (July 16, 2018) is 1404 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 5465, but not defined == Missing Reference: 'IMAP-OBSOLETE' is mentioned on line 5460, but not defined == Missing Reference: 'IMAP-COMPAT' is mentioned on line 5450, but not defined == Missing Reference: 'IMAP-HISTORICAL' is mentioned on line 5455, but not defined == Missing Reference: 'RFC-822' is mentioned on line 5469, but not defined ** Obsolete undefined reference: RFC 822 (Obsoleted by RFC 2822) == Missing Reference: 'HEADER' is mentioned on line 4502, but not defined == Missing Reference: 'IMAP-DISC' is mentioned on line 5418, but not defined == Missing Reference: 'SMTP' is mentioned on line 5432, but not defined == Missing Reference: 'IMAP-URL' is mentioned on line 5442, but not defined == Missing Reference: 'UNSEEN 12' is mentioned on line 1656, but not defined == Missing Reference: 'UIDVALIDITY 3857529045' is mentioned on line 4485, but not defined == Missing Reference: 'UIDNEXT 4392' is mentioned on line 1690, but not defined == Missing Reference: 'UNSEEN 8' is mentioned on line 1688, but not defined == Missing Reference: 'UNSEEN 1' is mentioned on line 2481, but not defined == Missing Reference: 'UIDNEXT 2' is mentioned on line 2483, but not defined == Missing Reference: 'UIDVALIDITY 1' is mentioned on line 2553, but not defined == Missing Reference: 'TEXT' is mentioned on line 4438, but not defined == Missing Reference: 'RFC4314' is mentioned on line 5435, but not defined == Missing Reference: 'RFC2087' is mentioned on line 5439, but not defined ** Obsolete undefined reference: RFC 2087 (Obsoleted by RFC 9208) == Missing Reference: 'UNSEEN 17' is mentioned on line 4484, but not defined == Missing Reference: 'READ-WRITE' is mentioned on line 4486, but not defined == Missing Reference: 'RFC4422' is mentioned on line 4797, but not defined == Missing Reference: 'IMAP-TLS' is mentioned on line 5477, but not defined == Missing Reference: 'IMAP-MODEL' is mentioned on line 5423, but not defined == Missing Reference: 'ACAP' is mentioned on line 5428, but not defined == Missing Reference: 'RFC-821' is mentioned on line 5473, but not defined ** Obsolete undefined reference: RFC 821 (Obsoleted by RFC 2821) ** Obsolete normative reference: RFC 2831 (ref. 'DIGEST-MD5') (Obsoleted by RFC 6331) ** 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 (~~), 28 warnings (==), 3 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) July 16, 2018 5 Intended status: Standards Track 6 Expires: January 17, 2019 8 INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev2 9 draft-ietf-extra-imap4rev2-01.txt 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 and RFC 2045 parsing, searching, 23 and selective fetching of message attributes, texts, and portions 24 thereof. Messages in IMAP4rev2 are accessed by the use of numbers. 25 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 17, 2019. 48 Copyright Notice 50 Copyright (c) 2018 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 . . . . . . . . 13 92 2.3.6. Body Structure Message Attribute . . . . . . . . . . 13 93 2.4. Message Texts . . . . . . . . . . . . . . . . . . . . . . 13 94 3. State and Flow Diagram . . . . . . . . . . . . . . . . . . . 13 95 3.1. Not Authenticated State . . . . . . . . . . . . . . . . . 14 96 3.2. Authenticated State . . . . . . . . . . . . . . . . . . . 14 97 3.3. Selected State . . . . . . . . . . . . . . . . . . . . . 14 98 3.4. Logout State . . . . . . . . . . . . . . . . . . . . . . 14 99 4. Data Formats . . . . . . . . . . . . . . . . . . . . . . . . 16 100 4.1. Atom . . . . . . . . . . . . . . . . . . . . . . . . . . 16 101 4.1.1. Sequence set and UID set . . . . . . . . . . . . . . 16 102 4.2. Number . . . . . . . . . . . . . . . . . . . . . . . . . 16 103 4.3. String . . . . . . . . . . . . . . . . . . . . . . . . . 16 104 4.3.1. 8-bit and Binary Strings . . . . . . . . . . . . . . 17 105 4.4. Parenthesized List . . . . . . . . . . . . . . . . . . . 17 106 4.5. NIL . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 107 5. Operational Considerations . . . . . . . . . . . . . . . . . 18 108 5.1. Mailbox Naming . . . . . . . . . . . . . . . . . . . . . 18 109 5.1.1. Mailbox Hierarchy Naming . . . . . . . . . . . . . . 19 110 5.1.2. Namespaces . . . . . . . . . . . . . . . . . . . . . 19 111 5.1.3. Mailbox International Naming Convention . . . . . . . 20 112 5.2. Mailbox Size and Message Status Updates . . . . . . . . . 22 113 5.3. Response when no Command in Progress . . . . . . . . . . 22 114 5.4. Autologout Timer . . . . . . . . . . . . . . . . . . . . 22 115 5.5. Multiple Commands in Progress (Command Pipelining) . . . 23 116 6. Client Commands . . . . . . . . . . . . . . . . . . . . . . . 24 117 6.1. Client Commands - Any State . . . . . . . . . . . . . . . 24 118 6.1.1. CAPABILITY Command . . . . . . . . . . . . . . . . . 25 119 6.1.2. NOOP Command . . . . . . . . . . . . . . . . . . . . 26 120 6.1.3. LOGOUT Command . . . . . . . . . . . . . . . . . . . 26 121 6.2. Client Commands - Not Authenticated State . . . . . . . . 27 122 6.2.1. STARTTLS Command . . . . . . . . . . . . . . . . . . 27 123 6.2.2. AUTHENTICATE Command . . . . . . . . . . . . . . . . 28 124 6.2.3. LOGIN Command . . . . . . . . . . . . . . . . . . . . 31 125 6.3. Client Commands - Authenticated State . . . . . . . . . . 32 126 6.3.1. ENABLE Command . . . . . . . . . . . . . . . . . . . 32 127 6.3.2. SELECT Command . . . . . . . . . . . . . . . . . . . 34 128 6.3.3. EXAMINE Command . . . . . . . . . . . . . . . . . . . 36 129 6.3.4. CREATE Command . . . . . . . . . . . . . . . . . . . 37 130 6.3.5. DELETE Command . . . . . . . . . . . . . . . . . . . 38 131 6.3.6. RENAME Command . . . . . . . . . . . . . . . . . . . 39 132 6.3.7. SUBSCRIBE Command . . . . . . . . . . . . . . . . . . 41 133 6.3.8. UNSUBSCRIBE Command . . . . . . . . . . . . . . . . . 42 134 6.3.9. LIST Command . . . . . . . . . . . . . . . . . . . . 42 135 6.3.10. LSUB Command . . . . . . . . . . . . . . . . . . . . 45 136 6.3.11. NAMESPACE Command . . . . . . . . . . . . . . . . . . 46 137 6.3.12. STATUS Command . . . . . . . . . . . . . . . . . . . 50 138 6.3.13. APPEND Command . . . . . . . . . . . . . . . . . . . 52 139 6.3.14. IDLE Command . . . . . . . . . . . . . . . . . . . . 55 140 6.4. Client Commands - Selected State . . . . . . . . . . . . 56 141 6.4.1. CHECK Command . . . . . . . . . . . . . . . . . . . . 57 142 6.4.2. CLOSE Command . . . . . . . . . . . . . . . . . . . . 57 143 6.4.3. UNSELECT Command . . . . . . . . . . . . . . . . . . 58 144 6.4.4. EXPUNGE Command . . . . . . . . . . . . . . . . . . . 58 145 6.4.5. SEARCH Command . . . . . . . . . . . . . . . . . . . 59 146 6.4.6. FETCH Command . . . . . . . . . . . . . . . . . . . . 64 147 6.4.7. STORE Command . . . . . . . . . . . . . . . . . . . . 68 148 6.4.8. COPY Command . . . . . . . . . . . . . . . . . . . . 69 149 6.4.9. UID Command . . . . . . . . . . . . . . . . . . . . . 70 150 6.5. Client Commands - Experimental/Expansion . . . . . . . . 72 151 6.5.1. X Command . . . . . . . . . . . . . . . . . . . 72 152 7. Server Responses . . . . . . . . . . . . . . . . . . . . . . 72 153 7.1. Server Responses - Status Responses . . . . . . . . . . . 73 154 7.1.1. OK Response . . . . . . . . . . . . . . . . . . . . . 80 155 7.1.2. NO Response . . . . . . . . . . . . . . . . . . . . . 81 156 7.1.3. BAD Response . . . . . . . . . . . . . . . . . . . . 81 157 7.1.4. PREAUTH Response . . . . . . . . . . . . . . . . . . 82 158 7.1.5. BYE Response . . . . . . . . . . . . . . . . . . . . 82 159 7.2. Server Responses - Server and Mailbox Status . . . . . . 83 160 7.2.1. The ENABLED Response . . . . . . . . . . . . . . . . 83 161 7.2.2. CAPABILITY Response . . . . . . . . . . . . . . . . . 83 162 7.2.3. LIST Response . . . . . . . . . . . . . . . . . . . . 84 163 7.2.4. LSUB Response . . . . . . . . . . . . . . . . . . . . 87 164 7.2.5. NAMESPACE Response . . . . . . . . . . . . . . . . . 87 165 7.2.6. STATUS Response . . . . . . . . . . . . . . . . . . . 87 166 7.2.7. ESEARCH Response . . . . . . . . . . . . . . . . . . 88 167 7.2.8. FLAGS Response . . . . . . . . . . . . . . . . . . . 88 168 7.3. Server Responses - Mailbox Size . . . . . . . . . . . . . 89 169 7.3.1. EXISTS Response . . . . . . . . . . . . . . . . . . . 89 170 7.3.2. RECENT Response . . . . . . . . . . . . . . . . . . . 89 171 7.4. Server Responses - Message Status . . . . . . . . . . . . 90 172 7.4.1. EXPUNGE Response . . . . . . . . . . . . . . . . . . 90 173 7.4.2. FETCH Response . . . . . . . . . . . . . . . . . . . 91 174 7.5. Server Responses - Command Continuation Request . . . . . 96 175 8. Sample IMAP4rev2 connection . . . . . . . . . . . . . . . . . 96 176 9. Formal Syntax . . . . . . . . . . . . . . . . . . . . . . . . 98 177 10. Author's Note . . . . . . . . . . . . . . . . . . . . . . . . 111 178 11. Security Considerations . . . . . . . . . . . . . . . . . . . 111 179 11.1. STARTTLS Security Considerations . . . . . . . . . . . . 112 180 11.2. COPYUID and APPENDUID response codes . . . . . . . . . . 112 181 11.3. Other Security Considerations . . . . . . . . . . . . . 112 182 12. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 113 183 12.1. Updates to IMAP4 Capabilities registry . . . . . . . . . 113 184 12.2. GSSAPI/SASL service name . . . . . . . . . . . . . . . . 114 185 13. References . . . . . . . . . . . . . . . . . . . . . . . . . 114 186 13.1. Normative References . . . . . . . . . . . . . . . . . . 114 187 13.2. Informative References (related protocols) . . . . . . . 116 188 13.3. Informative References (historical aspects of IMAP and 189 related protocols) . . . . . . . . . . . . . . . . . . . 117 190 Appendix A. Backward compatibility with IMAP4rev1 . . . . . . . 118 191 Appendix B. Changes from RFC 3501 / IMAP4rev1 . . . . . . . . . 118 192 Appendix C. Acknowledgement . . . . . . . . . . . . . . . . . . 119 193 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 194 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 125 196 1. How to Read This Document 198 1.1. Organization of This Document 200 This document is written from the point of view of the implementor of 201 an IMAP4rev2 client or server. Beyond the protocol overview in 202 section 2, it is not optimized for someone trying to understand the 203 operation of the protocol. The material in sections 3 through 5 204 provides the general context and definitions with which IMAP4rev2 205 operates. 207 Sections 6, 7, and 9 describe the IMAP commands, responses, and 208 syntax, respectively. The relationships among these are such that it 209 is almost impossible to understand any of them separately. In 210 particular, do not attempt to deduce command syntax from the command 211 section alone; instead refer to the Formal Syntax section. 213 1.2. Conventions Used in This Document 215 "Conventions" are basic principles or procedures. Document 216 conventions are noted in this section. 218 In examples, "C:" and "S:" indicate lines sent by the client and 219 server respectively. 221 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 222 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 223 document are to be interpreted as described in [KEYWORDS]. 225 The word "can" (not "may") is used to refer to a possible 226 circumstance or situation, as opposed to an optional facility of the 227 protocol. 229 "User" is used to refer to a human user, whereas "client" refers to 230 the software being run by the user. 232 "Connection" refers to the entire sequence of client/server 233 interaction from the initial establishment of the network connection 234 until its termination. 236 "Session" refers to the sequence of client/server interaction from 237 the time that a mailbox is selected (SELECT or EXAMINE command) until 238 the time that selection ends (SELECT or EXAMINE of another mailbox, 239 CLOSE command, or connection termination). 241 Characters are 7-bit US-ASCII unless otherwise specified. Other 242 character sets are indicated using a "CHARSET", as described in 243 [MIME-IMT] and defined in [CHARSET]. CHARSETs have important 244 additional semantics in addition to defining character set; refer to 245 these documents for more detail. 247 There are several protocol conventions in IMAP. These refer to 248 aspects of the specification which are not strictly part of the IMAP 249 protocol, but reflect generally-accepted practice. Implementations 250 need to be aware of these conventions, and avoid conflicts whether or 251 not they implement the convention. For example, "&" may not be used 252 as a hierarchy delimiter since it conflicts with the Mailbox 253 International Naming Convention, and other uses of "&" in mailbox 254 names are impacted as well. 256 1.3. Special Notes to Implementors 258 Implementors of the IMAP protocol are strongly encouraged to read the 259 IMAP implementation recommendations document [IMAP-IMPLEMENTATION] in 260 conjunction with this document, to help understand the intricacies of 261 this protocol and how best to build an interoperable product. 263 IMAP4rev2 is designed to be upwards compatible from the [IMAP2] and 264 unpublished IMAP2bis protocols. IMAP4rev2 is largely compatible with 265 the IMAP4rev1 protocol described in RFC 3501 and the IMAP4 protocol 266 described in RFC 1730; the exception being in certain facilities 267 added in RFC 1730 that proved problematic and were subsequently 268 removed. In the course of the evolution of IMAP4rev2, some aspects 269 in the earlier protocols have become obsolete. Obsolete commands, 270 responses, and data formats which an IMAP4rev2 implementation can 271 encounter when used with an earlier implementation are described in 272 [IMAP-OBSOLETE]. 274 Other compatibility issues with IMAP2bis, the most common variant of 275 the earlier protocol, are discussed in [IMAP-COMPAT]. A full 276 discussion of compatibility issues with rare (and presumed extinct) 277 variants of [IMAP2] is in [IMAP-HISTORICAL]; this document is 278 primarily of historical interest. 280 IMAP was originally developed for the older [RFC-822] standard, and 281 as a consequence several fetch items in IMAP incorporate "RFC822" in 282 their name. With the exception of RFC822.SIZE, there are more modern 283 replacements; for example, the modern version of RFC822.HEADER is 284 BODY.PEEK[HEADER]. In all cases, "RFC822" should be interpreted as a 285 reference to the updated [RFC-5322] standard. 287 2. Protocol Overview 289 2.1. Link Level 291 The IMAP4rev2 protocol assumes a reliable data stream such as that 292 provided by TCP. When TCP is used, an IMAP4rev2 server listens on 293 port 143. 295 2.2. Commands and Responses 297 An IMAP4rev2 connection consists of the establishment of a client/ 298 server network connection, an initial greeting from the server, and 299 client/server interactions. These client/server interactions consist 300 of a client command, server data, and a server completion result 301 response. 303 All interactions transmitted by client and server are in the form of 304 lines, that is, strings that end with a CRLF. The protocol receiver 305 of an IMAP4rev2 client or server is either reading a line, or is 306 reading a sequence of octets with a known count followed by a line. 308 2.2.1. Client Protocol Sender and Server Protocol Receiver 310 The client command begins an operation. Each client command is 311 prefixed with an identifier (typically a short alphanumeric string, 312 e.g., A0001, A0002, etc.) called a "tag". A different tag is 313 generated by the client for each command. 315 Clients MUST follow the syntax outlined in this specification 316 strictly. It is a syntax error to send a command with missing or 317 extraneous spaces or arguments. 319 There are two cases in which a line from the client does not 320 represent a complete command. In one case, a command argument is 321 quoted with an octet count (see the description of literal in String 322 under Data Formats); in the other case, the command arguments require 323 server feedback (see the AUTHENTICATE command). In either case, the 324 server sends a command continuation request response if it is ready 325 for the octets (if appropriate) and the remainder of the command. 326 This response is prefixed with the token "+". 328 Note: If instead, the server detected an error in the command, it 329 sends a BAD completion response with a tag matching the command 330 (as described below) to reject the command and prevent the client 331 from sending any more of the command. 333 It is also possible for the server to send a completion response 334 for some other command (if multiple commands are in progress), or 335 untagged data. In either case, the command continuation request 336 is still pending; the client takes the appropriate action for the 337 response, and reads another response from the server. In all 338 cases, the client MUST send a complete command (including 339 receiving all command continuation request responses and command 340 continuations for the command) before initiating a new command. 342 The protocol receiver of an IMAP4rev2 server reads a command line 343 from the client, parses the command and its arguments, and transmits 344 server data and a server command completion result response. 346 2.2.2. Server Protocol Sender and Client Protocol Receiver 348 Data transmitted by the server to the client and status responses 349 that do not indicate command completion are prefixed with the token 350 "*", and are called untagged responses. 352 Server data MAY be sent as a result of a client command, or MAY be 353 sent unilaterally by the server. There is no syntactic difference 354 between server data that resulted from a specific command and server 355 data that were sent unilaterally. 357 The server completion result response indicates the success or 358 failure of the operation. It is tagged with the same tag as the 359 client command which began the operation. Thus, if more than one 360 command is in progress, the tag in a server completion response 361 identifies the command to which the response applies. There are 362 three possible server completion responses: OK (indicating success), 363 NO (indicating failure), or BAD (indicating a protocol error such as 364 unrecognized command or command syntax error). 366 Servers SHOULD enforce the syntax outlined in this specification 367 strictly. Any client command with a protocol syntax error, including 368 (but not limited to) missing or extraneous spaces or arguments, 369 SHOULD be rejected, and the client given a BAD server completion 370 response. 372 The protocol receiver of an IMAP4rev2 client reads a response line 373 from the server. It then takes action on the response based upon the 374 first token of the response, which can be a tag, a "*", or a "+". 376 A client MUST be prepared to accept any server response at all times. 377 This includes server data that was not requested. Server data SHOULD 378 be recorded, so that the client can reference its recorded copy 379 rather than sending a command to the server to request the data. In 380 the case of certain server data, the data MUST be recorded. 382 This topic is discussed in greater detail in the Server Responses 383 section. 385 2.3. Message Attributes 387 In addition to message text, each message has several attributes 388 associated with it. These attributes can be retrieved individually 389 or in conjunction with other attributes or message texts. 391 2.3.1. Message Numbers 393 Messages in IMAP4rev2 are accessed by one of two numbers; the unique 394 identifier or the message sequence number. 396 2.3.1.1. Unique Identifier (UID) Message Attribute 398 An unsigned 32-bit value assigned to each message, which when used 399 with the unique identifier validity value (see below) forms a 64-bit 400 value that MUST NOT refer to any other message in the mailbox or any 401 subsequent mailbox with the same name forever. Unique identifiers 402 are assigned in a strictly ascending fashion in the mailbox; as each 403 message is added to the mailbox it is assigned a higher UID than the 404 message(s) which were added previously. Unlike message sequence 405 numbers, unique identifiers are not necessarily contiguous. 407 The unique identifier of a message MUST NOT change during the 408 session, and SHOULD NOT change between sessions. Any change of 409 unique identifiers between sessions MUST be detectable using the 410 UIDVALIDITY mechanism discussed below. Persistent unique identifiers 411 are required for a client to resynchronize its state from a previous 412 session with the server (e.g., disconnected or offline access 413 clients); this is discussed further in [IMAP-DISC]. 415 Associated with every mailbox are two 32-bit unsigned values which 416 aid in unique identifier handling: the next unique identifier value 417 (UIDNEXT) and the unique identifier validity value (UIDVALIDITY). 419 The next unique identifier value is the predicted value that will be 420 assigned to a new message in the mailbox. Unless the unique 421 identifier validity also changes (see below), the next unique 422 identifier value MUST have the following two characteristics. First, 423 the next unique identifier value MUST NOT change unless new messages 424 are added to the mailbox; and second, the next unique identifier 425 value MUST change whenever new messages are added to the mailbox, 426 even if those new messages are subsequently expunged. 428 Note: The next unique identifier value is intended to provide a 429 means for a client to determine whether any messages have been 430 delivered to the mailbox since the previous time it checked this 431 value. It is not intended to provide any guarantee that any 432 message will have this unique identifier. A client can only 433 assume, at the time that it obtains the next unique identifier 434 value, that messages arriving after that time will have a UID 435 greater than or equal to that value. 437 The unique identifier validity value is sent in a UIDVALIDITY 438 response code in an OK untagged response at mailbox selection time. 439 If unique identifiers from an earlier session fail to persist in this 440 session, the unique identifier validity value MUST be greater than 441 the one used in the earlier session. 443 Note: Ideally, unique identifiers SHOULD persist at all times. 444 Although this specification recognizes that failure to persist can 445 be unavoidable in certain server environments, it STRONGLY 446 ENCOURAGES message store implementation techniques that avoid this 447 problem. For example: 449 1. Unique identifiers MUST be strictly ascending in the mailbox 450 at all times. If the physical message store is re-ordered by 451 a non-IMAP agent, this requires that the unique identifiers in 452 the mailbox be regenerated, since the former unique 453 identifiers are no longer strictly ascending as a result of 454 the re-ordering. 456 2. If the message store has no mechanism to store unique 457 identifiers, it must regenerate unique identifiers at each 458 session, and each session must have a unique UIDVALIDITY 459 value. 461 3. If the mailbox is deleted and a new mailbox with the same name 462 is created at a later date, the server must either keep track 463 of unique identifiers from the previous instance of the 464 mailbox, or it must assign a new UIDVALIDITY value to the new 465 instance of the mailbox. A good UIDVALIDITY value to use in 466 this case is a 32-bit representation of the creation date/time 467 of the mailbox. It is alright to use a constant such as 1, 468 but only if it guaranteed that unique identifiers will never 469 be reused, even in the case of a mailbox being deleted (or 470 renamed) and a new mailbox by the same name created at some 471 future time. 473 4. The combination of mailbox name, UIDVALIDITY, and UID must 474 refer to a single immutable message on that server forever. 475 In particular, the internal date, [RFC-5322] size, envelope, 476 body structure, and message texts (RFC822, RFC822.HEADER, 477 RFC822.TEXT, and all BODY[...] fetch data items) must never 478 change. This does not include message numbers, nor does it 479 include attributes that can be set by a STORE command (e.g., 480 FLAGS). 482 2.3.1.2. Message Sequence Number Message Attribute 484 A relative position from 1 to the number of messages in the mailbox. 485 This position MUST be ordered by ascending unique identifier. As 486 each new message is added, it is assigned a message sequence number 487 that is 1 higher than the number of messages in the mailbox before 488 that new message was added. 490 Message sequence numbers can be reassigned during the session. For 491 example, when a message is permanently removed (expunged) from the 492 mailbox, the message sequence number for all subsequent messages is 493 decremented. The number of messages in the mailbox is also 494 decremented. Similarly, a new message can be assigned a message 495 sequence number that was once held by some other message prior to an 496 expunge. 498 In addition to accessing messages by relative position in the 499 mailbox, message sequence numbers can be used in mathematical 500 calculations. For example, if an untagged "11 EXISTS" is received, 501 and previously an untagged "8 EXISTS" was received, three new 502 messages have arrived with message sequence numbers of 9, 10, and 11. 503 Another example, if message 287 in a 523 message mailbox has UID 504 12345, there are exactly 286 messages which have lesser UIDs and 236 505 messages which have greater UIDs. 507 2.3.2. Flags Message Attribute 509 A list of zero or more named tokens associated with the message. A 510 flag is set by its addition to this list, and is cleared by its 511 removal. There are two types of flags in IMAP4rev2. A flag of 512 either type can be permanent or session-only. 514 A system flag is a flag name that is pre-defined in this 515 specification and begin with "\". Certain system flags (\Deleted and 516 \Seen) have special semantics described elsewhere. The currently- 517 defined system flags are: 519 \Seen Message has been read 521 \Answered Message has been answered 523 \Flagged Message is "flagged" for urgent/special attention 525 \Deleted Message is "deleted" for removal by later EXPUNGE 526 \Draft Message has not completed composition (marked as a draft). 528 \Recent Message is "recently" arrived in this mailbox. This session 529 is the first session to have been notified about this message; if 530 the session is read-write, subsequent sessions will not see 531 \Recent set for this message. This flag can not be altered by the 532 client. 534 If it is not possible to determine whether or not this session is 535 the first session to be notified about a message, then that 536 message SHOULD be considered recent. 538 If multiple connections have the same mailbox selected 539 simultaneously, it is undefined which of these connections will 540 see newly-arrived messages with \Recent set and which will see it 541 without \Recent set. 543 A keyword is defined by the server implementation. Keywords do not 544 begin with "\". Servers MAY permit the client to define new keywords 545 in the mailbox (see the description of the PERMANENTFLAGS response 546 code for more information). Some keywords that start with "$" are 547 also defined in this specification. 549 This document defines several keywords that were not originally 550 defined in RFC 3501, but which were found to be useful by client 551 implementations. These keywords SHOULD be supported (i.e. allowed in 552 APPEND, COPY and SEARCH commands) by server implementations: 554 \Forwarded Message has been forwarded to another email address, 555 embedded within or attached to a new message. An email client 556 sets this keyword when it successfully forwards the message to 557 another email address. Typical usage of this keyword is to show a 558 different (or additional) icon for a message that has been 559 forwarded. Once set, the flag SHOULD NOT be cleared. 561 $MDNSent Message Disposition Notification was generated and sent for 562 this message. 564 A flag can be permanent or session-only on a per-flag basis. 565 Permanent flags are those which the client can add or remove from the 566 message flags permanently; that is, concurrent and subsequent 567 sessions will see any change in permanent flags. Changes to session 568 flags are valid only in that session. 570 Note: The \Recent system flag is a special case of a session flag. 571 \Recent can not be used as an argument in a STORE or APPEND 572 command, and thus can not be changed at all. 574 2.3.3. Internal Date Message Attribute 576 The internal date and time of the message on the server. This is not 577 the date and time in the [RFC-5322] header, but rather a date and 578 time which reflects when the message was received. In the case of 579 messages delivered via [SMTP], this SHOULD be the date and time of 580 final delivery of the message as defined by [SMTP]. In the case of 581 messages delivered by the IMAP4rev2 COPY command, this SHOULD be the 582 internal date and time of the source message. In the case of 583 messages delivered by the IMAP4rev2 APPEND command, this SHOULD be 584 the date and time as specified in the APPEND command description. 585 All other cases are implementation defined. 587 2.3.4. [RFC-5322] Size Message Attribute 589 The number of octets in the message, as expressed in [RFC-5322] 590 format. 592 2.3.5. Envelope Structure Message Attribute 594 A parsed representation of the [RFC-5322] header of the message. 595 Note that the IMAP Envelope structure is not the same as an [SMTP] 596 envelope. 598 2.3.6. Body Structure Message Attribute 600 A parsed representation of the [MIME-IMB] body structure information 601 of the message. 603 2.4. Message Texts 605 In addition to being able to fetch the full [RFC-5322] text of a 606 message, IMAP4rev2 permits the fetching of portions of the full 607 message text. Specifically, it is possible to fetch the [RFC-5322] 608 message header, [RFC-5322] message body, a [MIME-IMB] body part, or a 609 [MIME-IMB] header. 611 3. State and Flow Diagram 613 Once the connection between client and server is established, an 614 IMAP4rev2 connection is in one of four states. The initial state is 615 identified in the server greeting. Most commands are only valid in 616 certain states. It is a protocol error for the client to attempt a 617 command while the connection is in an inappropriate state, and the 618 server will respond with a BAD or NO (depending upon server 619 implementation) command completion result. 621 3.1. Not Authenticated State 623 In the not authenticated state, the client MUST supply authentication 624 credentials before most commands will be permitted. This state is 625 entered when a connection starts unless the connection has been pre- 626 authenticated. 628 3.2. Authenticated State 630 In the authenticated state, the client is authenticated and MUST 631 select a mailbox to access before commands that affect messages will 632 be permitted. This state is entered when a pre-authenticated 633 connection starts, when acceptable authentication credentials have 634 been provided, after an error in selecting a mailbox, or after a 635 successful CLOSE command. 637 3.3. Selected State 639 In a selected state, a mailbox has been selected to access. This 640 state is entered when a mailbox has been successfully selected. 642 3.4. Logout State 644 In the logout state, the connection is being terminated. This state 645 can be entered as a result of a client request (via the LOGOUT 646 command) or by unilateral action on the part of either the client or 647 server. 649 If the client requests the logout state, the server MUST send an 650 untagged BYE response and a tagged OK response to the LOGOUT command 651 before the server closes the connection; and the client MUST read the 652 tagged OK response to the LOGOUT command before the client closes the 653 connection. 655 A server MUST NOT unilaterally close the connection without sending 656 an untagged BYE response that contains the reason for having done so. 657 A client SHOULD NOT unilaterally close the connection, and instead 658 SHOULD issue a LOGOUT command. If the server detects that the client 659 has unilaterally closed the connection, the server MAY omit the 660 untagged BYE response and simply close its connection. 662 +----------------------+ 663 |connection established| 664 +----------------------+ 665 || 666 \/ 667 +--------------------------------------+ 668 | server greeting | 669 +--------------------------------------+ 670 || (1) || (2) || (3) 671 \/ || || 672 +-----------------+ || || 673 |Not Authenticated| || || 674 +-----------------+ || || 675 || (7) || (4) || || 676 || \/ \/ || 677 || +----------------+ || 678 || | Authenticated |<=++ || 679 || +----------------+ || || 680 || || (7) || (5) || (6) || 681 || || \/ || || 682 || || +--------+ || || 683 || || |Selected|==++ || 684 || || +--------+ || 685 || || || (7) || 686 \/ \/ \/ \/ 687 +--------------------------------------+ 688 | Logout | 689 +--------------------------------------+ 690 || 691 \/ 692 +-------------------------------+ 693 |both sides close the connection| 694 +-------------------------------+ 696 (1) connection without pre-authentication (OK greeting) 697 (2) pre-authenticated connection (PREAUTH greeting) 698 (3) rejected connection (BYE greeting) 699 (4) successful LOGIN or AUTHENTICATE command 700 (5) successful SELECT or EXAMINE command 701 (6) CLOSE command, unsolicited CLOSED response code or 702 failed SELECT or EXAMINE command 703 (7) LOGOUT command, server shutdown, or connection closed 705 4. Data Formats 707 IMAP4rev2 uses textual commands and responses. Data in IMAP4rev2 can 708 be in one of several forms: atom, number, string, parenthesized list, 709 or NIL. Note that a particular data item may take more than one 710 form; for example, a data item defined as using "astring" syntax may 711 be either an atom or a string. 713 4.1. Atom 715 An atom consists of one or more non-special characters. 717 4.1.1. Sequence set and UID set 719 A set of messages can be referenced by a sequence set containing 720 either message sequence numbers or unique identifiers. See Section 9 721 for details. Sequence sets can contain ranges (e.g. "5:50"), an 722 enumeration of specific message/UID numbers, a special symbol "*", or 723 a combination of the above. 725 A "UID set" is similar to the sequence set of unique identifiers; 726 however, the "*" value for a sequence number is not permitted. 728 4.2. Number 730 A number consists of one or more digit characters, and represents a 731 numeric value. 733 4.3. String 735 A string is in one of two forms: either literal or quoted string. 736 The literal form is the general form of string. The quoted string 737 form is an alternative that avoids the overhead of processing a 738 literal at the cost of limitations of characters which may be used. 740 A literal is a sequence of zero or more octets (including CR and LF), 741 prefix-quoted with an octet count in the form of an open brace ("{"), 742 the number of octets, close brace ("}"), and CRLF. In the case of 743 literals transmitted from server to client, the CRLF is immediately 744 followed by the octet data. In the case of literals transmitted from 745 client to server, the client MUST wait to receive a command 746 continuation request (described later in this document) before 747 sending the octet data (and the remainder of the command). 749 A quoted string is a sequence of zero or more 7-bit characters, 750 excluding CR and LF, with double quote (<">) characters at each end. 752 The empty string is represented as either "" (a quoted string with 753 zero characters between double quotes) or as {0} followed by CRLF (a 754 literal with an octet count of 0). 756 Note: Even if the octet count is 0, a client transmitting a 757 literal MUST wait to receive a command continuation request. 759 4.3.1. 8-bit and Binary Strings 761 8-bit textual and binary mail is supported through the use of a 762 [MIME-IMB] content transfer encoding. IMAP4rev2 implementations MAY 763 transmit 8-bit or multi-octet characters in literals, but SHOULD do 764 so only when the [CHARSET] is identified. 766 Although a BINARY body encoding is defined, unencoded binary strings 767 are not permitted. A "binary string" is any string with NUL 768 characters. Implementations MUST encode binary data into a textual 769 form, such as BASE64, before transmitting the data. A string with an 770 excessive amount of CTL characters MAY also be considered to be 771 binary. 773 4.4. Parenthesized List 775 Data structures are represented as a "parenthesized list"; a sequence 776 of data items, delimited by space, and bounded at each end by 777 parentheses. A parenthesized list can contain other parenthesized 778 lists, using multiple levels of parentheses to indicate nesting. 780 The empty list is represented as () -- a parenthesized list with no 781 members. 783 4.5. NIL 785 The special form "NIL" represents the non-existence of a particular 786 data item that is represented as a string or parenthesized list, as 787 distinct from the empty string "" or the empty parenthesized list (). 789 Note: NIL is never used for any data item which takes the form of 790 an atom. For example, a mailbox name of "NIL" is a mailbox named 791 NIL as opposed to a non-existent mailbox name. This is because 792 mailbox uses "astring" syntax which is an atom or a string. 793 Conversely, an addr-name of NIL is a non-existent personal name, 794 because addr-name uses "nstring" syntax which is NIL or a string, 795 but never an atom. 797 5. Operational Considerations 799 The following rules are listed here to ensure that all IMAP4rev2 800 implementations interoperate properly. 802 5.1. Mailbox Naming 804 Mailbox names are 7-bit. Client implementations MUST NOT attempt to 805 create 8-bit mailbox names, and SHOULD interpret any 8-bit mailbox 806 names returned by LIST or LSUB as UTF-8. Server implementations 807 SHOULD prohibit the creation of 8-bit mailbox names, and SHOULD NOT 808 return 8-bit mailbox names in LIST or LSUB. See Section 5.1.3 for 809 more information on how to represent non-ASCII mailbox names. 811 Note: 8-bit mailbox names were undefined in earlier versions of 812 this protocol. Some sites used a local 8-bit character set to 813 represent non-ASCII mailbox names. Such usage is not 814 interoperable, and is now formally deprecated. 816 The case-insensitive mailbox name INBOX is a special name reserved to 817 mean "the primary mailbox for this user on this server". (Note that 818 this special name may not exist on some servers for some users.) The 819 interpretation of all other names is implementation-dependent. 821 In particular, this specification takes no position on case 822 sensitivity in non-INBOX mailbox names. Some server implementations 823 are fully case-sensitive; others preserve case of a newly-created 824 name but otherwise are case-insensitive; and yet others coerce names 825 to a particular case. Client implementations MUST interact with any 826 of these. If a server implementation interprets non-INBOX mailbox 827 names as case-insensitive, it MUST treat names using the 828 international naming convention specially as described in 829 Section 5.1.3. 831 There are certain client considerations when creating a new mailbox 832 name: 834 1. Any character which is one of the atom-specials (see the Formal 835 Syntax) will require that the mailbox name be represented as a 836 quoted string or literal. 838 2. CTL and other non-graphic characters are difficult to represent 839 in a user interface and are best avoided. 841 3. Although the list-wildcard characters ("%" and "*") are valid in 842 a mailbox name, it is difficult to use such mailbox names with 843 the LIST and LSUB commands due to the conflict with wildcard 844 interpretation. 846 4. Usually, a character (determined by the server implementation) is 847 reserved to delimit levels of hierarchy. 849 5. Two characters, "#" and "&", have meanings by convention, and 850 should be avoided except when used in that convention. 852 5.1.1. Mailbox Hierarchy Naming 854 If it is desired to export hierarchical mailbox names, mailbox names 855 MUST be left-to-right hierarchical using a single character to 856 separate levels of hierarchy. The same hierarchy separator character 857 is used for all levels of hierarchy within a single name. 859 5.1.2. Namespaces 861 Personal Namespace: A namespace that the server considers within the 862 personal scope of the authenticated user on a particular connection. 863 Typically, only the authenticated user has access to mailboxes in 864 their Personal Namespace. It is the part of the namespace that 865 belongs to the user that is allocated for mailboxes. If an INBOX 866 exists for a user, it MUST appear within the user's personal 867 namespace. In the typical case, there SHOULD be only one Personal 868 Namespace on a server. 870 Other Users' Namespace: A namespace that consists of mailboxes from 871 the Personal Namespaces of other users. To access mailboxes in the 872 Other Users' Namespace, the currently authenticated user MUST be 873 explicitly granted access rights. For example, it is common for a 874 manager to grant to their secretary access rights to their mailbox. 875 In the typical case, there SHOULD be only one Other Users' Namespace 876 on a server. 878 Shared Namespace: A namespace that consists of mailboxes that are 879 intended to be shared amongst users and do not exist within a user's 880 Personal Namespace. 882 The namespaces a server uses MAY differ on a per-user basis. 884 5.1.2.1. Historic Mailbox Namespace Naming Convention 886 By convention, the first hierarchical element of any mailbox name 887 which begins with "#" identifies the "namespace" of the remainder of 888 the name. This makes it possible to disambiguate between different 889 types of mailbox stores, each of which have their own namespaces. 891 For example, implementations which offer access to USENET 892 newsgroups MAY use the "#news" namespace to partition the USENET 893 newsgroup namespace from that of other mailboxes. Thus, the 894 comp.mail.misc newsgroup would have a mailbox name of 895 "#news.comp.mail.misc", and the name "comp.mail.misc" can refer to 896 a different object (e.g., a user's private mailbox). 898 Namespaces that include the "#" character are not IMAP URL [IMAP-URL] 899 friendly requiring the "#" character to be represented as %23 when 900 within URLs. As such, server implementers MAY instead consider using 901 namespace prefixes that do not contain the "#" character. 903 5.1.2.2. Common namespace models 905 Previous version of this protocol does not define a default server 906 namespace. Two common namespace models have evolved: 908 The "Personal Mailbox" model, in which the default namespace that is 909 presented consists of only the user's personal mailboxes. To access 910 shared mailboxes, the user must use an escape mechanism to reach 911 another namespace. 913 The "Complete Hierarchy" model, in which the default namespace that 914 is presented includes the user's personal mailboxes along with any 915 other mailboxes they have access to. 917 5.1.3. Mailbox International Naming Convention 919 By convention, international mailbox names in IMAP4rev2 are specified 920 using a modified version of the UTF-7 encoding described in [UTF-7]. 921 Modified UTF-7 may also be usable in servers that implement an 922 earlier version of this protocol. 924 In modified UTF-7, printable US-ASCII characters, except for "&", 925 represent themselves; that is, characters with octet values 0x20-0x25 926 and 0x27-0x7e. The character "&" (0x26) is represented by the two- 927 octet sequence "&-". 929 All other characters (octet values 0x00-0x1f and 0x7f-0xff) are 930 represented in modified BASE64, with a further modification from 931 [UTF-7] that "," is used instead of "/". Modified BASE64 MUST NOT be 932 used to represent any printing US-ASCII character which can represent 933 itself. Only characters inside the modified BASE64 alphabet are 934 permitted in modified BASE64 text. 936 "&" is used to shift to modified BASE64 and "-" to shift back to US- 937 ASCII. There is no implicit shift from BASE64 to US-ASCII, and null 938 shifts ("-&" while in BASE64; note that "&-" while in US-ASCII means 939 "&") are not permitted. However, all names start in US-ASCII, and 940 MUST end in US-ASCII; that is, a name that ends with a non-ASCII 941 ISO-10646 character MUST end with a "-"). 943 The purpose of these modifications is to correct the following 944 problems with UTF-7: 946 1. UTF-7 uses the "+" character for shifting; this conflicts with 947 the common use of "+" in mailbox names, in particular USENET 948 newsgroup names. 950 2. UTF-7's encoding is BASE64 which uses the "/" character; this 951 conflicts with the use of "/" as a popular hierarchy delimiter. 953 3. UTF-7 prohibits the unencoded usage of "\"; this conflicts with 954 the use of "\" as a popular hierarchy delimiter. 956 4. UTF-7 prohibits the unencoded usage of "~"; this conflicts with 957 the use of "~" in some servers as a home directory indicator. 959 5. UTF-7 permits multiple alternate forms to represent the same 960 string; in particular, printable US-ASCII characters can be 961 represented in encoded form. 963 Although modified UTF-7 is a convention, it establishes certain 964 requirements on server handling of any mailbox name with an embedded 965 "&" character. In particular, server implementations MUST preserve 966 the exact form of the modified BASE64 portion of a modified UTF-7 967 name and treat that text as case-sensitive, even if names are 968 otherwise case-insensitive or case-folded. 970 Server implementations SHOULD verify that any mailbox name with an 971 embedded "&" character, used as an argument to CREATE, is: in the 972 correctly modified UTF-7 syntax, has no superfluous shifts, and has 973 no encoding in modified BASE64 of any printing US-ASCII character 974 which can represent itself. However, client implementations MUST NOT 975 depend upon the server doing this, and SHOULD NOT attempt to create a 976 mailbox name with an embedded "&" character unless it complies with 977 the modified UTF-7 syntax. 979 Server implementations which export a mail store that does not follow 980 the modified UTF-7 convention MUST convert to modified UTF-7 any 981 mailbox name that contains either non-ASCII characters or the "&" 982 character. 984 For example, here is a mailbox name which mixes English, Chinese, 985 and Japanese text: ~peter/mail/&U,BTFw-/&ZeVnLIqe- 987 For example, the string "&Jjo!" is not a valid mailbox name 988 because it does not contain a shift to US-ASCII before the "!". 989 The correct form is "&Jjo-!". The string "&U,BTFw-&ZeVnLIqe-" is 990 not permitted because it contains a superfluous shift. The 991 correct form is "&U,BTF2XlZyyKng-". 993 5.2. Mailbox Size and Message Status Updates 995 At any time, a server can send data that the client did not request. 996 Sometimes, such behavior is REQUIRED. For example, agents other than 997 the server MAY add messages to the mailbox (e.g., new message 998 delivery), change the flags of the messages in the mailbox (e.g., 999 simultaneous access to the same mailbox by multiple agents), or even 1000 remove messages from the mailbox. A server MUST send mailbox size 1001 updates automatically if a mailbox size change is observed during the 1002 processing of a command. A server SHOULD send message flag updates 1003 automatically, without requiring the client to request such updates 1004 explicitly. 1006 Special rules exist for server notification of a client about the 1007 removal of messages to prevent synchronization errors; see the 1008 description of the EXPUNGE response for more detail. In particular, 1009 it is NOT permitted to send an EXISTS response that would reduce the 1010 number of messages in the mailbox; only the EXPUNGE response can do 1011 this. 1013 Regardless of what implementation decisions a client makes on 1014 remembering data from the server, a client implementation MUST record 1015 mailbox size updates. It MUST NOT assume that any command after the 1016 initial mailbox selection will return the size of the mailbox. 1018 5.3. Response when no Command in Progress 1020 Server implementations are permitted to send an untagged response 1021 (except for EXPUNGE) while there is no command in progress. Server 1022 implementations that send such responses MUST deal with flow control 1023 considerations. Specifically, they MUST either (1) verify that the 1024 size of the data does not exceed the underlying transport's available 1025 window size, or (2) use non-blocking writes. 1027 5.4. Autologout Timer 1029 If a server has an inactivity autologout timer that applies to 1030 sessions after authentication, the duration of that timer MUST be at 1031 least 30 minutes. The receipt of ANY command from the client during 1032 that interval SHOULD suffice to reset the autologout timer. 1034 5.5. Multiple Commands in Progress (Command Pipelining) 1036 The client MAY send another command without waiting for the 1037 completion result response of a command, subject to ambiguity rules 1038 (see below) and flow control constraints on the underlying data 1039 stream. Similarly, a server MAY begin processing another command 1040 before processing the current command to completion, subject to 1041 ambiguity rules. However, any command continuation request responses 1042 and command continuations MUST be negotiated before any subsequent 1043 command is initiated. 1045 The exception is if an ambiguity would result because of a command 1046 that would affect the results of other commands. Clients MUST NOT 1047 send multiple commands without waiting if an ambiguity would result. 1048 If the server detects a possible ambiguity, it MUST execute commands 1049 to completion in the order given by the client. 1051 The most obvious example of ambiguity is when a command would affect 1052 the results of another command, e.g., a FETCH of a message's flags 1053 and a STORE of that same message's flags. 1055 A non-obvious ambiguity occurs with commands that permit an untagged 1056 EXPUNGE response (commands other than FETCH, STORE, and SEARCH), 1057 since an untagged EXPUNGE response can invalidate sequence numbers in 1058 a subsequent command. This is not a problem for FETCH, STORE, or 1059 SEARCH commands because servers are prohibited from sending EXPUNGE 1060 responses while any of those commands are in progress. Therefore, if 1061 the client sends any command other than FETCH, STORE, or SEARCH, it 1062 MUST wait for the completion result response before sending a command 1063 with message sequence numbers. 1065 Note: EXPUNGE responses are permitted while UID FETCH, UID STORE, 1066 and UID SEARCH are in progress. If the client sends a UID 1067 command, it MUST wait for a completion result response before 1068 sending a command which uses message sequence numbers (this may 1069 include UID SEARCH). Any message sequence numbers in an argument 1070 to UID SEARCH are associated with messages prior to the effect of 1071 any untagged EXPUNGE returned by the UID SEARCH. 1073 For example, the following non-waiting command sequences are invalid: 1075 FETCH + NOOP + STORE 1077 STORE + COPY + FETCH 1079 COPY + COPY 1081 CHECK + FETCH 1083 The following are examples of valid non-waiting command sequences: 1085 FETCH + STORE + SEARCH + CHECK 1087 STORE + COPY + EXPUNGE 1089 UID SEARCH + UID SEARCH may be valid or invalid as a non-waiting 1090 command sequence, depending upon whether or not the second UID 1091 SEARCH contains message sequence numbers. 1093 6. Client Commands 1095 IMAP4rev2 commands are described in this section. Commands are 1096 organized by the state in which the command is permitted. Commands 1097 which are permitted in multiple states are listed in the minimum 1098 permitted state (for example, commands valid in authenticated and 1099 selected state are listed in the authenticated state commands). 1101 Command arguments, identified by "Arguments:" in the command 1102 descriptions below, are described by function, not by syntax. The 1103 precise syntax of command arguments is described in the Formal Syntax 1104 (Section 9). 1106 Some commands cause specific server responses to be returned; these 1107 are identified by "Responses:" in the command descriptions below. 1108 See the response descriptions in the Responses section for 1109 information on these responses, and the Formal Syntax section for the 1110 precise syntax of these responses. It is possible for server data to 1111 be transmitted as a result of any command. Thus, commands that do 1112 not specifically require server data specify "no specific responses 1113 for this command" instead of "none". 1115 The "Result:" in the command description refers to the possible 1116 tagged status responses to a command, and any special interpretation 1117 of these status responses. 1119 The state of a connection is only changed by successful commands 1120 which are documented as changing state. A rejected command (BAD 1121 response) never changes the state of the connection or of the 1122 selected mailbox. A failed command (NO response) generally does not 1123 change the state of the connection or of the selected mailbox; the 1124 exception being the SELECT and EXAMINE commands. 1126 6.1. Client Commands - Any State 1128 The following commands are valid in any state: CAPABILITY, NOOP, and 1129 LOGOUT. 1131 6.1.1. CAPABILITY Command 1133 Arguments: none 1135 Responses: REQUIRED untagged response: CAPABILITY 1137 Result: OK - capability completed 1138 BAD - command unknown or arguments invalid 1140 The CAPABILITY command requests a listing of capabilities that the 1141 server supports. The server MUST send a single untagged CAPABILITY 1142 response with "IMAP4rev2" as one of the listed capabilities before 1143 the (tagged) OK response. 1145 A capability name which begins with "AUTH=" indicates that the server 1146 supports that particular authentication mechanism. All such names 1147 are, by definition, part of this specification. For example, the 1148 authorization capability for an experimental "blurdybloop" 1149 authenticator would be "AUTH=XBLURDYBLOOP" and not 1150 "XAUTH=BLURDYBLOOP" or "XAUTH=XBLURDYBLOOP". 1152 Other capability names refer to extensions, revisions, or amendments 1153 to this specification. See the documentation of the CAPABILITY 1154 response for additional information. No capabilities, beyond the 1155 base IMAP4rev2 set defined in this specification, are enabled without 1156 explicit client action to invoke the capability. 1158 Client and server implementations MUST implement the STARTTLS, 1159 LOGINDISABLED, and AUTH=PLAIN (described in [PLAIN]) capabilities. 1160 See the Security Considerations section for important information. 1162 See the section entitled "Client Commands - Experimental/Expansion" 1163 for information about the form of site or implementation-specific 1164 capabilities. 1166 Example: C: abcd CAPABILITY 1167 S: * CAPABILITY IMAP4rev2 STARTTLS AUTH=GSSAPI 1168 LOGINDISABLED 1169 S: abcd OK CAPABILITY completed 1170 C: efgh STARTTLS 1171 S: efgh OK STARTLS completed 1172 1173 C: ijkl CAPABILITY 1174 S: * CAPABILITY IMAP4rev2 AUTH=GSSAPI AUTH=PLAIN 1175 S: ijkl OK CAPABILITY completed 1177 6.1.2. NOOP Command 1179 Arguments: none 1181 Responses: no specific responses for this command (but see below) 1183 Result: OK - noop completed 1184 BAD - command unknown or arguments invalid 1186 The NOOP command always succeeds. It does nothing. 1188 Since any command can return a status update as untagged data, the 1189 NOOP command can be used as a periodic poll for new messages or 1190 message status updates during a period of inactivity (this is the 1191 preferred method to do this). The NOOP command can also be used to 1192 reset any inactivity autologout timer on the server. 1194 Example: C: a002 NOOP 1195 S: a002 OK NOOP completed 1196 . . . 1197 C: a047 NOOP 1198 S: * 22 EXPUNGE 1199 S: * 23 EXISTS 1200 S: * 3 RECENT 1201 S: * 14 FETCH (FLAGS (\Seen \Deleted)) 1202 S: a047 OK NOOP completed 1204 6.1.3. LOGOUT Command 1206 Arguments: none 1208 Responses: REQUIRED untagged response: BYE 1210 Result: OK - logout completed 1211 BAD - command unknown or arguments invalid 1213 The LOGOUT command informs the server that the client is done with 1214 the connection. The server MUST send a BYE untagged response before 1215 the (tagged) OK response, and then close the network connection. 1217 Example: C: A023 LOGOUT 1218 S: * BYE IMAP4rev2 Server logging out 1219 S: A023 OK LOGOUT completed 1220 (Server and client then close the connection) 1222 6.2. Client Commands - Not Authenticated State 1224 In the not authenticated state, the AUTHENTICATE or LOGIN command 1225 establishes authentication and enters the authenticated state. The 1226 AUTHENTICATE command provides a general mechanism for a variety of 1227 authentication techniques, privacy protection, and integrity 1228 checking; whereas the LOGIN command uses a traditional user name and 1229 plaintext password pair and has no means of establishing privacy 1230 protection or integrity checking. 1232 The STARTTLS command is an alternate form of establishing session 1233 privacy protection and integrity checking, but does not by itself 1234 establish authentication or enter the authenticated state. 1236 Server implementations MAY allow access to certain mailboxes without 1237 establishing authentication. This can be done by means of the 1238 ANONYMOUS [SASL] authenticator described in [ANONYMOUS]. An older 1239 convention is a LOGIN command using the userid "anonymous"; in this 1240 case, a password is required although the server may choose to accept 1241 any password. The restrictions placed on anonymous users are 1242 implementation-dependent. 1244 Once authenticated (including as anonymous), it is not possible to 1245 re-enter not authenticated state. 1247 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 1248 the following commands are valid in the not authenticated state: 1249 STARTTLS, AUTHENTICATE and LOGIN. See the Security Considerations 1250 section for important information about these commands. 1252 6.2.1. STARTTLS Command 1254 Arguments: none 1256 Responses: no specific response for this command 1258 Result: OK - starttls completed, begin TLS negotiation 1259 BAD - command unknown or arguments invalid 1261 A [TLS] negotiation begins immediately after the CRLF at the end of 1262 the tagged OK response from the server. Once a client issues a 1263 STARTTLS command, it MUST NOT issue further commands until a server 1264 response is seen and the [TLS] negotiation is complete. 1266 The server remains in the non-authenticated state, even if client 1267 credentials are supplied during the [TLS] negotiation. This does not 1268 preclude an authentication mechanism such as EXTERNAL (defined in 1270 [SASL]) from using client identity determined by the [TLS] 1271 negotiation. 1273 Once [TLS] has been started, the client MUST discard cached 1274 information about server capabilities and SHOULD re-issue the 1275 CAPABILITY command. This is necessary to protect against man-in- 1276 the-middle attacks which alter the capabilities list prior to 1277 STARTTLS. The server MAY advertise different capabilities, and in 1278 particular SHOULD NOT advertise the STARTTLS capability, after a 1279 successful STARTTLS command. 1281 Example: C: a001 CAPABILITY 1282 S: * CAPABILITY IMAP4rev2 STARTTLS LOGINDISABLED 1283 S: a001 OK CAPABILITY completed 1284 C: a002 STARTTLS 1285 S: a002 OK Begin TLS negotiation now 1286 1287 C: a003 CAPABILITY 1288 S: * CAPABILITY IMAP4rev2 AUTH=PLAIN 1289 S: a003 OK CAPABILITY completed 1290 C: a004 LOGIN joe password 1291 S: a004 OK LOGIN completed 1293 6.2.2. AUTHENTICATE Command 1295 Arguments: SASL authentication mechanism name 1296 OPTIONAL initial response 1298 Responses: continuation data can be requested 1300 Result: OK - authenticate completed, now in authenticated state 1301 NO - authenticate failure: unsupported authentication 1302 mechanism, credentials rejected 1303 BAD - command unknown or arguments invalid, 1304 authentication exchange cancelled 1306 The AUTHENTICATE command indicates a [SASL] authentication mechanism 1307 to the server. If the server supports the requested authentication 1308 mechanism, it performs an authentication protocol exchange to 1309 authenticate and identify the client. It MAY also negotiate an 1310 OPTIONAL security layer for subsequent protocol interactions. If the 1311 requested authentication mechanism is not supported, the server 1312 SHOULD reject the AUTHENTICATE command by sending a tagged NO 1313 response. 1315 The AUTHENTICATE command supports the optional "initial response" 1316 feature defined in Section 5.1 of [SASL]. The client doesn't need to 1317 use it. If a SASL mechanism supports "initial response", but it is 1318 not specified by the client, the server handles this as specified in 1319 Section 3 of [SASL]. 1321 The service name specified by this protocol's profile of [SASL] is 1322 "imap". 1324 The authentication protocol exchange consists of a series of server 1325 challenges and client responses that are specific to the 1326 authentication mechanism. A server challenge consists of a command 1327 continuation request response with the "+" token followed by a BASE64 1328 encoded string. The client response consists of a single line 1329 consisting of a BASE64 encoded string. If the client wishes to 1330 cancel an authentication exchange, it issues a line consisting of a 1331 single "*". If the server receives such a response, or if it 1332 receives an invalid BASE64 string (e.g. characters outside the 1333 BASE64 alphabet, or non-terminal "="), it MUST reject the 1334 AUTHENTICATE command by sending a tagged BAD response. 1336 As with any other client response, this initial response MUST be 1337 encoded as BASE64 (see Section 4 of [RFC4648]). It also MUST be 1338 transmitted outside of a quoted string or literal. To send a zero- 1339 length initial response, the client MUST send a single pad character 1340 ("="). This indicates that the response is present, but is a zero- 1341 length string. 1343 When decoding the BASE64 data in the initial response, decoding 1344 errors MUST be treated as in any normal SASL client response, i.e. 1345 with a tagged BAD response. In particular, the server should check 1346 for any characters not explicitly allowed by the BASE64 alphabet, as 1347 well as any sequence of BASE64 characters that contains the pad 1348 character ('=') anywhere other than the end of the string (e.g., 1349 "=AAA" and "AAA=BBB" are not allowed). 1351 If the client uses an initial response with a SASL mechanism that 1352 does not support an initial response, the server MUST reject the 1353 command with a tagged BAD response. 1355 If a security layer is negotiated through the [SASL] authentication 1356 exchange, it takes effect immediately following the CRLF that 1357 concludes the authentication exchange for the client, and the CRLF of 1358 the tagged OK response for the server. 1360 While client and server implementations MUST implement the 1361 AUTHENTICATE command itself, it is not required to implement any 1362 authentication mechanisms other than the PLAIN mechanism described in 1363 [PLAIN]. Also, an authentication mechanism is not required to 1364 support any security layers. 1366 Note: a server implementation MUST implement a configuration in 1367 which it does NOT permit any plaintext password mechanisms, unless 1368 either the STARTTLS command has been negotiated or some other 1369 mechanism that protects the session from password snooping has 1370 been provided. Server sites SHOULD NOT use any configuration 1371 which permits a plaintext password mechanism without such a 1372 protection mechanism against password snooping. Client and server 1373 implementations SHOULD implement additional [SASL] mechanisms that 1374 do not use plaintext passwords, such the GSSAPI mechanism 1375 described in [SASL] and/or the [DIGEST-MD5] mechanism. 1377 Servers and clients can support multiple authentication mechanisms. 1378 The server SHOULD list its supported authentication mechanisms in the 1379 response to the CAPABILITY command so that the client knows which 1380 authentication mechanisms to use. 1382 A server MAY include a CAPABILITY response code in the tagged OK 1383 response of a successful AUTHENTICATE command in order to send 1384 capabilities automatically. It is unnecessary for a client to send a 1385 separate CAPABILITY command if it recognizes these automatic 1386 capabilities. This should only be done if a security layer was not 1387 negotiated by the AUTHENTICATE command, because the tagged OK 1388 response as part of an AUTHENTICATE command is not protected by 1389 encryption/integrity checking. [SASL] requires the client to re- 1390 issue a CAPABILITY command in this case. The server MAY advertise 1391 different capabilities after a successful AUTHENTICATE command. 1393 If an AUTHENTICATE command fails with a NO response, the client MAY 1394 try another authentication mechanism by issuing another AUTHENTICATE 1395 command. It MAY also attempt to authenticate by using the LOGIN 1396 command (see Section 6.2.3 for more detail). In other words, the 1397 client MAY request authentication types in decreasing order of 1398 preference, with the LOGIN command as a last resort. 1400 The authorization identity passed from the client to the server 1401 during the authentication exchange is interpreted by the server as 1402 the user name whose privileges the client is requesting. 1404 Example: S: * OK IMAP4rev2 Server 1405 C: A001 AUTHENTICATE GSSAPI 1406 S: + 1407 C: YIIB+wYJKoZIhvcSAQICAQBuggHqMIIB5qADAgEFoQMCAQ6iBw 1408 MFACAAAACjggEmYYIBIjCCAR6gAwIBBaESGxB1Lndhc2hpbmd0 1409 b24uZWR1oi0wK6ADAgEDoSQwIhsEaW1hcBsac2hpdmFtcy5jYW 1410 Mud2FzaGluZ3Rvbi5lZHWjgdMwgdCgAwIBAaEDAgEDooHDBIHA 1411 cS1GSa5b+fXnPZNmXB9SjL8Ollj2SKyb+3S0iXMljen/jNkpJX 1412 AleKTz6BQPzj8duz8EtoOuNfKgweViyn/9B9bccy1uuAE2HI0y 1413 C/PHXNNU9ZrBziJ8Lm0tTNc98kUpjXnHZhsMcz5Mx2GR6dGknb 1414 I0iaGcRerMUsWOuBmKKKRmVMMdR9T3EZdpqsBd7jZCNMWotjhi 1415 vd5zovQlFqQ2Wjc2+y46vKP/iXxWIuQJuDiisyXF0Y8+5GTpAL 1416 pHDc1/pIGmMIGjoAMCAQGigZsEgZg2on5mSuxoDHEA1w9bcW9n 1417 FdFxDKpdrQhVGVRDIzcCMCTzvUboqb5KjY1NJKJsfjRQiBYBdE 1418 NKfzK+g5DlV8nrw81uOcP8NOQCLR5XkoMHC0Dr/80ziQzbNqhx 1419 O6652Npft0LQwJvenwDI13YxpwOdMXzkWZN/XrEqOWp6GCgXTB 1420 vCyLWLlWnbaUkZdEYbKHBPjd8t/1x5Yg== 1421 S: + YGgGCSqGSIb3EgECAgIAb1kwV6ADAgEFoQMCAQ+iSzBJoAMC 1422 AQGiQgRAtHTEuOP2BXb9sBYFR4SJlDZxmg39IxmRBOhXRKdDA0 1423 uHTCOT9Bq3OsUTXUlk0CsFLoa8j+gvGDlgHuqzWHPSQg== 1424 C: 1425 S: + YDMGCSqGSIb3EgECAgIBAAD/////6jcyG4GE3KkTzBeBiVHe 1426 ceP2CWY0SR0fAQAgAAQEBAQ= 1427 C: YDMGCSqGSIb3EgECAgIBAAD/////3LQBHXTpFfZgrejpLlLImP 1428 wkhbfa2QteAQAgAG1yYwE= 1429 S: A001 OK GSSAPI authentication successful 1431 Note: The line breaks within server challenges and client responses 1432 are for editorial clarity and are not in real authenticators. 1434 6.2.3. LOGIN Command 1436 Arguments: user name 1437 password 1439 Responses: no specific responses for this command 1441 Result: OK - login completed, now in authenticated state 1442 NO - login failure: user name or password rejected 1443 BAD - command unknown or arguments invalid 1445 The LOGIN command identifies the client to the server and carries the 1446 plaintext password authenticating this user. 1448 A server MAY include a CAPABILITY response code in the tagged OK 1449 response to a successful LOGIN command in order to send capabilities 1450 automatically. It is unnecessary for a client to send a separate 1451 CAPABILITY command if it recognizes these automatic capabilities. 1453 Example: C: a001 LOGIN SMITH SESAME 1454 S: a001 OK LOGIN completed 1456 Note: Use of the LOGIN command over an insecure network (such as the 1457 Internet) is a security risk, because anyone monitoring network 1458 traffic can obtain plaintext passwords. The LOGIN command SHOULD NOT 1459 be used except as a last resort, and it is recommended that client 1460 implementations have a means to disable any automatic use of the 1461 LOGIN command. 1463 Unless either the client is accessing IMAP service on IMAPS port 1464 [RFC8314], the STARTTLS command has been negotiated or some other 1465 mechanism that protects the session from password snooping has been 1466 provided, a server implementation MUST implement a configuration in 1467 which it advertises the LOGINDISABLED capability and does NOT permit 1468 the LOGIN command. Server sites SHOULD NOT use any configuration 1469 which permits the LOGIN command without such a protection mechanism 1470 against password snooping. A client implementation MUST NOT send a 1471 LOGIN command if the LOGINDISABLED capability is advertised. 1473 6.3. Client Commands - Authenticated State 1475 In the authenticated state, commands that manipulate mailboxes as 1476 atomic entities are permitted. Of these commands, the SELECT and 1477 EXAMINE commands will select a mailbox for access and enter the 1478 selected state. 1480 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 1481 the following commands are valid in the authenticated state: ENABLE, 1482 SELECT, EXAMINE, NAMESPACE, CREATE, DELETE, RENAME, SUBSCRIBE, 1483 UNSUBSCRIBE, LIST, LSUB, STATUS, APPEND and IDLE. 1485 6.3.1. ENABLE Command 1487 Arguments: capability names 1489 Responses: no specific responses for this command 1491 Result: OK - Relevant capabilities enabled 1492 BAD - No arguments, or syntax error in an argument 1494 Several IMAP extensions allow the server to return unsolicited 1495 responses specific to these extensions in certain circumstances. 1496 However, servers cannot send those unsolicited responses (with the 1497 exception of response codes included in tagged or untagged OK/NO/BAD 1498 responses, which can always be sent) until they know that the clients 1499 support such extensions and thus won't choke on the extension 1500 response data. 1502 The ENABLE command provides an explicit indication from the client 1503 that it supports particular extensions. 1505 The ENABLE command takes a list of capability names, and requests the 1506 server to enable the named extensions. Once enabled using ENABLE, 1507 each extension remains active until the IMAP connection is closed. 1508 For each argument, the server does the following: 1510 o If the argument is not an extension known to the server, the 1511 server MUST ignore the argument. 1513 o If the argument is an extension known to the server, and it is not 1514 specifically permitted to be enabled using ENABLE, the server MUST 1515 ignore the argument. (Note that knowing about an extension 1516 doesn't necessarily imply supporting that extension.) 1518 o If the argument is an extension that is supported by the server 1519 and that needs to be enabled, the server MUST enable the extension 1520 for the duration of the connection. Note that once an extension 1521 is enabled, there is no way to disable it. 1523 If the ENABLE command is successful, the server MUST send an untagged 1524 ENABLED response Section 7.2.1. 1526 Clients SHOULD only include extensions that need to be enabled by the 1527 server. For example, a client can enable IMAP4rev2 specific 1528 behaviour when both IMAP4rev1 and IMAP4rev2 are advertised in the 1529 CAPABILITY response. Future RFCs may add to this list. 1531 The ENABLE command is only valid in the authenticated state, before 1532 any mailbox is selected. Clients MUST NOT issue ENABLE once they 1533 SELECT/EXAMINE a mailbox; however, server implementations don't have 1534 to check that no mailbox is selected or was previously selected 1535 during the duration of a connection. 1537 The ENABLE command can be issued multiple times in a session. It is 1538 additive; i.e., "ENABLE a b", followed by "ENABLE c" is the same as a 1539 single command "ENABLE a b c". When multiple ENABLE commands are 1540 issued, each corresponding ENABLED response SHOULD only contain 1541 extensions enabled by the corresponding ENABLE command. 1543 There are no limitations on pipelining ENABLE. For example, it is 1544 possible to send ENABLE and then immediately SELECT, or a LOGIN 1545 immediately followed by ENABLE. 1547 The server MUST NOT change the CAPABILITY list as a result of 1548 executing ENABLE; i.e., a CAPABILITY command issued right after an 1549 ENABLE command MUST list the same capabilities as a CAPABILITY 1550 command issued before the ENABLE command. This is demonstrated in 1551 the following example: 1553 C: t1 CAPABILITY 1554 S: * CAPABILITY IMAP4rev1 ID LITERAL+ ENABLE X-GOOD-IDEA 1555 S: t1 OK foo 1556 C: t2 ENABLE CONDSTORE X-GOOD-IDEA 1557 S: * ENABLED X-GOOD-IDEA 1558 S: t2 OK foo 1559 C: t3 CAPABILITY 1560 S: * CAPABILITY IMAP4rev1 ID LITERAL+ ENABLE X-GOOD-IDEA 1561 S: t3 OK foo again 1563 In the following example, the client enables CONDSTORE: 1565 C: a1 ENABLE CONDSTORE 1566 S: * ENABLED CONDSTORE 1567 S: a1 OK Conditional Store enabled 1569 6.3.1.1. Note to Designers of Extensions That May Use the ENABLE 1570 Command 1572 Designers of IMAP extensions are discouraged from creating extensions 1573 that require ENABLE unless there is no good alternative design. 1574 Specifically, extensions that cause potentially incompatible behavior 1575 changes to deployed server responses (and thus benefit from ENABLE) 1576 have a higher complexity cost than extensions that do not. 1578 6.3.2. SELECT Command 1580 Arguments: mailbox name 1582 Responses: REQUIRED untagged responses: FLAGS, EXISTS, RECENT 1583 REQUIRED OK untagged responses: UNSEEN (if any unseen 1584 exist), PERMANENTFLAGS, 1585 UIDNEXT, UIDVALIDITY 1587 Result: OK - select completed, now in selected state 1588 NO - select failure, now in authenticated state: no 1589 such mailbox, can't access mailbox 1590 BAD - command unknown or arguments invalid 1592 The SELECT command selects a mailbox so that messages in the mailbox 1593 can be accessed. Before returning an OK to the client, the server 1594 MUST send the following untagged data to the client. Note that 1595 earlier versions of this protocol only required the FLAGS, EXISTS, 1596 and RECENT untagged data; consequently, client implementations SHOULD 1597 implement default behavior for missing data as discussed with the 1598 individual item. 1600 FLAGS Defined flags in the mailbox. See the description of the 1601 FLAGS response for more detail. 1603 EXISTS The number of messages in the mailbox. See the 1604 description of the EXISTS response for more detail. 1606 RECENT The number of messages with the \Recent flag set. See 1607 the description of the RECENT response for more detail. 1609 OK [UNSEEN ] The message sequence number of the first unseen 1610 message in the mailbox. If there are any unseen messages in the 1611 mailbox, an UNSEEN response MUST be sent, if not it MUST be 1612 omitted. If this is missing, the client can not make any 1613 assumptions about the first unseen message in the mailbox, and 1614 needs to issue a SEARCH command if it wants to find it. 1616 OK [PERMANENTFLAGS ()] A list of message flags that 1617 the client can change permanently. If this is missing, the client 1618 should assume that all flags can be changed permanently. 1620 OK [UIDNEXT ] The next unique identifier value. Refer to 1621 Section 2.3.1.1 for more information. If this is missing, the 1622 client can not make any assumptions about the next unique 1623 identifier value. 1625 OK [UIDVALIDITY ] The unique identifier validity value. Refer to 1626 Section 2.3.1.1 for more information. If this is missing, the 1627 server does not support unique identifiers. 1629 Only one mailbox can be selected at a time in a connection; 1630 simultaneous access to multiple mailboxes requires multiple 1631 connections. The SELECT command automatically deselects any 1632 currently selected mailbox before attempting the new selection. 1633 Consequently, if a mailbox is selected and a SELECT command that 1634 fails is attempted, no mailbox is selected. When deselecting a 1635 selected mailbox, the server MUST return an untagged OK response with 1636 the "[CLOSED]" response code when the currently selected mailbox is 1637 closed. 1639 If the client is permitted to modify the mailbox, the server SHOULD 1640 prefix the text of the tagged OK response with the "[READ-WRITE]" 1641 response code. 1643 If the client is not permitted to modify the mailbox but is permitted 1644 read access, the mailbox is selected as read-only, and the server 1645 MUST prefix the text of the tagged OK response to SELECT with the 1646 "[READ-ONLY]" response code. Read-only access through SELECT differs 1647 from the EXAMINE command in that certain read-only mailboxes MAY 1648 permit the change of permanent state on a per-user (as opposed to 1649 global) basis. Netnews messages marked in a server-based .newsrc 1650 file are an example of such per-user permanent state that can be 1651 modified with read-only mailboxes. 1653 Example: C: A142 SELECT INBOX 1654 S: * 172 EXISTS 1655 S: * 1 RECENT 1656 S: * OK [UNSEEN 12] Message 12 is first unseen 1657 S: * OK [UIDVALIDITY 3857529045] UIDs valid 1658 S: * OK [UIDNEXT 4392] Predicted next UID 1659 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1660 S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited 1661 S: A142 OK [READ-WRITE] SELECT completed 1663 6.3.3. EXAMINE Command 1665 Arguments: mailbox name 1667 Responses: REQUIRED untagged responses: FLAGS, EXISTS, RECENT 1668 REQUIRED OK untagged responses: UNSEEN, PERMANENTFLAGS, 1669 UIDNEXT, UIDVALIDITY 1671 Result: OK - examine completed, now in selected state 1672 NO - examine failure, now in authenticated state: no 1673 such mailbox, can't access mailbox BAD - command unknown 1674 or arguments invalid 1676 The EXAMINE command is identical to SELECT and returns the same 1677 output; however, the selected mailbox is identified as read-only. No 1678 changes to the permanent state of the mailbox, including per-user 1679 state, are permitted; in particular, EXAMINE MUST NOT cause messages 1680 to lose the \Recent flag. 1682 The text of the tagged OK response to the EXAMINE command MUST begin 1683 with the "[READ-ONLY]" response code. 1685 Example: C: A932 EXAMINE blurdybloop 1686 S: * 17 EXISTS 1687 S: * 2 RECENT 1688 S: * OK [UNSEEN 8] Message 8 is first unseen 1689 S: * OK [UIDVALIDITY 3857529045] UIDs valid 1690 S: * OK [UIDNEXT 4392] Predicted next UID 1691 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1692 S: * OK [PERMANENTFLAGS ()] No permanent flags permitted 1693 S: A932 OK [READ-ONLY] EXAMINE completed 1695 6.3.4. CREATE Command 1697 Arguments: mailbox name 1699 Responses: no specific responses for this command 1701 Result: OK - create completed 1702 NO - create failure: can't create mailbox with that name 1703 BAD - command unknown or arguments invalid 1705 The CREATE command creates a mailbox with the given name. An OK 1706 response is returned only if a new mailbox with that name has been 1707 created. It is an error to attempt to create INBOX or a mailbox with 1708 a name that refers to an extant mailbox. Any error in creation will 1709 return a tagged NO response. 1711 If the mailbox name is suffixed with the server's hierarchy separator 1712 character (as returned from the server by a LIST command), this is a 1713 declaration that the client intends to create mailbox names under 1714 this name in the hierarchy. Server implementations that do not 1715 require this declaration MUST ignore the declaration. In any case, 1716 the name created is without the trailing hierarchy delimiter. 1718 If the server's hierarchy separator character appears elsewhere in 1719 the name, the server SHOULD create any superior hierarchical names 1720 that are needed for the CREATE command to be successfully completed. 1721 In other words, an attempt to create "foo/bar/zap" on a server in 1722 which "/" is the hierarchy separator character SHOULD create foo/ and 1723 foo/bar/ if they do not already exist. 1725 If a new mailbox is created with the same name as a mailbox which was 1726 deleted, its unique identifiers MUST be greater than any unique 1727 identifiers used in the previous incarnation of the mailbox UNLESS 1728 the new incarnation has a different unique identifier validity value. 1729 See the description of the UID command for more detail. 1731 Example: C: A003 CREATE owatagusiam/ 1732 S: A003 OK CREATE completed 1733 C: A004 CREATE owatagusiam/blurdybloop 1734 S: A004 OK CREATE completed 1736 Note: The interpretation of this example depends on whether "/" 1737 was returned as the hierarchy separator from LIST. If "/" is the 1738 hierarchy separator, a new level of hierarchy named "owatagusiam" 1739 with a member called "blurdybloop" is created. Otherwise, two 1740 mailboxes at the same hierarchy level are created. 1742 6.3.5. DELETE Command 1744 Arguments: mailbox name 1746 Responses: no specific responses for this command 1748 Result: OK - delete completed 1749 NO - delete failure: can't delete mailbox with that name 1750 BAD - command unknown or arguments invalid 1752 The DELETE command permanently removes the mailbox with the given 1753 name. A tagged OK response is returned only if the mailbox has been 1754 deleted. It is an error to attempt to delete INBOX or a mailbox name 1755 that does not exist. 1757 The DELETE command MUST NOT remove inferior hierarchical names. For 1758 example, if a mailbox "foo" has an inferior "foo.bar" (assuming "." 1759 is the hierarchy delimiter character), removing "foo" MUST NOT remove 1760 "foo.bar". It is an error to attempt to delete a name that has 1761 inferior hierarchical names and also has the \Noselect mailbox name 1762 attribute (see the description of the LIST response for more 1763 details). 1765 It is permitted to delete a name that has inferior hierarchical names 1766 and does not have the \Noselect mailbox name attribute. If the 1767 server implementation does not permit deleting the name while 1768 inferior hierarchical names exists the \Noselect mailbox name 1769 attribute is set for that name. In any case, all messages in that 1770 mailbox are removed by the DELETE command. 1772 The value of the highest-used unique identifier of the deleted 1773 mailbox MUST be preserved so that a new mailbox created with the same 1774 name will not reuse the identifiers of the former incarnation, UNLESS 1775 the new incarnation has a different unique identifier validity value. 1776 See the description of the UID command for more detail. 1778 Examples: C: A682 LIST "" * 1779 S: * LIST () "/" blurdybloop 1780 S: * LIST (\Noselect) "/" foo 1781 S: * LIST () "/" foo/bar 1782 S: A682 OK LIST completed 1783 C: A683 DELETE blurdybloop 1784 S: A683 OK DELETE completed 1785 C: A684 DELETE foo 1786 S: A684 NO Name "foo" has inferior hierarchical names 1787 C: A685 DELETE foo/bar 1788 S: A685 OK DELETE Completed 1789 C: A686 LIST "" * 1790 S: * LIST (\Noselect) "/" foo 1791 S: A686 OK LIST completed 1792 C: A687 DELETE foo 1793 S: A687 OK DELETE Completed 1794 C: A82 LIST "" * 1795 S: * LIST () "." blurdybloop 1796 S: * LIST () "." foo 1797 S: * LIST () "." foo.bar 1798 S: A82 OK LIST completed 1799 C: A83 DELETE blurdybloop 1800 S: A83 OK DELETE completed 1801 C: A84 DELETE foo 1802 S: A84 OK DELETE Completed 1803 C: A85 LIST "" * 1804 S: * LIST () "." foo.bar 1805 S: A85 OK LIST completed 1806 C: A86 LIST "" % 1807 S: * LIST (\Noselect) "." foo 1808 S: A86 OK LIST completed 1810 6.3.6. RENAME Command 1812 Arguments: existing mailbox name 1813 new mailbox name 1815 Responses: no specific responses for this command 1817 Result: OK - rename completed 1818 NO - rename failure: can't rename mailbox with that name, 1819 can't rename to mailbox with that name 1820 BAD - command unknown or arguments invalid 1822 The RENAME command changes the name of a mailbox. A tagged OK 1823 response is returned only if the mailbox has been renamed. It is an 1824 error to attempt to rename from a mailbox name that does not exist or 1825 to a mailbox name that already exists. Any error in renaming will 1826 return a tagged NO response. 1828 If the name has inferior hierarchical names, then the inferior 1829 hierarchical names MUST also be renamed. For example, a rename of 1830 "foo" to "zap" will rename "foo/bar" (assuming "/" is the hierarchy 1831 delimiter character) to "zap/bar". 1833 If the server's hierarchy separator character appears in the name, 1834 the server SHOULD create any superior hierarchical names that are 1835 needed for the RENAME command to complete successfully. In other 1836 words, an attempt to rename "foo/bar/zap" to baz/rag/zowie on a 1837 server in which "/" is the hierarchy separator character SHOULD 1838 create baz/ and baz/rag/ if they do not already exist. 1840 The value of the highest-used unique identifier of the old mailbox 1841 name MUST be preserved so that a new mailbox created with the same 1842 name will not reuse the identifiers of the former incarnation, UNLESS 1843 the new incarnation has a different unique identifier validity value. 1844 See the description of the UID command for more detail. 1846 Renaming INBOX is permitted, and has special behavior. It moves all 1847 messages in INBOX to a new mailbox with the given name, leaving INBOX 1848 empty. If the server implementation supports inferior hierarchical 1849 names of INBOX, these are unaffected by a rename of INBOX. 1851 Examples: C: A682 LIST "" * 1852 S: * LIST () "/" blurdybloop 1853 S: * LIST (\Noselect) "/" foo 1854 S: * LIST () "/" foo/bar 1855 S: A682 OK LIST completed 1856 C: A683 RENAME blurdybloop sarasoop 1857 S: A683 OK RENAME completed 1858 C: A684 RENAME foo zowie 1859 S: A684 OK RENAME Completed 1860 C: A685 LIST "" * 1861 S: * LIST () "/" sarasoop 1862 S: * LIST (\Noselect) "/" zowie 1863 S: * LIST () "/" zowie/bar 1864 S: A685 OK LIST completed 1866 C: Z432 LIST "" * 1867 S: * LIST () "." INBOX 1868 S: * LIST () "." INBOX.bar 1869 S: Z432 OK LIST completed 1870 C: Z433 RENAME INBOX old-mail 1871 S: Z433 OK RENAME completed 1872 C: Z434 LIST "" * 1873 S: * LIST () "." INBOX 1874 S: * LIST () "." INBOX.bar 1875 S: * LIST () "." old-mail 1876 S: Z434 OK LIST completed 1878 6.3.7. SUBSCRIBE Command 1880 Arguments: mailbox 1882 Responses: no specific responses for this command 1884 Result: OK - subscribe completed 1885 NO - subscribe failure: can't subscribe to that name 1886 BAD - command unknown or arguments invalid 1888 The SUBSCRIBE command adds the specified mailbox name to the server's 1889 set of "active" or "subscribed" mailboxes as returned by the LSUB 1890 command. This command returns a tagged OK response only if the 1891 subscription is successful. 1893 A server MAY validate the mailbox argument to SUBSCRIBE to verify 1894 that it exists. However, it MUST NOT unilaterally remove an existing 1895 mailbox name from the subscription list even if a mailbox by that 1896 name no longer exists. 1898 Note: This requirement is because a server site can choose to 1899 routinely remove a mailbox with a well-known name (e.g., "system- 1900 alerts") after its contents expire, with the intention of 1901 recreating it when new contents are appropriate. 1903 Example: C: A002 SUBSCRIBE #news.comp.mail.mime 1904 S: A002 OK SUBSCRIBE completed 1906 6.3.8. UNSUBSCRIBE Command 1908 Arguments: mailbox name 1910 Responses: no specific responses for this command 1912 Result: OK - unsubscribe completed 1913 NO - unsubscribe failure: can't unsubscribe that name 1914 BAD - command unknown or arguments invalid 1916 The UNSUBSCRIBE command removes the specified mailbox name from the 1917 server's set of "active" or "subscribed" mailboxes as returned by the 1918 LSUB command. This command returns a tagged OK response only if the 1919 unsubscription is successful. 1921 Example: C: A002 UNSUBSCRIBE #news.comp.mail.mime 1922 S: A002 OK UNSUBSCRIBE completed 1924 6.3.9. LIST Command 1926 Arguments: reference name 1927 mailbox name with possible wildcards 1929 Responses: untagged responses: LIST 1931 Result: OK - list completed 1932 NO - list failure: can't list that reference or name 1933 BAD - command unknown or arguments invalid 1935 The LIST command returns a subset of names from the complete set of 1936 all names available to the client. Zero or more untagged LIST 1937 replies are returned, containing the name attributes, hierarchy 1938 delimiter, and name; see the description of the LIST reply for more 1939 detail. 1941 The LIST command SHOULD return its data quickly, without undue delay. 1942 For example, it SHOULD NOT go to excess trouble to calculate the 1943 \Marked or \Unmarked status or perform other processing; if each name 1944 requires 1 second of processing, then a list of 1200 names would take 1945 20 minutes! 1946 An empty ("" string) reference name argument indicates that the 1947 mailbox name is interpreted as by SELECT. The returned mailbox names 1948 MUST match the supplied mailbox name pattern. A non-empty reference 1949 name argument is the name of a mailbox or a level of mailbox 1950 hierarchy, and indicates the context in which the mailbox name is 1951 interpreted. 1953 An empty ("" string) mailbox name argument is a special request to 1954 return the hierarchy delimiter and the root name of the name given in 1955 the reference. The value returned as the root MAY be the empty 1956 string if the reference is non-rooted or is an empty string. In all 1957 cases, a hierarchy delimiter (or NIL if there is no hierarchy) is 1958 returned. This permits a client to get the hierarchy delimiter (or 1959 find out that the mailbox names are flat) even when no mailboxes by 1960 that name currently exist. 1962 The reference and mailbox name arguments are interpreted into a 1963 canonical form that represents an unambiguous left-to-right 1964 hierarchy. The returned mailbox names will be in the interpreted 1965 form. 1967 Note: The interpretation of the reference argument is 1968 implementation-defined. It depends upon whether the server 1969 implementation has a concept of the "current working directory" 1970 and leading "break out characters", which override the current 1971 working directory. 1973 For example, on a server which exports a UNIX or NT filesystem, 1974 the reference argument contains the current working directory, and 1975 the mailbox name argument would contain the name as interpreted in 1976 the current working directory. 1978 If a server implementation has no concept of break out characters, 1979 the canonical form is normally the reference name appended with 1980 the mailbox name. Note that if the server implements the 1981 namespace convention (Section 5.1.2.1), "#" is a break out 1982 character and must be treated as such. 1984 If the reference argument is not a level of mailbox hierarchy 1985 (that is, it is a \NoInferiors name), and/or the reference 1986 argument does not end with the hierarchy delimiter, it is 1987 implementation-dependent how this is interpreted. For example, a 1988 reference of "foo/bar" and mailbox name of "rag/baz" could be 1989 interpreted as "foo/bar/rag/baz", "foo/barrag/baz", or "foo/rag/ 1990 baz". A client SHOULD NOT use such a reference argument except at 1991 the explicit request of the user. A hierarchical browser MUST NOT 1992 make any assumptions about server interpretation of the reference 1993 unless the reference is a level of mailbox hierarchy AND ends with 1994 the hierarchy delimiter. 1996 Any part of the reference argument that is included in the 1997 interpreted form SHOULD prefix the interpreted form. It SHOULD also 1998 be in the same form as the reference name argument. This rule 1999 permits the client to determine if the returned mailbox name is in 2000 the context of the reference argument, or if something about the 2001 mailbox argument overrode the reference argument. Without this rule, 2002 the client would have to have knowledge of the server's naming 2003 semantics including what characters are "breakouts" that override a 2004 naming context. 2006 For example, here are some examples of how references 2007 and mailbox names might be interpreted on a UNIX-based 2008 server: 2010 Reference Mailbox Name Interpretation 2011 ------------ ------------ -------------- 2012 ~smith/Mail/ foo.* ~smith/Mail/foo.* 2013 archive/ % archive/% 2014 #news. comp.mail.* #news.comp.mail.* 2015 ~smith/Mail/ /usr/doc/foo /usr/doc/foo 2016 archive/ ~fred/Mail/* ~fred/Mail/* 2018 The first three examples demonstrate interpretations in 2019 the context of the reference argument. Note that 2020 "~smith/Mail" SHOULD NOT be transformed into something 2021 like "/u2/users/smith/Mail", or it would be impossible 2022 for the client to determine that the interpretation was 2023 in the context of the reference. 2025 The character "*" is a wildcard, and matches zero or more characters 2026 at this position. The character "%" is similar to "*", but it does 2027 not match a hierarchy delimiter. If the "%" wildcard is the last 2028 character of a mailbox name argument, matching levels of hierarchy 2029 are also returned. If these levels of hierarchy are not also 2030 selectable mailboxes, they are returned with the \Noselect mailbox 2031 name attribute (see the description of the LIST response for more 2032 details). 2034 Server implementations are permitted to "hide" otherwise accessible 2035 mailboxes from the wildcard characters, by preventing certain 2036 characters or names from matching a wildcard in certain situations. 2037 For example, a UNIX-based server might restrict the interpretation of 2038 "*" so that an initial "/" character does not match. 2040 The special name INBOX is included in the output from LIST, if INBOX 2041 is supported by this server for this user and if the uppercase string 2042 "INBOX" matches the interpreted reference and mailbox name arguments 2043 with wildcards as described above. The criteria for omitting INBOX 2044 is whether SELECT INBOX will return failure; it is not relevant 2045 whether the user's real INBOX resides on this or some other server. 2047 Example: C: A101 LIST "" "" 2048 S: * LIST (\Noselect) "/" "" 2049 S: A101 OK LIST Completed 2050 C: A102 LIST #news.comp.mail.misc "" 2051 S: * LIST (\Noselect) "." #news. 2052 S: A102 OK LIST Completed 2053 C: A103 LIST /usr/staff/jones "" 2054 S: * LIST (\Noselect) "/" / 2055 S: A103 OK LIST Completed 2056 C: A202 LIST ~/Mail/ % 2057 S: * LIST (\Noselect) "/" ~/Mail/foo 2058 S: * LIST () "/" ~/Mail/meetings 2059 S: A202 OK LIST completed 2061 6.3.10. LSUB Command 2063 Arguments: reference name 2064 mailbox name with possible wildcards 2066 Responses: untagged responses: LSUB 2068 Result: OK - lsub completed 2069 NO - lsub failure: can't list that reference or name 2070 BAD - command unknown or arguments invalid 2072 The LSUB command returns a subset of names from the set of names that 2073 the user has declared as being "active" or "subscribed". Zero or 2074 more untagged LSUB replies are returned. The arguments to LSUB are 2075 in the same form as those for LIST. 2077 The returned untagged LSUB response MAY contain different mailbox 2078 flags from a LIST untagged response. If this should happen, the 2079 flags in the untagged LIST are considered more authoritative. 2081 A special situation occurs when using LSUB with the % wildcard. 2082 Consider what happens if "foo/bar" (with a hierarchy delimiter of 2083 "/") is subscribed but "foo" is not. A "%" wildcard to LSUB must 2084 return foo, not foo/bar, in the LSUB response, and it MUST be flagged 2085 with the \Noselect attribute. 2087 The server MUST NOT unilaterally remove an existing mailbox name from 2088 the subscription list even if a mailbox by that name no longer 2089 exists. 2091 Example: C: A002 LSUB "#news." "comp.mail.*" 2092 S: * LSUB () "." #news.comp.mail.mime 2093 S: * LSUB () "." #news.comp.mail.misc 2094 S: A002 OK LSUB completed 2095 C: A003 LSUB "#news." "comp.%" 2096 S: * LSUB (\NoSelect) "." #news.comp.mail 2097 S: A003 OK LSUB completed 2099 6.3.11. NAMESPACE Command 2101 Arguments: none 2103 Responses: REQUIRED untagged responses: NAMESPACE 2105 Result: OK - command completed 2106 NO - Can't complete the command 2107 BAD - arguments invalid 2109 The NAMESPACE command causes a single ungagged NAMESPACE response to 2110 be returned. The untagged NAMESPACE response contains the prefix and 2111 hierarchy delimiter to the server's Personal Namespace(s), Other 2112 Users' Namespace(s), and Shared Namespace(s) that the server wishes 2113 to expose. The response will contain a NIL for any namespace class 2114 that is not available. Namespace_Response_Extensions MAY be included 2115 in the response. Namespace_Response_Extensions which are not on the 2116 IETF standards track, MUST be prefixed with an "X-". 2118 Example 1: 2120 In this example a server supports a single personal namespace. No 2121 leading prefix is used on personal mailboxes and "/" is the hierarchy 2122 delimiter. 2124 C: A001 NAMESPACE 2125 S: * NAMESPACE (("" "/")) NIL NIL 2126 S: A001 OK NAMESPACE command completed 2128 Example 2: 2130 A user logged on anonymously to a server. No personal mailboxes are 2131 associated with the anonymous user and the user does not have access 2132 to the Other Users' Namespace. No prefix is required to access 2133 shared mailboxes and the hierarchy delimiter is "." 2134 C: A001 NAMESPACE 2135 S: * NAMESPACE NIL NIL (("" ".")) 2136 S: A001 OK NAMESPACE command completed 2138 Example 3: 2140 A server that contains a Personal Namespace and a single Shared 2141 Namespace. 2143 C: A001 NAMESPACE 2144 S: * NAMESPACE (("" "/")) NIL (("Public Folders/" "/")) 2145 S: A001 OK NAMESPACE command completed 2147 Example 4: 2149 A server that contains a Personal Namespace, Other Users' Namespace 2150 and multiple Shared Namespaces. Note that the hierarchy delimiter 2151 used within each namespace can be different. 2153 C: A001 NAMESPACE 2154 S: * NAMESPACE (("" "/")) (("~" "/")) (("#shared/" "/") 2155 ("#public/" "/")("#ftp/" "/")("#news." ".")) 2156 S: A001 OK NAMESPACE command completed 2158 The prefix string allows a client to do things such as automatically 2159 creating personal mailboxes or LISTing all available mailboxes within 2160 a namespace. 2162 Example 5: 2164 A server that supports only the Personal Namespace, with a leading 2165 prefix of INBOX to personal mailboxes and a hierarchy delimiter of 2166 "." 2168 C: A001 NAMESPACE 2169 S: * NAMESPACE (("INBOX." ".")) NIL NIL 2170 S: A001 OK NAMESPACE command completed 2172 < Automatically create a mailbox to store sent items.> 2174 C: A002 CREATE "INBOX.Sent Mail" 2175 S: A002 OK CREATE command completed 2177 Although typically a server will support only a single Personal 2178 Namespace, and a single Other User's Namespace, circumstances exist 2179 where there MAY be multiples of these, and a client MUST be prepared 2180 for them. If a client is configured such that it is required to 2181 create a certain mailbox, there can be circumstances where it is 2182 unclear which Personal Namespaces it should create the mailbox in. 2183 In these situations a client SHOULD let the user select which 2184 namespaces to create the mailbox in. 2186 Example 6: 2188 In this example, a server supports 2 Personal Namespaces. In 2189 addition to the regular Personal Namespace, the user has an 2190 additional personal namespace to allow access to mailboxes in an MH 2191 format mailstore. 2193 The client is configured to save a copy of all mail sent by the user 2194 into a mailbox called 'Sent Mail'. Furthermore, after a message is 2195 deleted from a mailbox, the client is configured to move that message 2196 to a mailbox called 'Deleted Items'. 2198 Note that this example demonstrates how some extension flags can be 2199 passed to further describe the #mh namespace. 2201 C: A001 NAMESPACE 2202 S: * NAMESPACE (("" "/")("#mh/" "/" "X-PARAM" ("FLAG1" "FLAG2"))) 2203 NIL NIL 2204 S: A001 OK NAMESPACE command completed 2206 < It is desired to keep only one copy of sent mail. It is unclear 2207 which Personal Namespace the client should use to create the 'Sent 2208 Mail' mailbox. The user is prompted to select a namespace and 2209 only one 'Sent Mail' mailbox is created. > 2211 C: A002 CREATE "Sent Mail" 2212 S: A002 OK CREATE command completed 2214 < The client is designed so that it keeps two 'Deleted Items' 2215 mailboxes, one for each namespace. > 2217 C: A003 CREATE "Delete Items" 2218 S: A003 OK CREATE command completed 2220 C: A004 CREATE "#mh/Deleted Items" 2221 S: A004 OK CREATE command completed 2223 The next level of hierarchy following the Other Users' Namespace 2224 prefix SHOULD consist of , where is a user name 2225 as per the LOGIN or AUTHENTICATE command. 2227 A client can construct a LIST command by appending a "%" to the Other 2228 Users' Namespace prefix to discover the Personal Namespaces of other 2229 users that are available to the currently authenticated user. 2231 In response to such a LIST command, a server SHOULD NOT return user 2232 names that have not granted access to their personal mailboxes to the 2233 user in question. 2235 A server MAY return a LIST response containing only the names of 2236 users that have explicitly granted access to the user in question. 2238 Alternatively, a server MAY return NO to such a LIST command, 2239 requiring that a user name be included with the Other Users' 2240 Namespace prefix before listing any other user's mailboxes. 2242 Example 7: 2244 A server that supports providing a list of other user's mailboxes 2245 that are accessible to the currently logged on user. 2247 C: A001 NAMESPACE 2248 S: * NAMESPACE (("" "/")) (("Other Users/" "/")) NIL 2249 S: A001 OK NAMESPACE command completed 2251 C: A002 LIST "" "Other Users/%" 2252 S: * LIST () "/" "Other Users/Mike" 2253 S: * LIST () "/" "Other Users/Karen" 2254 S: * LIST () "/" "Other Users/Matthew" 2255 S: * LIST () "/" "Other Users/Tesa" 2256 S: A002 OK LIST command completed 2258 Example 8: 2260 A server that does not support providing a list of other user's 2261 mailboxes that are accessible to the currently logged on user. The 2262 mailboxes are listable if the client includes the name of the other 2263 user with the Other Users' Namespace prefix. 2265 C: A001 NAMESPACE 2266 S: * NAMESPACE (("" "/")) (("#Users/" "/")) NIL 2267 S: A001 OK NAMESPACE command completed 2269 < In this example, the currently logged on user has access to the 2270 Personal Namespace of user Mike, but the server chose to suppress 2271 this information in the LIST response. However, by appending the 2272 user name Mike (received through user input) to the Other Users' 2273 Namespace prefix, the client is able to get a listing of the 2274 personal mailboxes of user Mike. > 2276 C: A002 LIST "" "#Users/%" 2277 S: A002 NO The requested item could not be found. 2279 C: A003 LIST "" "#Users/Mike/%" 2280 S: * LIST () "/" "#Users/Mike/INBOX" 2281 S: * LIST () "/" "#Users/Mike/Foo" 2282 S: A003 OK LIST command completed. 2284 A prefix string might not contain a hierarchy delimiter, because in 2285 some cases it is not needed as part of the prefix. 2287 Example 9: 2289 A server that allows access to the Other Users' Namespace by 2290 prefixing the others' mailboxes with a '~' followed by , 2291 where is a user name as per the LOGIN or AUTHENTICATE 2292 command. 2294 C: A001 NAMESPACE 2295 S: * NAMESPACE (("" "/")) (("~" "/")) NIL 2296 S: A001 OK NAMESPACE command completed 2298 < List the mailboxes for user mark > 2300 C: A002 LIST "" "~mark/%" 2301 S: * LIST () "/" "~mark/INBOX" 2302 S: * LIST () "/" "~mark/foo" 2303 S: A002 OK LIST command completed 2305 6.3.12. STATUS Command 2307 Arguments: mailbox name 2308 status data item names 2310 Responses: REQUIRED untagged responses: STATUS 2312 Result: OK - status completed 2313 NO - status failure: no status for that name 2314 BAD - command unknown or arguments invalid 2316 The STATUS command requests the status of the indicated mailbox. It 2317 does not change the currently selected mailbox, nor does it affect 2318 the state of any messages in the queried mailbox (in particular, 2319 STATUS MUST NOT cause messages to lose the \Recent flag). 2321 The STATUS command provides an alternative to opening a second 2322 IMAP4rev2 connection and doing an EXAMINE command on a mailbox to 2323 query that mailbox's status without deselecting the current mailbox 2324 in the first IMAP4rev2 connection. 2326 Unlike the LIST command, the STATUS command is not guaranteed to be 2327 fast in its response. Under certain circumstances, it can be quite 2328 slow. In some implementations, the server is obliged to open the 2329 mailbox read-only internally to obtain certain status information. 2330 Also unlike the LIST command, the STATUS command does not accept 2331 wildcards. 2333 Note: The STATUS command is intended to access the status of 2334 mailboxes other than the currently selected mailbox. Because the 2335 STATUS command can cause the mailbox to be opened internally, and 2336 because this information is available by other means on the 2337 selected mailbox, the STATUS command SHOULD NOT be used on the 2338 currently selected mailbox. 2340 The STATUS command MUST NOT be used as a "check for new messages 2341 in the selected mailbox" operation (refer to sections 7, 2342 Section 7.3.1, and Section 7.3.2 for more information about the 2343 proper method for new message checking). 2345 Because the STATUS command is not guaranteed to be fast in its 2346 results, clients SHOULD NOT expect to be able to issue many 2347 consecutive STATUS commands and obtain reasonable performance. 2349 The currently defined status data items that can be requested are: 2351 MESSAGES The number of messages in the mailbox. 2353 RECENT The number of messages with the \Recent flag set. 2355 UIDNEXT The next unique identifier value of the mailbox. Refer to 2356 Section 2.3.1.1 for more information. 2358 UIDVALIDITY The unique identifier validity value of the mailbox. 2359 Refer to Section 2.3.1.1 for more information. 2361 UNSEEN The number of messages which do not have the \Seen flag set. 2363 SIZE The total size of the mailbox in octets. This MUST be equal to 2364 the sum of the [RFC-5322] size of all messages in the mailbox. 2365 The total size of the mailbox in octets. This is not strictly 2366 required to be an exact value, but it MUST be equal to or greater 2367 than the sum of the values of the RFC822.SIZE FETCH message data 2368 items (see Section 6.4.6) of all messages in the mailbox. 2370 Example: C: A042 STATUS blurdybloop (UIDNEXT MESSAGES) 2371 S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) 2372 S: A042 OK STATUS completed 2374 6.3.13. APPEND Command 2376 Arguments: mailbox name 2377 OPTIONAL flag parenthesized list 2378 OPTIONAL date/time string 2379 message literal 2381 Responses: no specific responses for this command 2383 Result: OK - append completed 2384 NO - append error: can't append to that mailbox, error 2385 in flags or date/time or message text 2386 BAD - command unknown or arguments invalid 2388 The APPEND command appends the literal argument as a new message to 2389 the end of the specified destination mailbox. This argument SHOULD 2390 be in the format of an [RFC-5322] message. 8-bit characters are 2391 permitted in the message. A server implementation that is unable to 2392 preserve 8-bit data properly MUST be able to reversibly convert 8-bit 2393 APPEND data to 7-bit using a [MIME-IMB] content transfer encoding. 2395 Note: There may be exceptions, e.g., draft messages, in which 2396 required [RFC-5322] header lines are omitted in the message 2397 literal argument to APPEND. The full implications of doing so 2398 must be understood and carefully weighed. 2400 If a flag parenthesized list is specified, the flags SHOULD be set in 2401 the resulting message; otherwise, the flag list of the resulting 2402 message is set to empty by default. In either case, the Recent flag 2403 is also set. 2405 If a date-time is specified, the internal date SHOULD be set in the 2406 resulting message; otherwise, the internal date of the resulting 2407 message is set to the current date and time by default. 2409 If the append is unsuccessful for any reason, the mailbox MUST be 2410 restored to its state before the APPEND attempt; no partial appending 2411 is permitted. 2413 If the destination mailbox does not exist, a server MUST return an 2414 error, and MUST NOT automatically create the mailbox. Unless it is 2415 certain that the destination mailbox can not be created, the server 2416 MUST send the response code "[TRYCREATE]" as the prefix of the text 2417 of the tagged NO response. This gives a hint to the client that it 2418 can attempt a CREATE command and retry the APPEND if the CREATE is 2419 successful. 2421 On successful completion of an APPEND, the server SHOULD return an 2422 APPENDUID response code. 2424 In the case of a mailbox that has permissions set so that the client 2425 can APPEND to the mailbox, but not SELECT or EXAMINE it, the server 2426 SHOULD NOT send an APPENDUID response code as it would disclose 2427 information about the mailbox. 2429 In the case of a mailbox that has UIDNOTSTICKY status (see 2430 UIDNOTSTICKY response code definition), the server MAY omit the 2431 APPENDUID response code as it is not meaningful. 2433 If the server does not return the APPENDUID response codes, the 2434 client can discover this information by selecting the destination 2435 mailbox. The location of messages placed in the destination mailbox 2436 by APPEND can be determined by using FETCH and/or SEARCH commands 2437 (e.g., for Message-ID or some unique marker placed in the message in 2438 an APPEND). 2440 If the mailbox is currently selected, the normal new message actions 2441 SHOULD occur. Specifically, the server SHOULD notify the client 2442 immediately via an untagged EXISTS response. If the server does not 2443 do so, the client MAY issue a NOOP command (or failing that, a CHECK 2444 command) after one or more APPEND commands. 2446 Example: C: A003 APPEND saved-messages (\Seen) {310} 2447 S: + Ready for literal data 2448 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST) 2449 C: From: Fred Foobar 2450 C: Subject: afternoon meeting 2451 C: To: mooch@owatagu.siam.edu 2452 C: Message-Id: 2453 C: MIME-Version: 1.0 2454 C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 2455 C: 2456 C: Hello Joe, do you think we can meet at 3:30 tomorrow? 2457 C: 2458 S: A003 OK APPEND completed 2460 Example: C: A003 APPEND saved-messages (\Seen) {297} 2461 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST) 2462 C: From: Fred Foobar 2463 C: Subject: afternoon meeting 2464 C: To: mooch@example.com 2465 C: Message-Id: 2466 C: MIME-Version: 1.0 2467 C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 2468 C: 2469 C: Hello Joe, do you think we can meet at 3:30 tomorrow? 2470 C: 2471 S: A003 OK [APPENDUID 38505 3955] APPEND completed 2472 C: A004 COPY 2:4 meeting 2473 S: A004 OK [COPYUID 38505 304,319:320 3956:3958] Done 2474 C: A005 UID COPY 305:310 meeting 2475 S: A005 OK No matching messages, so nothing copied 2476 C: A006 COPY 2 funny 2477 S: A006 OK Done 2478 C: A007 SELECT funny 2479 S: * 1 EXISTS 2480 S: * 1 RECENT 2481 S: * OK [UNSEEN 1] Message 1 is first unseen 2482 S: * OK [UIDVALIDITY 3857529045] Validity session-only 2483 S: * OK [UIDNEXT 2] Predicted next UID 2484 S: * NO [UIDNOTSTICKY] Non-persistent UIDs 2485 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 2486 S: * OK [PERMANENTFLAGS (\Deleted \Seen)] Limited 2487 S: A007 OK [READ-WRITE] SELECT completed 2489 In this example, A003 and A004 demonstrate successful appending and 2490 copying to a mailbox that returns the UIDs assigned to the messages. 2491 A005 is an example in which no messages were copied; this is because 2492 in A003, we see that message 2 had UID 304, and message 3 had UID 2493 319; therefore, UIDs 305 through 310 do not exist (refer to 2494 Section 2.3.1.1 for further explanation). A006 is an example of a 2495 message being copied that did not return a COPYUID; and, as expected, 2496 A007 shows that the mail store containing that mailbox does not 2497 support persistent UIDs. 2499 Note: The APPEND command is not used for message delivery, because 2500 it does not provide a mechanism to transfer [SMTP] envelope 2501 information. 2503 6.3.14. IDLE Command 2505 Arguments: none 2507 Responses: continuation data will be requested; the client sends the 2508 continuation data "DONE" to end the command 2510 Result: OK - IDLE completed after client sent "DONE" 2511 NO - failure: the server will not allow the IDLE command 2512 at this time 2513 BAD - command unknown or arguments invalid 2515 Without the IDLE command a client requires to poll the server for 2516 changes to the selected mailbox (new mail, deletions, flag changes). 2517 It's often more desirable to have the server transmit updates to the 2518 client in real time. This allows a user to see new mail immediately. 2519 The IDLE command allows a client to tell the server that it's ready 2520 to accept such real-time updates. 2522 The IDLE command is sent from the client to the server when the 2523 client is ready to accept unsolicited mailbox update messages. The 2524 server requests a response to the IDLE command using the continuation 2525 ("+") response. The IDLE command remains active until the client 2526 responds to the continuation, and as long as an IDLE command is 2527 active, the server is now free to send untagged EXISTS, EXPUNGE, and 2528 other responses at any time. 2530 The IDLE command is terminated by the receipt of a "DONE" 2531 continuation from the client; such response satisfies the server's 2532 continuation request. At that point, the server MAY send any 2533 remaining queued untagged responses and then MUST immediately send 2534 the tagged response to the IDLE command and prepare to process other 2535 commands. As in the base specification, the processing of any new 2536 command may cause the sending of unsolicited untagged responses, 2537 subject to the ambiguity limitations. The client MUST NOT send a 2538 command while the server is waiting for the DONE, since the server 2539 will not be able to distinguish a command from a continuation. 2541 The server MAY consider a client inactive if it has an IDLE command 2542 running, and if such a server has an inactivity timeout it MAY log 2543 the client off implicitly at the end of its timeout period. Because 2544 of that, clients using IDLE are advised to terminate the IDLE and re- 2545 issue it at least every 29 minutes to avoid being logged off. This 2546 still allows a client to receive immediate mailbox updates even 2547 though it need only "poll" at half hour intervals. 2549 Example: C: A001 SELECT INBOX 2550 S: * FLAGS (Deleted Seen) 2551 S: * 3 EXISTS 2552 S: * 0 RECENT 2553 S: * OK [UIDVALIDITY 1] 2554 S: A001 OK SELECT completed 2555 C: A002 IDLE 2556 S: + idling 2557 ...time passes; new mail arrives... 2558 S: * 4 EXISTS 2559 C: DONE 2560 S: A002 OK IDLE terminated 2561 ...another client expunges message 2 now... 2562 C: A003 FETCH 4 ALL 2563 S: * 4 FETCH (...) 2564 S: A003 OK FETCH completed 2565 C: A004 IDLE 2566 S: * 2 EXPUNGE 2567 S: * 3 EXISTS 2568 S: + idling 2569 ...time passes; another client expunges message 3... 2570 S: * 3 EXPUNGE 2571 S: * 2 EXISTS 2572 ...time passes; new mail arrives... 2573 S: * 3 EXISTS 2574 C: DONE 2575 S: A004 OK IDLE terminated 2576 C: A005 FETCH 3 ALL 2577 S: * 3 FETCH (...) 2578 S: A005 OK FETCH completed 2579 C: A006 IDLE 2581 6.4. Client Commands - Selected State 2583 In the selected state, commands that manipulate messages in a mailbox 2584 are permitted. 2586 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 2587 and the authenticated state commands (SELECT, EXAMINE, NAMESPACE, 2588 CREATE, DELETE, RENAME, SUBSCRIBE, UNSUBSCRIBE, LIST, LSUB , STATUS, 2589 and APPEND), the following commands are valid in the selected state: 2590 CHECK, CLOSE, UNSELECT, EXPUNGE, SEARCH, FETCH, STORE, COPY, and UID. 2592 6.4.1. CHECK Command 2594 Arguments: none 2596 Responses: no specific responses for this command 2598 Result: OK - check completed 2599 BAD - command unknown or arguments invalid 2601 The CHECK command requests a checkpoint of the currently selected 2602 mailbox. A checkpoint refers to any implementation-dependent 2603 housekeeping associated with the mailbox (e.g., resolving the 2604 server's in-memory state of the mailbox with the state on its disk) 2605 that is not normally executed as part of each command. A checkpoint 2606 MAY take a non-instantaneous amount of real time to complete. If a 2607 server implementation has no such housekeeping considerations, CHECK 2608 is equivalent to NOOP. 2610 There is no guarantee that an EXISTS untagged response will happen as 2611 a result of CHECK. NOOP, not CHECK, SHOULD be used for new message 2612 polling. 2614 Example: C: FXXZ CHECK 2615 S: FXXZ OK CHECK Completed 2617 6.4.2. CLOSE Command 2619 Arguments: none 2621 Responses: no specific responses for this command 2623 Result: OK - close completed, now in authenticated state 2624 BAD - command unknown or arguments invalid 2626 The CLOSE command permanently removes all messages that have the 2627 \Deleted flag set from the currently selected mailbox, and returns to 2628 the authenticated state from the selected state. No untagged EXPUNGE 2629 responses are sent. 2631 No messages are removed, and no error is given, if the mailbox is 2632 selected by an EXAMINE command or is otherwise selected read-only. 2634 Even if a mailbox is selected, a SELECT, EXAMINE, or LOGOUT command 2635 MAY be issued without previously issuing a CLOSE command. The 2636 SELECT, EXAMINE, and LOGOUT commands implicitly close the currently 2637 selected mailbox without doing an expunge. However, when many 2638 messages are deleted, a CLOSE-LOGOUT or CLOSE-SELECT sequence is 2639 considerably faster than an EXPUNGE-LOGOUT or EXPUNGE-SELECT because 2640 no untagged EXPUNGE responses (which the client would probably 2641 ignore) are sent. 2643 Example: C: A341 CLOSE 2644 S: A341 OK CLOSE completed 2646 6.4.3. UNSELECT Command 2648 Arguments: none 2650 Responses: no specific responses for this command 2652 Result: OK - unselect completed, now in authenticated state 2653 BAD - no mailbox selected, or argument supplied but none 2654 permitted 2656 The UNSELECT command frees server's resources associated with the 2657 selected mailbox and returns the server to the authenticated state. 2658 This command performs the same actions as CLOSE, except that no 2659 messages are permanently removed from the currently selected mailbox. 2661 Example: C: A342 UNSELECT 2662 S: A342 OK Unselect completed 2664 6.4.4. EXPUNGE Command 2666 Arguments: none 2668 Responses: untagged responses: EXPUNGE 2670 Result: OK - expunge completed 2671 NO - expunge failure: can't expunge (e.g., permission 2672 denied) 2673 BAD - command unknown or arguments invalid 2675 The EXPUNGE command permanently removes all messages that have the 2676 \Deleted flag set from the currently selected mailbox. Before 2677 returning an OK to the client, an untagged EXPUNGE response is sent 2678 for each message that is removed. Note that if any messages with the 2679 \Recent flag set are expunged, an untagged RECENT response is sent 2680 after the untagged EXPUNGE(s) to update the client's count of RECENT 2681 messages. 2683 Example: C: A202 EXPUNGE 2684 S: * 3 EXPUNGE 2685 S: * 3 EXPUNGE 2686 S: * 5 EXPUNGE 2687 S: * 8 EXPUNGE 2688 S: A202 OK EXPUNGE completed 2690 Note: In this example, messages 3, 4, 7, and 11 had the \Deleted flag 2691 set. See the description of the EXPUNGE response for further 2692 explanation. 2694 6.4.5. SEARCH Command 2696 Arguments: OPTIONAL result specifier 2697 OPTIONAL [CHARSET] specification 2698 searching criteria (one or more) 2700 Responses: REQUIRED untagged response: ESEARCH 2702 Result: OK - search completed 2703 NO - search error: can't search that [CHARSET] or 2704 criteria 2705 BAD - command unknown or arguments invalid 2707 The SEARCH command searches the mailbox for messages that match the 2708 given searching criteria. 2710 The SEARCH command may contain result options. Result options 2711 control what kind of information is returned about messages matching 2712 the search criteria in an untagged ESEARCH response. If no result 2713 option is specified or empty list of options is specified "()", ALL 2714 is assumed (see below). The order of individual options is 2715 arbitrary. Individual options may contain parameters enclosed in 2716 parentheses (*). If an option has parameters, they consist of atoms 2717 and/or strings and/or lists in a specific order. Any options not 2718 defined by extensions that the server supports must be rejected with 2719 a BAD response. 2721 (*) - if an option has a mandatory parameter, which can always be 2722 represented as a number or a sequence-set, the option parameter does 2723 not need the enclosing (). See ABNF for more details. 2725 This document specifies the following result options: 2727 MIN 2729 Return the lowest message number/UID that satisfies the SEARCH 2730 criteria. 2732 If the SEARCH results in no matches, the server MUST NOT 2733 include the MIN result option in the ESEARCH response; however, 2734 it still MUST send the ESEARCH response. 2736 MAX 2738 Return the highest message number/UID that satisfies the SEARCH 2739 criteria. 2741 If the SEARCH results in no matches, the server MUST NOT 2742 include the MAX result option in the ESEARCH response; however, 2743 it still MUST send the ESEARCH response. 2745 ALL 2747 Return all message numbers/UIDs that satisfy the SEARCH 2748 criteria using the sequence-set syntax. Note, the client MUST 2749 NOT assume that messages/UIDs will be listed in any particular 2750 order. 2752 If the SEARCH results in no matches, the server MUST NOT 2753 include the ALL result option in the ESEARCH response; however, 2754 it still MUST send the ESEARCH response. 2756 COUNT Return number of the messages that satisfy the SEARCH 2757 criteria. This result option MUST always be included in the 2758 ESEARCH response. 2760 Note: future extensions to this document can allow servers to return 2761 multiple ESEARCH responses for a single extended SEARCH command. 2762 However all options specified above MUST result in a single ESEARCH 2763 response. These extensions will have to describe how results from 2764 multiple ESEARCH responses are to be amalgamated. 2766 Searching criteria consist of one or more search keys. 2768 When multiple keys are specified, the result is the intersection (AND 2769 function) of all the messages that match those keys. For example, 2770 the criteria DELETED FROM "SMITH" SINCE 1-Feb-1994 refers to all 2771 deleted messages from Smith that were placed in the mailbox since 2772 February 1, 1994. A search key can also be a parenthesized list of 2773 one or more search keys (e.g., for use with the OR and NOT keys). 2775 Server implementations MAY exclude [MIME-IMB] body parts with 2776 terminal content media types other than TEXT and MESSAGE from 2777 consideration in SEARCH matching. 2779 The OPTIONAL [CHARSET] specification consists of the word "CHARSET" 2780 followed by a registered [CHARSET]. It indicates the [CHARSET] of 2781 the strings that appear in the search criteria. [MIME-IMB] content 2782 transfer encodings, and [MIME-HDRS] strings in [RFC-5322]/[MIME-IMB] 2783 headers, MUST be decoded before comparing text. US-ASCII MUST be 2784 supported; other [CHARSET]s MAY be supported. 2786 If the server does not support the specified [CHARSET], it MUST 2787 return a tagged NO response (not a BAD). This response SHOULD 2788 contain the BADCHARSET response code, which MAY list the [CHARSET]s 2789 supported by the server. 2791 In all search keys that use strings, a message matches the key if the 2792 string is a substring of the associated text. The matching is case- 2793 insensitive. Note that the empty string is a substring; this is 2794 useful when doing a HEADER search. 2796 The defined search keys are as follows. Refer to the Formal Syntax 2797 section for the precise syntactic definitions of the arguments. 2799 Messages with message sequence numbers corresponding 2800 to the specified message sequence number set. 2802 ALL All messages in the mailbox; the default initial key for ANDing. 2804 ANSWERED Messages with the \Answered flag set. 2806 BCC Messages that contain the specified string in the 2807 envelope structure's BCC field. 2809 BEFORE Messages whose internal date (disregarding time and 2810 timezone) is earlier than the specified date. 2812 BODY Messages that contain the specified string in the body 2813 of the message. 2815 CC Messages that contain the specified string in the 2816 envelope structure's CC field. 2818 DELETED Messages with the \Deleted flag set. 2820 DRAFT Messages with the \Draft flag set. 2822 FLAGGED Messages with the \Flagged flag set. 2824 FROM Messages that contain the specified string in the 2825 envelope structure's FROM field. 2827 HEADER Messages that have a header with the 2828 specified field-name (as defined in [RFC-5322]) and that contains 2829 the specified string in the text of the header (what comes after 2830 the colon). If the string to search is zero-length, this matches 2831 all messages that have a header line with the specified field-name 2832 regardless of the contents. 2834 KEYWORD Messages with the specified keyword flag set. 2836 LARGER Messages with an [RFC-5322] size larger than the 2837 specified number of octets. 2839 NEW Messages that have the \Recent flag set but not the \Seen flag. 2840 This is functionally equivalent to "(RECENT UNSEEN)". 2842 NOT Messages that do not match the specified search 2843 key. 2845 OLD Messages that do not have the \Recent flag set. This is 2846 functionally equivalent to "NOT RECENT" (as opposed to "NOT NEW"). 2848 ON Messages whose internal date (disregarding time and 2849 timezone) is within the specified date. 2851 OR Messages that match either search 2852 key. 2854 RECENT Messages that have the \Recent flag set. 2856 SEEN Messages that have the \Seen flag set. 2858 SENTBEFORE Messages whose [RFC-5322] Date: header 2859 (disregarding time and timezone) is earlier than the specified 2860 date. 2862 SENTON Messages whose [RFC-5322] Date: header (disregarding 2863 time and timezone) is within the specified date. 2865 SENTSINCE Messages whose [RFC-5322] Date: header 2866 (disregarding time and timezone) is within or later than the 2867 specified date. 2869 SINCE Messages whose internal date (disregarding time and 2870 timezone) is within or later than the specified date. 2872 SMALLER Messages with an [RFC-5322] size smaller than the 2873 specified number of octets. 2875 SUBJECT Messages that contain the specified string in the 2876 envelope structure's SUBJECT field. 2878 TEXT Messages that contain the specified string in the 2879 header or body of the message. 2881 TO Messages that contain the specified string in the 2882 envelope structure's TO field. 2884 UID Messages with unique identifiers corresponding to 2885 the specified unique identifier set. Sequence set ranges are 2886 permitted. 2888 UNANSWERED Messages that do not have the \Answered flag set. 2890 UNDELETED Messages that do not have the \Deleted flag set. 2892 UNDRAFT Messages that do not have the \Draft flag set. 2894 UNFLAGGED Messages that do not have the \Flagged flag set. 2896 UNKEYWORD Messages that do not have the specified keyword 2897 flag set. 2899 UNSEEN Messages that do not have the \Seen flag set. 2901 Example: C: A282 SEARCH RETURN (MIN COUNT) FLAGGED 2902 SINCE 1-Feb-1994 NOT FROM "Smith" 2903 S: * ESEARCH (TAG "A282") MIN 2 COUNT 3 2904 S: A282 OK SEARCH completed 2906 Example: C: A283 SEARCH RETURN () FLAGGED 2907 SINCE 1-Feb-1994 NOT FROM "Smith" 2908 S: * ESEARCH (TAG "A283") ALL 2,10:11 2909 S: A283 OK SEARCH completed 2911 Example: C: A284 SEARCH TEXT "string not in mailbox" 2912 S: * ESEARCH (TAG "A284") 2913 S: A284 OK SEARCH completed 2914 C: A285 SEARCH CHARSET UTF-8 TEXT {6} 2915 S: + Ready for literal text 2916 C: XXXXXX 2917 S: * ESEARCH (TAG "A285") ALL 43 2918 S: A285 OK SEARCH completed 2920 Note: Since this document is restricted to 7-bit ASCII text, it is 2921 not possible to show actual UTF-8 data. The "XXXXXX" is a 2922 placeholder for what would be 6 octets of 8-bit data in an actual 2923 transaction. 2925 The following example demonstrates finding the first unseen message 2926 as returned in the UNSEEN response code on a successful SELECT 2927 command: 2929 Example: C: A284 SEARCH RETURN (MIN) UNSEEN 2930 S: * ESEARCH (TAG "A284") MIN 4 2931 S: A284 OK SEARCH completed 2933 The following example demonstrates that if the ESEARCH UID indicator 2934 is present, all data in the ESEARCH response is referring to UIDs; 2935 for example, the MIN result specifier will be followed by a UID. 2937 Example: C: A285 UID SEARCH RETURN (MIN MAX) 1:5000 2938 S: * ESEARCH (TAG "A285") UID MIN 7 MAX 3800 2939 S: A285 OK SEARCH completed 2941 The following example demonstrates returning the number of deleted 2942 messages: 2944 Example: C: A286 SEARCH RETURN (COUNT) DELETED 2945 S: * ESEARCH (TAG "A286") COUNT 15 2946 S: A286 OK SEARCH completed 2948 6.4.6. FETCH Command 2950 Arguments: sequence set 2951 message data item names or macro 2953 Responses: untagged responses: FETCH 2955 Result: OK - fetch completed 2956 NO - fetch error: can't fetch that data 2957 BAD - command unknown or arguments invalid 2959 The FETCH command retrieves data associated with a message in the 2960 mailbox. The data items to be fetched can be either a single atom or 2961 a parenthesized list. 2963 Most data items, identified in the formal syntax under the msg-att- 2964 static rule, are static and MUST NOT change for any particular 2965 message. Other data items, identified in the formal syntax under the 2966 msg-att-dynamic rule, MAY change, either as a result of a STORE 2967 command or due to external events. 2969 For example, if a client receives an ENVELOPE for a message when 2970 it already knows the envelope, it can safely ignore the newly 2971 transmitted envelope. 2973 There are three macros which specify commonly-used sets of data 2974 items, and can be used instead of data items. A macro must be used 2975 by itself, and not in conjunction with other macros or data items. 2977 ALL Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE) 2979 FAST Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE) 2981 FULL Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE 2982 BODY) 2984 The currently defined data items that can be fetched are: 2986 BODY Non-extensible form of BODYSTRUCTURE. 2988 BODY[
]<> 2990 The text of a particular body section. The section 2991 specification is a set of zero or more part specifiers 2992 delimited by periods. A part specifier is either a part number 2993 or one of the following: HEADER, HEADER.FIELDS, 2994 HEADER.FIELDS.NOT, MIME, and TEXT. An empty section 2995 specification refers to the entire message, including the 2996 header. 2998 Every message has at least one part number. Non-[MIME-IMB] 2999 messages, and non-multipart [MIME-IMB] messages with no 3000 encapsulated message, only have a part 1. 3002 Multipart messages are assigned consecutive part numbers, as 3003 they occur in the message. If a particular part is of type 3004 message or multipart, its parts MUST be indicated by a period 3005 followed by the part number within that nested multipart part. 3007 A part of type MESSAGE/RFC822 also has nested part numbers, 3008 referring to parts of the MESSAGE part's body. 3010 The HEADER, HEADER.FIELDS, HEADER.FIELDS.NOT, and TEXT part 3011 specifiers can be the sole part specifier or can be prefixed by 3012 one or more numeric part specifiers, provided that the numeric 3013 part specifier refers to a part of type MESSAGE/RFC822. The 3014 MIME part specifier MUST be prefixed by one or more numeric 3015 part specifiers. 3017 The HEADER, HEADER.FIELDS, and HEADER.FIELDS.NOT part 3018 specifiers refer to the [RFC-5322] header of the message or of 3019 an encapsulated [MIME-IMT] MESSAGE/RFC822 message. 3020 HEADER.FIELDS and HEADER.FIELDS.NOT are followed by a list of 3021 field-name (as defined in [RFC-5322]) names, and return a 3022 subset of the header. The subset returned by HEADER.FIELDS 3023 contains only those header fields with a field-name that 3024 matches one of the names in the list; similarly, the subset 3025 returned by HEADER.FIELDS.NOT contains only the header fields 3026 with a non-matching field-name. The field-matching is case- 3027 insensitive but otherwise exact. Subsetting does not exclude 3028 the [RFC-5322] delimiting blank line between the header and the 3029 body; the blank line is included in all header fetches, except 3030 in the case of a message which has no body and no blank line. 3032 The MIME part specifier refers to the [MIME-IMB] header for 3033 this part. 3035 The TEXT part specifier refers to the text body of the message, 3036 omitting the [RFC-5322] header. 3038 Here is an example of a complex message with some of its 3039 part specifiers: 3041 HEADER ([RFC-5322] header of the message) 3042 TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 3043 1 TEXT/PLAIN 3044 2 APPLICATION/OCTET-STREAM 3045 3 MESSAGE/RFC822 3046 3.HEADER ([RFC-5322] header of the message) 3047 3.TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 3048 3.1 TEXT/PLAIN 3049 3.2 APPLICATION/OCTET-STREAM 3050 4 MULTIPART/MIXED 3051 4.1 IMAGE/GIF 3052 4.1.MIME ([MIME-IMB] header for the IMAGE/GIF) 3053 4.2 MESSAGE/RFC822 3054 4.2.HEADER ([RFC-5322] header of the message) 3055 4.2.TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 3056 4.2.1 TEXT/PLAIN 3057 4.2.2 MULTIPART/ALTERNATIVE 3058 4.2.2.1 TEXT/PLAIN 3059 4.2.2.2 TEXT/RICHTEXT 3061 It is possible to fetch a substring of the designated text. 3062 This is done by appending an open angle bracket ("<"), the 3063 octet position of the first desired octet, a period, the 3064 maximum number of octets desired, and a close angle bracket 3065 (">") to the part specifier. If the starting octet is beyond 3066 the end of the text, an empty string is returned. 3068 Any partial fetch that attempts to read beyond the end of the 3069 text is truncated as appropriate. A partial fetch that starts 3070 at octet 0 is returned as a partial fetch, even if this 3071 truncation happened. 3073 Note: This means that BODY[]<0.2048> of a 1500-octet message 3074 will return BODY[]<0> with a literal of size 1500, not 3075 BODY[]. 3077 Note: A substring fetch of a HEADER.FIELDS or 3078 HEADER.FIELDS.NOT part specifier is calculated after 3079 subsetting the header. 3081 The \Seen flag is implicitly set; if this causes the flags to 3082 change, they SHOULD be included as part of the FETCH responses. 3084 BODY.PEEK[
]<> An alternate form of BODY[
] 3085 that does not implicitly set the \Seen flag. 3087 BODYSTRUCTURE The [MIME-IMB] body structure of the message. This is 3088 computed by the server by parsing the [MIME-IMB] header fields in 3089 the [RFC-5322] header and [MIME-IMB] headers. 3091 ENVELOPE The envelope structure of the message. This is computed by 3092 the server by parsing the [RFC-5322] header into the component 3093 parts, defaulting various fields as necessary. 3095 FLAGS The flags that are set for this message. 3097 INTERNALDATE The internal date of the message. 3099 RFC822 Functionally equivalent to BODY[], differing in the syntax of 3100 the resulting untagged FETCH data (RFC822 is returned). 3102 RFC822.HEADER Functionally equivalent to BODY.PEEK[HEADER], 3103 differing in the syntax of the resulting untagged FETCH data 3104 (RFC822.HEADER is returned). 3106 RFC822.SIZE The [RFC-5322] size of the message. 3108 RFC822.TEXT Functionally equivalent to BODY[TEXT], differing in the 3109 syntax of the resulting untagged FETCH data (RFC822.TEXT is 3110 returned). 3112 UID The unique identifier for the message. 3114 Example: C: A654 FETCH 2:4 (FLAGS BODY[HEADER.FIELDS (DATE FROM)]) 3115 S: * 2 FETCH .... 3116 S: * 3 FETCH .... 3117 S: * 4 FETCH .... 3118 S: A654 OK FETCH completed 3120 6.4.7. STORE Command 3122 Arguments: sequence set 3123 message data item name 3124 value for message data item 3126 Responses: untagged responses: FETCH 3128 Result: OK - store completed 3129 NO - store error: can't store that data 3130 BAD - command unknown or arguments invalid 3132 The STORE command alters data associated with a message in the 3133 mailbox. Normally, STORE will return the updated value of the data 3134 with an untagged FETCH response. A suffix of ".SILENT" in the data 3135 item name prevents the untagged FETCH, and the server SHOULD assume 3136 that the client has determined the updated value itself or does not 3137 care about the updated value. 3139 Note: Regardless of whether or not the ".SILENT" suffix was used, 3140 the server SHOULD send an untagged FETCH response if a change to a 3141 message's flags from an external source is observed. The intent 3142 is that the status of the flags is determinate without a race 3143 condition. 3145 The currently defined data items that can be stored are: 3147 FLAGS Replace the flags for the message (other than 3148 \Recent) with the argument. The new value of the flags is 3149 returned as if a FETCH of those flags was done. 3151 FLAGS.SILENT Equivalent to FLAGS, but without returning 3152 a new value. 3154 +FLAGS Add the argument to the flags for the message. 3155 The new value of the flags is returned as if a FETCH of those 3156 flags was done. 3158 +FLAGS.SILENT Equivalent to +FLAGS, but without 3159 returning a new value. 3161 -FLAGS Remove the argument from the flags for the 3162 message. The new value of the flags is returned as if a FETCH of 3163 those flags was done. 3165 -FLAGS.SILENT Equivalent to -FLAGS, but without 3166 returning a new value. 3168 Example: C: A003 STORE 2:4 +FLAGS (\Deleted) 3169 S: * 2 FETCH (FLAGS (\Deleted \Seen)) 3170 S: * 3 FETCH (FLAGS (\Deleted)) 3171 S: * 4 FETCH (FLAGS (\Deleted \Flagged \Seen)) 3172 S: A003 OK STORE completed 3174 6.4.8. COPY Command 3176 Arguments: sequence set 3177 mailbox name 3179 Responses: no specific responses for this command 3181 Result: OK - copy completed 3182 NO - copy error: can't copy those messages or to that 3183 name 3184 BAD - command unknown or arguments invalid 3186 The COPY command copies the specified message(s) to the end of the 3187 specified destination mailbox. The flags and internal date of the 3188 message(s) SHOULD be preserved, and the Recent flag SHOULD be set, in 3189 the copy. 3191 If the destination mailbox does not exist, a server SHOULD return an 3192 error. It SHOULD NOT automatically create the mailbox. Unless it is 3193 certain that the destination mailbox can not be created, the server 3194 MUST send the response code "[TRYCREATE]" as the prefix of the text 3195 of the tagged NO response. This gives a hint to the client that it 3196 can attempt a CREATE command and retry the COPY if the CREATE is 3197 successful. 3199 If the COPY command is unsuccessful for any reason, server 3200 implementations MUST restore the destination mailbox to its state 3201 before the COPY attempt. 3203 On successful completion of a COPY, the server SHOULD return a 3204 COPYUID response code. 3206 In the case of a mailbox that has permissions set so that the client 3207 can COPY to the mailbox, but not SELECT or EXAMINE it, the server 3208 SHOULD NOT send an COPYUID response code as it would disclose 3209 information about the mailbox. 3211 In the case of a mailbox that has UIDNOTSTICKY status (see the 3212 UIDNOTSTICKY response code), the server MAY omit the COPYUID response 3213 code as it is not meaningful. 3215 If the server does not return the COPYUID response code, the client 3216 can discover this information by selecting the destination mailbox. 3217 The location of messages placed in the destination mailbox by COPY 3218 can be determined by using FETCH and/or SEARCH commands (e.g., for 3219 Message-ID). 3221 Example: C: A003 COPY 2:4 MEETING 3222 S: A003 OK COPY completed 3224 6.4.9. UID Command 3226 Arguments: command name 3227 command arguments 3229 Responses: untagged responses: FETCH, SEARCH 3231 Result: OK - UID command completed 3232 NO - UID command error 3233 BAD - command unknown or arguments invalid 3235 The UID command has three forms. In the first form, it takes as its 3236 arguments a COPY, FETCH, or STORE command with arguments appropriate 3237 for the associated command. However, the numbers in the sequence set 3238 argument are unique identifiers instead of message sequence numbers. 3239 Sequence set ranges are permitted, but there is no guarantee that 3240 unique identifiers will be contiguous. 3242 A non-existent unique identifier is ignored without any error message 3243 generated. Thus, it is possible for a UID FETCH command to return an 3244 OK without any data or a UID COPY or UID STORE to return an OK 3245 without performing any operations. 3247 In the second form, the UID command takes an EXPUNGE command with an 3248 extra parameter the specified a sequence set of UIDs to operate on. 3249 The UID EXPUNGE command permanently removes all messages that both 3250 have the \Deleted flag set and have a UID that is included in the 3251 specified sequence set from the currently selected mailbox. If a 3252 message either does not have the \Deleted flag set or has a UID that 3253 is not included in the specified sequence set, it is not affected. 3255 UID EXPUNGE is particularly useful for disconnected use clients. 3256 By using UID EXPUNGE instead of EXPUNGE when resynchronizing with 3257 the server, the client can ensure that it does not inadvertantly 3258 remove any messages that have been marked as \Deleted by other 3259 clients between the time that the client was last connected and 3260 the time the client resynchronizes. 3262 Example: C: A003 UID EXPUNGE 3000:3002 3263 S: * 3 EXPUNGE 3264 S: * 3 EXPUNGE 3265 S: * 3 EXPUNGE 3266 S: A003 OK UID EXPUNGE completed 3268 In the third form, the UID command takes a SEARCH command with SEARCH 3269 command arguments. The interpretation of the arguments is the same 3270 as with SEARCH; however, the numbers returned in a ESEARCH response 3271 for a UID SEARCH command are unique identifiers instead of message 3272 sequence numbers. Also, the corresponding ESEARCH response MUST 3273 include the UID indicator. For example, the command UID SEARCH 1:100 3274 UID 443:557 returns the unique identifiers corresponding to the 3275 intersection of two sequence sets, the message sequence number range 3276 1:100 and the UID range 443:557. 3278 Note: in the above example, the UID range 443:557 appears. The 3279 same comment about a non-existent unique identifier being ignored 3280 without any error message also applies here. Hence, even if 3281 neither UID 443 or 557 exist, this range is valid and would 3282 include an existing UID 495. 3284 Also note that a UID range of 559:* always includes the UID of the 3285 last message in the mailbox, even if 559 is higher than any 3286 assigned UID value. This is because the contents of a range are 3287 independent of the order of the range endpoints. Thus, any UID 3288 range with * as one of the endpoints indicates at least one 3289 message (the message with the highest numbered UID), unless the 3290 mailbox is empty. 3292 The number after the "*" in an untagged FETCH or EXPUNGE response is 3293 always a message sequence number, not a unique identifier, even for a 3294 UID command response. However, server implementations MUST 3295 implicitly include the UID message data item as part of any FETCH 3296 response caused by a UID command, regardless of whether a UID was 3297 specified as a message data item to the FETCH. 3299 Note: The rule about including the UID message data item as part of a 3300 FETCH response primarily applies to the UID FETCH and UID STORE 3301 commands, including a UID FETCH command that does not include UID as 3302 a message data item. Although it is unlikely that the other UID 3303 commands will cause an untagged FETCH, this rule applies to these 3304 commands as well. 3306 Example: C: A999 UID FETCH 4827313:4828442 FLAGS 3307 S: * 23 FETCH (FLAGS (\Seen) UID 4827313) 3308 S: * 24 FETCH (FLAGS (\Seen) UID 4827943) 3309 S: * 25 FETCH (FLAGS (\Seen) UID 4828442) 3310 S: A999 OK UID FETCH completed 3312 6.5. Client Commands - Experimental/Expansion 3314 6.5.1. X Command 3316 Arguments: implementation defined 3318 Responses: implementation defined 3320 Result: OK - command completed 3321 NO - failure 3322 BAD - command unknown or arguments invalid 3324 Any command prefixed with an X is an experimental command. Commands 3325 which are not part of this specification, a standard or standards- 3326 track revision of this specification, or an IESG-approved 3327 experimental protocol, MUST use the X prefix. 3329 Any added untagged responses issued by an experimental command MUST 3330 also be prefixed with an X. Server implementations MUST NOT send any 3331 such untagged responses, unless the client requested it by issuing 3332 the associated experimental command. 3334 Example: C: a441 CAPABILITY 3335 S: * CAPABILITY IMAP4rev2 XPIG-LATIN 3336 S: a441 OK CAPABILITY completed 3337 C: A442 XPIG-LATIN 3338 S: * XPIG-LATIN ow-nay eaking-spay ig-pay atin-lay 3339 S: A442 OK XPIG-LATIN ompleted-cay 3341 7. Server Responses 3343 Server responses are in three forms: status responses, server data, 3344 and command continuation request. The information contained in a 3345 server response, identified by "Contents:" in the response 3346 descriptions below, is described by function, not by syntax. The 3347 precise syntax of server responses is described in the Formal Syntax 3348 section. 3350 The client MUST be prepared to accept any response at all times. 3352 Status responses can be tagged or untagged. Tagged status responses 3353 indicate the completion result (OK, NO, or BAD status) of a client 3354 command, and have a tag matching the command. 3356 Some status responses, and all server data, are untagged. An 3357 untagged response is indicated by the token "*" instead of a tag. 3358 Untagged status responses indicate server greeting, or server status 3359 that does not indicate the completion of a command (for example, an 3360 impending system shutdown alert). For historical reasons, untagged 3361 server data responses are also called "unsolicited data", although 3362 strictly speaking, only unilateral server data is truly 3363 "unsolicited". 3365 Certain server data MUST be recorded by the client when it is 3366 received; this is noted in the description of that data. Such data 3367 conveys critical information which affects the interpretation of all 3368 subsequent commands and responses (e.g., updates reflecting the 3369 creation or destruction of messages). 3371 Other server data SHOULD be recorded for later reference; if the 3372 client does not need to record the data, or if recording the data has 3373 no obvious purpose (e.g., a SEARCH response when no SEARCH command is 3374 in progress), the data SHOULD be ignored. 3376 An example of unilateral untagged server data occurs when the IMAP 3377 connection is in the selected state. In the selected state, the 3378 server checks the mailbox for new messages as part of command 3379 execution. Normally, this is part of the execution of every command; 3380 hence, a NOOP command suffices to check for new messages. If new 3381 messages are found, the server sends untagged EXISTS and RECENT 3382 responses reflecting the new size of the mailbox. Server 3383 implementations that offer multiple simultaneous access to the same 3384 mailbox SHOULD also send appropriate unilateral untagged FETCH and 3385 EXPUNGE responses if another agent changes the state of any message 3386 flags or expunges any messages. 3388 Command continuation request responses use the token "+" instead of a 3389 tag. These responses are sent by the server to indicate acceptance 3390 of an incomplete client command and readiness for the remainder of 3391 the command. 3393 7.1. Server Responses - Status Responses 3395 Status responses are OK, NO, BAD, PREAUTH and BYE. OK, NO, and BAD 3396 can be tagged or untagged. PREAUTH and BYE are always untagged. 3398 Status responses MAY include an OPTIONAL "response code". A response 3399 code consists of data inside square brackets in the form of an atom, 3400 possibly followed by a space and arguments. The response code 3401 contains additional information or status codes for client software 3402 beyond the OK/NO/BAD condition, and are defined when there is a 3403 specific action that a client can take based upon the additional 3404 information. 3406 The currently defined response codes are: 3408 ALERT The human-readable text contains a special alert that MUST be 3409 presented to the user in a fashion that calls the user's attention 3410 to the message. 3412 ALREADYEXISTS 3414 The operation attempts to create something that already exists, 3415 such as when the CREATE or RENAME directories attempt to create 3416 a mailbox and there is already one of that name. 3418 C: o RENAME this that 3419 S: o NO [ALREADYEXISTS] Mailbox "that" already exists 3421 APPENDUID 3423 Followed by the UIDVALIDITY of the destination mailbox and the 3424 UID assigned to the appended message in the destination 3425 mailbox, indicates that the message has been appended to the 3426 destination mailbox with that UID. 3428 If the server also supports the [MULTIAPPEND] extension, and if 3429 multiple messages were appended in the APPEND command, then the 3430 second value is a UID set containing the UIDs assigned to the 3431 appended messages, in the order they were transmitted in the 3432 APPEND command. This UID set may not contain extraneous UIDs 3433 or the symbol "*". 3435 Note: the UID set form of the APPENDUID response code MUST 3436 NOT be used if only a single message was appended. In 3437 particular, a server MUST NOT send a range such as 123:123. 3438 This is because a client that does not support [MULTIAPPEND] 3439 expects only a single UID and not a UID set. 3441 UIDs are assigned in strictly ascending order in the mailbox 3442 (refer to Section 2.3.1.1); note that a range of 12:10 is 3443 exactly equivalent to 10:12 and refers to the sequence 3444 10,11,12. 3446 This response code is returned in a tagged OK response to the 3447 APPEND command. 3449 AUTHENTICATIONFAILED 3451 Authentication failed for some reason on which the server is 3452 unwilling to elaborate. Typically, this includes "unknown 3453 user" and "bad password". 3455 This is the same as not sending any response code, except that 3456 when a client sees AUTHENTICATIONFAILED, it knows that the 3457 problem wasn't, e.g., UNAVAILABLE, so there's no point in 3458 trying the same login/password again later. 3460 C: b LOGIN "fred" "foo" 3461 S: b NO [AUTHENTICATIONFAILED] Authentication failed 3463 AUTHORIZATIONFAILED Authentication succeeded in using the 3464 authentication identity, but the server cannot or will not allow 3465 the authentication identity to act as the requested authorization 3466 identity. This is only applicable when the authentication and 3467 authorization identities are different. C: c1 AUTHENTICATE PLAIN 3468 [...] 3469 S: c1 NO [AUTHORIZATIONFAILED] No such authorization-ID 3470 C: c2 AUTHENTICATE PLAIN 3471 [...] 3472 S: c2 NO [AUTHORIZATIONFAILED] Authenticator is not an admin 3474 BADCHARSET Optionally followed by a parenthesized list of charsets. 3475 A SEARCH failed because the given charset is not supported by this 3476 implementation. If the optional list of charsets is given, this 3477 lists the charsets that are supported by this implementation. 3479 CANNOT 3481 The operation violates some invariant of the server and can 3482 never succeed. 3484 C: l create "///////" 3485 S: l NO [CANNOT] Adjacent slashes are not supported 3487 CAPABILITY Followed by a list of capabilities. This can appear in 3488 the initial OK or PREAUTH response to transmit an initial 3489 capabilities list. This makes it unnecessary for a client to send 3490 a separate CAPABILITY command if it recognizes this response. 3492 CLIENTBUG 3493 The server has detected a client bug. This can accompany all 3494 of OK, NO, and BAD, depending on what the client bug is. 3496 C: k1 select "/archive/projects/experiment-iv" 3497 [...] 3498 S: k1 OK [READ-ONLY] Done 3499 C: k2 status "/archive/projects/experiment-iv" (messages) 3500 [...] 3501 S: k2 OK [CLIENTBUG] Done 3503 CLOSED 3505 The CLOSED response code has no parameters. A server return 3506 the CLOSED response code when the currently selected mailbox is 3507 closed implicitly using the SELECT/EXAMINE command on another 3508 mailbox. The CLOSED response code serves as a boundary between 3509 responses for the previously opened mailbox (which was closed) 3510 and the newly selected mailbox; all responses before the CLOSED 3511 response code relate to the mailbox that was closed, and all 3512 subsequent responses relate to the newly opened mailbox. 3514 There is no need to return the CLOSED response code on 3515 completion of the CLOSE or the UNSELECT command (or similar), 3516 whose purpose is to close the currently selected mailbox 3517 without opening a new one. 3519 The server can also return an unsolicited CLOSED response code 3520 when it wants to force the client to return to authenticated 3521 state. For example, the server can do that when the mailbox 3522 requires repairs or is deleted in another session. 3524 CONTACTADMIN 3526 The user should contact the system administrator or support 3527 desk. 3529 C: e login "fred" "foo" 3530 S: e OK [CONTACTADMIN] 3532 COPYUID 3534 Followed by the UIDVALIDITY of the destination mailbox, a UID 3535 set containing the UIDs of the message(s) in the source mailbox 3536 that were copied to the destination mailbox and containing the 3537 UIDs assigned to the copied message(s) in the destination 3538 mailbox, indicates that the message(s) have been copied to the 3539 destination mailbox with the stated UID(s). 3541 The source UID set is in the order the message(s) were copied; 3542 the destination UID set corresponds to the source UID set and 3543 is in the same order. Neither of the UID sets may contain 3544 extraneous UIDs or the symbol "*". 3546 UIDs are assigned in strictly ascending order in the mailbox 3547 (refer to Section 2.3.1.1); note that a range of 12:10 is 3548 exactly equivalent to 10:12 and refers to the sequence 3549 10,11,12. 3551 This response code is returned in a tagged OK response to the 3552 COPY command. 3554 CORRUPTION 3556 The server discovered that some relevant data (e.g., the 3557 mailbox) are corrupt. This response code does not include any 3558 information about what's corrupt, but the server can write that 3559 to its logfiles. 3561 C: i select "/archive/projects/experiment-iv" 3562 S: i NO [CORRUPTION] Cannot open mailbox 3564 EXPIRED 3566 Either authentication succeeded or the server no longer had the 3567 necessary data; either way, access is no longer permitted using 3568 that passphrase. The client or user should get a new 3569 passphrase. 3571 C: d login "fred" "foo" 3572 S: d NO [EXPIRED] That password isn't valid any more 3574 EXPUNGEISSUED 3576 Someone else has issued an EXPUNGE for the same mailbox. The 3577 client may want to issue NOOP soon. [IMAP-MULTIACCESS] 3578 discusses this subject in depth. 3580 C: h search from fred@example.com 3581 S: * SEARCH 1 2 3 5 8 13 21 42 3582 S: h OK [EXPUNGEISSUED] Search completed 3584 INUSE 3586 An operation has not been carried out because it involves 3587 sawing off a branch someone else is sitting on. Someone else 3588 may be holding an exclusive lock needed for this operation, or 3589 the operation may involve deleting a resource someone else is 3590 using, typically a mailbox. 3592 The operation may succeed if the client tries again later. 3594 C: g delete "/archive/projects/experiment-iv" 3595 S: g NO [INUSE] Mailbox in use 3597 LIMIT 3599 The operation ran up against an implementation limit of some 3600 kind, such as the number of flags on a single message or the 3601 number of flags used in a mailbox. 3603 C: m STORE 42 FLAGS f1 f2 f3 f4 f5 ... f250 3604 S: m NO [LIMIT] At most 32 flags in one mailbox supported 3606 NONEXISTENT 3608 The operation attempts to delete something that does not exist. 3609 Similar to ALREADYEXISTS. 3611 C: p RENAME this that 3612 S: p NO [NONEXISTENT] No such mailbox 3614 NOPERM 3616 The access control system (e.g., Access Control List (ACL), see 3617 [RFC4314] does not permit this user to carry out an operation, 3618 such as selecting or creating a mailbox. 3620 C: f select "/archive/projects/experiment-iv" 3621 S: f NO [NOPERM] Access denied 3623 OVERQUOTA 3625 The user would be over quota after the operation. (The user 3626 may or may not be over quota already.) 3628 Note that if the server sends OVERQUOTA but doesn't support the 3629 IMAP QUOTA extension defined by [RFC2087], then there is a 3630 quota, but the client cannot find out what the quota is. 3632 C: n1 uid copy 1:* oldmail 3633 S: n1 NO [OVERQUOTA] Sorry 3635 C: n2 uid copy 1:* oldmail 3636 S: n2 OK [OVERQUOTA] You are now over your soft quota 3638 PARSE The human-readable text represents an error in parsing the 3639 [RFC-5322] header or [MIME-IMB] headers of a message in the 3640 mailbox. 3642 PERMANENTFLAGS Followed by a parenthesized list of flags, indicates 3643 which of the known flags the client can change permanently. Any 3644 flags that are in the FLAGS untagged response, but not the 3645 PERMANENTFLAGS list, can not be set permanently. If the client 3646 attempts to STORE a flag that is not in the PERMANENTFLAGS list, 3647 the server will either ignore the change or store the state change 3648 for the remainder of the current session only. The PERMANENTFLAGS 3649 list can also include the special flag \*, which indicates that it 3650 is possible to create new keywords by attempting to store those 3651 flags in the mailbox. 3653 PRIVACYREQUIRED 3655 The operation is not permitted due to a lack of privacy. If 3656 Transport Layer Security (TLS) is not in use, the client could 3657 try STARTTLS (see Section 6.2.1) and then repeat the operation. 3659 C: d login "fred" "foo" 3660 S: d NO [PRIVACYREQUIRED] Connection offers no privacy 3662 C: d select inbox 3663 S: d NO [PRIVACYREQUIRED] Connection offers no privacy 3665 READ-ONLY The mailbox is selected read-only, or its access while 3666 selected has changed from read-write to read-only. 3668 READ-WRITE The mailbox is selected read-write, or its access while 3669 selected has changed from read-only to read-write. 3671 SERVERBUG 3673 The server encountered a bug in itself or violated one of its 3674 own invariants. 3676 C: j select "/archive/projects/experiment-iv" 3677 S: j NO [SERVERBUG] This should not happen 3679 TRYCREATE An APPEND or COPY attempt is failing because the target 3680 mailbox does not exist (as opposed to some other reason). This is 3681 a hint to the client that the operation can succeed if the mailbox 3682 is first created by the CREATE command. 3684 UIDNEXT Followed by a decimal number, indicates the next unique 3685 identifier value. Refer to Section 2.3.1.1 for more information. 3687 UIDNOTSTICKY 3689 The selected mailbox is supported by a mail store that does not 3690 support persistent UIDs; that is, UIDVALIDITY will be different 3691 each time the mailbox is selected. Consequently, APPEND or 3692 COPY to this mailbox will not return an APPENDUID or COPYUID 3693 response code. 3695 This response code is returned in an untagged NO response to 3696 the SELECT command. 3698 Note: servers SHOULD NOT have any UIDNOTSTICKY mail stores. 3699 This facility exists to support legacy mail stores in which 3700 it is technically infeasible to support persistent UIDs. 3701 This should be avoided when designing new mail stores. 3703 UIDVALIDITY Followed by a decimal number, indicates the unique 3704 identifier validity value. Refer to Section 2.3.1.1 for more 3705 information. 3707 UNAVAILABLE 3709 Temporary failure because a subsystem is down. For example, an 3710 IMAP server that uses a Lightweight Directory Access Protocol 3711 (LDAP) or Radius server for authentication might use this 3712 response code when the LDAP/Radius server is down. 3714 C: a LOGIN "fred" "foo" 3715 S: a NO [UNAVAILABLE] User's backend down for maintenance 3717 UNSEEN Followed by a decimal number, indicates the number of the 3718 first message without the \Seen flag set. 3720 Additional response codes defined by particular client or server 3721 implementations SHOULD be prefixed with an "X" until they are added 3722 to a revision of this protocol. Client implementations SHOULD ignore 3723 response codes that they do not recognize. 3725 7.1.1. OK Response 3727 Contents: OPTIONAL response code 3728 human-readable text 3730 The OK response indicates an information message from the server. 3731 When tagged, it indicates successful completion of the associated 3732 command. The human-readable text MAY be presented to the user as an 3733 information message. The untagged form indicates an information-only 3734 message; the nature of the information MAY be indicated by a response 3735 code. 3737 The untagged form is also used as one of three possible greetings at 3738 connection startup. It indicates that the connection is not yet 3739 authenticated and that a LOGIN or an AUTHENTICATE command is needed. 3741 Example: S: * OK IMAP4rev2 server ready 3742 C: A001 LOGIN fred blurdybloop 3743 S: * OK [ALERT] System shutdown in 10 minutes 3744 S: A001 OK LOGIN Completed 3746 7.1.2. NO Response 3748 Contents: OPTIONAL response code 3749 human-readable text 3751 The NO response indicates an operational error message from the 3752 server. When tagged, it indicates unsuccessful completion of the 3753 associated command. The untagged form indicates a warning; the 3754 command can still complete successfully. The human-readable text 3755 describes the condition. 3757 Example: C: A222 COPY 1:2 owatagusiam 3758 S: * NO Disk is 98% full, please delete unnecessary data 3759 S: A222 OK COPY completed 3760 C: A223 COPY 3:200 blurdybloop 3761 S: * NO Disk is 98% full, please delete unnecessary data 3762 S: * NO Disk is 99% full, please delete unnecessary data 3763 S: A223 NO COPY failed: disk is full 3765 7.1.3. BAD Response 3767 Contents: OPTIONAL response code 3768 human-readable text 3770 The BAD response indicates an error message from the server. When 3771 tagged, it reports a protocol-level error in the client's command; 3772 the tag indicates the command that caused the error. The untagged 3773 form indicates a protocol-level error for which the associated 3774 command can not be determined; it can also indicate an internal 3775 server failure. The human-readable text describes the condition. 3777 Example: C: ...very long command line... 3778 S: * BAD Command line too long 3779 C: ...empty line... 3780 S: * BAD Empty command line 3781 C: A443 EXPUNGE 3782 S: * BAD Disk crash, attempting salvage to a new disk! 3783 S: * OK Salvage successful, no data lost 3784 S: A443 OK Expunge completed 3786 7.1.4. PREAUTH Response 3788 Contents: OPTIONAL response code 3789 human-readable text 3791 The PREAUTH response is always untagged, and is one of three possible 3792 greetings at connection startup. It indicates that the connection 3793 has already been authenticated by external means; thus no LOGIN/ 3794 AUTHENTICATE command is needed. 3796 Example: S: * PREAUTH IMAP4rev2 server logged in as Smith 3798 7.1.5. BYE Response 3800 Contents: OPTIONAL response code 3801 human-readable text 3803 The BYE response is always untagged, and indicates that the server is 3804 about to close the connection. The human-readable text MAY be 3805 displayed to the user in a status report by the client. The BYE 3806 response is sent under one of four conditions: 3808 1. as part of a normal logout sequence. The server will close the 3809 connection after sending the tagged OK response to the LOGOUT 3810 command. 3812 2. as a panic shutdown announcement. The server closes the 3813 connection immediately. 3815 3. as an announcement of an inactivity autologout. The server 3816 closes the connection immediately. 3818 4. as one of three possible greetings at connection startup, 3819 indicating that the server is not willing to accept a connection 3820 from this client. The server closes the connection immediately. 3822 The difference between a BYE that occurs as part of a normal LOGOUT 3823 sequence (the first case) and a BYE that occurs because of a failure 3824 (the other three cases) is that the connection closes immediately in 3825 the failure case. In all cases the client SHOULD continue to read 3826 response data from the server until the connection is closed; this 3827 will ensure that any pending untagged or completion responses are 3828 read and processed. 3830 Example: S: * BYE Autologout; idle for too long 3832 7.2. Server Responses - Server and Mailbox Status 3834 These responses are always untagged. This is how server and mailbox 3835 status data are transmitted from the server to the client. Many of 3836 these responses typically result from a command with the same name. 3838 7.2.1. The ENABLED Response 3840 Contents: capability listing 3842 The ENABLED response occurs as a result of an ENABLE command. The 3843 capability listing contains a space-separated listing of capability 3844 names that the server supports and that were successfully enabled. 3845 The ENABLED response may contain no capabilities, which means that no 3846 extensions listed by the client were successfully enabled. 3848 7.2.2. CAPABILITY Response 3850 Contents: capability listing 3852 The CAPABILITY response occurs as a result of a CAPABILITY command. 3853 The capability listing contains a space-separated listing of 3854 capability names that the server supports. The capability listing 3855 MUST include the atom "IMAP4rev2". 3857 In addition, client and server implementations MUST implement the 3858 STARTTLS, LOGINDISABLED, and AUTH=PLAIN (described in [PLAIN]) 3859 capabilities. See the Security Considerations section for important 3860 information. 3862 A capability name which begins with "AUTH=" indicates that the server 3863 supports that particular authentication mechanism. 3865 The LOGINDISABLED capability indicates that the LOGIN command is 3866 disabled, and that the server will respond with a tagged NO response 3867 to any attempt to use the LOGIN command even if the user name and 3868 password are valid. An IMAP client MUST NOT issue the LOGIN command 3869 if the server advertises the LOGINDISABLED capability. 3871 Other capability names indicate that the server supports an 3872 extension, revision, or amendment to the IMAP4rev2 protocol. Server 3873 responses MUST conform to this document until the client issues a 3874 command that uses the associated capability. 3876 Capability names MUST either begin with "X" or be standard or 3877 standards-track IMAP4rev2 extensions, revisions, or amendments 3878 registered with IANA. A server MUST NOT offer unregistered or non- 3879 standard capability names, unless such names are prefixed with an 3880 "X". 3882 Client implementations SHOULD NOT require any capability name other 3883 than "IMAP4rev2", and MUST ignore any unknown capability names. 3885 A server MAY send capabilities automatically, by using the CAPABILITY 3886 response code in the initial PREAUTH or OK responses, and by sending 3887 an updated CAPABILITY response code in the tagged OK response as part 3888 of a successful authentication. It is unnecessary for a client to 3889 send a separate CAPABILITY command if it recognizes these automatic 3890 capabilities. 3892 Example: S: * CAPABILITY IMAP4rev2 STARTTLS AUTH=GSSAPI XPIG-LATIN 3894 7.2.3. LIST Response 3896 Contents: name attributes 3897 hierarchy delimiter 3898 name 3900 The LIST response occurs as a result of a LIST command. It returns a 3901 single name that matches the LIST specification. There can be 3902 multiple LIST responses for a single LIST command. 3904 The following base name attributes are defined: 3906 \Noinferiors It is not possible for any child levels of hierarchy to 3907 exist under this name; no child levels exist now and none can be 3908 created in the future. 3910 \Noselect It is not possible to use this name as a selectable 3911 mailbox. 3913 \HasChildren The presence of this attribute indicates that the 3914 mailbox has child mailboxes. A server SHOULD NOT set this 3915 attribute if there are child mailboxes and the user does not have 3916 permission to access any of them. In this case, \HasNoChildren 3917 SHOULD be used. In many cases, however, a server may not be able 3918 to efficiently compute whether a user has access to any child 3919 mailbox. Note that even though the \HasChildren attribute for a 3920 mailbox must be correct at the time of processing of the mailbox, 3921 a client must be prepared to deal with a situation when a mailbox 3922 is marked with the \HasChildren attribute, but no child mailbox 3923 appears in the response to the LIST command. This might happen, 3924 for example, due to children mailboxes being deleted or made 3925 inaccessible to the user (using access control) by another client 3926 before the server is able to list them. 3928 \HasNoChildren The presence of this attribute indicates that the 3929 mailbox has NO child mailboxes that are accessible to the 3930 currently authenticated user. 3932 \Marked The mailbox has been marked "interesting" by the server; the 3933 mailbox probably contains messages that have been added since the 3934 last time the mailbox was selected. 3936 \Unmarked The mailbox does not contain any additional messages since 3937 the last time the mailbox was selected. 3939 It is an error for the server to return both a \HasChildren and a 3940 \HasNoChildren attribute in the same LIST response. 3942 Note: the \HasNoChildren attribute should not be confused with the 3943 \NoInferiors attribute, which indicates that no child mailboxes 3944 exist now and none can be created in the future. 3946 If it is not feasible for the server to determine whether or not the 3947 mailbox is "interesting", the server SHOULD NOT send either \Marked 3948 or \Unmarked. The server MUST NOT send more than one of \Marked, 3949 \Unmarked, and \Noselect for a single mailbox, and MAY send none of 3950 these. 3952 In addition to the base name attributes defined above, an IMAP server 3953 MAY also include any or all of the following attributes that denote 3954 "role" (or "special-use") of a mailbox. These attributes are 3955 included along with base attributes defined above. A given mailbox 3956 may have none, one, or more than one of these attributes. In some 3957 cases, a special use is advice to a client about what to put in that 3958 mailbox. In other cases, it's advice to a client about what to 3959 expect to find there. 3961 \All This mailbox presents all messages in the user's message store. 3962 Implementations MAY omit some messages, such as, perhaps, those in 3963 \Trash and \Junk. When this special use is supported, it is 3964 almost certain to represent a virtual mailbox. 3966 \Archive This mailbox is used to archive messages. The meaning of 3967 an "archival" mailbox is server-dependent; typically, it will be 3968 used to get messages out of the inbox, or otherwise keep them out 3969 of the user's way, while still making them accessible. 3971 \Drafts This mailbox is used to hold draft messages -- typically, 3972 messages that are being composed but have not yet been sent. In 3973 some server implementations, this might be a virtual mailbox, 3974 containing messages from other mailboxes that are marked with the 3975 "\Draft" message flag. Alternatively, this might just be advice 3976 that a client put drafts here. 3978 \Flagged This mailbox presents all messages marked in some way as 3979 "important". When this special use is supported, it is likely to 3980 represent a virtual mailbox collecting messages (from other 3981 mailboxes) that are marked with the "\Flagged" message flag. 3983 \Junk This mailbox is where messages deemed to be junk mail are 3984 held. Some server implementations might put messages here 3985 automatically. Alternatively, this might just be advice to a 3986 client-side spam filter. 3988 \Sent This mailbox is used to hold copies of messages that have been 3989 sent. Some server implementations might put messages here 3990 automatically. Alternatively, this might just be advice that a 3991 client save sent messages here. 3993 \Trash This mailbox is used to hold messages that have been deleted 3994 or marked for deletion. In some server implementations, this 3995 might be a virtual mailbox, containing messages from other 3996 mailboxes that are marked with the "\Deleted" message flag. 3997 Alternatively, this might just be advice that a client that 3998 chooses not to use the IMAP "\Deleted" model should use this as 3999 its trash location. In server implementations that strictly 4000 expect the IMAP "\Deleted" model, this special use is likely not 4001 to be supported. 4003 All of special-use attributes are OPTIONAL, and any given server or 4004 message store may support any combination of the attributes, or none 4005 at all. In most cases, there will likely be at most one mailbox with 4006 a given attribute for a given user, but in some server or message 4007 store implementations it might be possible for multiple mailboxes to 4008 have the same special-use attribute. 4010 Special-use attributes are likely to be user-specific. User Adam 4011 might share his \Sent mailbox with user Barb, but that mailbox is 4012 unlikely to also serve as Barb's \Sent mailbox. 4014 The hierarchy delimiter is a character used to delimit levels of 4015 hierarchy in a mailbox name. A client can use it to create child 4016 mailboxes, and to search higher or lower levels of naming hierarchy. 4017 All children of a top-level hierarchy node MUST use the same 4018 separator character. A NIL hierarchy delimiter means that no 4019 hierarchy exists; the name is a "flat" name. 4021 The name represents an unambiguous left-to-right hierarchy, and MUST 4022 be valid for use as a reference in LIST and LSUB commands. Unless 4023 \Noselect is indicated, the name MUST also be valid as an argument 4024 for commands, such as SELECT, that accept mailbox names. 4026 Example: S: * LIST (\Noselect) "/" ~/Mail/foo 4028 7.2.4. LSUB Response 4030 Contents: name attributes 4031 hierarchy delimiter 4032 name 4034 The LSUB response occurs as a result of an LSUB command. It returns 4035 a single name that matches the LSUB specification. There can be 4036 multiple LSUB responses for a single LSUB command. The data is 4037 identical in format to the LIST response. 4039 Example: S: * LSUB () "." #news.comp.mail.misc 4041 7.2.5. NAMESPACE Response 4043 Contents: the prefix and hierarchy delimiter to the server's 4044 Personal Namespace(s), Other Users' Namespace(s), and 4045 Shared Namespace(s) 4047 The NAMESPACE response occurs as a result of a NAMESPACE command. It 4048 contains the prefix and hierarchy delimiter to the server's Personal 4049 Namespace(s), Other Users' Namespace(s), and Shared Namespace(s) that 4050 the server wishes to expose. The response will contain a NIL for any 4051 namespace class that is not available. Namespace_Response_Extensions 4052 MAY be included in the response. Namespace_Response_Extensions which 4053 are not on the IETF standards track, MUST be prefixed with an "X-". 4055 Example: S: * NAMESPACE (("" "/")) (("~" "/")) NIL 4057 7.2.6. STATUS Response 4059 Contents: name 4060 status parenthesized list 4062 The STATUS response occurs as a result of an STATUS command. It 4063 returns the mailbox name that matches the STATUS specification and 4064 the requested mailbox status information. 4066 Example: S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) 4068 7.2.7. ESEARCH Response 4070 Contents: one or more search-return-data pairs 4072 The ESEARCH response occurs as a result of a SEARCH or UID SEARCH 4073 command. 4075 The ESEARCH response starts with an optional search correlator. If 4076 it is missing, then the response was not caused by a particular IMAP 4077 command, whereas if it is present, it contains the tag of the command 4078 that caused the response to be returned. 4080 The search correlator is followed by an optional UID indicator. If 4081 this indicator is present, all data in the ESEARCH response refers to 4082 UIDs, otherwise all returned data refers to message numbers. 4084 The rest of the ESEARCH response contains one or more search data 4085 pairs. Each pair starts with unique return item name, followed by a 4086 space and the corresponding data. Search data pairs may be returned 4087 in any order. Unless specified otherwise by an extension, any return 4088 item name SHOULD appear only once in an ESEARCH response. 4090 [[TBD: describe the most common search data pairs returned.]] 4092 Example: S: * ESEARCH UID COUNT 5 ALL 4:19,21,28 4094 Example: S: * ESEARCH (TAG "a567") UID COUNT 5 ALL 4:19,21,28 4096 Example: S: * ESEARCH COUNT 5 ALL 1:17,21 4098 7.2.8. FLAGS Response 4100 Contents: flag parenthesized list 4102 The FLAGS response occurs as a result of a SELECT or EXAMINE command. 4103 The flag parenthesized list identifies the flags (at a minimum, the 4104 system-defined flags) that are applicable for this mailbox. Flags 4105 other than the system flags can also exist, depending on server 4106 implementation. 4108 The update from the FLAGS response MUST be recorded by the client. 4110 Example: S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 4112 7.3. Server Responses - Mailbox Size 4114 These responses are always untagged. This is how changes in the size 4115 of the mailbox are transmitted from the server to the client. 4116 Immediately following the "*" token is a number that represents a 4117 message count. 4119 7.3.1. EXISTS Response 4121 Contents: none 4123 The EXISTS response reports the number of messages in the mailbox. 4124 This response occurs as a result of a SELECT or EXAMINE command, and 4125 if the size of the mailbox changes (e.g., new messages). 4127 The update from the EXISTS response MUST be recorded by the client. 4129 Example: S: * 23 EXISTS 4131 7.3.2. RECENT Response 4133 Contents: none 4135 The RECENT response reports the number of messages with the \Recent 4136 flag set. This response occurs as a result of a SELECT or EXAMINE 4137 command, and if the size of the mailbox changes (e.g., new messages). 4139 Note: It is not guaranteed that the message sequence numbers of 4140 recent messages will be a contiguous range of the highest n 4141 messages in the mailbox (where n is the value reported by the 4142 RECENT response). Examples of situations in which this is not the 4143 case are: multiple clients having the same mailbox open (the first 4144 session to be notified will see it as recent, others will probably 4145 see it as non-recent), and when the mailbox is re-ordered by a 4146 non-IMAP agent. 4148 The only reliable way to identify recent messages is to look at 4149 message flags to see which have the \Recent flag set, or to do a 4150 SEARCH RECENT. 4152 The update from the RECENT response MUST be recorded by the client. 4154 Example: S: * 5 RECENT 4156 7.4. Server Responses - Message Status 4158 These responses are always untagged. This is how message data are 4159 transmitted from the server to the client, often as a result of a 4160 command with the same name. Immediately following the "*" token is a 4161 number that represents a message sequence number. 4163 7.4.1. EXPUNGE Response 4165 Contents: none 4167 The EXPUNGE response reports that the specified message sequence 4168 number has been permanently removed from the mailbox. The message 4169 sequence number for each successive message in the mailbox is 4170 immediately decremented by 1, and this decrement is reflected in 4171 message sequence numbers in subsequent responses (including other 4172 untagged EXPUNGE responses). 4174 The EXPUNGE response also decrements the number of messages in the 4175 mailbox; it is not necessary to send an EXISTS response with the new 4176 value. 4178 As a result of the immediate decrement rule, message sequence numbers 4179 that appear in a set of successive EXPUNGE responses depend upon 4180 whether the messages are removed starting from lower numbers to 4181 higher numbers, or from higher numbers to lower numbers. For 4182 example, if the last 5 messages in a 9-message mailbox are expunged, 4183 a "lower to higher" server will send five untagged EXPUNGE responses 4184 for message sequence number 5, whereas a "higher to lower server" 4185 will send successive untagged EXPUNGE responses for message sequence 4186 numbers 9, 8, 7, 6, and 5. 4188 An EXPUNGE response MUST NOT be sent when no command is in progress, 4189 nor while responding to a FETCH, STORE, or SEARCH command. This rule 4190 is necessary to prevent a loss of synchronization of message sequence 4191 numbers between client and server. A command is not "in progress" 4192 until the complete command has been received; in particular, a 4193 command is not "in progress" during the negotiation of command 4194 continuation. 4196 Note: UID FETCH, UID STORE, and UID SEARCH are different commands 4197 from FETCH, STORE, and SEARCH. An EXPUNGE response MAY be sent 4198 during a UID command. 4200 The update from the EXPUNGE response MUST be recorded by the client. 4202 Example: S: * 44 EXPUNGE 4204 7.4.2. FETCH Response 4206 Contents: message data 4208 The FETCH response returns data about a message to the client. The 4209 data are pairs of data item names and their values in parentheses. 4210 This response occurs as the result of a FETCH or STORE command, as 4211 well as by unilateral server decision (e.g., flag updates). 4213 The current data items are: 4215 BODY A form of BODYSTRUCTURE without extension data. 4217 BODY[
]<> 4219 A string expressing the body contents of the specified section. 4220 The string SHOULD be interpreted by the client according to the 4221 content transfer encoding, body type, and subtype. 4223 If the origin octet is specified, this string is a substring of 4224 the entire body contents, starting at that origin octet. This 4225 means that BODY[]<0> MAY be truncated, but BODY[] is NEVER 4226 truncated. 4228 Note: The origin octet facility MUST NOT be used by a server 4229 in a FETCH response unless the client specifically requested 4230 it by means of a FETCH of a BODY[
]<> data 4231 item. 4233 8-bit textual data is permitted if a [CHARSET] identifier is 4234 part of the body parameter parenthesized list for this section. 4235 Note that headers (part specifiers HEADER or MIME, or the 4236 header portion of a MESSAGE/RFC822 part), MUST be 7-bit; 8-bit 4237 characters are not permitted in headers. Note also that the 4238 [RFC-5322] delimiting blank line between the header and the 4239 body is not affected by header line subsetting; the blank line 4240 is always included as part of header data, except in the case 4241 of a message which has no body and no blank line. 4243 Non-textual data such as binary data MUST be transfer encoded 4244 into a textual form, such as BASE64, prior to being sent to the 4245 client. To derive the original binary data, the client MUST 4246 decode the transfer encoded string. 4248 BODYSTRUCTURE 4250 A parenthesized list that describes the [MIME-IMB] body 4251 structure of a message. This is computed by the server by 4252 parsing the [MIME-IMB] header fields, defaulting various fields 4253 as necessary. 4255 For example, a simple text message of 48 lines and 2279 octets 4256 can have a body structure of: ("TEXT" "PLAIN" ("CHARSET" "US- 4257 ASCII") NIL NIL "7BIT" 2279 48) 4259 Multiple parts are indicated by parenthesis nesting. Instead 4260 of a body type as the first element of the parenthesized list, 4261 there is a sequence of one or more nested body structures. The 4262 second element of the parenthesized list is the multipart 4263 subtype (mixed, digest, parallel, alternative, etc.). 4265 For example, a two part message consisting of a text and a 4266 BASE64-encoded text attachment can have a body structure of: 4267 (("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 1152 4268 23)("TEXT" "PLAIN" ("CHARSET" "US-ASCII" "NAME" "cc.diff") 4269 "<960723163407.20117h@cac.washington.edu>" "Compiler diff" 4270 "BASE64" 4554 73) "MIXED") 4272 Extension data follows the multipart subtype. Extension data 4273 is never returned with the BODY fetch, but can be returned with 4274 a BODYSTRUCTURE fetch. Extension data, if present, MUST be in 4275 the defined order. The extension data of a multipart body part 4276 are in the following order: 4278 body parameter parenthesized list A parenthesized list of 4279 attribute/value pairs [e.g., ("foo" "bar" "baz" "rag") where 4280 "bar" is the value of "foo", and "rag" is the value of 4281 "baz"] as defined in [MIME-IMB]. 4283 body disposition A parenthesized list, consisting of a 4284 disposition type string, followed by a parenthesized list of 4285 disposition attribute/value pairs as defined in 4286 [DISPOSITION]. 4288 body language A string or parenthesized list giving the body 4289 language value as defined in [LANGUAGE-TAGS]. 4291 body location A string giving the body content URI as defined 4292 in [LOCATION]. 4294 Any following extension data are not yet defined in this 4295 version of the protocol. Such extension data can consist of 4296 zero or more NILs, strings, numbers, or potentially nested 4297 parenthesized lists of such data. Client implementations that 4298 do a BODYSTRUCTURE fetch MUST be prepared to accept such 4299 extension data. Server implementations MUST NOT send such 4300 extension data until it has been defined by a revision of this 4301 protocol. 4303 The basic fields of a non-multipart body part are in the 4304 following order: 4306 body type A string giving the content media type name as 4307 defined in [MIME-IMB]. 4309 body subtype A string giving the content subtype name as 4310 defined in [MIME-IMB]. 4312 body parameter parenthesized list A parenthesized list of 4313 attribute/value pairs [e.g., ("foo" "bar" "baz" "rag") where 4314 "bar" is the value of "foo" and "rag" is the value of "baz"] 4315 as defined in [MIME-IMB]. 4317 body id A string giving the content id as defined in 4318 [MIME-IMB]. 4320 body description A string giving the content description as 4321 defined in [MIME-IMB]. 4323 body encoding A string giving the content transfer encoding as 4324 defined in [MIME-IMB]. 4326 body size A number giving the size of the body in octets. 4327 Note that this size is the size in its transfer encoding and 4328 not the resulting size after any decoding. 4330 A body type of type MESSAGE and subtype RFC822 contains, 4331 immediately after the basic fields, the envelope structure, 4332 body structure, and size in text lines of the encapsulated 4333 message. 4335 A body type of type TEXT contains, immediately after the basic 4336 fields, the size of the body in text lines. Note that this 4337 size is the size in its content transfer encoding and not the 4338 resulting size after any decoding. 4340 Extension data follows the basic fields and the type-specific 4341 fields listed above. Extension data is never returned with the 4342 BODY fetch, but can be returned with a BODYSTRUCTURE fetch. 4343 Extension data, if present, MUST be in the defined order. 4345 The extension data of a non-multipart body part are in the 4346 following order: 4348 body MD5 A string giving the body MD5 value as defined in 4349 [MD5]. 4351 body disposition A parenthesized list with the same content 4352 and function as the body disposition for a multipart body 4353 part. 4355 body language A string or parenthesized list giving the body 4356 language value as defined in [LANGUAGE-TAGS]. 4358 body location A string giving the body content URI as defined 4359 in [LOCATION]. 4361 Any following extension data are not yet defined in this 4362 version of the protocol, and would be as described above under 4363 multipart extension data. 4365 ENVELOPE 4367 A parenthesized list that describes the envelope structure of a 4368 message. This is computed by the server by parsing the 4369 [RFC-5322] header into the component parts, defaulting various 4370 fields as necessary. 4372 The fields of the envelope structure are in the following 4373 order: date, subject, from, sender, reply-to, to, cc, bcc, in- 4374 reply-to, and message-id. The date, subject, in-reply-to, and 4375 message-id fields are strings. The from, sender, reply-to, to, 4376 cc, and bcc fields are parenthesized lists of address 4377 structures. 4379 An address structure is a parenthesized list that describes an 4380 electronic mail address. The fields of an address structure 4381 are in the following order: personal name, [SMTP] at-domain- 4382 list (source route), mailbox name, and host name. 4384 [RFC-5322] group syntax is indicated by a special form of 4385 address structure in which the host name field is NIL. If the 4386 mailbox name field is also NIL, this is an end of group marker 4387 (semi-colon in RFC 822 syntax). If the mailbox name field is 4388 non-NIL, this is a start of group marker, and the mailbox name 4389 field holds the group name phrase. 4391 If the Date, Subject, In-Reply-To, and Message-ID header lines 4392 are absent in the [RFC-5322] header, the corresponding member 4393 of the envelope is NIL; if these header lines are present but 4394 empty the corresponding member of the envelope is the empty 4395 string. 4397 Note: some servers may return a NIL envelope member in the 4398 "present but empty" case. Clients SHOULD treat NIL and 4399 empty string as identical. 4401 Note: [RFC-5322] requires that all messages have a valid 4402 Date header. Therefore, the date member in the envelope can 4403 not be NIL or the empty string. 4405 Note: [RFC-5322] requires that the In-Reply-To and Message- 4406 ID headers, if present, have non-empty content. Therefore, 4407 the in-reply-to and message-id members in the envelope can 4408 not be the empty string. 4410 If the From, To, Cc, and Bcc header lines are absent in the 4411 [RFC-5322] header, or are present but empty, the corresponding 4412 member of the envelope is NIL. 4414 If the Sender or Reply-To lines are absent in the [RFC-5322] 4415 header, or are present but empty, the server sets the 4416 corresponding member of the envelope to be the same value as 4417 the from member (the client is not expected to know to do 4418 this). 4420 Note: [RFC-5322] requires that all messages have a valid 4421 From header. Therefore, the from, sender, and reply-to 4422 members in the envelope can not be NIL. 4424 FLAGS A parenthesized list of flags that are set for this message. 4426 INTERNALDATE A string representing the internal date of the message. 4428 RFC822 Equivalent to BODY[]. 4430 RFC822.HEADER Equivalent to BODY[HEADER]. Note that this did not 4431 result in \Seen being set, because RFC822.HEADER response data 4432 occurs as a result of a FETCH of RFC822.HEADER. BODY[HEADER] 4433 response data occurs as a result of a FETCH of BODY[HEADER] (which 4434 sets \Seen) or BODY.PEEK[HEADER] (which does not set \Seen). 4436 RFC822.SIZE A number expressing the [RFC-5322] size of the message. 4438 RFC822.TEXT Equivalent to BODY[TEXT]. 4440 UID A number expressing the unique identifier of the message. 4442 Example: S: * 23 FETCH (FLAGS (\Seen) RFC822.SIZE 44827) 4444 7.5. Server Responses - Command Continuation Request 4446 The command continuation request response is indicated by a "+" token 4447 instead of a tag. This form of response indicates that the server is 4448 ready to accept the continuation of a command from the client. The 4449 remainder of this response is a line of text. 4451 This response is used in the AUTHENTICATE command to transmit server 4452 data to the client, and request additional client data. This 4453 response is also used if an argument to any command is a literal. 4455 The client is not permitted to send the octets of the literal unless 4456 the server indicates that it is expected. This permits the server to 4457 process commands and reject errors on a line-by-line basis. The 4458 remainder of the command, including the CRLF that terminates a 4459 command, follows the octets of the literal. If there are any 4460 additional command arguments, the literal octets are followed by a 4461 space and those arguments. 4463 Example: C: A001 LOGIN {11} 4464 S: + Ready for additional command text 4465 C: FRED FOOBAR {7} 4466 S: + Ready for additional command text 4467 C: fat man 4468 S: A001 OK LOGIN completed 4469 C: A044 BLURDYBLOOP {102856} 4470 S: A044 BAD No such command as "BLURDYBLOOP" 4472 8. Sample IMAP4rev2 connection 4474 The following is a transcript of an IMAP4rev2 connection. A long 4475 line in this sample is broken for editorial clarity. 4477 S: * OK IMAP4rev2 Service Ready 4478 C: a001 login mrc secret 4479 S: a001 OK LOGIN completed 4480 C: a002 select inbox 4481 S: * 18 EXISTS 4482 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 4483 S: * 2 RECENT 4484 S: * OK [UNSEEN 17] Message 17 is the first unseen message 4485 S: * OK [UIDVALIDITY 3857529045] UIDs valid 4486 S: a002 OK [READ-WRITE] SELECT completed 4487 C: a003 fetch 12 full 4488 S: * 12 FETCH (FLAGS (\Seen) INTERNALDATE "17-Jul-1996 02:44:25 -0700" 4489 RFC822.SIZE 4286 ENVELOPE ("Wed, 17 Jul 1996 02:23:25 -0700 (PDT)" 4490 "IMAP4rev2 WG mtg summary and minutes" 4491 (("Terry Gray" NIL "gray" "cac.washington.edu")) 4492 (("Terry Gray" NIL "gray" "cac.washington.edu")) 4493 (("Terry Gray" NIL "gray" "cac.washington.edu")) 4494 ((NIL NIL "imap" "cac.washington.edu")) 4495 ((NIL NIL "minutes" "CNRI.Reston.VA.US") 4496 ("John Klensin" NIL "KLENSIN" "MIT.EDU")) NIL NIL 4497 "") 4498 BODY ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 3028 4499 92)) 4500 S: a003 OK FETCH completed 4501 C: a004 fetch 12 body[header] 4502 S: * 12 FETCH (BODY[HEADER] {342} 4503 S: Date: Wed, 17 Jul 1996 02:23:25 -0700 (PDT) 4504 S: From: Terry Gray 4505 S: Subject: IMAP4rev2 WG mtg summary and minutes 4506 S: To: imap@cac.washington.edu 4507 S: cc: minutes@CNRI.Reston.VA.US, John Klensin 4508 S: Message-Id: 4509 S: MIME-Version: 1.0 4510 S: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 4511 S: 4512 S: ) 4513 S: a004 OK FETCH completed 4514 C: a005 store 12 +flags \deleted 4515 S: * 12 FETCH (FLAGS (\Seen \Deleted)) 4516 S: a005 OK +FLAGS completed 4517 C: a006 logout 4518 S: * BYE IMAP4rev2 server terminating connection 4519 S: a006 OK LOGOUT completed 4520 9. Formal Syntax 4522 The following syntax specification uses the Augmented Backus-Naur 4523 Form (ABNF) notation as specified in [ABNF]. 4525 In the case of alternative or optional rules in which a later rule 4526 overlaps an earlier rule, the rule which is listed earlier MUST take 4527 priority. For example, "\Seen" when parsed as a flag is the \Seen 4528 flag name and not a flag-extension, even though "\Seen" can be parsed 4529 as a flag-extension. Some, but not all, instances of this rule are 4530 noted below. 4532 Note: [ABNF] rules MUST be followed strictly; in particular: 4534 (1) Except as noted otherwise, all alphabetic characters are case- 4535 insensitive. The use of upper or lower case characters to define 4536 token strings is for editorial clarity only. Implementations MUST 4537 accept these strings in a case-insensitive fashion. 4539 (2) In all cases, SP refers to exactly one space. It is NOT 4540 permitted to substitute TAB, insert additional spaces, or 4541 otherwise treat SP as being equivalent to LWSP. 4543 (3) The ASCII NUL character, %x00, MUST NOT be used at any time. 4545 address = "(" addr-name SP addr-adl SP addr-mailbox SP 4546 addr-host ")" 4548 addr-adl = nstring 4549 ; Holds route from [RFC-5322] route-addr if 4550 ; non-NIL 4552 addr-host = nstring 4553 ; NIL indicates [RFC-5322] group syntax. 4554 ; Otherwise, holds [RFC-5322] domain name 4556 addr-mailbox = nstring 4557 ; NIL indicates end of [RFC-5322] group; if 4558 ; non-NIL and addr-host is NIL, holds 4559 ; [RFC-5322] group name. 4560 ; Otherwise, holds [RFC-5322] local-part 4561 ; after removing [RFC-5322] quoting 4563 addr-name = nstring 4564 ; If non-NIL, holds phrase from [RFC-5322] 4565 ; mailbox after removing [RFC-5322] quoting 4567 append = "APPEND" SP mailbox [SP flag-list] [SP date-time] SP 4568 literal 4570 append-uid = uniqueid 4572 astring = 1*ASTRING-CHAR / string 4574 ASTRING-CHAR = ATOM-CHAR / resp-specials 4576 atom = 1*ATOM-CHAR 4578 ATOM-CHAR = 4580 atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards / 4581 quoted-specials / resp-specials 4583 authenticate = "AUTHENTICATE" SP auth-type [SP initial-resp] 4584 *(CRLF base64) 4586 auth-type = atom 4587 ; Defined by [SASL] 4589 base64 = *(4base64-char) [base64-terminal] 4591 base64-char = ALPHA / DIGIT / "+" / "/" 4592 ; Case-sensitive 4594 base64-terminal = (2base64-char "==") / (3base64-char "=") 4596 body = "(" (body-type-1part / body-type-mpart) ")" 4598 body-extension = nstring / number / 4599 "(" body-extension *(SP body-extension) ")" 4600 ; Future expansion. Client implementations 4601 ; MUST accept body-extension fields. Server 4602 ; implementations MUST NOT generate 4603 ; body-extension fields except as defined by 4604 ; future standard or standards-track 4605 ; revisions of this specification. 4607 body-ext-1part = body-fld-md5 [SP body-fld-dsp [SP body-fld-lang 4608 [SP body-fld-loc *(SP body-extension)]]] 4609 ; MUST NOT be returned on non-extensible 4610 ; "BODY" fetch 4612 body-ext-mpart = body-fld-param [SP body-fld-dsp [SP body-fld-lang 4613 [SP body-fld-loc *(SP body-extension)]]] 4614 ; MUST NOT be returned on non-extensible 4615 ; "BODY" fetch 4617 body-fields = body-fld-param SP body-fld-id SP body-fld-desc SP 4618 body-fld-enc SP body-fld-octets 4620 body-fld-desc = nstring 4622 body-fld-dsp = "(" string SP body-fld-param ")" / nil 4624 body-fld-enc = (DQUOTE ("7BIT" / "8BIT" / "BINARY" / "BASE64"/ 4625 "QUOTED-PRINTABLE") DQUOTE) / string 4627 body-fld-id = nstring 4629 body-fld-lang = nstring / "(" string *(SP string) ")" 4631 body-fld-loc = nstring 4633 body-fld-lines = number 4635 body-fld-md5 = nstring 4637 body-fld-octets = number 4639 body-fld-param = "(" string SP string *(SP string SP string) ")" / nil 4641 body-type-1part = (body-type-basic / body-type-msg / body-type-text) 4642 [SP body-ext-1part] 4644 body-type-basic = media-basic SP body-fields 4645 ; MESSAGE subtype MUST NOT be "RFC822" 4647 body-type-mpart = 1*body SP media-subtype 4648 [SP body-ext-mpart] 4649 ; MULTIPART body part 4651 body-type-msg = media-message SP body-fields SP envelope 4652 SP body SP body-fld-lines 4654 body-type-text = media-text SP body-fields SP body-fld-lines 4656 capability = ("AUTH=" auth-type) / atom 4657 ; New capabilities MUST begin with "X" or be 4658 ; registered with IANA as standard or 4659 ; standards-track 4661 capability-data = "CAPABILITY" *(SP capability) SP "IMAP4rev2" 4662 *(SP capability) 4663 ; Servers MUST implement the STARTTLS, AUTH=PLAIN, 4664 ; and LOGINDISABLED capabilities 4665 ; Servers which offer RFC 1730 compatibility MUST 4666 ; list "IMAP4" as the first capability. 4668 CHAR8 = %x01-ff 4669 ; any OCTET except NUL, %x00 4671 charset = atom / quoted 4673 command = tag SP (command-any / command-auth / command-nonauth / 4674 command-select) CRLF 4675 ; Modal based on state 4677 command-any = "CAPABILITY" / "LOGOUT" / "NOOP" / enable / x-command 4678 ; Valid in all states 4680 command-auth = append / create / delete / examine / list / lsub / 4681 Namespace-Command / 4682 rename / select / status / subscribe / unsubscribe / 4683 idle 4684 ; Valid only in Authenticated or Selected state 4686 command-nonauth = login / authenticate / "STARTTLS" 4687 ; Valid only when in Not Authenticated state 4689 command-select = "CHECK" / "CLOSE" / "UNSELECT" / "EXPUNGE" / copy / 4690 fetch / store / search / uid 4691 ; Valid only when in Selected state 4693 continue-req = "+" SP (resp-text / base64) CRLF 4695 copy = "COPY" SP sequence-set SP mailbox 4697 create = "CREATE" SP mailbox 4698 ; Use of INBOX gives a NO error 4700 date = date-text / DQUOTE date-text DQUOTE 4702 date-day = 1*2DIGIT 4703 ; Day of month 4705 date-day-fixed = (SP DIGIT) / 2DIGIT 4706 ; Fixed-format version of date-day 4708 date-month = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / 4709 "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec" 4711 date-text = date-day "-" date-month "-" date-year 4712 date-year = 4DIGIT 4714 date-time = DQUOTE date-day-fixed "-" date-month "-" date-year 4715 SP time SP zone DQUOTE 4717 delete = "DELETE" SP mailbox 4718 ; Use of INBOX gives a NO error 4720 digit-nz = %x31-39 4721 ; 1-9 4723 enable = "ENABLE" 1*(SP capability) 4725 enable-data = "ENABLED" *(SP capability) 4727 envelope = "(" env-date SP env-subject SP env-from SP 4728 env-sender SP env-reply-to SP env-to SP env-cc SP 4729 env-bcc SP env-in-reply-to SP env-message-id ")" 4731 env-bcc = "(" 1*address ")" / nil 4733 env-cc = "(" 1*address ")" / nil 4735 env-date = nstring 4737 env-from = "(" 1*address ")" / nil 4739 env-in-reply-to = nstring 4741 env-message-id = nstring 4743 env-reply-to = "(" 1*address ")" / nil 4745 env-sender = "(" 1*address ")" / nil 4747 env-subject = nstring 4749 env-to = "(" 1*address ")" / nil 4751 esearch-response = "ESEARCH" [search-correlator] [SP "UID"] 4752 *(SP search-return-data) 4753 ; ESEARCH response replaces SEARCH response 4754 ; from IMAP4rev1. 4756 examine = "EXAMINE" SP mailbox 4758 fetch = "FETCH" SP sequence-set SP ("ALL" / "FULL" / "FAST" / 4759 fetch-att / "(" fetch-att *(SP fetch-att) ")") 4761 fetch-att = "ENVELOPE" / "FLAGS" / "INTERNALDATE" / 4762 "RFC822" [".HEADER" / ".SIZE" / ".TEXT"] / 4763 "BODY" ["STRUCTURE"] / "UID" / 4764 "BODY" section [partial] / 4765 "BODY.PEEK" section [partial] 4767 flag = "\Answered" / "\Flagged" / "\Deleted" / 4768 "\Seen" / "\Draft" / flag-keyword / flag-extension 4769 ; Does not include "\Recent" 4771 flag-extension = "\" atom 4772 ; Future expansion. Client implementations 4773 ; MUST accept flag-extension flags. Server 4774 ; implementations MUST NOT generate 4775 ; flag-extension flags except as defined by 4776 ; future standard or standards-track 4777 ; revisions of this specification. 4779 flag-fetch = flag / "\Recent" 4781 flag-keyword = "$MDNSent" / "$Forwarded" / atom 4783 flag-list = "(" [flag *(SP flag)] ")" 4785 flag-perm = flag / "\*" 4787 greeting = "*" SP (resp-cond-auth / resp-cond-bye) CRLF 4789 header-fld-name = astring 4791 header-list = "(" header-fld-name *(SP header-fld-name) ")" 4793 idle = "IDLE" CRLF "DONE" 4795 initial-resp = (base64 / "=") 4796 ; "initial response" defined in 4797 ; Section 5.1 of [RFC4422] 4799 list = "LIST" SP mailbox SP list-mailbox 4801 list-mailbox = 1*list-char / string 4803 list-char = ATOM-CHAR / list-wildcards / resp-specials 4805 list-wildcards = "%" / "*" 4807 literal = "{" number "}" CRLF *CHAR8 4808 ; Number represents the number of CHAR8s 4810 login = "LOGIN" SP userid SP password 4812 lsub = "LSUB" SP mailbox SP list-mailbox 4814 mailbox = "INBOX" / astring 4815 ; INBOX is case-insensitive. All case variants of 4816 ; INBOX (e.g., "iNbOx") MUST be interpreted as INBOX 4817 ; not as an astring. An astring which consists of 4818 ; the case-insensitive sequence "I" "N" "B" "O" "X" 4819 ; is considered to be INBOX and not an astring. 4820 ; Refer to section 5.1 for further 4821 ; semantic details of mailbox names. 4823 mailbox-data = "FLAGS" SP flag-list / "LIST" SP mailbox-list / 4824 "LSUB" SP mailbox-list / esearch-response / 4825 "STATUS" SP mailbox SP "(" [status-att-list] ")" / 4826 number SP "EXISTS" / number SP "RECENT" / 4827 Namespace-Response 4829 mailbox-list = "(" [mbx-list-flags] ")" SP 4830 (DQUOTE QUOTED-CHAR DQUOTE / nil) SP mailbox 4832 mbx-list-flags = *(mbx-list-oflag SP) mbx-list-sflag 4833 *(SP mbx-list-oflag) / 4834 mbx-list-oflag *(SP mbx-list-oflag) 4836 mbx-list-oflag = "\Noinferiors" / flag-extension 4837 ; Other flags; multiple possible per LIST response 4839 mbx-list-sflag = "\Noselect" / "\Marked" / "\Unmarked" 4840 ; Selectability flags; only one per LIST response 4842 media-basic = ((DQUOTE ("APPLICATION" / "AUDIO" / "IMAGE" / 4843 "MESSAGE" / "VIDEO" / "FONT") DQUOTE) / string) SP 4844 media-subtype 4845 ; Defined in [MIME-IMT]. 4846 ; FONT defined in RFC YYYY. 4848 media-message = DQUOTE "MESSAGE" DQUOTE SP DQUOTE "RFC822" DQUOTE 4849 ; Defined in [MIME-IMT] 4851 media-subtype = string 4852 ; Defined in [MIME-IMT] 4854 media-text = DQUOTE "TEXT" DQUOTE SP media-subtype 4855 ; Defined in [MIME-IMT] 4857 message-data = nz-number SP ("EXPUNGE" / ("FETCH" SP msg-att)) 4858 msg-att = "(" (msg-att-dynamic / msg-att-static) 4859 *(SP (msg-att-dynamic / msg-att-static)) ")" 4861 msg-att-dynamic = "FLAGS" SP "(" [flag-fetch *(SP flag-fetch)] ")" 4862 ; MAY change for a message 4864 msg-att-static = "ENVELOPE" SP envelope / "INTERNALDATE" SP date-time / 4865 "RFC822" [".HEADER" / ".TEXT"] SP nstring / 4866 "RFC822.SIZE" SP number / 4867 "BODY" ["STRUCTURE"] SP body / 4868 "BODY" section ["<" number ">"] SP nstring / 4869 "UID" SP uniqueid 4870 ; MUST NOT change for a message 4872 Namespace = nil / "(" 1*Namespace-Descr ")" 4874 Namespace-Command = "NAMESPACE" 4876 Namespace-Descr = "(" string SP 4877 (DQUOTE QUOTED-CHAR DQUOTE / nil) 4878 *(Namespace-Response-Extension) ")" 4880 Namespace-Response-Extension = SP string SP 4881 "(" string *(SP string) ")" 4883 Namespace-Response = "NAMESPACE" SP Namespace 4884 SP Namespace SP Namespace 4885 ; The first Namespace is the Personal Namespace(s) 4886 ; The second Namespace is the Other Users' Namespace(s) 4887 ; The third Namespace is the Shared Namespace(s) 4889 nil = "NIL" 4891 nstring = string / nil 4893 number = 1*DIGIT 4894 ; Unsigned 32-bit integer 4895 ; (0 <= n < 4,294,967,296) 4897 number64 = 1*DIGIT 4898 ; Unsigned 63-bit integer 4899 ; (0 <= n <= 9,223,372,036,854,775,807) 4901 nz-number = digit-nz *DIGIT 4902 ; Non-zero unsigned 32-bit integer 4903 ; (0 < n < 4,294,967,296) 4905 password = astring 4906 partial-range = number ["." nz-number] 4907 ; Copied from RFC 5092 (IMAP URL) 4909 partial = "<" number "." nz-number ">" 4910 ; Partial FETCH request. 0-based offset of 4911 ; the first octet, followed by the number of octets 4912 ; in the fragment. 4914 quoted = DQUOTE *QUOTED-CHAR DQUOTE 4916 QUOTED-CHAR = / 4917 "\" quoted-specials 4919 quoted-specials = DQUOTE / "\" 4921 rename = "RENAME" SP mailbox SP mailbox 4922 ; Use of INBOX as a destination gives a NO error 4924 response = *(continue-req / response-data) response-done 4926 response-data = "*" SP (resp-cond-state / resp-cond-bye / 4927 mailbox-data / message-data / capability-data / 4928 enable-data) CRLF 4930 response-done = response-tagged / response-fatal 4932 response-fatal = "*" SP resp-cond-bye CRLF 4933 ; Server closes connection immediately 4935 response-tagged = tag SP resp-cond-state CRLF 4937 resp-code-apnd = "APPENDUID" SP nz-number SP append-uid 4939 resp-code-copy = "COPYUID" SP nz-number SP uid-set SP uid-set 4941 resp-cond-auth = ("OK" / "PREAUTH") SP resp-text 4942 ; Authentication condition 4944 resp-cond-bye = "BYE" SP resp-text 4946 resp-cond-state = ("OK" / "NO" / "BAD") SP resp-text 4947 ; Status condition 4949 resp-specials = "]" 4951 ;; ////Can we make "text" optional? Will this have any bad side effects? 4952 resp-text = ["[" resp-text-code "]" SP] text 4953 resp-text-code = "ALERT" / 4954 "BADCHARSET" [SP "(" charset *(SP charset) ")" ] / 4955 capability-data / "PARSE" / 4956 "PERMANENTFLAGS" SP "(" 4957 [flag-perm *(SP flag-perm)] ")" / 4958 "READ-ONLY" / "READ-WRITE" / "TRYCREATE" / 4959 "UIDNEXT" SP nz-number / "UIDVALIDITY" SP nz-number / 4960 "UNSEEN" SP nz-number / 4961 resp-code-apnd / resp-code-copy / "UIDNOTSTICKY" / 4962 "UNAVAILABLE" / "AUTHENTICATIONFAILED" / 4963 "AUTHORIZATIONFAILED" / "EXPIRED" / 4964 "PRIVACYREQUIRED" / "CONTACTADMIN" / "NOPERM" / 4965 "INUSE" / "EXPUNGEISSUED" / "CORRUPTION" / 4966 "SERVERBUG" / "CLIENTBUG" / "CANNOT" / 4967 "LIMIT" / "OVERQUOTA" / "ALREADYEXISTS" / 4968 "NONEXISTENT" / 4969 "CLOSED" / 4970 atom [SP 1*] 4972 search = "SEARCH" [search-return-opts] 4973 SP search-program 4975 search-correlator = SP "(" "TAG" SP tag-string ")" 4977 search-key = "ALL" / "ANSWERED" / "BCC" SP astring / 4978 "BEFORE" SP date / "BODY" SP astring / 4979 "CC" SP astring / "DELETED" / "FLAGGED" / 4980 "FROM" SP astring / "KEYWORD" SP flag-keyword / 4981 "NEW" / "OLD" / "ON" SP date / "RECENT" / "SEEN" / 4982 "SINCE" SP date / "SUBJECT" SP astring / 4983 "TEXT" SP astring / "TO" SP astring / 4984 "UNANSWERED" / "UNDELETED" / "UNFLAGGED" / 4985 "UNKEYWORD" SP flag-keyword / "UNSEEN" / 4986 ; Above this line were in [IMAP2] 4987 "DRAFT" / "HEADER" SP header-fld-name SP astring / 4988 "LARGER" SP number / "NOT" SP search-key / 4989 "OR" SP search-key SP search-key / 4990 "SENTBEFORE" SP date / "SENTON" SP date / 4991 "SENTSINCE" SP date / "SMALLER" SP number / 4992 "UID" SP sequence-set / "UNDRAFT" / sequence-set / 4993 "(" search-key *(SP search-key) ")" 4995 search-modifier-name = tagged-ext-label 4997 search-mod-params = tagged-ext-val 4998 ; This non-terminal shows recommended syntax 4999 ; for future extensions. 5001 search-program = ["CHARSET" SP charset SP] 5002 search-key *(SP search-key) 5003 ; CHARSET argument to SEARCH MUST be 5004 ; registered with IANA. 5006 search-ret-data-ext = search-modifier-name SP search-return-value 5007 ; Note that not every SEARCH return option 5008 ; is required to have the corresponding 5009 ; ESEARCH return data. 5011 search-return-data = "MIN" SP nz-number / 5012 "MAX" SP nz-number / 5013 "ALL" SP sequence-set / 5014 "COUNT" SP number / 5015 search-ret-data-ext 5016 ; All return data items conform to search-ret-data-ext 5017 ; syntax 5019 search-return-opts = SP "RETURN" SP "(" [search-return-opt 5020 *(SP search-return-opt)] ")" 5022 search-return-opt = "MIN" / "MAX" / "ALL" / "COUNT" / 5023 search-ret-opt-ext 5024 ; conforms to generic search-ret-opt-ext 5025 ; syntax 5027 search-ret-opt-ext = search-modifier-name [SP search-mod-params] 5029 search-return-value = tagged-ext-val 5030 ; Data for the returned search option. 5031 ; A single "nz-number"/"number"/"number64" value 5032 ; can be returned as an atom (i.e., without 5033 ; quoting). A sequence-set can be returned 5034 ; as an atom as well. 5036 section = "[" [section-spec] "]" 5038 section-msgtext = "HEADER" / "HEADER.FIELDS" [".NOT"] SP header-list / 5039 "TEXT" 5040 ; top-level or MESSAGE/RFC822 part 5042 section-part = nz-number *("." nz-number) 5043 ; body part reference. 5044 ; Allows for accessing nested body parts. 5046 section-spec = section-msgtext / (section-part ["." section-text]) 5048 section-text = section-msgtext / "MIME" 5049 ; text other than actual body part (headers, etc.) 5051 select = "SELECT" SP mailbox 5053 seq-number = nz-number / "*" 5054 ; message sequence number (COPY, FETCH, STORE 5055 ; commands) or unique identifier (UID COPY, 5056 ; UID FETCH, UID STORE commands). 5057 ; * represents the largest number in use. In 5058 ; the case of message sequence numbers, it is 5059 ; the number of messages in a non-empty mailbox. 5060 ; In the case of unique identifiers, it is the 5061 ; unique identifier of the last message in the 5062 ; mailbox or, if the mailbox is empty, the 5063 ; mailbox's current UIDNEXT value. 5064 ; The server should respond with a tagged BAD 5065 ; response to a command that uses a message 5066 ; sequence number greater than the number of 5067 ; messages in the selected mailbox. This 5068 ; includes "*" if the selected mailbox is empty. 5070 seq-range = seq-number ":" seq-number 5071 ; two seq-number values and all values between 5072 ; these two regardless of order. 5073 ; Example: 2:4 and 4:2 are equivalent and indicate 5074 ; values 2, 3, and 4. 5075 ; Example: a unique identifier sequence range of 5076 ; 3291:* includes the UID of the last message in 5077 ; the mailbox, even if that value is less than 3291. 5079 sequence-set = (seq-number / seq-range) ["," sequence-set] 5080 ; set of seq-number values, regardless of order. 5081 ; Servers MAY coalesce overlaps and/or execute the 5082 ; sequence in any order. 5083 ; Example: a message sequence number set of 5084 ; 2,4:7,9,12:* for a mailbox with 15 messages is 5085 ; equivalent to 2,4,5,6,7,9,12,13,14,15 5086 ; Example: a message sequence number set of *:4,5:7 5087 ; for a mailbox with 10 messages is equivalent to 5088 ; 10,9,8,7,6,5,4,5,6,7 and MAY be reordered and 5089 ; overlap coalesced to be 4,5,6,7,8,9,10. 5091 status = "STATUS" SP mailbox SP 5092 "(" status-att *(SP status-att) ")" 5094 status-att = "MESSAGES" / "RECENT" / "UIDNEXT" / "UIDVALIDITY" / 5095 "UNSEEN" / "SIZE" 5097 status-att-val = ("MESSAGES" SP number) / ("RECENT" SP number) / 5098 ("UIDNEXT" SP nz-number) / ("UIDVALIDITY" SP nz-number) / 5099 ("UNSEEN" SP number) / ("SIZE" SP number64) 5100 ; Extensions to the STATUS responses 5101 ; should extend this production. 5102 ; Extensions should use the generic 5103 ; syntax defined by tagged-ext. 5105 status-att-list = status-att-val *(SP status-att-val) 5107 store = "STORE" SP sequence-set SP store-att-flags 5109 store-att-flags = (["+" / "-"] "FLAGS" [".SILENT"]) SP 5110 (flag-list / (flag *(SP flag))) 5112 string = quoted / literal 5114 subscribe = "SUBSCRIBE" SP mailbox 5116 tag = 1* 5118 tagged-ext-label = tagged-label-fchar *tagged-label-char 5119 ;; Is a valid RFC 3501 "atom". 5121 tagged-label-fchar = ALPHA / "-" / "_" / "." 5123 tagged-label-char = tagged-label-fchar / DIGIT / ":" 5125 tagged-ext-comp = astring / 5126 tagged-ext-comp *(SP tagged-ext-comp) / 5127 "(" tagged-ext-comp ")" 5128 ;; Extensions that follow this general 5129 ;; syntax should use nstring instead of 5130 ;; astring when appropriate in the context 5131 ;; of the extension. 5132 ;; Note that a message set or a "number" 5133 ;; can always be represented as an "atom". 5134 ;; An URL should be represented as 5135 ;; a "quoted" string. 5137 tagged-ext-simple = sequence-set / number / number64 5139 tagged-ext-val = tagged-ext-simple / 5140 "(" [tagged-ext-comp] ")" 5142 text = 1*TEXT-CHAR 5144 TEXT-CHAR = 5145 time = 2DIGIT ":" 2DIGIT ":" 2DIGIT 5146 ; Hours minutes seconds 5148 uid = "UID" SP (copy / fetch / search / store / uid-expunge) 5149 ; Unique identifiers used instead of message 5150 ; sequence numbers 5152 uid-expunge = "EXPUNGE" SP sequence-set 5153 ; Unique identifiers used instead of message 5154 ; sequence numbers 5156 uid-set = (uniqueid / uid-range) *("," uid-set) 5158 uid-range = (uniqueid ":" uniqueid) 5159 ; two uniqueid values and all values 5160 ; between these two regards of order. 5161 ; Example: 2:4 and 4:2 are equivalent. 5163 uniqueid = nz-number 5164 ; Strictly ascending 5166 unsubscribe = "UNSUBSCRIBE" SP mailbox 5168 userid = astring 5170 x-command = "X" atom 5172 zone = ("+" / "-") 4DIGIT 5173 ; Signed four-digit value of hhmm representing 5174 ; hours and minutes east of Greenwich (that is, 5175 ; the amount that the given time differs from 5176 ; Universal Time). Subtracting the timezone 5177 ; from the given time will give the UT form. 5178 ; The Universal Time zone is "+0000". 5180 10. Author's Note 5182 This document is a revision or rewrite of earlier documents, and 5183 supercedes the protocol specification in those documents: RFC 2060, 5184 RFC 1730, unpublished IMAP2bis.TXT document, RFC 1176, and RFC 1064. 5186 11. Security Considerations 5188 IMAP4rev2 protocol transactions, including electronic mail data, are 5189 sent in the clear over the network unless protection from snooping is 5190 negotiated. This can be accomplished either by the use of IMAPS 5191 service, STARTTLS command, negotiated privacy protection in the 5192 AUTHENTICATE command, or some other protection mechanism. 5194 11.1. STARTTLS Security Considerations 5196 IMAP client and server implementations MUST comply with relevant TLS 5197 recommendations from [RFC8314]. Additionally, when using TLS 1.2, 5198 IMAP implementations MUST implement 5199 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 cipher suite, and SHOULD 5200 implement the TLS_RSA_WITH_AES_128_CBC_SHA [TLS] cipher suite. This 5201 is important as it assures that any two compliant implementations can 5202 be configured to interoperate. Other TLS cipher suites recommended 5203 in RFC 7525 are RECOMMENDED: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 5204 TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 and 5205 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384. All other cipher suites are 5206 OPTIONAL. Note that this is a change from section 2.1 of [IMAP-TLS]. 5208 During the [TLS] negotiation, the client MUST check its understanding 5209 of the server hostname against the server's identity as presented in 5210 the server Certificate message, in order to prevent man-in-the-middle 5211 attacks. This procedure is described in [RFC7817]. 5213 Both the client and server MUST check the result of the STARTTLS 5214 command and subsequent [TLS] negotiation to see whether acceptable 5215 authentication and/or privacy was achieved. 5217 11.2. COPYUID and APPENDUID response codes 5219 The COPYUID and APPENDUID response codes return information about the 5220 mailbox, which may be considered sensitive if the mailbox has 5221 permissions set that permit the client to COPY or APPEND to the 5222 mailbox, but not SELECT or EXAMINE it. 5224 Consequently, these response codes SHOULD NOT be issued if the client 5225 does not have access to SELECT or EXAMINE the mailbox. 5227 11.3. Other Security Considerations 5229 A server error message for an AUTHENTICATE command which fails due to 5230 invalid credentials SHOULD NOT detail why the credentials are 5231 invalid. 5233 Use of the LOGIN command sends passwords in the clear. This can be 5234 avoided by using the AUTHENTICATE command with a [SASL] mechanism 5235 that does not use plaintext passwords, by first negotiating 5236 encryption via STARTTLS or some other protection mechanism. 5238 A server implementation MUST implement a configuration that, at the 5239 time of authentication, requires: 5240 (1) The STARTTLS command has been negotiated. 5241 OR 5242 (2) Some other mechanism that protects the session from password 5243 snooping has been provided. 5244 OR 5245 (3) The following measures are in place: 5246 (a) The LOGINDISABLED capability is advertised, and [SASL] mechanisms 5247 (such as PLAIN) using plaintext passwords are NOT advertised in the 5248 CAPABILITY list. 5249 AND 5250 (b) The LOGIN command returns an error even if the password is 5251 correct. 5252 AND 5253 (c) The AUTHENTICATE command returns an error with all [SASL] 5254 mechanisms that use plaintext passwords, even if the password is 5255 correct. 5257 A server error message for a failing LOGIN command SHOULD NOT specify 5258 that the user name, as opposed to the password, is invalid. 5260 A server SHOULD have mechanisms in place to limit or delay failed 5261 AUTHENTICATE/LOGIN attempts. 5263 Additional security considerations are discussed in the section 5264 discussing the AUTHENTICATE and LOGIN commands. 5266 12. IANA Considerations 5268 IANA is requested to update "Service Names and Transport Protocol 5269 Port Numbers" registry as follows: 5271 1. Registration for TCP "imap" port 143 should be updated to point 5272 to this document and RFC 3501. 5274 2. Registration for TCP "imaps" port 993 should be updated to point 5275 to this document and RFC 3501. 5277 3. Both UDP port 143 and UDP port 993 should be marked as "Reserved" 5278 in the registry. 5280 Additional IANA actions are specified in subsection of this section. 5282 12.1. Updates to IMAP4 Capabilities registry 5284 IMAP4 capabilities are registered by publishing a standards track or 5285 IESG approved informational or experimental RFC. The registry is 5286 currently located at: http://www.iana.org/assignments/ 5287 imap4-capabilities 5288 As this specification revises the STARTTLS and LOGINDISABLED 5289 extensions previously defined in [IMAP-TLS], IANA is requested to 5290 update registry entries for these 2 extensions to point to this 5291 document. 5293 12.2. GSSAPI/SASL service name 5295 GSSAPI/Kerberos/SASL service names are registered by publishing a 5296 standards track or IESG approved experimental RFC. The registry is 5297 currently located at: http://www.iana.org/assignments/gssapi-service- 5298 names 5300 IANA is requested to update the "imap" service name previously 5301 registered in RFC 3501, to point to this document. 5303 13. References 5305 13.1. Normative References 5307 [ABNF] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 5308 Specifications: ABNF", STD 68, RFC 5234, January 2008, 5309 . 5311 [ANONYMOUS] 5312 Zeilenga, K., "Anonymous Simple Authentication and 5313 Security Layer (SASL) Mechanism", RFC 4505, June 2006, 5314 . 5316 [CHARSET] Freed, N. and J. Postel, "IANA Charset Registration 5317 Procedures", BCP 19, RFC 2978, October 2000, 5318 . 5320 [DIGEST-MD5] 5321 Leach, P. and C. Newman, "Using Digest Authentication as a 5322 SASL Mechanism", RFC 2831, May 2000, 5323 . 5325 [DISPOSITION] 5326 Troost, R., Dorner, S., and K. Moore, Ed., "Communicating 5327 Presentation Information in Internet Messages: The 5328 Content-Disposition Header Field", RFC 2183, August 1997, 5329 . 5331 [PLAIN] Zeilenga, K., Ed., "The PLAIN Simple Authentication and 5332 Security Layer (SASL) Mechanism", RFC 4616, August 2006, 5333 . 5335 [KEYWORDS] 5336 Bradner, S., "Key words for use in RFCs to Indicate 5337 Requirement Levels", BCP 14, RFC 2119, March 1997, 5338 . 5340 [LANGUAGE-TAGS] 5341 Alvestrand, H., "Content Language Headers", RFC 3282, May 5342 2002, . 5344 [LOCATION] 5345 Palme, J., Hopmann, A., and N. Shelness, "MIME 5346 Encapsulation of Aggregate Documents, such as HTML 5347 (MHTML)", RFC 2557, March 1999, 5348 . 5350 [MD5] Myers, J. and M. Rose, "The Content-MD5 Header Field", 5351 RFC 1864, October 1995, 5352 . 5354 [MIME-HDRS] 5355 Moore, K., "MIME (Multipurpose Internet Mail Extensions) 5356 Part Three: Message Header Extensions for Non-ASCII Text", 5357 RFC 2047, November 1996, 5358 . 5360 [MIME-IMB] 5361 Freed, N. and N. Borenstein, "Multipurpose Internet Mail 5362 Extensions (MIME) Part One: Format of Internet Message 5363 Bodies", RFC 2045, November 1996, 5364 . 5366 [MIME-IMT] 5367 Freed, N. and N. Borenstein, "Multipurpose Internet Mail 5368 Extensions (MIME) Part Two: Media Types", RFC 2046, 5369 November 1996, . 5371 [RFC-5322] 5372 Resnick, P., Ed., "Internet Message Format", RFC 5322, 5373 October 2008, . 5375 [SASL] Melnikov, A., Ed. and K. Zeilenga, Ed., "Simple 5376 Authentication and Security Layer (SASL)", RFC 4422, June 5377 2006, . 5379 [TLS] Dierks, T. and E. Rescorla, "The Transport Layer Security 5380 (TLS) Protocol Version 1.2", RFC 5246, August 2008, 5381 . 5383 [UTF-7] Goldsmith, D. and M. Davis, "UTF-7 A Mail-Safe 5384 Transformation Format of Unicode", RFC 2152, May 1997, 5385 . 5387 [MULTIAPPEND] 5388 Crispin, M., "Internet Message Access Protocol (IMAP) - 5389 MULTIAPPEND Extension", RFC 3502, March 2003, 5390 . 5392 [IMAP-IMPLEMENTATION] 5393 Leiba, B., "IMAP4 Implementation Recommendations", 5394 RFC 2683, September 1999, 5395 . 5397 [IMAP-MULTIACCESS] 5398 Gahrns, M., "IMAP4 Multi-Accessed Mailbox Practice", 5399 RFC 2180, July 1997, 5400 . 5402 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 5403 Encodings", RFC 4648, DOI 10.17487/RFC4648, October 2006, 5404 . 5406 [RFC7817] Melnikov, A., "Updated Transport Layer Security (TLS) 5407 Server Identity Check Procedure for Email-Related 5408 Protocols", RFC 7817, DOI 10.17487/RFC7817, March 2016, 5409 . 5411 [RFC8314] Moore, K. and C. Newman, "Cleartext Considered Obsolete: 5412 Use of Transport Layer Security (TLS) for Email Submission 5413 and Access", RFC 8314, DOI 10.17487/RFC8314, January 2018, 5414 . 5416 13.2. Informative References (related protocols) 5418 [IMAP-DISC] 5419 Melnikov, A., Ed., "Synchronization Operations for 5420 Disconnected IMAP4 Clients", RFC 4549, June 2006, 5421 . 5423 [IMAP-MODEL] 5424 Crispin, M., "Distributed Electronic Mail Models in 5425 IMAP4", RFC 1733, December 1994, 5426 . 5428 [ACAP] Newman, C. and J. G. Myers, "ACAP -- Application 5429 Configuration Access Protocol", RFC 2244, November 1997, 5430 . 5432 [SMTP] Klensin, J., "Simple Mail Transfer Protocol", RFC 5321, 5433 October 2008, . 5435 [RFC4314] Melnikov, A., "IMAP4 Access Control List (ACL) Extension", 5436 RFC 4314, December 2005, 5437 . 5439 [RFC2087] Myers, J., "IMAP4 QUOTA extension", RFC 2087, January 5440 1997, . 5442 [IMAP-URL] 5443 Melnikov, A., Ed. and C. Newman, "IMAP URL Scheme", 5444 RFC 5092, DOI 10.17487/RFC5092, November 2007, 5445 . 5447 13.3. Informative References (historical aspects of IMAP and related 5448 protocols) 5450 [IMAP-COMPAT] 5451 Crispin, M., "IMAP4 Compatibility with IMAP2bis", 5452 RFC 2061, December 1996, 5453 . 5455 [IMAP-HISTORICAL] 5456 Crispin, M., "IMAP4 Compatibility with IMAP2 and 5457 IMAP2bis", RFC 1732, December 1994, 5458 . 5460 [IMAP-OBSOLETE] 5461 Crispin, M., "Internet Message Access Protocol - Obsolete 5462 Syntax", RFC 2062, December 1996, 5463 . 5465 [IMAP2] Crispin, M., "Interactive Mail Access Protocol: Version 5466 2", RFC 1176, August 1990, 5467 . 5469 [RFC-822] Crocker, D., "STANDARD FOR THE FORMAT OF ARPA INTERNET 5470 TEXT MESSAGES", STD 11, RFC 822, August 1982, 5471 . 5473 [RFC-821] Postel, J., "Simple Mail Transfer Protocol", STD 10, 5474 RFC 821, August 1982, 5475 . 5477 [IMAP-TLS] 5478 Newman, C., "Using TLS with IMAP, POP3 and ACAP", 5479 RFC 2595, June 1999, 5480 . 5482 Appendix A. Backward compatibility with IMAP4rev1 5484 An implementation that wants to remain compatible with IMAP4rev1 can 5485 advertise both IMAP4rev1 and IMAP4rev2 in its CAPABILITY response/ 5486 response code. While some IMAP4rev1 response were removed in 5487 IMAP4rev2, their presence will not break IMAP4rev2-only clients. 5489 If both IMAP4rev1 and IMAP4rev2 are advertised, an IMAP client that 5490 wants to use IMAP4rev2 MUST issue "ENABLE IMAP4rev2" command. 5492 Appendix B. Changes from RFC 3501 / IMAP4rev1 5494 The following is the plan for remaining changes. The plan might 5495 change over time. 5497 1. Fold in the following extensions/RFC: RFC 5530 (IMAP Response 5498 Codes, done), UIDPLUS (done), ENABLE (done), ESEARCH (done), 5499 SPECIAL-USE (list of new mailbox attributes is done), LITERAL-, 5500 NAMESPACE (done), SASL-IR (done). 5502 2. Add CLOSED response code (from CONDSTORE) - done 5504 3. Add support for $MDNSent and $Forwarded IMAP keywords - done. 5505 Add more examples showing their use? 5507 4. Require all unsolicited updates to include UID (?) 5509 5. Update recommendations on TLS ciphers to match UTA WG work (as 5510 per RFC 8314, RFC 7525 and RFC 7817) - done. 5512 6. Possibly fold in the following extensions/RFC: Base LIST- 5513 EXTENDED syntax plus deprecate LSUB (replace it with LIST 5514 \Subscribed) minus the requirement to support multiple list 5515 patterns, STATUS-in-LIST, Unique mailstore IDs for messages 5516 (OBJECTID extension, see draft-ietf-extra-imap-objectid), IDLE 5517 (done), SEARCHRES, BINARY. 5519 7. Add STATUS SIZE (total mailbox size) - done Add STATUS DELETED 5520 (number of messages with \Deleted flag set)? 5522 8. Deprecate features: RECENT response on SELECT/EXAMINE, \Recent 5523 flag, RECENT STATUS item. UNSEEN response code on SELECT/ 5524 EXAMINE. SEARCH response (use ESEARCH instead). 5526 9. Drop UTF-7, all mailboxes are always in UTF-8. 5528 10. Revise IANA registration of IMAP extensions and advice on use of 5529 "X-" convention. 5531 The following changes since RFC 3501 were done so far: 5533 1. Folded in IMAP UNSELECT (RFC 3691), UIDPLUS (RFC 4315), ESEARCH 5534 (RFC 4731), ENABLE (RFC 5161), IDLE (RFC 2177) and SASL-IR (RFC 5535 4959) extensions. Also folded RFC 5530. 5537 2. Added CLOSED response code from RFC 7162. 5539 3. Updated to use modern TLS-related recommendations as per RFC 5540 8314, RFC 7817, RFC 7525. 5542 4. For future extensibility extended ABNF for tagged-ext-simple to 5543 allow for bare number64. 5545 5. Added SHOULD level requirement on IMAP servers to support 5546 $MDNSent and $Forwarded keywords. 5548 6. Added STATUS SIZE. 5550 Appendix C. Acknowledgement 5552 Earlier versions of this document were edited by Mark Crispin. 5553 Sadly, he is no longer available to help with this work. Editor of 5554 this revisions is hoping that Mark would have approved. 5556 Thank you to Tony Hansen for helping with the index generation. 5558 This document incorporate text from RFC 4315, RFC 4466, RFC 4731, RFC 5559 5161, RFC 6154 so work done by authors/editors of these documents is 5560 appreciated. 5562 Index 5564 $ 5565 $Forwarded (predefined flag) 12 5566 $MDNSent (predefined flag) 12 5568 + 5569 +FLAGS 68 5570 +FLAGS.SILENT 68 5572 - 5573 -FLAGS 69 5574 -FLAGS.SILENT 69 5576 A 5577 ALERT (response code) 74 5578 ALL (fetch item) 65 5579 ALL (search key) 61 5580 ALL (search result option) 60 5581 ALREADYEXISTS (response code) 74 5582 ANSWERED (search key) 61 5583 APPEND (command) 52 5584 APPENDUID (response code) 74 5585 AUTHENTICATE (command) 28 5586 AUTHENTICATIONFAILED (response code) 75 5587 AUTHORIZATIONFAILED (response code) 75 5589 B 5590 BAD (response) 81 5591 BADCHARSET (response code) 75 5592 BCC (search key) 61 5593 BEFORE (search key) 61 5594 BODY (fetch item) 65 5595 BODY (fetch result) 91 5596 BODY (search key) 61 5597 BODY.PEEK[
]<> (fetch item) 67 5598 BODYSTRUCTURE (fetch item) 67 5599 BODYSTRUCTURE (fetch result) 91 5600 BODY[
]<> (fetch result) 91 5601 BODY[
]<> (fetch item) 65 5602 BYE (response) 82 5603 Body Structure (message attribute) 13 5605 C 5606 CANNOT (response code) 75 5607 CAPABILITY (command) 25 5608 CAPABILITY (response code) 75 5609 CAPABILITY (response) 83 5610 CC (search key) 61 5611 CHECK (command) 57 5612 CLIENTBUG (response code) 75 5613 CLOSE (command) 57 5614 CLOSED (response code) 76 5615 CONTACTADMIN (response code) 76 5616 COPY (command) 69 5617 COPYUID (response code) 76 5618 CORRUPTION (response code) 77 5619 COUNT (search result option) 60 5620 CREATE (command) 37 5622 D 5623 DELETE (command) 38 5624 DELETED (search key) 61 5625 DRAFT (search key) 61 5627 E 5628 ENABLE (command) 32 5629 ENVELOPE (fetch item) 67 5630 ENVELOPE (fetch result) 94 5631 ESEARCH (response) 88 5632 EXAMINE (command) 36 5633 EXPIRED (response code) 77 5634 EXPUNGE (command) 58 5635 EXPUNGE (response) 90 5636 EXPUNGEISSUED (response code) 77 5637 Envelope Structure (message attribute) 13 5639 F 5640 FAST (fetch item) 65 5641 FETCH (command) 64 5642 FETCH (response) 91 5643 FLAGGED (search key) 61 5644 FLAGS (fetch item) 67 5645 FLAGS (fetch result) 95 5646 FLAGS (response) 88 5647 FLAGS (store command data item) 68 5648 FLAGS.SILENT (store command data item) 68 5649 FROM (search key) 61 5650 FULL (fetch item) 65 5651 Flags (message attribute) 11 5653 H 5654 HEADER (part specifier) 65 5655 HEADER (search key) 62 5656 HEADER.FIELDS (part specifier) 65 5657 HEADER.FIELDS.NOT (part specifier) 65 5659 I 5660 IDLE (command) 55 5661 INTERNALDATE (fetch item) 67 5662 INTERNALDATE (fetch result) 95 5663 INUSE (response code) 77 5664 Internal Date (message attribute) 13 5666 K 5667 KEYWORD (search key) 62 5668 Keyword (type of flag) 12 5670 L 5671 LARGER (search key) 62 5672 LIMIT (response code) 78 5673 LIST (command) 42 5674 LIST (response) 84 5675 LOGOUT (command) 26 5676 LSUB (command) 45 5677 LSUB (response) 87 5679 M 5680 MAX (search result option) 60 5681 MAY (specification requirement term) 5 5682 MESSAGES (status item) 51 5683 MIME (part specifier) 66 5684 MIN (search result option) 59 5685 MUST (specification requirement term) 5 5686 MUST NOT (specification requirement term) 5 5687 Message Sequence Number (message attribute) 11 5689 N 5690 NAMESPACE (command) 46 5691 NAMESPACE (response) 87 5692 NEW (search key) 62 5693 NO (response) 81 5694 NONEXISTENT (response code) 78 5695 NOOP (command) 26 5696 NOPERM (response code) 78 5697 NOT (search key) 62 5699 O 5700 OK (response) 80 5701 OLD (search key) 62 5702 ON (search key) 62 5703 OPTIONAL (specification requirement term) 5 5704 OR (search key) 62 5705 OVERQUOTA (response code) 78 5707 P 5708 PARSE (response code) 79 5709 PERMANENTFLAGS (response code) 79 5710 PREAUTH (response) 82 5711 PRIVACYREQUIRED (response code) 79 5712 Permanent Flag (class of flag) 12 5713 Predefined keywords 12 5715 R 5716 READ-ONLY (response code) 79 5717 READ-WRITE (response code) 79 5718 RECENT (search key) 62 5719 RECENT (status item) 51 5720 RECOMMENDED (specification requirement term) 5 5721 RENAME (command) 39 5722 REQUIRED (specification requirement term) 5 5723 RFC822 (fetch item) 67 5724 RFC822 (fetch result) 95 5725 RFC822.HEADER (fetch item) 67 5726 RFC822.HEADER (fetch result) 95 5727 RFC822.SIZE (fetch item) 67 5728 RFC822.SIZE (fetch result) 95 5729 RFC822.TEXT (fetch item) 67 5730 RFC822.TEXT (fetch result) 95 5732 S 5733 SEARCH (command) 59 5734 SEEN (search key) 62 5735 SELECT (command) 34 5736 SENTBEFORE (search key) 62 5737 SENTON (search key) 62 5738 SENTSINCE (search key) 62 5739 SERVERBUG (response code) 79 5740 SHOULD (specification requirement term) 5 5741 SHOULD NOT (specification requirement term) 5 5742 SINCE (search key) 62 5743 SIZE (status item) 52 5744 SMALLER (search key) 62 5745 STARTTLS (command) 27 5746 STATUS (command) 50 5747 STATUS (response) 87 5748 STORE (command) 68 5749 SUBJECT (search key) 63 5750 SUBSCRIBE (command) 41 5751 Session Flag (class of flag) 12 5752 System Flag (type of flag) 11 5754 T 5755 TEXT (part specifier) 65 5756 TEXT (search key) 63 5757 TO (search key) 63 5758 TRYCREATE (response code) 79 5760 U 5761 UID (command) 70 5762 UID (fetch item) 67 5763 UID (fetch result) 95 5764 UID (search key) 63 5765 UIDNEXT (response code) 80 5766 UIDNEXT (status item) 51 5767 UIDNOTSTICKY (response code) 80 5768 UIDVALIDITY (response code) 80 5769 UIDVALIDITY (status item) 51 5770 UNANSWERED (search key) 63 5771 UNAVAILABLE (response code) 80 5772 UNDELETED (search key) 63 5773 UNDRAFT (search key) 63 5774 UNFLAGGED (search key) 63 5775 UNKEYWORD (search key) 63 5776 UNSEEN (response code) 80 5777 UNSEEN (search key) 63 5778 UNSEEN (status item) 52 5779 UNSELECT (command) 58 5780 UNSUBSCRIBE (command) 42 5781 Unique Identifier (UID) (message attribute) 9 5783 X 5784 X (command) 72 5786 [ 5787 [RFC-5322] Size (message attribute) 13 5789 \ 5790 \All (mailbox name attribute) 85 5791 \Answered (system flag) 11 5792 \Archive (mailbox name attribute) 85 5793 \Deleted (system flag) 11 5794 \Draft (system flag) 12 5795 \Drafts (mailbox name attribute) 86 5796 \Flagged (mailbox name attribute) 86 5797 \Flagged (system flag) 11 5798 \HasChildren (mailbox name attribute) 84 5799 \HasNoChildren (mailbox name attribute) 85 5800 \Junk (mailbox name attribute) 86 5801 \Marked (mailbox name attribute) 85 5802 \Noinferiors (mailbox name attribute) 84 5803 \Noselect (mailbox name attribute) 84 5804 \Recent (system flag) 12 5805 \Seen (system flag) 11 5806 \Sent (mailbox name attribute) 86 5807 \Trash (mailbox name attribute) 86 5808 \Unmarked (mailbox name attribute) 85 5810 Author's Address 5812 Alexey Melnikov (editor) 5813 Isode Ltd 5814 14 Castle Mews 5815 Hampton, Middlesex TW12 2NP 5816 UK 5818 Email: Alexey.Melnikov@isode.com