idnits 2.17.1 draft-melnikov-imap4rev2-08.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 (May 29, 2018) is 2130 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 5455, but not defined == Missing Reference: 'IMAP-OBSOLETE' is mentioned on line 5450, but not defined == Missing Reference: 'IMAP-COMPAT' is mentioned on line 5440, but not defined == Missing Reference: 'IMAP-HISTORICAL' is mentioned on line 5445, but not defined == Missing Reference: 'RFC-822' is mentioned on line 5459, but not defined ** Obsolete undefined reference: RFC 822 (Obsoleted by RFC 2822) == Missing Reference: 'HEADER' is mentioned on line 4492, but not defined == Missing Reference: 'IMAP-DISC' is mentioned on line 5408, but not defined == Missing Reference: 'SMTP' is mentioned on line 5422, but not defined == Missing Reference: 'IMAP-URL' is mentioned on line 5432, but not defined == Missing Reference: 'UNSEEN 12' is mentioned on line 1656, but not defined == Missing Reference: 'UIDVALIDITY 3857529045' is mentioned on line 4475, 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 2474, but not defined == Missing Reference: 'UIDNEXT 2' is mentioned on line 2476, but not defined == Missing Reference: 'UIDVALIDITY 1' is mentioned on line 2545, but not defined == Missing Reference: 'TEXT' is mentioned on line 4428, but not defined == Missing Reference: 'RFC4314' is mentioned on line 5425, but not defined == Missing Reference: 'RFC2087' is mentioned on line 5429, but not defined ** Obsolete undefined reference: RFC 2087 (Obsoleted by RFC 9208) == Missing Reference: 'UNSEEN 17' is mentioned on line 4474, but not defined == Missing Reference: 'READ-WRITE' is mentioned on line 4476, but not defined == Missing Reference: 'RFC4422' is mentioned on line 4787, but not defined == Missing Reference: 'IMAP-TLS' is mentioned on line 5467, but not defined == Missing Reference: 'IMAP-MODEL' is mentioned on line 5413, but not defined == Missing Reference: 'ACAP' is mentioned on line 5418, but not defined == Missing Reference: 'RFC-821' is mentioned on line 5463, 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) May 29, 2018 5 Intended status: Standards Track 6 Expires: November 30, 2018 8 INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev2 9 draft-melnikov-imap4rev2-08.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 November 30, 2018. 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 . . . . . . . . . . . . . . . . . . . . 54 140 6.4. Client Commands - Selected State . . . . . . . . . . . . 56 141 6.4.1. CHECK Command . . . . . . . . . . . . . . . . . . . . 56 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 . . . . . . . . . . . . . . . . . . . . 67 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 . . . . . . . . . . . . . . . . . . . . . . . . 124 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 Example: C: A042 STATUS blurdybloop (UIDNEXT MESSAGES) 2364 S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) 2365 S: A042 OK STATUS completed 2367 6.3.13. APPEND Command 2369 Arguments: mailbox name 2370 OPTIONAL flag parenthesized list 2371 OPTIONAL date/time string 2372 message literal 2374 Responses: no specific responses for this command 2376 Result: OK - append completed 2377 NO - append error: can't append to that mailbox, error 2378 in flags or date/time or message text 2379 BAD - command unknown or arguments invalid 2381 The APPEND command appends the literal argument as a new message to 2382 the end of the specified destination mailbox. This argument SHOULD 2383 be in the format of an [RFC-5322] message. 8-bit characters are 2384 permitted in the message. A server implementation that is unable to 2385 preserve 8-bit data properly MUST be able to reversibly convert 8-bit 2386 APPEND data to 7-bit using a [MIME-IMB] content transfer encoding. 2388 Note: There may be exceptions, e.g., draft messages, in which 2389 required [RFC-5322] header lines are omitted in the message 2390 literal argument to APPEND. The full implications of doing so 2391 must be understood and carefully weighed. 2393 If a flag parenthesized list is specified, the flags SHOULD be set in 2394 the resulting message; otherwise, the flag list of the resulting 2395 message is set to empty by default. In either case, the Recent flag 2396 is also set. 2398 If a date-time is specified, the internal date SHOULD be set in the 2399 resulting message; otherwise, the internal date of the resulting 2400 message is set to the current date and time by default. 2402 If the append is unsuccessful for any reason, the mailbox MUST be 2403 restored to its state before the APPEND attempt; no partial appending 2404 is permitted. 2406 If the destination mailbox does not exist, a server MUST return an 2407 error, and MUST NOT automatically create the mailbox. Unless it is 2408 certain that the destination mailbox can not be created, the server 2409 MUST send the response code "[TRYCREATE]" as the prefix of the text 2410 of the tagged NO response. This gives a hint to the client that it 2411 can attempt a CREATE command and retry the APPEND if the CREATE is 2412 successful. 2414 On successful completion of an APPEND, the server SHOULD return an 2415 APPENDUID response code. 2417 In the case of a mailbox that has permissions set so that the client 2418 can APPEND to the mailbox, but not SELECT or EXAMINE it, the server 2419 SHOULD NOT send an APPENDUID response code as it would disclose 2420 information about the mailbox. 2422 In the case of a mailbox that has UIDNOTSTICKY status (see 2423 UIDNOTSTICKY response code definition), the server MAY omit the 2424 APPENDUID response code as it is not meaningful. 2426 If the server does not return the APPENDUID response codes, the 2427 client can discover this information by selecting the destination 2428 mailbox. The location of messages placed in the destination mailbox 2429 by APPEND can be determined by using FETCH and/or SEARCH commands 2430 (e.g., for Message-ID or some unique marker placed in the message in 2431 an APPEND). 2433 If the mailbox is currently selected, the normal new message actions 2434 SHOULD occur. Specifically, the server SHOULD notify the client 2435 immediately via an untagged EXISTS response. If the server does not 2436 do so, the client MAY issue a NOOP command (or failing that, a CHECK 2437 command) after one or more APPEND commands. 2439 Example: C: A003 APPEND saved-messages (\Seen) {310} 2440 S: + Ready for literal data 2441 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST) 2442 C: From: Fred Foobar 2443 C: Subject: afternoon meeting 2444 C: To: mooch@owatagu.siam.edu 2445 C: Message-Id: 2446 C: MIME-Version: 1.0 2447 C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 2448 C: 2449 C: Hello Joe, do you think we can meet at 3:30 tomorrow? 2450 C: 2451 S: A003 OK APPEND completed 2453 Example: C: A003 APPEND saved-messages (\Seen) {297} 2454 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST) 2455 C: From: Fred Foobar 2456 C: Subject: afternoon meeting 2457 C: To: mooch@example.com 2458 C: Message-Id: 2459 C: MIME-Version: 1.0 2460 C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 2461 C: 2462 C: Hello Joe, do you think we can meet at 3:30 tomorrow? 2463 C: 2464 S: A003 OK [APPENDUID 38505 3955] APPEND completed 2465 C: A004 COPY 2:4 meeting 2466 S: A004 OK [COPYUID 38505 304,319:320 3956:3958] Done 2467 C: A005 UID COPY 305:310 meeting 2468 S: A005 OK No matching messages, so nothing copied 2469 C: A006 COPY 2 funny 2470 S: A006 OK Done 2471 C: A007 SELECT funny 2472 S: * 1 EXISTS 2473 S: * 1 RECENT 2474 S: * OK [UNSEEN 1] Message 1 is first unseen 2475 S: * OK [UIDVALIDITY 3857529045] Validity session-only 2476 S: * OK [UIDNEXT 2] Predicted next UID 2477 S: * NO [UIDNOTSTICKY] Non-persistent UIDs 2478 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 2479 S: * OK [PERMANENTFLAGS (\Deleted \Seen)] Limited 2480 S: A007 OK [READ-WRITE] SELECT completed 2482 In this example, A003 and A004 demonstrate successful appending and 2483 copying to a mailbox that returns the UIDs assigned to the messages. 2484 A005 is an example in which no messages were copied; this is because 2485 in A003, we see that message 2 had UID 304, and message 3 had UID 2486 319; therefore, UIDs 305 through 310 do not exist (refer to 2487 Section 2.3.1.1 for further explanation). A006 is an example of a 2488 message being copied that did not return a COPYUID; and, as expected, 2489 A007 shows that the mail store containing that mailbox does not 2490 support persistent UIDs. 2492 Note: The APPEND command is not used for message delivery, because 2493 it does not provide a mechanism to transfer [SMTP] envelope 2494 information. 2496 6.3.14. IDLE Command 2498 Arguments: none 2499 Responses: continuation data will be requested; the client sends the 2500 continuation data "DONE" to end the command 2502 Result: OK - IDLE completed after client sent "DONE" 2503 NO - failure: the server will not allow the IDLE command 2504 at this time 2505 BAD - command unknown or arguments invalid 2507 Without the IDLE command a client requires to poll the server for 2508 changes to the selected mailbox (new mail, deletions, flag changes). 2509 It's often more desirable to have the server transmit updates to the 2510 client in real time. This allows a user to see new mail immediately. 2511 The IDLE command allows a client to tell the server that it's ready 2512 to accept such real-time updates. 2514 The IDLE command is sent from the client to the server when the 2515 client is ready to accept unsolicited mailbox update messages. The 2516 server requests a response to the IDLE command using the continuation 2517 ("+") response. The IDLE command remains active until the client 2518 responds to the continuation, and as long as an IDLE command is 2519 active, the server is now free to send untagged EXISTS, EXPUNGE, and 2520 other responses at any time. 2522 The IDLE command is terminated by the receipt of a "DONE" 2523 continuation from the client; such response satisfies the server's 2524 continuation request. At that point, the server MAY send any 2525 remaining queued untagged responses and then MUST immediately send 2526 the tagged response to the IDLE command and prepare to process other 2527 commands. As in the base specification, the processing of any new 2528 command may cause the sending of unsolicited untagged responses, 2529 subject to the ambiguity limitations. The client MUST NOT send a 2530 command while the server is waiting for the DONE, since the server 2531 will not be able to distinguish a command from a continuation. 2533 The server MAY consider a client inactive if it has an IDLE command 2534 running, and if such a server has an inactivity timeout it MAY log 2535 the client off implicitly at the end of its timeout period. Because 2536 of that, clients using IDLE are advised to terminate the IDLE and re- 2537 issue it at least every 29 minutes to avoid being logged off. This 2538 still allows a client to receive immediate mailbox updates even 2539 though it need only "poll" at half hour intervals. 2541 Example: C: A001 SELECT INBOX 2542 S: * FLAGS (Deleted Seen) 2543 S: * 3 EXISTS 2544 S: * 0 RECENT 2545 S: * OK [UIDVALIDITY 1] 2546 S: A001 OK SELECT completed 2547 C: A002 IDLE 2548 S: + idling 2549 ...time passes; new mail arrives... 2550 S: * 4 EXISTS 2551 C: DONE 2552 S: A002 OK IDLE terminated 2553 ...another client expunges message 2 now... 2554 C: A003 FETCH 4 ALL 2555 S: * 4 FETCH (...) 2556 S: A003 OK FETCH completed 2557 C: A004 IDLE 2558 S: * 2 EXPUNGE 2559 S: * 3 EXISTS 2560 S: + idling 2561 ...time passes; another client expunges message 3... 2562 S: * 3 EXPUNGE 2563 S: * 2 EXISTS 2564 ...time passes; new mail arrives... 2565 S: * 3 EXISTS 2566 C: DONE 2567 S: A004 OK IDLE terminated 2568 C: A005 FETCH 3 ALL 2569 S: * 3 FETCH (...) 2570 S: A005 OK FETCH completed 2571 C: A006 IDLE 2573 6.4. Client Commands - Selected State 2575 In the selected state, commands that manipulate messages in a mailbox 2576 are permitted. 2578 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 2579 and the authenticated state commands (SELECT, EXAMINE, NAMESPACE, 2580 CREATE, DELETE, RENAME, SUBSCRIBE, UNSUBSCRIBE, LIST, LSUB , STATUS, 2581 and APPEND), the following commands are valid in the selected state: 2582 CHECK, CLOSE, UNSELECT, EXPUNGE, SEARCH, FETCH, STORE, COPY, and UID. 2584 6.4.1. CHECK Command 2586 Arguments: none 2588 Responses: no specific responses for this command 2589 Result: OK - check completed 2590 BAD - command unknown or arguments invalid 2592 The CHECK command requests a checkpoint of the currently selected 2593 mailbox. A checkpoint refers to any implementation-dependent 2594 housekeeping associated with the mailbox (e.g., resolving the 2595 server's in-memory state of the mailbox with the state on its disk) 2596 that is not normally executed as part of each command. A checkpoint 2597 MAY take a non-instantaneous amount of real time to complete. If a 2598 server implementation has no such housekeeping considerations, CHECK 2599 is equivalent to NOOP. 2601 There is no guarantee that an EXISTS untagged response will happen as 2602 a result of CHECK. NOOP, not CHECK, SHOULD be used for new message 2603 polling. 2605 Example: C: FXXZ CHECK 2606 S: FXXZ OK CHECK Completed 2608 6.4.2. CLOSE Command 2610 Arguments: none 2612 Responses: no specific responses for this command 2614 Result: OK - close completed, now in authenticated state 2615 BAD - command unknown or arguments invalid 2617 The CLOSE command permanently removes all messages that have the 2618 \Deleted flag set from the currently selected mailbox, and returns to 2619 the authenticated state from the selected state. No untagged EXPUNGE 2620 responses are sent. 2622 No messages are removed, and no error is given, if the mailbox is 2623 selected by an EXAMINE command or is otherwise selected read-only. 2625 Even if a mailbox is selected, a SELECT, EXAMINE, or LOGOUT command 2626 MAY be issued without previously issuing a CLOSE command. The 2627 SELECT, EXAMINE, and LOGOUT commands implicitly close the currently 2628 selected mailbox without doing an expunge. However, when many 2629 messages are deleted, a CLOSE-LOGOUT or CLOSE-SELECT sequence is 2630 considerably faster than an EXPUNGE-LOGOUT or EXPUNGE-SELECT because 2631 no untagged EXPUNGE responses (which the client would probably 2632 ignore) are sent. 2634 Example: C: A341 CLOSE 2635 S: A341 OK CLOSE completed 2637 6.4.3. UNSELECT Command 2639 Arguments: none 2641 Responses: no specific responses for this command 2643 Result: OK - unselect completed, now in authenticated state 2644 BAD - no mailbox selected, or argument supplied but none 2645 permitted 2647 The UNSELECT command frees server's resources associated with the 2648 selected mailbox and returns the server to the authenticated state. 2649 This command performs the same actions as CLOSE, except that no 2650 messages are permanently removed from the currently selected mailbox. 2652 Example: C: A342 UNSELECT 2653 S: A342 OK Unselect completed 2655 6.4.4. EXPUNGE Command 2657 Arguments: none 2659 Responses: untagged responses: EXPUNGE 2661 Result: OK - expunge completed 2662 NO - expunge failure: can't expunge (e.g., permission 2663 denied) 2664 BAD - command unknown or arguments invalid 2666 The EXPUNGE command permanently removes all messages that have the 2667 \Deleted flag set from the currently selected mailbox. Before 2668 returning an OK to the client, an untagged EXPUNGE response is sent 2669 for each message that is removed. Note that if any messages with the 2670 \Recent flag set are expunged, an untagged RECENT response is sent 2671 after the untagged EXPUNGE(s) to update the client's count of RECENT 2672 messages. 2674 Example: C: A202 EXPUNGE 2675 S: * 3 EXPUNGE 2676 S: * 3 EXPUNGE 2677 S: * 5 EXPUNGE 2678 S: * 8 EXPUNGE 2679 S: A202 OK EXPUNGE completed 2681 Note: In this example, messages 3, 4, 7, and 11 had the \Deleted flag 2682 set. See the description of the EXPUNGE response for further 2683 explanation. 2685 6.4.5. SEARCH Command 2687 Arguments: OPTIONAL result specifier 2688 OPTIONAL [CHARSET] specification 2689 searching criteria (one or more) 2691 Responses: REQUIRED untagged response: ESEARCH 2693 Result: OK - search completed 2694 NO - search error: can't search that [CHARSET] or 2695 criteria 2696 BAD - command unknown or arguments invalid 2698 The SEARCH command searches the mailbox for messages that match the 2699 given searching criteria. 2701 The SEARCH command may contain result options. Result options 2702 control what kind of information is returned about messages matching 2703 the search criteria in an untagged ESEARCH response. If no result 2704 option is specified or empty list of options is specified "()", ALL 2705 is assumed (see below). The order of individual options is 2706 arbitrary. Individual options may contain parameters enclosed in 2707 parentheses (*). If an option has parameters, they consist of atoms 2708 and/or strings and/or lists in a specific order. Any options not 2709 defined by extensions that the server supports must be rejected with 2710 a BAD response. 2712 (*) - if an option has a mandatory parameter, which can always be 2713 represented as a number or a sequence-set, the option parameter does 2714 not need the enclosing (). See ABNF for more details. 2716 This document specifies the following result options: 2718 MIN 2720 Return the lowest message number/UID that satisfies the SEARCH 2721 criteria. 2723 If the SEARCH results in no matches, the server MUST NOT 2724 include the MIN result option in the ESEARCH response; however, 2725 it still MUST send the ESEARCH response. 2727 MAX 2729 Return the highest message number/UID that satisfies the SEARCH 2730 criteria. 2732 If the SEARCH results in no matches, the server MUST NOT 2733 include the MAX result option in the ESEARCH response; however, 2734 it still MUST send the ESEARCH response. 2736 ALL 2738 Return all message numbers/UIDs that satisfy the SEARCH 2739 criteria using the sequence-set syntax. Note, the client MUST 2740 NOT assume that messages/UIDs will be listed in any particular 2741 order. 2743 If the SEARCH results in no matches, the server MUST NOT 2744 include the ALL result option in the ESEARCH response; however, 2745 it still MUST send the ESEARCH response. 2747 COUNT Return number of the messages that satisfy the SEARCH 2748 criteria. This result option MUST always be included in the 2749 ESEARCH response. 2751 Note: future extensions to this document can allow servers to return 2752 multiple ESEARCH responses for a single extended SEARCH command. 2753 However all options specified above MUST result in a single ESEARCH 2754 response. These extensions will have to describe how results from 2755 multiple ESEARCH responses are to be amalgamated. 2757 Searching criteria consist of one or more search keys. 2759 When multiple keys are specified, the result is the intersection (AND 2760 function) of all the messages that match those keys. For example, 2761 the criteria DELETED FROM "SMITH" SINCE 1-Feb-1994 refers to all 2762 deleted messages from Smith that were placed in the mailbox since 2763 February 1, 1994. A search key can also be a parenthesized list of 2764 one or more search keys (e.g., for use with the OR and NOT keys). 2766 Server implementations MAY exclude [MIME-IMB] body parts with 2767 terminal content media types other than TEXT and MESSAGE from 2768 consideration in SEARCH matching. 2770 The OPTIONAL [CHARSET] specification consists of the word "CHARSET" 2771 followed by a registered [CHARSET]. It indicates the [CHARSET] of 2772 the strings that appear in the search criteria. [MIME-IMB] content 2773 transfer encodings, and [MIME-HDRS] strings in [RFC-5322]/[MIME-IMB] 2774 headers, MUST be decoded before comparing text. US-ASCII MUST be 2775 supported; other [CHARSET]s MAY be supported. 2777 If the server does not support the specified [CHARSET], it MUST 2778 return a tagged NO response (not a BAD). This response SHOULD 2779 contain the BADCHARSET response code, which MAY list the [CHARSET]s 2780 supported by the server. 2782 In all search keys that use strings, a message matches the key if the 2783 string is a substring of the associated text. The matching is case- 2784 insensitive. Note that the empty string is a substring; this is 2785 useful when doing a HEADER search. 2787 The defined search keys are as follows. Refer to the Formal Syntax 2788 section for the precise syntactic definitions of the arguments. 2790 Messages with message sequence numbers corresponding 2791 to the specified message sequence number set. 2793 ALL All messages in the mailbox; the default initial key for ANDing. 2795 ANSWERED Messages with the \Answered flag set. 2797 BCC Messages that contain the specified string in the 2798 envelope structure's BCC field. 2800 BEFORE Messages whose internal date (disregarding time and 2801 timezone) is earlier than the specified date. 2803 BODY Messages that contain the specified string in the body 2804 of the message. 2806 CC Messages that contain the specified string in the 2807 envelope structure's CC field. 2809 DELETED Messages with the \Deleted flag set. 2811 DRAFT Messages with the \Draft flag set. 2813 FLAGGED Messages with the \Flagged flag set. 2815 FROM Messages that contain the specified string in the 2816 envelope structure's FROM field. 2818 HEADER Messages that have a header with the 2819 specified field-name (as defined in [RFC-5322]) and that contains 2820 the specified string in the text of the header (what comes after 2821 the colon). If the string to search is zero-length, this matches 2822 all messages that have a header line with the specified field-name 2823 regardless of the contents. 2825 KEYWORD Messages with the specified keyword flag set. 2827 LARGER Messages with an [RFC-5322] size larger than the 2828 specified number of octets. 2830 NEW Messages that have the \Recent flag set but not the \Seen flag. 2831 This is functionally equivalent to "(RECENT UNSEEN)". 2833 NOT Messages that do not match the specified search 2834 key. 2836 OLD Messages that do not have the \Recent flag set. This is 2837 functionally equivalent to "NOT RECENT" (as opposed to "NOT NEW"). 2839 ON Messages whose internal date (disregarding time and 2840 timezone) is within the specified date. 2842 OR Messages that match either search 2843 key. 2845 RECENT Messages that have the \Recent flag set. 2847 SEEN Messages that have the \Seen flag set. 2849 SENTBEFORE Messages whose [RFC-5322] Date: header 2850 (disregarding time and timezone) is earlier than the specified 2851 date. 2853 SENTON Messages whose [RFC-5322] Date: header (disregarding 2854 time and timezone) is within the specified date. 2856 SENTSINCE Messages whose [RFC-5322] Date: header 2857 (disregarding time and timezone) is within or later than the 2858 specified date. 2860 SINCE Messages whose internal date (disregarding time and 2861 timezone) is within or later than the specified date. 2863 SMALLER Messages with an [RFC-5322] size smaller than the 2864 specified number of octets. 2866 SUBJECT Messages that contain the specified string in the 2867 envelope structure's SUBJECT field. 2869 TEXT Messages that contain the specified string in the 2870 header or body of the message. 2872 TO Messages that contain the specified string in the 2873 envelope structure's TO field. 2875 UID Messages with unique identifiers corresponding to 2876 the specified unique identifier set. Sequence set ranges are 2877 permitted. 2879 UNANSWERED Messages that do not have the \Answered flag set. 2881 UNDELETED Messages that do not have the \Deleted flag set. 2883 UNDRAFT Messages that do not have the \Draft flag set. 2885 UNFLAGGED Messages that do not have the \Flagged flag set. 2887 UNKEYWORD Messages that do not have the specified keyword 2888 flag set. 2890 UNSEEN Messages that do not have the \Seen flag set. 2892 Example: C: A282 SEARCH RETURN (MIN COUNT) FLAGGED 2893 SINCE 1-Feb-1994 NOT FROM "Smith" 2894 S: * ESEARCH (TAG "A282") MIN 2 COUNT 3 2895 S: A282 OK SEARCH completed 2897 Example: C: A283 SEARCH RETURN () FLAGGED 2898 SINCE 1-Feb-1994 NOT FROM "Smith" 2899 S: * ESEARCH (TAG "A283") ALL 2,10:11 2900 S: A283 OK SEARCH completed 2902 Example: C: A284 SEARCH TEXT "string not in mailbox" 2903 S: * ESEARCH (TAG "A284") 2904 S: A284 OK SEARCH completed 2905 C: A285 SEARCH CHARSET UTF-8 TEXT {6} 2906 S: + Ready for literal text 2907 C: XXXXXX 2908 S: * ESEARCH (TAG "A285") ALL 43 2909 S: A285 OK SEARCH completed 2911 Note: Since this document is restricted to 7-bit ASCII text, it is 2912 not possible to show actual UTF-8 data. The "XXXXXX" is a 2913 placeholder for what would be 6 octets of 8-bit data in an actual 2914 transaction. 2916 The following example demonstrates finding the first unseen message 2917 as returned in the UNSEEN response code on a successful SELECT 2918 command: 2920 Example: C: A284 SEARCH RETURN (MIN) UNSEEN 2921 S: * ESEARCH (TAG "A284") MIN 4 2922 S: A284 OK SEARCH completed 2924 The following example demonstrates that if the ESEARCH UID indicator 2925 is present, all data in the ESEARCH response is referring to UIDs; 2926 for example, the MIN result specifier will be followed by a UID. 2928 Example: C: A285 UID SEARCH RETURN (MIN MAX) 1:5000 2929 S: * ESEARCH (TAG "A285") UID MIN 7 MAX 3800 2930 S: A285 OK SEARCH completed 2932 The following example demonstrates returning the number of deleted 2933 messages: 2935 Example: C: A286 SEARCH RETURN (COUNT) DELETED 2936 S: * ESEARCH (TAG "A286") COUNT 15 2937 S: A286 OK SEARCH completed 2939 6.4.6. FETCH Command 2941 Arguments: sequence set 2942 message data item names or macro 2944 Responses: untagged responses: FETCH 2946 Result: OK - fetch completed 2947 NO - fetch error: can't fetch that data 2948 BAD - command unknown or arguments invalid 2950 The FETCH command retrieves data associated with a message in the 2951 mailbox. The data items to be fetched can be either a single atom or 2952 a parenthesized list. 2954 Most data items, identified in the formal syntax under the msg-att- 2955 static rule, are static and MUST NOT change for any particular 2956 message. Other data items, identified in the formal syntax under the 2957 msg-att-dynamic rule, MAY change, either as a result of a STORE 2958 command or due to external events. 2960 For example, if a client receives an ENVELOPE for a message when 2961 it already knows the envelope, it can safely ignore the newly 2962 transmitted envelope. 2964 There are three macros which specify commonly-used sets of data 2965 items, and can be used instead of data items. A macro must be used 2966 by itself, and not in conjunction with other macros or data items. 2968 ALL Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE) 2970 FAST Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE) 2971 FULL Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE 2972 BODY) 2974 The currently defined data items that can be fetched are: 2976 BODY Non-extensible form of BODYSTRUCTURE. 2978 BODY[
]<> 2980 The text of a particular body section. The section 2981 specification is a set of zero or more part specifiers 2982 delimited by periods. A part specifier is either a part number 2983 or one of the following: HEADER, HEADER.FIELDS, 2984 HEADER.FIELDS.NOT, MIME, and TEXT. An empty section 2985 specification refers to the entire message, including the 2986 header. 2988 Every message has at least one part number. Non-[MIME-IMB] 2989 messages, and non-multipart [MIME-IMB] messages with no 2990 encapsulated message, only have a part 1. 2992 Multipart messages are assigned consecutive part numbers, as 2993 they occur in the message. If a particular part is of type 2994 message or multipart, its parts MUST be indicated by a period 2995 followed by the part number within that nested multipart part. 2997 A part of type MESSAGE/RFC822 also has nested part numbers, 2998 referring to parts of the MESSAGE part's body. 3000 The HEADER, HEADER.FIELDS, HEADER.FIELDS.NOT, and TEXT part 3001 specifiers can be the sole part specifier or can be prefixed by 3002 one or more numeric part specifiers, provided that the numeric 3003 part specifier refers to a part of type MESSAGE/RFC822. The 3004 MIME part specifier MUST be prefixed by one or more numeric 3005 part specifiers. 3007 The HEADER, HEADER.FIELDS, and HEADER.FIELDS.NOT part 3008 specifiers refer to the [RFC-5322] header of the message or of 3009 an encapsulated [MIME-IMT] MESSAGE/RFC822 message. 3010 HEADER.FIELDS and HEADER.FIELDS.NOT are followed by a list of 3011 field-name (as defined in [RFC-5322]) names, and return a 3012 subset of the header. The subset returned by HEADER.FIELDS 3013 contains only those header fields with a field-name that 3014 matches one of the names in the list; similarly, the subset 3015 returned by HEADER.FIELDS.NOT contains only the header fields 3016 with a non-matching field-name. The field-matching is case- 3017 insensitive but otherwise exact. Subsetting does not exclude 3018 the [RFC-5322] delimiting blank line between the header and the 3019 body; the blank line is included in all header fetches, except 3020 in the case of a message which has no body and no blank line. 3022 The MIME part specifier refers to the [MIME-IMB] header for 3023 this part. 3025 The TEXT part specifier refers to the text body of the message, 3026 omitting the [RFC-5322] header. 3028 Here is an example of a complex message with some of its 3029 part specifiers: 3031 HEADER ([RFC-5322] header of the message) 3032 TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 3033 1 TEXT/PLAIN 3034 2 APPLICATION/OCTET-STREAM 3035 3 MESSAGE/RFC822 3036 3.HEADER ([RFC-5322] header of the message) 3037 3.TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 3038 3.1 TEXT/PLAIN 3039 3.2 APPLICATION/OCTET-STREAM 3040 4 MULTIPART/MIXED 3041 4.1 IMAGE/GIF 3042 4.1.MIME ([MIME-IMB] header for the IMAGE/GIF) 3043 4.2 MESSAGE/RFC822 3044 4.2.HEADER ([RFC-5322] header of the message) 3045 4.2.TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 3046 4.2.1 TEXT/PLAIN 3047 4.2.2 MULTIPART/ALTERNATIVE 3048 4.2.2.1 TEXT/PLAIN 3049 4.2.2.2 TEXT/RICHTEXT 3051 It is possible to fetch a substring of the designated text. 3052 This is done by appending an open angle bracket ("<"), the 3053 octet position of the first desired octet, a period, the 3054 maximum number of octets desired, and a close angle bracket 3055 (">") to the part specifier. If the starting octet is beyond 3056 the end of the text, an empty string is returned. 3058 Any partial fetch that attempts to read beyond the end of the 3059 text is truncated as appropriate. A partial fetch that starts 3060 at octet 0 is returned as a partial fetch, even if this 3061 truncation happened. 3063 Note: This means that BODY[]<0.2048> of a 1500-octet message 3064 will return BODY[]<0> with a literal of size 1500, not 3065 BODY[]. 3067 Note: A substring fetch of a HEADER.FIELDS or 3068 HEADER.FIELDS.NOT part specifier is calculated after 3069 subsetting the header. 3071 The \Seen flag is implicitly set; if this causes the flags to 3072 change, they SHOULD be included as part of the FETCH responses. 3074 BODY.PEEK[
]<> An alternate form of BODY[
] 3075 that does not implicitly set the \Seen flag. 3077 BODYSTRUCTURE The [MIME-IMB] body structure of the message. This is 3078 computed by the server by parsing the [MIME-IMB] header fields in 3079 the [RFC-5322] header and [MIME-IMB] headers. 3081 ENVELOPE The envelope structure of the message. This is computed by 3082 the server by parsing the [RFC-5322] header into the component 3083 parts, defaulting various fields as necessary. 3085 FLAGS The flags that are set for this message. 3087 INTERNALDATE The internal date of the message. 3089 RFC822 Functionally equivalent to BODY[], differing in the syntax of 3090 the resulting untagged FETCH data (RFC822 is returned). 3092 RFC822.HEADER Functionally equivalent to BODY.PEEK[HEADER], 3093 differing in the syntax of the resulting untagged FETCH data 3094 (RFC822.HEADER is returned). 3096 RFC822.SIZE The [RFC-5322] size of the message. 3098 RFC822.TEXT Functionally equivalent to BODY[TEXT], differing in the 3099 syntax of the resulting untagged FETCH data (RFC822.TEXT is 3100 returned). 3102 UID The unique identifier for the message. 3104 Example: C: A654 FETCH 2:4 (FLAGS BODY[HEADER.FIELDS (DATE FROM)]) 3105 S: * 2 FETCH .... 3106 S: * 3 FETCH .... 3107 S: * 4 FETCH .... 3108 S: A654 OK FETCH completed 3110 6.4.7. STORE Command 3112 Arguments: sequence set 3113 message data item name 3114 value for message data item 3116 Responses: untagged responses: FETCH 3118 Result: OK - store completed 3119 NO - store error: can't store that data 3120 BAD - command unknown or arguments invalid 3122 The STORE command alters data associated with a message in the 3123 mailbox. Normally, STORE will return the updated value of the data 3124 with an untagged FETCH response. A suffix of ".SILENT" in the data 3125 item name prevents the untagged FETCH, and the server SHOULD assume 3126 that the client has determined the updated value itself or does not 3127 care about the updated value. 3129 Note: Regardless of whether or not the ".SILENT" suffix was used, 3130 the server SHOULD send an untagged FETCH response if a change to a 3131 message's flags from an external source is observed. The intent 3132 is that the status of the flags is determinate without a race 3133 condition. 3135 The currently defined data items that can be stored are: 3137 FLAGS Replace the flags for the message (other than 3138 \Recent) with the argument. The new value of the flags is 3139 returned as if a FETCH of those flags was done. 3141 FLAGS.SILENT Equivalent to FLAGS, but without returning 3142 a new value. 3144 +FLAGS Add the argument to the flags for the message. 3145 The new value of the flags is returned as if a FETCH of those 3146 flags was done. 3148 +FLAGS.SILENT Equivalent to +FLAGS, but without 3149 returning a new value. 3151 -FLAGS Remove the argument from the flags for the 3152 message. The new value of the flags is returned as if a FETCH of 3153 those flags was done. 3155 -FLAGS.SILENT Equivalent to -FLAGS, but without 3156 returning a new value. 3158 Example: C: A003 STORE 2:4 +FLAGS (\Deleted) 3159 S: * 2 FETCH (FLAGS (\Deleted \Seen)) 3160 S: * 3 FETCH (FLAGS (\Deleted)) 3161 S: * 4 FETCH (FLAGS (\Deleted \Flagged \Seen)) 3162 S: A003 OK STORE completed 3164 6.4.8. COPY Command 3166 Arguments: sequence set 3167 mailbox name 3169 Responses: no specific responses for this command 3171 Result: OK - copy completed 3172 NO - copy error: can't copy those messages or to that 3173 name 3174 BAD - command unknown or arguments invalid 3176 The COPY command copies the specified message(s) to the end of the 3177 specified destination mailbox. The flags and internal date of the 3178 message(s) SHOULD be preserved, and the Recent flag SHOULD be set, in 3179 the copy. 3181 If the destination mailbox does not exist, a server SHOULD return an 3182 error. It SHOULD NOT automatically create the mailbox. Unless it is 3183 certain that the destination mailbox can not be created, the server 3184 MUST send the response code "[TRYCREATE]" as the prefix of the text 3185 of the tagged NO response. This gives a hint to the client that it 3186 can attempt a CREATE command and retry the COPY if the CREATE is 3187 successful. 3189 If the COPY command is unsuccessful for any reason, server 3190 implementations MUST restore the destination mailbox to its state 3191 before the COPY attempt. 3193 On successful completion of a COPY, the server SHOULD return a 3194 COPYUID response code. 3196 In the case of a mailbox that has permissions set so that the client 3197 can COPY to the mailbox, but not SELECT or EXAMINE it, the server 3198 SHOULD NOT send an COPYUID response code as it would disclose 3199 information about the mailbox. 3201 In the case of a mailbox that has UIDNOTSTICKY status (see the 3202 UIDNOTSTICKY response code), the server MAY omit the COPYUID response 3203 code as it is not meaningful. 3205 If the server does not return the COPYUID response code, the client 3206 can discover this information by selecting the destination mailbox. 3207 The location of messages placed in the destination mailbox by COPY 3208 can be determined by using FETCH and/or SEARCH commands (e.g., for 3209 Message-ID). 3211 Example: C: A003 COPY 2:4 MEETING 3212 S: A003 OK COPY completed 3214 6.4.9. UID Command 3216 Arguments: command name 3217 command arguments 3219 Responses: untagged responses: FETCH, SEARCH 3221 Result: OK - UID command completed 3222 NO - UID command error 3223 BAD - command unknown or arguments invalid 3225 The UID command has three forms. In the first form, it takes as its 3226 arguments a COPY, FETCH, or STORE command with arguments appropriate 3227 for the associated command. However, the numbers in the sequence set 3228 argument are unique identifiers instead of message sequence numbers. 3229 Sequence set ranges are permitted, but there is no guarantee that 3230 unique identifiers will be contiguous. 3232 A non-existent unique identifier is ignored without any error message 3233 generated. Thus, it is possible for a UID FETCH command to return an 3234 OK without any data or a UID COPY or UID STORE to return an OK 3235 without performing any operations. 3237 In the second form, the UID command takes an EXPUNGE command with an 3238 extra parameter the specified a sequence set of UIDs to operate on. 3239 The UID EXPUNGE command permanently removes all messages that both 3240 have the \Deleted flag set and have a UID that is included in the 3241 specified sequence set from the currently selected mailbox. If a 3242 message either does not have the \Deleted flag set or has a UID that 3243 is not included in the specified sequence set, it is not affected. 3245 UID EXPUNGE is particularly useful for disconnected use clients. 3246 By using UID EXPUNGE instead of EXPUNGE when resynchronizing with 3247 the server, the client can ensure that it does not inadvertantly 3248 remove any messages that have been marked as \Deleted by other 3249 clients between the time that the client was last connected and 3250 the time the client resynchronizes. 3252 Example: C: A003 UID EXPUNGE 3000:3002 3253 S: * 3 EXPUNGE 3254 S: * 3 EXPUNGE 3255 S: * 3 EXPUNGE 3256 S: A003 OK UID EXPUNGE completed 3258 In the third form, the UID command takes a SEARCH command with SEARCH 3259 command arguments. The interpretation of the arguments is the same 3260 as with SEARCH; however, the numbers returned in a ESEARCH response 3261 for a UID SEARCH command are unique identifiers instead of message 3262 sequence numbers. Also, the corresponding ESEARCH response MUST 3263 include the UID indicator. For example, the command UID SEARCH 1:100 3264 UID 443:557 returns the unique identifiers corresponding to the 3265 intersection of two sequence sets, the message sequence number range 3266 1:100 and the UID range 443:557. 3268 Note: in the above example, the UID range 443:557 appears. The 3269 same comment about a non-existent unique identifier being ignored 3270 without any error message also applies here. Hence, even if 3271 neither UID 443 or 557 exist, this range is valid and would 3272 include an existing UID 495. 3274 Also note that a UID range of 559:* always includes the UID of the 3275 last message in the mailbox, even if 559 is higher than any 3276 assigned UID value. This is because the contents of a range are 3277 independent of the order of the range endpoints. Thus, any UID 3278 range with * as one of the endpoints indicates at least one 3279 message (the message with the highest numbered UID), unless the 3280 mailbox is empty. 3282 The number after the "*" in an untagged FETCH or EXPUNGE response is 3283 always a message sequence number, not a unique identifier, even for a 3284 UID command response. However, server implementations MUST 3285 implicitly include the UID message data item as part of any FETCH 3286 response caused by a UID command, regardless of whether a UID was 3287 specified as a message data item to the FETCH. 3289 Note: The rule about including the UID message data item as part of a 3290 FETCH response primarily applies to the UID FETCH and UID STORE 3291 commands, including a UID FETCH command that does not include UID as 3292 a message data item. Although it is unlikely that the other UID 3293 commands will cause an untagged FETCH, this rule applies to these 3294 commands as well. 3296 Example: C: A999 UID FETCH 4827313:4828442 FLAGS 3297 S: * 23 FETCH (FLAGS (\Seen) UID 4827313) 3298 S: * 24 FETCH (FLAGS (\Seen) UID 4827943) 3299 S: * 25 FETCH (FLAGS (\Seen) UID 4828442) 3300 S: A999 OK UID FETCH completed 3302 6.5. Client Commands - Experimental/Expansion 3304 6.5.1. X Command 3306 Arguments: implementation defined 3308 Responses: implementation defined 3310 Result: OK - command completed 3311 NO - failure 3312 BAD - command unknown or arguments invalid 3314 Any command prefixed with an X is an experimental command. Commands 3315 which are not part of this specification, a standard or standards- 3316 track revision of this specification, or an IESG-approved 3317 experimental protocol, MUST use the X prefix. 3319 Any added untagged responses issued by an experimental command MUST 3320 also be prefixed with an X. Server implementations MUST NOT send any 3321 such untagged responses, unless the client requested it by issuing 3322 the associated experimental command. 3324 Example: C: a441 CAPABILITY 3325 S: * CAPABILITY IMAP4rev2 XPIG-LATIN 3326 S: a441 OK CAPABILITY completed 3327 C: A442 XPIG-LATIN 3328 S: * XPIG-LATIN ow-nay eaking-spay ig-pay atin-lay 3329 S: A442 OK XPIG-LATIN ompleted-cay 3331 7. Server Responses 3333 Server responses are in three forms: status responses, server data, 3334 and command continuation request. The information contained in a 3335 server response, identified by "Contents:" in the response 3336 descriptions below, is described by function, not by syntax. The 3337 precise syntax of server responses is described in the Formal Syntax 3338 section. 3340 The client MUST be prepared to accept any response at all times. 3342 Status responses can be tagged or untagged. Tagged status responses 3343 indicate the completion result (OK, NO, or BAD status) of a client 3344 command, and have a tag matching the command. 3346 Some status responses, and all server data, are untagged. An 3347 untagged response is indicated by the token "*" instead of a tag. 3348 Untagged status responses indicate server greeting, or server status 3349 that does not indicate the completion of a command (for example, an 3350 impending system shutdown alert). For historical reasons, untagged 3351 server data responses are also called "unsolicited data", although 3352 strictly speaking, only unilateral server data is truly 3353 "unsolicited". 3355 Certain server data MUST be recorded by the client when it is 3356 received; this is noted in the description of that data. Such data 3357 conveys critical information which affects the interpretation of all 3358 subsequent commands and responses (e.g., updates reflecting the 3359 creation or destruction of messages). 3361 Other server data SHOULD be recorded for later reference; if the 3362 client does not need to record the data, or if recording the data has 3363 no obvious purpose (e.g., a SEARCH response when no SEARCH command is 3364 in progress), the data SHOULD be ignored. 3366 An example of unilateral untagged server data occurs when the IMAP 3367 connection is in the selected state. In the selected state, the 3368 server checks the mailbox for new messages as part of command 3369 execution. Normally, this is part of the execution of every command; 3370 hence, a NOOP command suffices to check for new messages. If new 3371 messages are found, the server sends untagged EXISTS and RECENT 3372 responses reflecting the new size of the mailbox. Server 3373 implementations that offer multiple simultaneous access to the same 3374 mailbox SHOULD also send appropriate unilateral untagged FETCH and 3375 EXPUNGE responses if another agent changes the state of any message 3376 flags or expunges any messages. 3378 Command continuation request responses use the token "+" instead of a 3379 tag. These responses are sent by the server to indicate acceptance 3380 of an incomplete client command and readiness for the remainder of 3381 the command. 3383 7.1. Server Responses - Status Responses 3385 Status responses are OK, NO, BAD, PREAUTH and BYE. OK, NO, and BAD 3386 can be tagged or untagged. PREAUTH and BYE are always untagged. 3388 Status responses MAY include an OPTIONAL "response code". A response 3389 code consists of data inside square brackets in the form of an atom, 3390 possibly followed by a space and arguments. The response code 3391 contains additional information or status codes for client software 3392 beyond the OK/NO/BAD condition, and are defined when there is a 3393 specific action that a client can take based upon the additional 3394 information. 3396 The currently defined response codes are: 3398 ALERT The human-readable text contains a special alert that MUST be 3399 presented to the user in a fashion that calls the user's attention 3400 to the message. 3402 ALREADYEXISTS 3404 The operation attempts to create something that already exists, 3405 such as when the CREATE or RENAME directories attempt to create 3406 a mailbox and there is already one of that name. 3408 C: o RENAME this that 3409 S: o NO [ALREADYEXISTS] Mailbox "that" already exists 3411 APPENDUID 3413 Followed by the UIDVALIDITY of the destination mailbox and the 3414 UID assigned to the appended message in the destination 3415 mailbox, indicates that the message has been appended to the 3416 destination mailbox with that UID. 3418 If the server also supports the [MULTIAPPEND] extension, and if 3419 multiple messages were appended in the APPEND command, then the 3420 second value is a UID set containing the UIDs assigned to the 3421 appended messages, in the order they were transmitted in the 3422 APPEND command. This UID set may not contain extraneous UIDs 3423 or the symbol "*". 3425 Note: the UID set form of the APPENDUID response code MUST 3426 NOT be used if only a single message was appended. In 3427 particular, a server MUST NOT send a range such as 123:123. 3428 This is because a client that does not support [MULTIAPPEND] 3429 expects only a single UID and not a UID set. 3431 UIDs are assigned in strictly ascending order in the mailbox 3432 (refer to Section 2.3.1.1); note that a range of 12:10 is 3433 exactly equivalent to 10:12 and refers to the sequence 3434 10,11,12. 3436 This response code is returned in a tagged OK response to the 3437 APPEND command. 3439 AUTHENTICATIONFAILED 3441 Authentication failed for some reason on which the server is 3442 unwilling to elaborate. Typically, this includes "unknown 3443 user" and "bad password". 3445 This is the same as not sending any response code, except that 3446 when a client sees AUTHENTICATIONFAILED, it knows that the 3447 problem wasn't, e.g., UNAVAILABLE, so there's no point in 3448 trying the same login/password again later. 3450 C: b LOGIN "fred" "foo" 3451 S: b NO [AUTHENTICATIONFAILED] Authentication failed 3453 AUTHORIZATIONFAILED Authentication succeeded in using the 3454 authentication identity, but the server cannot or will not allow 3455 the authentication identity to act as the requested authorization 3456 identity. This is only applicable when the authentication and 3457 authorization identities are different. C: c1 AUTHENTICATE PLAIN 3458 [...] 3459 S: c1 NO [AUTHORIZATIONFAILED] No such authorization-ID 3460 C: c2 AUTHENTICATE PLAIN 3461 [...] 3462 S: c2 NO [AUTHORIZATIONFAILED] Authenticator is not an admin 3464 BADCHARSET Optionally followed by a parenthesized list of charsets. 3465 A SEARCH failed because the given charset is not supported by this 3466 implementation. If the optional list of charsets is given, this 3467 lists the charsets that are supported by this implementation. 3469 CANNOT 3471 The operation violates some invariant of the server and can 3472 never succeed. 3474 C: l create "///////" 3475 S: l NO [CANNOT] Adjacent slashes are not supported 3477 CAPABILITY Followed by a list of capabilities. This can appear in 3478 the initial OK or PREAUTH response to transmit an initial 3479 capabilities list. This makes it unnecessary for a client to send 3480 a separate CAPABILITY command if it recognizes this response. 3482 CLIENTBUG 3484 The server has detected a client bug. This can accompany all 3485 of OK, NO, and BAD, depending on what the client bug is. 3487 C: k1 select "/archive/projects/experiment-iv" 3488 [...] 3489 S: k1 OK [READ-ONLY] Done 3490 C: k2 status "/archive/projects/experiment-iv" (messages) 3491 [...] 3492 S: k2 OK [CLIENTBUG] Done 3494 CLOSED 3496 The CLOSED response code has no parameters. A server return 3497 the CLOSED response code when the currently selected mailbox is 3498 closed implicitly using the SELECT/EXAMINE command on another 3499 mailbox. The CLOSED response code serves as a boundary between 3500 responses for the previously opened mailbox (which was closed) 3501 and the newly selected mailbox; all responses before the CLOSED 3502 response code relate to the mailbox that was closed, and all 3503 subsequent responses relate to the newly opened mailbox. 3505 There is no need to return the CLOSED response code on 3506 completion of the CLOSE or the UNSELECT command (or similar), 3507 whose purpose is to close the currently selected mailbox 3508 without opening a new one. 3510 The server can also return an unsolicited CLOSED response code 3511 when it wants to force the client to return to authenticated 3512 state. For example, the server can do that when the mailbox 3513 requires repairs or is deleted in another session. 3515 CONTACTADMIN 3517 The user should contact the system administrator or support 3518 desk. 3520 C: e login "fred" "foo" 3521 S: e OK [CONTACTADMIN] 3523 COPYUID 3525 Followed by the UIDVALIDITY of the destination mailbox, a UID 3526 set containing the UIDs of the message(s) in the source mailbox 3527 that were copied to the destination mailbox and containing the 3528 UIDs assigned to the copied message(s) in the destination 3529 mailbox, indicates that the message(s) have been copied to the 3530 destination mailbox with the stated UID(s). 3532 The source UID set is in the order the message(s) were copied; 3533 the destination UID set corresponds to the source UID set and 3534 is in the same order. Neither of the UID sets may contain 3535 extraneous UIDs or the symbol "*". 3537 UIDs are assigned in strictly ascending order in the mailbox 3538 (refer to Section 2.3.1.1); note that a range of 12:10 is 3539 exactly equivalent to 10:12 and refers to the sequence 3540 10,11,12. 3542 This response code is returned in a tagged OK response to the 3543 COPY command. 3545 CORRUPTION 3547 The server discovered that some relevant data (e.g., the 3548 mailbox) are corrupt. This response code does not include any 3549 information about what's corrupt, but the server can write that 3550 to its logfiles. 3552 C: i select "/archive/projects/experiment-iv" 3553 S: i NO [CORRUPTION] Cannot open mailbox 3555 EXPIRED 3557 Either authentication succeeded or the server no longer had the 3558 necessary data; either way, access is no longer permitted using 3559 that passphrase. The client or user should get a new 3560 passphrase. 3562 C: d login "fred" "foo" 3563 S: d NO [EXPIRED] That password isn't valid any more 3565 EXPUNGEISSUED 3567 Someone else has issued an EXPUNGE for the same mailbox. The 3568 client may want to issue NOOP soon. [IMAP-MULTIACCESS] 3569 discusses this subject in depth. 3571 C: h search from fred@example.com 3572 S: * SEARCH 1 2 3 5 8 13 21 42 3573 S: h OK [EXPUNGEISSUED] Search completed 3575 INUSE 3577 An operation has not been carried out because it involves 3578 sawing off a branch someone else is sitting on. Someone else 3579 may be holding an exclusive lock needed for this operation, or 3580 the operation may involve deleting a resource someone else is 3581 using, typically a mailbox. 3583 The operation may succeed if the client tries again later. 3585 C: g delete "/archive/projects/experiment-iv" 3586 S: g NO [INUSE] Mailbox in use 3588 LIMIT 3589 The operation ran up against an implementation limit of some 3590 kind, such as the number of flags on a single message or the 3591 number of flags used in a mailbox. 3593 C: m STORE 42 FLAGS f1 f2 f3 f4 f5 ... f250 3594 S: m NO [LIMIT] At most 32 flags in one mailbox supported 3596 NONEXISTENT 3598 The operation attempts to delete something that does not exist. 3599 Similar to ALREADYEXISTS. 3601 C: p RENAME this that 3602 S: p NO [NONEXISTENT] No such mailbox 3604 NOPERM 3606 The access control system (e.g., Access Control List (ACL), see 3607 [RFC4314] does not permit this user to carry out an operation, 3608 such as selecting or creating a mailbox. 3610 C: f select "/archive/projects/experiment-iv" 3611 S: f NO [NOPERM] Access denied 3613 OVERQUOTA 3615 The user would be over quota after the operation. (The user 3616 may or may not be over quota already.) 3618 Note that if the server sends OVERQUOTA but doesn't support the 3619 IMAP QUOTA extension defined by [RFC2087], then there is a 3620 quota, but the client cannot find out what the quota is. 3622 C: n1 uid copy 1:* oldmail 3623 S: n1 NO [OVERQUOTA] Sorry 3625 C: n2 uid copy 1:* oldmail 3626 S: n2 OK [OVERQUOTA] You are now over your soft quota 3628 PARSE The human-readable text represents an error in parsing the 3629 [RFC-5322] header or [MIME-IMB] headers of a message in the 3630 mailbox. 3632 PERMANENTFLAGS Followed by a parenthesized list of flags, indicates 3633 which of the known flags the client can change permanently. Any 3634 flags that are in the FLAGS untagged response, but not the 3635 PERMANENTFLAGS list, can not be set permanently. If the client 3636 attempts to STORE a flag that is not in the PERMANENTFLAGS list, 3637 the server will either ignore the change or store the state change 3638 for the remainder of the current session only. The PERMANENTFLAGS 3639 list can also include the special flag \*, which indicates that it 3640 is possible to create new keywords by attempting to store those 3641 flags in the mailbox. 3643 PRIVACYREQUIRED 3645 The operation is not permitted due to a lack of privacy. If 3646 Transport Layer Security (TLS) is not in use, the client could 3647 try STARTTLS (see Section 6.2.1) and then repeat the operation. 3649 C: d login "fred" "foo" 3650 S: d NO [PRIVACYREQUIRED] Connection offers no privacy 3652 C: d select inbox 3653 S: d NO [PRIVACYREQUIRED] Connection offers no privacy 3655 READ-ONLY The mailbox is selected read-only, or its access while 3656 selected has changed from read-write to read-only. 3658 READ-WRITE The mailbox is selected read-write, or its access while 3659 selected has changed from read-only to read-write. 3661 SERVERBUG 3663 The server encountered a bug in itself or violated one of its 3664 own invariants. 3666 C: j select "/archive/projects/experiment-iv" 3667 S: j NO [SERVERBUG] This should not happen 3669 TRYCREATE An APPEND or COPY attempt is failing because the target 3670 mailbox does not exist (as opposed to some other reason). This is 3671 a hint to the client that the operation can succeed if the mailbox 3672 is first created by the CREATE command. 3674 UIDNEXT Followed by a decimal number, indicates the next unique 3675 identifier value. Refer to Section 2.3.1.1 for more information. 3677 UIDNOTSTICKY 3679 The selected mailbox is supported by a mail store that does not 3680 support persistent UIDs; that is, UIDVALIDITY will be different 3681 each time the mailbox is selected. Consequently, APPEND or 3682 COPY to this mailbox will not return an APPENDUID or COPYUID 3683 response code. 3685 This response code is returned in an untagged NO response to 3686 the SELECT command. 3688 Note: servers SHOULD NOT have any UIDNOTSTICKY mail stores. 3689 This facility exists to support legacy mail stores in which 3690 it is technically infeasible to support persistent UIDs. 3691 This should be avoided when designing new mail stores. 3693 UIDVALIDITY Followed by a decimal number, indicates the unique 3694 identifier validity value. Refer to Section 2.3.1.1 for more 3695 information. 3697 UNAVAILABLE 3699 Temporary failure because a subsystem is down. For example, an 3700 IMAP server that uses a Lightweight Directory Access Protocol 3701 (LDAP) or Radius server for authentication might use this 3702 response code when the LDAP/Radius server is down. 3704 C: a LOGIN "fred" "foo" 3705 S: a NO [UNAVAILABLE] User's backend down for maintenance 3707 UNSEEN Followed by a decimal number, indicates the number of the 3708 first message without the \Seen flag set. 3710 Additional response codes defined by particular client or server 3711 implementations SHOULD be prefixed with an "X" until they are added 3712 to a revision of this protocol. Client implementations SHOULD ignore 3713 response codes that they do not recognize. 3715 7.1.1. OK Response 3717 Contents: OPTIONAL response code 3718 human-readable text 3720 The OK response indicates an information message from the server. 3721 When tagged, it indicates successful completion of the associated 3722 command. The human-readable text MAY be presented to the user as an 3723 information message. The untagged form indicates an information-only 3724 message; the nature of the information MAY be indicated by a response 3725 code. 3727 The untagged form is also used as one of three possible greetings at 3728 connection startup. It indicates that the connection is not yet 3729 authenticated and that a LOGIN or an AUTHENTICATE command is needed. 3731 Example: S: * OK IMAP4rev2 server ready 3732 C: A001 LOGIN fred blurdybloop 3733 S: * OK [ALERT] System shutdown in 10 minutes 3734 S: A001 OK LOGIN Completed 3736 7.1.2. NO Response 3738 Contents: OPTIONAL response code 3739 human-readable text 3741 The NO response indicates an operational error message from the 3742 server. When tagged, it indicates unsuccessful completion of the 3743 associated command. The untagged form indicates a warning; the 3744 command can still complete successfully. The human-readable text 3745 describes the condition. 3747 Example: C: A222 COPY 1:2 owatagusiam 3748 S: * NO Disk is 98% full, please delete unnecessary data 3749 S: A222 OK COPY completed 3750 C: A223 COPY 3:200 blurdybloop 3751 S: * NO Disk is 98% full, please delete unnecessary data 3752 S: * NO Disk is 99% full, please delete unnecessary data 3753 S: A223 NO COPY failed: disk is full 3755 7.1.3. BAD Response 3757 Contents: OPTIONAL response code 3758 human-readable text 3760 The BAD response indicates an error message from the server. When 3761 tagged, it reports a protocol-level error in the client's command; 3762 the tag indicates the command that caused the error. The untagged 3763 form indicates a protocol-level error for which the associated 3764 command can not be determined; it can also indicate an internal 3765 server failure. The human-readable text describes the condition. 3767 Example: C: ...very long command line... 3768 S: * BAD Command line too long 3769 C: ...empty line... 3770 S: * BAD Empty command line 3771 C: A443 EXPUNGE 3772 S: * BAD Disk crash, attempting salvage to a new disk! 3773 S: * OK Salvage successful, no data lost 3774 S: A443 OK Expunge completed 3776 7.1.4. PREAUTH Response 3778 Contents: OPTIONAL response code 3779 human-readable text 3781 The PREAUTH response is always untagged, and is one of three possible 3782 greetings at connection startup. It indicates that the connection 3783 has already been authenticated by external means; thus no LOGIN/ 3784 AUTHENTICATE command is needed. 3786 Example: S: * PREAUTH IMAP4rev2 server logged in as Smith 3788 7.1.5. BYE Response 3790 Contents: OPTIONAL response code 3791 human-readable text 3793 The BYE response is always untagged, and indicates that the server is 3794 about to close the connection. The human-readable text MAY be 3795 displayed to the user in a status report by the client. The BYE 3796 response is sent under one of four conditions: 3798 1. as part of a normal logout sequence. The server will close the 3799 connection after sending the tagged OK response to the LOGOUT 3800 command. 3802 2. as a panic shutdown announcement. The server closes the 3803 connection immediately. 3805 3. as an announcement of an inactivity autologout. The server 3806 closes the connection immediately. 3808 4. as one of three possible greetings at connection startup, 3809 indicating that the server is not willing to accept a connection 3810 from this client. The server closes the connection immediately. 3812 The difference between a BYE that occurs as part of a normal LOGOUT 3813 sequence (the first case) and a BYE that occurs because of a failure 3814 (the other three cases) is that the connection closes immediately in 3815 the failure case. In all cases the client SHOULD continue to read 3816 response data from the server until the connection is closed; this 3817 will ensure that any pending untagged or completion responses are 3818 read and processed. 3820 Example: S: * BYE Autologout; idle for too long 3822 7.2. Server Responses - Server and Mailbox Status 3824 These responses are always untagged. This is how server and mailbox 3825 status data are transmitted from the server to the client. Many of 3826 these responses typically result from a command with the same name. 3828 7.2.1. The ENABLED Response 3830 Contents: capability listing 3832 The ENABLED response occurs as a result of an ENABLE command. The 3833 capability listing contains a space-separated listing of capability 3834 names that the server supports and that were successfully enabled. 3835 The ENABLED response may contain no capabilities, which means that no 3836 extensions listed by the client were successfully enabled. 3838 7.2.2. CAPABILITY Response 3840 Contents: capability listing 3842 The CAPABILITY response occurs as a result of a CAPABILITY command. 3843 The capability listing contains a space-separated listing of 3844 capability names that the server supports. The capability listing 3845 MUST include the atom "IMAP4rev2". 3847 In addition, client and server implementations MUST implement the 3848 STARTTLS, LOGINDISABLED, and AUTH=PLAIN (described in [PLAIN]) 3849 capabilities. See the Security Considerations section for important 3850 information. 3852 A capability name which begins with "AUTH=" indicates that the server 3853 supports that particular authentication mechanism. 3855 The LOGINDISABLED capability indicates that the LOGIN command is 3856 disabled, and that the server will respond with a tagged NO response 3857 to any attempt to use the LOGIN command even if the user name and 3858 password are valid. An IMAP client MUST NOT issue the LOGIN command 3859 if the server advertises the LOGINDISABLED capability. 3861 Other capability names indicate that the server supports an 3862 extension, revision, or amendment to the IMAP4rev2 protocol. Server 3863 responses MUST conform to this document until the client issues a 3864 command that uses the associated capability. 3866 Capability names MUST either begin with "X" or be standard or 3867 standards-track IMAP4rev2 extensions, revisions, or amendments 3868 registered with IANA. A server MUST NOT offer unregistered or non- 3869 standard capability names, unless such names are prefixed with an 3870 "X". 3872 Client implementations SHOULD NOT require any capability name other 3873 than "IMAP4rev2", and MUST ignore any unknown capability names. 3875 A server MAY send capabilities automatically, by using the CAPABILITY 3876 response code in the initial PREAUTH or OK responses, and by sending 3877 an updated CAPABILITY response code in the tagged OK response as part 3878 of a successful authentication. It is unnecessary for a client to 3879 send a separate CAPABILITY command if it recognizes these automatic 3880 capabilities. 3882 Example: S: * CAPABILITY IMAP4rev2 STARTTLS AUTH=GSSAPI XPIG-LATIN 3884 7.2.3. LIST Response 3886 Contents: name attributes 3887 hierarchy delimiter 3888 name 3890 The LIST response occurs as a result of a LIST command. It returns a 3891 single name that matches the LIST specification. There can be 3892 multiple LIST responses for a single LIST command. 3894 The following base name attributes are defined: 3896 \Noinferiors It is not possible for any child levels of hierarchy to 3897 exist under this name; no child levels exist now and none can be 3898 created in the future. 3900 \Noselect It is not possible to use this name as a selectable 3901 mailbox. 3903 \HasChildren The presence of this attribute indicates that the 3904 mailbox has child mailboxes. A server SHOULD NOT set this 3905 attribute if there are child mailboxes and the user does not have 3906 permission to access any of them. In this case, \HasNoChildren 3907 SHOULD be used. In many cases, however, a server may not be able 3908 to efficiently compute whether a user has access to any child 3909 mailbox. Note that even though the \HasChildren attribute for a 3910 mailbox must be correct at the time of processing of the mailbox, 3911 a client must be prepared to deal with a situation when a mailbox 3912 is marked with the \HasChildren attribute, but no child mailbox 3913 appears in the response to the LIST command. This might happen, 3914 for example, due to children mailboxes being deleted or made 3915 inaccessible to the user (using access control) by another client 3916 before the server is able to list them. 3918 \HasNoChildren The presence of this attribute indicates that the 3919 mailbox has NO child mailboxes that are accessible to the 3920 currently authenticated user. 3922 \Marked The mailbox has been marked "interesting" by the server; the 3923 mailbox probably contains messages that have been added since the 3924 last time the mailbox was selected. 3926 \Unmarked The mailbox does not contain any additional messages since 3927 the last time the mailbox was selected. 3929 It is an error for the server to return both a \HasChildren and a 3930 \HasNoChildren attribute in the same LIST response. 3932 Note: the \HasNoChildren attribute should not be confused with the 3933 \NoInferiors attribute, which indicates that no child mailboxes 3934 exist now and none can be created in the future. 3936 If it is not feasible for the server to determine whether or not the 3937 mailbox is "interesting", the server SHOULD NOT send either \Marked 3938 or \Unmarked. The server MUST NOT send more than one of \Marked, 3939 \Unmarked, and \Noselect for a single mailbox, and MAY send none of 3940 these. 3942 In addition to the base name attributes defined above, an IMAP server 3943 MAY also include any or all of the following attributes that denote 3944 "role" (or "special-use") of a mailbox. These attributes are 3945 included along with base attributes defined above. A given mailbox 3946 may have none, one, or more than one of these attributes. In some 3947 cases, a special use is advice to a client about what to put in that 3948 mailbox. In other cases, it's advice to a client about what to 3949 expect to find there. 3951 \All This mailbox presents all messages in the user's message store. 3952 Implementations MAY omit some messages, such as, perhaps, those in 3953 \Trash and \Junk. When this special use is supported, it is 3954 almost certain to represent a virtual mailbox. 3956 \Archive This mailbox is used to archive messages. The meaning of 3957 an "archival" mailbox is server-dependent; typically, it will be 3958 used to get messages out of the inbox, or otherwise keep them out 3959 of the user's way, while still making them accessible. 3961 \Drafts This mailbox is used to hold draft messages -- typically, 3962 messages that are being composed but have not yet been sent. In 3963 some server implementations, this might be a virtual mailbox, 3964 containing messages from other mailboxes that are marked with the 3965 "\Draft" message flag. Alternatively, this might just be advice 3966 that a client put drafts here. 3968 \Flagged This mailbox presents all messages marked in some way as 3969 "important". When this special use is supported, it is likely to 3970 represent a virtual mailbox collecting messages (from other 3971 mailboxes) that are marked with the "\Flagged" message flag. 3973 \Junk This mailbox is where messages deemed to be junk mail are 3974 held. Some server implementations might put messages here 3975 automatically. Alternatively, this might just be advice to a 3976 client-side spam filter. 3978 \Sent This mailbox is used to hold copies of messages that have been 3979 sent. Some server implementations might put messages here 3980 automatically. Alternatively, this might just be advice that a 3981 client save sent messages here. 3983 \Trash This mailbox is used to hold messages that have been deleted 3984 or marked for deletion. In some server implementations, this 3985 might be a virtual mailbox, containing messages from other 3986 mailboxes that are marked with the "\Deleted" message flag. 3987 Alternatively, this might just be advice that a client that 3988 chooses not to use the IMAP "\Deleted" model should use this as 3989 its trash location. In server implementations that strictly 3990 expect the IMAP "\Deleted" model, this special use is likely not 3991 to be supported. 3993 All of special-use attributes are OPTIONAL, and any given server or 3994 message store may support any combination of the attributes, or none 3995 at all. In most cases, there will likely be at most one mailbox with 3996 a given attribute for a given user, but in some server or message 3997 store implementations it might be possible for multiple mailboxes to 3998 have the same special-use attribute. 4000 Special-use attributes are likely to be user-specific. User Adam 4001 might share his \Sent mailbox with user Barb, but that mailbox is 4002 unlikely to also serve as Barb's \Sent mailbox. 4004 The hierarchy delimiter is a character used to delimit levels of 4005 hierarchy in a mailbox name. A client can use it to create child 4006 mailboxes, and to search higher or lower levels of naming hierarchy. 4007 All children of a top-level hierarchy node MUST use the same 4008 separator character. A NIL hierarchy delimiter means that no 4009 hierarchy exists; the name is a "flat" name. 4011 The name represents an unambiguous left-to-right hierarchy, and MUST 4012 be valid for use as a reference in LIST and LSUB commands. Unless 4013 \Noselect is indicated, the name MUST also be valid as an argument 4014 for commands, such as SELECT, that accept mailbox names. 4016 Example: S: * LIST (\Noselect) "/" ~/Mail/foo 4018 7.2.4. LSUB Response 4020 Contents: name attributes 4021 hierarchy delimiter 4022 name 4024 The LSUB response occurs as a result of an LSUB command. It returns 4025 a single name that matches the LSUB specification. There can be 4026 multiple LSUB responses for a single LSUB command. The data is 4027 identical in format to the LIST response. 4029 Example: S: * LSUB () "." #news.comp.mail.misc 4031 7.2.5. NAMESPACE Response 4033 Contents: the prefix and hierarchy delimiter to the server's 4034 Personal Namespace(s), Other Users' Namespace(s), and 4035 Shared Namespace(s) 4037 The NAMESPACE response occurs as a result of a NAMESPACE command. It 4038 contains the prefix and hierarchy delimiter to the server's Personal 4039 Namespace(s), Other Users' Namespace(s), and Shared Namespace(s) that 4040 the server wishes to expose. The response will contain a NIL for any 4041 namespace class that is not available. Namespace_Response_Extensions 4042 MAY be included in the response. Namespace_Response_Extensions which 4043 are not on the IETF standards track, MUST be prefixed with an "X-". 4045 Example: S: * NAMESPACE (("" "/")) (("~" "/")) NIL 4047 7.2.6. STATUS Response 4049 Contents: name 4050 status parenthesized list 4052 The STATUS response occurs as a result of an STATUS command. It 4053 returns the mailbox name that matches the STATUS specification and 4054 the requested mailbox status information. 4056 Example: S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) 4058 7.2.7. ESEARCH Response 4060 Contents: one or more search-return-data pairs 4062 The ESEARCH response occurs as a result of a SEARCH or UID SEARCH 4063 command. 4065 The ESEARCH response starts with an optional search correlator. If 4066 it is missing, then the response was not caused by a particular IMAP 4067 command, whereas if it is present, it contains the tag of the command 4068 that caused the response to be returned. 4070 The search correlator is followed by an optional UID indicator. If 4071 this indicator is present, all data in the ESEARCH response refers to 4072 UIDs, otherwise all returned data refers to message numbers. 4074 The rest of the ESEARCH response contains one or more search data 4075 pairs. Each pair starts with unique return item name, followed by a 4076 space and the corresponding data. Search data pairs may be returned 4077 in any order. Unless specified otherwise by an extension, any return 4078 item name SHOULD appear only once in an ESEARCH response. 4080 [[TBD: describe the most common search data pairs returned.]] 4082 Example: S: * ESEARCH UID COUNT 5 ALL 4:19,21,28 4084 Example: S: * ESEARCH (TAG "a567") UID COUNT 5 ALL 4:19,21,28 4086 Example: S: * ESEARCH COUNT 5 ALL 1:17,21 4088 7.2.8. FLAGS Response 4090 Contents: flag parenthesized list 4092 The FLAGS response occurs as a result of a SELECT or EXAMINE command. 4093 The flag parenthesized list identifies the flags (at a minimum, the 4094 system-defined flags) that are applicable for this mailbox. Flags 4095 other than the system flags can also exist, depending on server 4096 implementation. 4098 The update from the FLAGS response MUST be recorded by the client. 4100 Example: S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 4102 7.3. Server Responses - Mailbox Size 4104 These responses are always untagged. This is how changes in the size 4105 of the mailbox are transmitted from the server to the client. 4106 Immediately following the "*" token is a number that represents a 4107 message count. 4109 7.3.1. EXISTS Response 4111 Contents: none 4113 The EXISTS response reports the number of messages in the mailbox. 4114 This response occurs as a result of a SELECT or EXAMINE command, and 4115 if the size of the mailbox changes (e.g., new messages). 4117 The update from the EXISTS response MUST be recorded by the client. 4119 Example: S: * 23 EXISTS 4121 7.3.2. RECENT Response 4123 Contents: none 4125 The RECENT response reports the number of messages with the \Recent 4126 flag set. This response occurs as a result of a SELECT or EXAMINE 4127 command, and if the size of the mailbox changes (e.g., new messages). 4129 Note: It is not guaranteed that the message sequence numbers of 4130 recent messages will be a contiguous range of the highest n 4131 messages in the mailbox (where n is the value reported by the 4132 RECENT response). Examples of situations in which this is not the 4133 case are: multiple clients having the same mailbox open (the first 4134 session to be notified will see it as recent, others will probably 4135 see it as non-recent), and when the mailbox is re-ordered by a 4136 non-IMAP agent. 4138 The only reliable way to identify recent messages is to look at 4139 message flags to see which have the \Recent flag set, or to do a 4140 SEARCH RECENT. 4142 The update from the RECENT response MUST be recorded by the client. 4144 Example: S: * 5 RECENT 4146 7.4. Server Responses - Message Status 4148 These responses are always untagged. This is how message data are 4149 transmitted from the server to the client, often as a result of a 4150 command with the same name. Immediately following the "*" token is a 4151 number that represents a message sequence number. 4153 7.4.1. EXPUNGE Response 4155 Contents: none 4157 The EXPUNGE response reports that the specified message sequence 4158 number has been permanently removed from the mailbox. The message 4159 sequence number for each successive message in the mailbox is 4160 immediately decremented by 1, and this decrement is reflected in 4161 message sequence numbers in subsequent responses (including other 4162 untagged EXPUNGE responses). 4164 The EXPUNGE response also decrements the number of messages in the 4165 mailbox; it is not necessary to send an EXISTS response with the new 4166 value. 4168 As a result of the immediate decrement rule, message sequence numbers 4169 that appear in a set of successive EXPUNGE responses depend upon 4170 whether the messages are removed starting from lower numbers to 4171 higher numbers, or from higher numbers to lower numbers. For 4172 example, if the last 5 messages in a 9-message mailbox are expunged, 4173 a "lower to higher" server will send five untagged EXPUNGE responses 4174 for message sequence number 5, whereas a "higher to lower server" 4175 will send successive untagged EXPUNGE responses for message sequence 4176 numbers 9, 8, 7, 6, and 5. 4178 An EXPUNGE response MUST NOT be sent when no command is in progress, 4179 nor while responding to a FETCH, STORE, or SEARCH command. This rule 4180 is necessary to prevent a loss of synchronization of message sequence 4181 numbers between client and server. A command is not "in progress" 4182 until the complete command has been received; in particular, a 4183 command is not "in progress" during the negotiation of command 4184 continuation. 4186 Note: UID FETCH, UID STORE, and UID SEARCH are different commands 4187 from FETCH, STORE, and SEARCH. An EXPUNGE response MAY be sent 4188 during a UID command. 4190 The update from the EXPUNGE response MUST be recorded by the client. 4192 Example: S: * 44 EXPUNGE 4194 7.4.2. FETCH Response 4196 Contents: message data 4198 The FETCH response returns data about a message to the client. The 4199 data are pairs of data item names and their values in parentheses. 4200 This response occurs as the result of a FETCH or STORE command, as 4201 well as by unilateral server decision (e.g., flag updates). 4203 The current data items are: 4205 BODY A form of BODYSTRUCTURE without extension data. 4207 BODY[
]<> 4209 A string expressing the body contents of the specified section. 4210 The string SHOULD be interpreted by the client according to the 4211 content transfer encoding, body type, and subtype. 4213 If the origin octet is specified, this string is a substring of 4214 the entire body contents, starting at that origin octet. This 4215 means that BODY[]<0> MAY be truncated, but BODY[] is NEVER 4216 truncated. 4218 Note: The origin octet facility MUST NOT be used by a server 4219 in a FETCH response unless the client specifically requested 4220 it by means of a FETCH of a BODY[
]<> data 4221 item. 4223 8-bit textual data is permitted if a [CHARSET] identifier is 4224 part of the body parameter parenthesized list for this section. 4225 Note that headers (part specifiers HEADER or MIME, or the 4226 header portion of a MESSAGE/RFC822 part), MUST be 7-bit; 8-bit 4227 characters are not permitted in headers. Note also that the 4228 [RFC-5322] delimiting blank line between the header and the 4229 body is not affected by header line subsetting; the blank line 4230 is always included as part of header data, except in the case 4231 of a message which has no body and no blank line. 4233 Non-textual data such as binary data MUST be transfer encoded 4234 into a textual form, such as BASE64, prior to being sent to the 4235 client. To derive the original binary data, the client MUST 4236 decode the transfer encoded string. 4238 BODYSTRUCTURE 4240 A parenthesized list that describes the [MIME-IMB] body 4241 structure of a message. This is computed by the server by 4242 parsing the [MIME-IMB] header fields, defaulting various fields 4243 as necessary. 4245 For example, a simple text message of 48 lines and 2279 octets 4246 can have a body structure of: ("TEXT" "PLAIN" ("CHARSET" "US- 4247 ASCII") NIL NIL "7BIT" 2279 48) 4249 Multiple parts are indicated by parenthesis nesting. Instead 4250 of a body type as the first element of the parenthesized list, 4251 there is a sequence of one or more nested body structures. The 4252 second element of the parenthesized list is the multipart 4253 subtype (mixed, digest, parallel, alternative, etc.). 4255 For example, a two part message consisting of a text and a 4256 BASE64-encoded text attachment can have a body structure of: 4257 (("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 1152 4258 23)("TEXT" "PLAIN" ("CHARSET" "US-ASCII" "NAME" "cc.diff") 4259 "<960723163407.20117h@cac.washington.edu>" "Compiler diff" 4260 "BASE64" 4554 73) "MIXED") 4262 Extension data follows the multipart subtype. Extension data 4263 is never returned with the BODY fetch, but can be returned with 4264 a BODYSTRUCTURE fetch. Extension data, if present, MUST be in 4265 the defined order. The extension data of a multipart body part 4266 are in the following order: 4268 body parameter parenthesized list A parenthesized list of 4269 attribute/value pairs [e.g., ("foo" "bar" "baz" "rag") where 4270 "bar" is the value of "foo", and "rag" is the value of 4271 "baz"] as defined in [MIME-IMB]. 4273 body disposition A parenthesized list, consisting of a 4274 disposition type string, followed by a parenthesized list of 4275 disposition attribute/value pairs as defined in 4276 [DISPOSITION]. 4278 body language A string or parenthesized list giving the body 4279 language value as defined in [LANGUAGE-TAGS]. 4281 body location A string giving the body content URI as defined 4282 in [LOCATION]. 4284 Any following extension data are not yet defined in this 4285 version of the protocol. Such extension data can consist of 4286 zero or more NILs, strings, numbers, or potentially nested 4287 parenthesized lists of such data. Client implementations that 4288 do a BODYSTRUCTURE fetch MUST be prepared to accept such 4289 extension data. Server implementations MUST NOT send such 4290 extension data until it has been defined by a revision of this 4291 protocol. 4293 The basic fields of a non-multipart body part are in the 4294 following order: 4296 body type A string giving the content media type name as 4297 defined in [MIME-IMB]. 4299 body subtype A string giving the content subtype name as 4300 defined in [MIME-IMB]. 4302 body parameter parenthesized list A parenthesized list of 4303 attribute/value pairs [e.g., ("foo" "bar" "baz" "rag") where 4304 "bar" is the value of "foo" and "rag" is the value of "baz"] 4305 as defined in [MIME-IMB]. 4307 body id A string giving the content id as defined in 4308 [MIME-IMB]. 4310 body description A string giving the content description as 4311 defined in [MIME-IMB]. 4313 body encoding A string giving the content transfer encoding as 4314 defined in [MIME-IMB]. 4316 body size A number giving the size of the body in octets. 4317 Note that this size is the size in its transfer encoding and 4318 not the resulting size after any decoding. 4320 A body type of type MESSAGE and subtype RFC822 contains, 4321 immediately after the basic fields, the envelope structure, 4322 body structure, and size in text lines of the encapsulated 4323 message. 4325 A body type of type TEXT contains, immediately after the basic 4326 fields, the size of the body in text lines. Note that this 4327 size is the size in its content transfer encoding and not the 4328 resulting size after any decoding. 4330 Extension data follows the basic fields and the type-specific 4331 fields listed above. Extension data is never returned with the 4332 BODY fetch, but can be returned with a BODYSTRUCTURE fetch. 4333 Extension data, if present, MUST be in the defined order. 4335 The extension data of a non-multipart body part are in the 4336 following order: 4338 body MD5 A string giving the body MD5 value as defined in 4339 [MD5]. 4341 body disposition A parenthesized list with the same content 4342 and function as the body disposition for a multipart body 4343 part. 4345 body language A string or parenthesized list giving the body 4346 language value as defined in [LANGUAGE-TAGS]. 4348 body location A string giving the body content URI as defined 4349 in [LOCATION]. 4351 Any following extension data are not yet defined in this 4352 version of the protocol, and would be as described above under 4353 multipart extension data. 4355 ENVELOPE 4357 A parenthesized list that describes the envelope structure of a 4358 message. This is computed by the server by parsing the 4359 [RFC-5322] header into the component parts, defaulting various 4360 fields as necessary. 4362 The fields of the envelope structure are in the following 4363 order: date, subject, from, sender, reply-to, to, cc, bcc, in- 4364 reply-to, and message-id. The date, subject, in-reply-to, and 4365 message-id fields are strings. The from, sender, reply-to, to, 4366 cc, and bcc fields are parenthesized lists of address 4367 structures. 4369 An address structure is a parenthesized list that describes an 4370 electronic mail address. The fields of an address structure 4371 are in the following order: personal name, [SMTP] at-domain- 4372 list (source route), mailbox name, and host name. 4374 [RFC-5322] group syntax is indicated by a special form of 4375 address structure in which the host name field is NIL. If the 4376 mailbox name field is also NIL, this is an end of group marker 4377 (semi-colon in RFC 822 syntax). If the mailbox name field is 4378 non-NIL, this is a start of group marker, and the mailbox name 4379 field holds the group name phrase. 4381 If the Date, Subject, In-Reply-To, and Message-ID header lines 4382 are absent in the [RFC-5322] header, the corresponding member 4383 of the envelope is NIL; if these header lines are present but 4384 empty the corresponding member of the envelope is the empty 4385 string. 4387 Note: some servers may return a NIL envelope member in the 4388 "present but empty" case. Clients SHOULD treat NIL and 4389 empty string as identical. 4391 Note: [RFC-5322] requires that all messages have a valid 4392 Date header. Therefore, the date member in the envelope can 4393 not be NIL or the empty string. 4395 Note: [RFC-5322] requires that the In-Reply-To and Message- 4396 ID headers, if present, have non-empty content. Therefore, 4397 the in-reply-to and message-id members in the envelope can 4398 not be the empty string. 4400 If the From, To, Cc, and Bcc header lines are absent in the 4401 [RFC-5322] header, or are present but empty, the corresponding 4402 member of the envelope is NIL. 4404 If the Sender or Reply-To lines are absent in the [RFC-5322] 4405 header, or are present but empty, the server sets the 4406 corresponding member of the envelope to be the same value as 4407 the from member (the client is not expected to know to do 4408 this). 4410 Note: [RFC-5322] requires that all messages have a valid 4411 From header. Therefore, the from, sender, and reply-to 4412 members in the envelope can not be NIL. 4414 FLAGS A parenthesized list of flags that are set for this message. 4416 INTERNALDATE A string representing the internal date of the message. 4418 RFC822 Equivalent to BODY[]. 4420 RFC822.HEADER Equivalent to BODY[HEADER]. Note that this did not 4421 result in \Seen being set, because RFC822.HEADER response data 4422 occurs as a result of a FETCH of RFC822.HEADER. BODY[HEADER] 4423 response data occurs as a result of a FETCH of BODY[HEADER] (which 4424 sets \Seen) or BODY.PEEK[HEADER] (which does not set \Seen). 4426 RFC822.SIZE A number expressing the [RFC-5322] size of the message. 4428 RFC822.TEXT Equivalent to BODY[TEXT]. 4430 UID A number expressing the unique identifier of the message. 4432 Example: S: * 23 FETCH (FLAGS (\Seen) RFC822.SIZE 44827) 4434 7.5. Server Responses - Command Continuation Request 4436 The command continuation request response is indicated by a "+" token 4437 instead of a tag. This form of response indicates that the server is 4438 ready to accept the continuation of a command from the client. The 4439 remainder of this response is a line of text. 4441 This response is used in the AUTHENTICATE command to transmit server 4442 data to the client, and request additional client data. This 4443 response is also used if an argument to any command is a literal. 4445 The client is not permitted to send the octets of the literal unless 4446 the server indicates that it is expected. This permits the server to 4447 process commands and reject errors on a line-by-line basis. The 4448 remainder of the command, including the CRLF that terminates a 4449 command, follows the octets of the literal. If there are any 4450 additional command arguments, the literal octets are followed by a 4451 space and those arguments. 4453 Example: C: A001 LOGIN {11} 4454 S: + Ready for additional command text 4455 C: FRED FOOBAR {7} 4456 S: + Ready for additional command text 4457 C: fat man 4458 S: A001 OK LOGIN completed 4459 C: A044 BLURDYBLOOP {102856} 4460 S: A044 BAD No such command as "BLURDYBLOOP" 4462 8. Sample IMAP4rev2 connection 4464 The following is a transcript of an IMAP4rev2 connection. A long 4465 line in this sample is broken for editorial clarity. 4467 S: * OK IMAP4rev2 Service Ready 4468 C: a001 login mrc secret 4469 S: a001 OK LOGIN completed 4470 C: a002 select inbox 4471 S: * 18 EXISTS 4472 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 4473 S: * 2 RECENT 4474 S: * OK [UNSEEN 17] Message 17 is the first unseen message 4475 S: * OK [UIDVALIDITY 3857529045] UIDs valid 4476 S: a002 OK [READ-WRITE] SELECT completed 4477 C: a003 fetch 12 full 4478 S: * 12 FETCH (FLAGS (\Seen) INTERNALDATE "17-Jul-1996 02:44:25 -0700" 4479 RFC822.SIZE 4286 ENVELOPE ("Wed, 17 Jul 1996 02:23:25 -0700 (PDT)" 4480 "IMAP4rev2 WG mtg summary and minutes" 4481 (("Terry Gray" NIL "gray" "cac.washington.edu")) 4482 (("Terry Gray" NIL "gray" "cac.washington.edu")) 4483 (("Terry Gray" NIL "gray" "cac.washington.edu")) 4484 ((NIL NIL "imap" "cac.washington.edu")) 4485 ((NIL NIL "minutes" "CNRI.Reston.VA.US") 4486 ("John Klensin" NIL "KLENSIN" "MIT.EDU")) NIL NIL 4487 "") 4488 BODY ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 3028 4489 92)) 4490 S: a003 OK FETCH completed 4491 C: a004 fetch 12 body[header] 4492 S: * 12 FETCH (BODY[HEADER] {342} 4493 S: Date: Wed, 17 Jul 1996 02:23:25 -0700 (PDT) 4494 S: From: Terry Gray 4495 S: Subject: IMAP4rev2 WG mtg summary and minutes 4496 S: To: imap@cac.washington.edu 4497 S: cc: minutes@CNRI.Reston.VA.US, John Klensin 4498 S: Message-Id: 4499 S: MIME-Version: 1.0 4500 S: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 4501 S: 4502 S: ) 4503 S: a004 OK FETCH completed 4504 C: a005 store 12 +flags \deleted 4505 S: * 12 FETCH (FLAGS (\Seen \Deleted)) 4506 S: a005 OK +FLAGS completed 4507 C: a006 logout 4508 S: * BYE IMAP4rev2 server terminating connection 4509 S: a006 OK LOGOUT completed 4510 9. Formal Syntax 4512 The following syntax specification uses the Augmented Backus-Naur 4513 Form (ABNF) notation as specified in [ABNF]. 4515 In the case of alternative or optional rules in which a later rule 4516 overlaps an earlier rule, the rule which is listed earlier MUST take 4517 priority. For example, "\Seen" when parsed as a flag is the \Seen 4518 flag name and not a flag-extension, even though "\Seen" can be parsed 4519 as a flag-extension. Some, but not all, instances of this rule are 4520 noted below. 4522 Note: [ABNF] rules MUST be followed strictly; in particular: 4524 (1) Except as noted otherwise, all alphabetic characters are case- 4525 insensitive. The use of upper or lower case characters to define 4526 token strings is for editorial clarity only. Implementations MUST 4527 accept these strings in a case-insensitive fashion. 4529 (2) In all cases, SP refers to exactly one space. It is NOT 4530 permitted to substitute TAB, insert additional spaces, or 4531 otherwise treat SP as being equivalent to LWSP. 4533 (3) The ASCII NUL character, %x00, MUST NOT be used at any time. 4535 address = "(" addr-name SP addr-adl SP addr-mailbox SP 4536 addr-host ")" 4538 addr-adl = nstring 4539 ; Holds route from [RFC-5322] route-addr if 4540 ; non-NIL 4542 addr-host = nstring 4543 ; NIL indicates [RFC-5322] group syntax. 4544 ; Otherwise, holds [RFC-5322] domain name 4546 addr-mailbox = nstring 4547 ; NIL indicates end of [RFC-5322] group; if 4548 ; non-NIL and addr-host is NIL, holds 4549 ; [RFC-5322] group name. 4550 ; Otherwise, holds [RFC-5322] local-part 4551 ; after removing [RFC-5322] quoting 4553 addr-name = nstring 4554 ; If non-NIL, holds phrase from [RFC-5322] 4555 ; mailbox after removing [RFC-5322] quoting 4557 append = "APPEND" SP mailbox [SP flag-list] [SP date-time] SP 4558 literal 4560 append-uid = uniqueid 4562 astring = 1*ASTRING-CHAR / string 4564 ASTRING-CHAR = ATOM-CHAR / resp-specials 4566 atom = 1*ATOM-CHAR 4568 ATOM-CHAR = 4570 atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards / 4571 quoted-specials / resp-specials 4573 authenticate = "AUTHENTICATE" SP auth-type [SP initial-resp] 4574 *(CRLF base64) 4576 auth-type = atom 4577 ; Defined by [SASL] 4579 base64 = *(4base64-char) [base64-terminal] 4581 base64-char = ALPHA / DIGIT / "+" / "/" 4582 ; Case-sensitive 4584 base64-terminal = (2base64-char "==") / (3base64-char "=") 4586 body = "(" (body-type-1part / body-type-mpart) ")" 4588 body-extension = nstring / number / 4589 "(" body-extension *(SP body-extension) ")" 4590 ; Future expansion. Client implementations 4591 ; MUST accept body-extension fields. Server 4592 ; implementations MUST NOT generate 4593 ; body-extension fields except as defined by 4594 ; future standard or standards-track 4595 ; revisions of this specification. 4597 body-ext-1part = body-fld-md5 [SP body-fld-dsp [SP body-fld-lang 4598 [SP body-fld-loc *(SP body-extension)]]] 4599 ; MUST NOT be returned on non-extensible 4600 ; "BODY" fetch 4602 body-ext-mpart = body-fld-param [SP body-fld-dsp [SP body-fld-lang 4603 [SP body-fld-loc *(SP body-extension)]]] 4604 ; MUST NOT be returned on non-extensible 4605 ; "BODY" fetch 4607 body-fields = body-fld-param SP body-fld-id SP body-fld-desc SP 4608 body-fld-enc SP body-fld-octets 4610 body-fld-desc = nstring 4612 body-fld-dsp = "(" string SP body-fld-param ")" / nil 4614 body-fld-enc = (DQUOTE ("7BIT" / "8BIT" / "BINARY" / "BASE64"/ 4615 "QUOTED-PRINTABLE") DQUOTE) / string 4617 body-fld-id = nstring 4619 body-fld-lang = nstring / "(" string *(SP string) ")" 4621 body-fld-loc = nstring 4623 body-fld-lines = number 4625 body-fld-md5 = nstring 4627 body-fld-octets = number 4629 body-fld-param = "(" string SP string *(SP string SP string) ")" / nil 4631 body-type-1part = (body-type-basic / body-type-msg / body-type-text) 4632 [SP body-ext-1part] 4634 body-type-basic = media-basic SP body-fields 4635 ; MESSAGE subtype MUST NOT be "RFC822" 4637 body-type-mpart = 1*body SP media-subtype 4638 [SP body-ext-mpart] 4639 ; MULTIPART body part 4641 body-type-msg = media-message SP body-fields SP envelope 4642 SP body SP body-fld-lines 4644 body-type-text = media-text SP body-fields SP body-fld-lines 4646 capability = ("AUTH=" auth-type) / atom 4647 ; New capabilities MUST begin with "X" or be 4648 ; registered with IANA as standard or 4649 ; standards-track 4651 capability-data = "CAPABILITY" *(SP capability) SP "IMAP4rev2" 4652 *(SP capability) 4653 ; Servers MUST implement the STARTTLS, AUTH=PLAIN, 4654 ; and LOGINDISABLED capabilities 4655 ; Servers which offer RFC 1730 compatibility MUST 4656 ; list "IMAP4" as the first capability. 4658 CHAR8 = %x01-ff 4659 ; any OCTET except NUL, %x00 4661 charset = atom / quoted 4663 command = tag SP (command-any / command-auth / command-nonauth / 4664 command-select) CRLF 4665 ; Modal based on state 4667 command-any = "CAPABILITY" / "LOGOUT" / "NOOP" / enable / x-command 4668 ; Valid in all states 4670 command-auth = append / create / delete / examine / list / lsub / 4671 Namespace-Command / 4672 rename / select / status / subscribe / unsubscribe / 4673 idle 4674 ; Valid only in Authenticated or Selected state 4676 command-nonauth = login / authenticate / "STARTTLS" 4677 ; Valid only when in Not Authenticated state 4679 command-select = "CHECK" / "CLOSE" / "UNSELECT" / "EXPUNGE" / copy / 4680 fetch / store / search / uid 4681 ; Valid only when in Selected state 4683 continue-req = "+" SP (resp-text / base64) CRLF 4685 copy = "COPY" SP sequence-set SP mailbox 4687 create = "CREATE" SP mailbox 4688 ; Use of INBOX gives a NO error 4690 date = date-text / DQUOTE date-text DQUOTE 4692 date-day = 1*2DIGIT 4693 ; Day of month 4695 date-day-fixed = (SP DIGIT) / 2DIGIT 4696 ; Fixed-format version of date-day 4698 date-month = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / 4699 "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec" 4701 date-text = date-day "-" date-month "-" date-year 4702 date-year = 4DIGIT 4704 date-time = DQUOTE date-day-fixed "-" date-month "-" date-year 4705 SP time SP zone DQUOTE 4707 delete = "DELETE" SP mailbox 4708 ; Use of INBOX gives a NO error 4710 digit-nz = %x31-39 4711 ; 1-9 4713 enable = "ENABLE" 1*(SP capability) 4715 enable-data = "ENABLED" *(SP capability) 4717 envelope = "(" env-date SP env-subject SP env-from SP 4718 env-sender SP env-reply-to SP env-to SP env-cc SP 4719 env-bcc SP env-in-reply-to SP env-message-id ")" 4721 env-bcc = "(" 1*address ")" / nil 4723 env-cc = "(" 1*address ")" / nil 4725 env-date = nstring 4727 env-from = "(" 1*address ")" / nil 4729 env-in-reply-to = nstring 4731 env-message-id = nstring 4733 env-reply-to = "(" 1*address ")" / nil 4735 env-sender = "(" 1*address ")" / nil 4737 env-subject = nstring 4739 env-to = "(" 1*address ")" / nil 4741 esearch-response = "ESEARCH" [search-correlator] [SP "UID"] 4742 *(SP search-return-data) 4743 ; ESEARCH response replaces SEARCH response 4744 ; from IMAP4rev1. 4746 examine = "EXAMINE" SP mailbox 4748 fetch = "FETCH" SP sequence-set SP ("ALL" / "FULL" / "FAST" / 4749 fetch-att / "(" fetch-att *(SP fetch-att) ")") 4751 fetch-att = "ENVELOPE" / "FLAGS" / "INTERNALDATE" / 4752 "RFC822" [".HEADER" / ".SIZE" / ".TEXT"] / 4753 "BODY" ["STRUCTURE"] / "UID" / 4754 "BODY" section [partial] / 4755 "BODY.PEEK" section [partial] 4757 flag = "\Answered" / "\Flagged" / "\Deleted" / 4758 "\Seen" / "\Draft" / flag-keyword / flag-extension 4759 ; Does not include "\Recent" 4761 flag-extension = "\" atom 4762 ; Future expansion. Client implementations 4763 ; MUST accept flag-extension flags. Server 4764 ; implementations MUST NOT generate 4765 ; flag-extension flags except as defined by 4766 ; future standard or standards-track 4767 ; revisions of this specification. 4769 flag-fetch = flag / "\Recent" 4771 flag-keyword = atom 4773 flag-list = "(" [flag *(SP flag)] ")" 4775 flag-perm = flag / "\*" 4777 greeting = "*" SP (resp-cond-auth / resp-cond-bye) CRLF 4779 header-fld-name = astring 4781 header-list = "(" header-fld-name *(SP header-fld-name) ")" 4783 idle = "IDLE" CRLF "DONE" 4785 initial-resp = (base64 / "=") 4786 ; "initial response" defined in 4787 ; Section 5.1 of [RFC4422] 4789 list = "LIST" SP mailbox SP list-mailbox 4791 list-mailbox = 1*list-char / string 4793 list-char = ATOM-CHAR / list-wildcards / resp-specials 4795 list-wildcards = "%" / "*" 4797 literal = "{" number "}" CRLF *CHAR8 4798 ; Number represents the number of CHAR8s 4800 login = "LOGIN" SP userid SP password 4802 lsub = "LSUB" SP mailbox SP list-mailbox 4804 mailbox = "INBOX" / astring 4805 ; INBOX is case-insensitive. All case variants of 4806 ; INBOX (e.g., "iNbOx") MUST be interpreted as INBOX 4807 ; not as an astring. An astring which consists of 4808 ; the case-insensitive sequence "I" "N" "B" "O" "X" 4809 ; is considered to be INBOX and not an astring. 4810 ; Refer to section 5.1 for further 4811 ; semantic details of mailbox names. 4813 mailbox-data = "FLAGS" SP flag-list / "LIST" SP mailbox-list / 4814 "LSUB" SP mailbox-list / esearch-response / 4815 "STATUS" SP mailbox SP "(" [status-att-list] ")" / 4816 number SP "EXISTS" / number SP "RECENT" / 4817 Namespace-Response 4819 mailbox-list = "(" [mbx-list-flags] ")" SP 4820 (DQUOTE QUOTED-CHAR DQUOTE / nil) SP mailbox 4822 mbx-list-flags = *(mbx-list-oflag SP) mbx-list-sflag 4823 *(SP mbx-list-oflag) / 4824 mbx-list-oflag *(SP mbx-list-oflag) 4826 mbx-list-oflag = "\Noinferiors" / flag-extension 4827 ; Other flags; multiple possible per LIST response 4829 mbx-list-sflag = "\Noselect" / "\Marked" / "\Unmarked" 4830 ; Selectability flags; only one per LIST response 4832 media-basic = ((DQUOTE ("APPLICATION" / "AUDIO" / "IMAGE" / 4833 "MESSAGE" / "VIDEO" / "FONT") DQUOTE) / string) SP 4834 media-subtype 4835 ; Defined in [MIME-IMT]. 4836 ; FONT defined in RFC YYYY. 4838 media-message = DQUOTE "MESSAGE" DQUOTE SP DQUOTE "RFC822" DQUOTE 4839 ; Defined in [MIME-IMT] 4841 media-subtype = string 4842 ; Defined in [MIME-IMT] 4844 media-text = DQUOTE "TEXT" DQUOTE SP media-subtype 4845 ; Defined in [MIME-IMT] 4847 message-data = nz-number SP ("EXPUNGE" / ("FETCH" SP msg-att)) 4848 msg-att = "(" (msg-att-dynamic / msg-att-static) 4849 *(SP (msg-att-dynamic / msg-att-static)) ")" 4851 msg-att-dynamic = "FLAGS" SP "(" [flag-fetch *(SP flag-fetch)] ")" 4852 ; MAY change for a message 4854 msg-att-static = "ENVELOPE" SP envelope / "INTERNALDATE" SP date-time / 4855 "RFC822" [".HEADER" / ".TEXT"] SP nstring / 4856 "RFC822.SIZE" SP number / 4857 "BODY" ["STRUCTURE"] SP body / 4858 "BODY" section ["<" number ">"] SP nstring / 4859 "UID" SP uniqueid 4860 ; MUST NOT change for a message 4862 Namespace = nil / "(" 1*Namespace-Descr ")" 4864 Namespace-Command = "NAMESPACE" 4866 Namespace-Descr = "(" string SP 4867 (DQUOTE QUOTED-CHAR DQUOTE / nil) 4868 *(Namespace-Response-Extension) ")" 4870 Namespace-Response-Extension = SP string SP 4871 "(" string *(SP string) ")" 4873 Namespace-Response = "NAMESPACE" SP Namespace 4874 SP Namespace SP Namespace 4875 ; The first Namespace is the Personal Namespace(s) 4876 ; The second Namespace is the Other Users' Namespace(s) 4877 ; The third Namespace is the Shared Namespace(s) 4879 nil = "NIL" 4881 nstring = string / nil 4883 number = 1*DIGIT 4884 ; Unsigned 32-bit integer 4885 ; (0 <= n < 4,294,967,296) 4887 number64 = 1*DIGIT 4888 ; Unsigned 63-bit integer 4889 ; (0 <= n <= 9,223,372,036,854,775,807) 4891 nz-number = digit-nz *DIGIT 4892 ; Non-zero unsigned 32-bit integer 4893 ; (0 < n < 4,294,967,296) 4895 password = astring 4896 partial-range = number ["." nz-number] 4897 ; Copied from RFC 5092 (IMAP URL) 4899 partial = "<" number "." nz-number ">" 4900 ; Partial FETCH request. 0-based offset of 4901 ; the first octet, followed by the number of octets 4902 ; in the fragment. 4904 quoted = DQUOTE *QUOTED-CHAR DQUOTE 4906 QUOTED-CHAR = / 4907 "\" quoted-specials 4909 quoted-specials = DQUOTE / "\" 4911 rename = "RENAME" SP mailbox SP mailbox 4912 ; Use of INBOX as a destination gives a NO error 4914 response = *(continue-req / response-data) response-done 4916 response-data = "*" SP (resp-cond-state / resp-cond-bye / 4917 mailbox-data / message-data / capability-data / 4918 enable-data) CRLF 4920 response-done = response-tagged / response-fatal 4922 response-fatal = "*" SP resp-cond-bye CRLF 4923 ; Server closes connection immediately 4925 response-tagged = tag SP resp-cond-state CRLF 4927 resp-code-apnd = "APPENDUID" SP nz-number SP append-uid 4929 resp-code-copy = "COPYUID" SP nz-number SP uid-set SP uid-set 4931 resp-cond-auth = ("OK" / "PREAUTH") SP resp-text 4932 ; Authentication condition 4934 resp-cond-bye = "BYE" SP resp-text 4936 resp-cond-state = ("OK" / "NO" / "BAD") SP resp-text 4937 ; Status condition 4939 resp-specials = "]" 4941 ;; ////Can we make "text" optional? Will this have any bad side effects? 4942 resp-text = ["[" resp-text-code "]" SP] text 4943 resp-text-code = "ALERT" / 4944 "BADCHARSET" [SP "(" charset *(SP charset) ")" ] / 4945 capability-data / "PARSE" / 4946 "PERMANENTFLAGS" SP "(" 4947 [flag-perm *(SP flag-perm)] ")" / 4948 "READ-ONLY" / "READ-WRITE" / "TRYCREATE" / 4949 "UIDNEXT" SP nz-number / "UIDVALIDITY" SP nz-number / 4950 "UNSEEN" SP nz-number / 4951 resp-code-apnd / resp-code-copy / "UIDNOTSTICKY" / 4952 "UNAVAILABLE" / "AUTHENTICATIONFAILED" / 4953 "AUTHORIZATIONFAILED" / "EXPIRED" / 4954 "PRIVACYREQUIRED" / "CONTACTADMIN" / "NOPERM" / 4955 "INUSE" / "EXPUNGEISSUED" / "CORRUPTION" / 4956 "SERVERBUG" / "CLIENTBUG" / "CANNOT" / 4957 "LIMIT" / "OVERQUOTA" / "ALREADYEXISTS" / 4958 "NONEXISTENT" / 4959 "CLOSED" / 4960 atom [SP 1*] 4962 search = "SEARCH" [search-return-opts] 4963 SP search-program 4965 search-correlator = SP "(" "TAG" SP tag-string ")" 4967 search-key = "ALL" / "ANSWERED" / "BCC" SP astring / 4968 "BEFORE" SP date / "BODY" SP astring / 4969 "CC" SP astring / "DELETED" / "FLAGGED" / 4970 "FROM" SP astring / "KEYWORD" SP flag-keyword / 4971 "NEW" / "OLD" / "ON" SP date / "RECENT" / "SEEN" / 4972 "SINCE" SP date / "SUBJECT" SP astring / 4973 "TEXT" SP astring / "TO" SP astring / 4974 "UNANSWERED" / "UNDELETED" / "UNFLAGGED" / 4975 "UNKEYWORD" SP flag-keyword / "UNSEEN" / 4976 ; Above this line were in [IMAP2] 4977 "DRAFT" / "HEADER" SP header-fld-name SP astring / 4978 "LARGER" SP number / "NOT" SP search-key / 4979 "OR" SP search-key SP search-key / 4980 "SENTBEFORE" SP date / "SENTON" SP date / 4981 "SENTSINCE" SP date / "SMALLER" SP number / 4982 "UID" SP sequence-set / "UNDRAFT" / sequence-set / 4983 "(" search-key *(SP search-key) ")" 4985 search-modifier-name = tagged-ext-label 4987 search-mod-params = tagged-ext-val 4988 ; This non-terminal shows recommended syntax 4989 ; for future extensions. 4991 search-program = ["CHARSET" SP charset SP] 4992 search-key *(SP search-key) 4993 ; CHARSET argument to SEARCH MUST be 4994 ; registered with IANA. 4996 search-ret-data-ext = search-modifier-name SP search-return-value 4997 ; Note that not every SEARCH return option 4998 ; is required to have the corresponding 4999 ; ESEARCH return data. 5001 search-return-data = "MIN" SP nz-number / 5002 "MAX" SP nz-number / 5003 "ALL" SP sequence-set / 5004 "COUNT" SP number / 5005 search-ret-data-ext 5006 ; All return data items conform to search-ret-data-ext 5007 ; syntax 5009 search-return-opts = SP "RETURN" SP "(" [search-return-opt 5010 *(SP search-return-opt)] ")" 5012 search-return-opt = "MIN" / "MAX" / "ALL" / "COUNT" / 5013 search-ret-opt-ext 5014 ; conforms to generic search-ret-opt-ext 5015 ; syntax 5017 search-ret-opt-ext = search-modifier-name [SP search-mod-params] 5019 search-return-value = tagged-ext-val 5020 ; Data for the returned search option. 5021 ; A single "nz-number"/"number"/"number64" value 5022 ; can be returned as an atom (i.e., without 5023 ; quoting). A sequence-set can be returned 5024 ; as an atom as well. 5026 section = "[" [section-spec] "]" 5028 section-msgtext = "HEADER" / "HEADER.FIELDS" [".NOT"] SP header-list / 5029 "TEXT" 5030 ; top-level or MESSAGE/RFC822 part 5032 section-part = nz-number *("." nz-number) 5033 ; body part reference. 5034 ; Allows for accessing nested body parts. 5036 section-spec = section-msgtext / (section-part ["." section-text]) 5038 section-text = section-msgtext / "MIME" 5039 ; text other than actual body part (headers, etc.) 5041 select = "SELECT" SP mailbox 5043 seq-number = nz-number / "*" 5044 ; message sequence number (COPY, FETCH, STORE 5045 ; commands) or unique identifier (UID COPY, 5046 ; UID FETCH, UID STORE commands). 5047 ; * represents the largest number in use. In 5048 ; the case of message sequence numbers, it is 5049 ; the number of messages in a non-empty mailbox. 5050 ; In the case of unique identifiers, it is the 5051 ; unique identifier of the last message in the 5052 ; mailbox or, if the mailbox is empty, the 5053 ; mailbox's current UIDNEXT value. 5054 ; The server should respond with a tagged BAD 5055 ; response to a command that uses a message 5056 ; sequence number greater than the number of 5057 ; messages in the selected mailbox. This 5058 ; includes "*" if the selected mailbox is empty. 5060 seq-range = seq-number ":" seq-number 5061 ; two seq-number values and all values between 5062 ; these two regardless of order. 5063 ; Example: 2:4 and 4:2 are equivalent and indicate 5064 ; values 2, 3, and 4. 5065 ; Example: a unique identifier sequence range of 5066 ; 3291:* includes the UID of the last message in 5067 ; the mailbox, even if that value is less than 3291. 5069 sequence-set = (seq-number / seq-range) ["," sequence-set] 5070 ; set of seq-number values, regardless of order. 5071 ; Servers MAY coalesce overlaps and/or execute the 5072 ; sequence in any order. 5073 ; Example: a message sequence number set of 5074 ; 2,4:7,9,12:* for a mailbox with 15 messages is 5075 ; equivalent to 2,4,5,6,7,9,12,13,14,15 5076 ; Example: a message sequence number set of *:4,5:7 5077 ; for a mailbox with 10 messages is equivalent to 5078 ; 10,9,8,7,6,5,4,5,6,7 and MAY be reordered and 5079 ; overlap coalesced to be 4,5,6,7,8,9,10. 5081 status = "STATUS" SP mailbox SP 5082 "(" status-att *(SP status-att) ")" 5084 status-att = "MESSAGES" / "RECENT" / "UIDNEXT" / "UIDVALIDITY" / 5085 "UNSEEN" 5087 status-att-val = ("MESSAGES" SP number) / ("RECENT" SP number) / 5088 ("UIDNEXT" SP nz-number) / ("UIDVALIDITY" SP nz-number) / 5089 ("UNSEEN" SP number) 5090 ; Extensions to the STATUS responses 5091 ; should extend this production. 5092 ; Extensions should use the generic 5093 ; syntax defined by tagged-ext. 5095 status-att-list = status-att-val *(SP status-att-val) 5097 store = "STORE" SP sequence-set SP store-att-flags 5099 store-att-flags = (["+" / "-"] "FLAGS" [".SILENT"]) SP 5100 (flag-list / (flag *(SP flag))) 5102 string = quoted / literal 5104 subscribe = "SUBSCRIBE" SP mailbox 5106 tag = 1* 5108 tagged-ext-label = tagged-label-fchar *tagged-label-char 5109 ;; Is a valid RFC 3501 "atom". 5111 tagged-label-fchar = ALPHA / "-" / "_" / "." 5113 tagged-label-char = tagged-label-fchar / DIGIT / ":" 5115 tagged-ext-comp = astring / 5116 tagged-ext-comp *(SP tagged-ext-comp) / 5117 "(" tagged-ext-comp ")" 5118 ;; Extensions that follow this general 5119 ;; syntax should use nstring instead of 5120 ;; astring when appropriate in the context 5121 ;; of the extension. 5122 ;; Note that a message set or a "number" 5123 ;; can always be represented as an "atom". 5124 ;; An URL should be represented as 5125 ;; a "quoted" string. 5127 tagged-ext-simple = sequence-set / number / number64 5129 tagged-ext-val = tagged-ext-simple / 5130 "(" [tagged-ext-comp] ")" 5132 text = 1*TEXT-CHAR 5134 TEXT-CHAR = 5135 time = 2DIGIT ":" 2DIGIT ":" 2DIGIT 5136 ; Hours minutes seconds 5138 uid = "UID" SP (copy / fetch / search / store / uid-expunge) 5139 ; Unique identifiers used instead of message 5140 ; sequence numbers 5142 uid-expunge = "EXPUNGE" SP sequence-set 5143 ; Unique identifiers used instead of message 5144 ; sequence numbers 5146 uid-set = (uniqueid / uid-range) *("," uid-set) 5148 uid-range = (uniqueid ":" uniqueid) 5149 ; two uniqueid values and all values 5150 ; between these two regards of order. 5151 ; Example: 2:4 and 4:2 are equivalent. 5153 uniqueid = nz-number 5154 ; Strictly ascending 5156 unsubscribe = "UNSUBSCRIBE" SP mailbox 5158 userid = astring 5160 x-command = "X" atom 5162 zone = ("+" / "-") 4DIGIT 5163 ; Signed four-digit value of hhmm representing 5164 ; hours and minutes east of Greenwich (that is, 5165 ; the amount that the given time differs from 5166 ; Universal Time). Subtracting the timezone 5167 ; from the given time will give the UT form. 5168 ; The Universal Time zone is "+0000". 5170 10. Author's Note 5172 This document is a revision or rewrite of earlier documents, and 5173 supercedes the protocol specification in those documents: RFC 2060, 5174 RFC 1730, unpublished IMAP2bis.TXT document, RFC 1176, and RFC 1064. 5176 11. Security Considerations 5178 IMAP4rev2 protocol transactions, including electronic mail data, are 5179 sent in the clear over the network unless protection from snooping is 5180 negotiated. This can be accomplished either by the use of IMAPS 5181 service, STARTTLS command, negotiated privacy protection in the 5182 AUTHENTICATE command, or some other protection mechanism. 5184 11.1. STARTTLS Security Considerations 5186 IMAP client and server implementations MUST comply with relevant TLS 5187 recommendations from [RFC8314]. Additionally, when using TLS 1.2, 5188 IMAP implementations MUST implement 5189 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 cipher suite, and SHOULD 5190 implement the TLS_RSA_WITH_AES_128_CBC_SHA [TLS] cipher suite. This 5191 is important as it assures that any two compliant implementations can 5192 be configured to interoperate. Other TLS cipher suites recommended 5193 in RFC 7525 are RECOMMENDED: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 5194 TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 and 5195 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384. All other cipher suites are 5196 OPTIONAL. Note that this is a change from section 2.1 of [IMAP-TLS]. 5198 During the [TLS] negotiation, the client MUST check its understanding 5199 of the server hostname against the server's identity as presented in 5200 the server Certificate message, in order to prevent man-in-the-middle 5201 attacks. This procedure is described in [RFC7817]. 5203 Both the client and server MUST check the result of the STARTTLS 5204 command and subsequent [TLS] negotiation to see whether acceptable 5205 authentication and/or privacy was achieved. 5207 11.2. COPYUID and APPENDUID response codes 5209 The COPYUID and APPENDUID response codes return information about the 5210 mailbox, which may be considered sensitive if the mailbox has 5211 permissions set that permit the client to COPY or APPEND to the 5212 mailbox, but not SELECT or EXAMINE it. 5214 Consequently, these response codes SHOULD NOT be issued if the client 5215 does not have access to SELECT or EXAMINE the mailbox. 5217 11.3. Other Security Considerations 5219 A server error message for an AUTHENTICATE command which fails due to 5220 invalid credentials SHOULD NOT detail why the credentials are 5221 invalid. 5223 Use of the LOGIN command sends passwords in the clear. This can be 5224 avoided by using the AUTHENTICATE command with a [SASL] mechanism 5225 that does not use plaintext passwords, by first negotiating 5226 encryption via STARTTLS or some other protection mechanism. 5228 A server implementation MUST implement a configuration that, at the 5229 time of authentication, requires: 5230 (1) The STARTTLS command has been negotiated. 5231 OR 5232 (2) Some other mechanism that protects the session from password 5233 snooping has been provided. 5234 OR 5235 (3) The following measures are in place: 5236 (a) The LOGINDISABLED capability is advertised, and [SASL] mechanisms 5237 (such as PLAIN) using plaintext passwords are NOT advertised in the 5238 CAPABILITY list. 5239 AND 5240 (b) The LOGIN command returns an error even if the password is 5241 correct. 5242 AND 5243 (c) The AUTHENTICATE command returns an error with all [SASL] 5244 mechanisms that use plaintext passwords, even if the password is 5245 correct. 5247 A server error message for a failing LOGIN command SHOULD NOT specify 5248 that the user name, as opposed to the password, is invalid. 5250 A server SHOULD have mechanisms in place to limit or delay failed 5251 AUTHENTICATE/LOGIN attempts. 5253 Additional security considerations are discussed in the section 5254 discussing the AUTHENTICATE and LOGIN commands. 5256 12. IANA Considerations 5258 IANA is requested to update "Service Names and Transport Protocol 5259 Port Numbers" registry as follows: 5261 1. Registration for TCP "imap" port 143 should be updated to point 5262 to this document and RFC 3501. 5264 2. Registration for TCP "imaps" port 993 should be updated to point 5265 to this document and RFC 3501. 5267 3. Both UDP port 143 and UDP port 993 should be marked as "Reserved" 5268 in the registry. 5270 Additional IANA actions are specified in subsection of this section. 5272 12.1. Updates to IMAP4 Capabilities registry 5274 IMAP4 capabilities are registered by publishing a standards track or 5275 IESG approved informational or experimental RFC. The registry is 5276 currently located at: http://www.iana.org/assignments/ 5277 imap4-capabilities 5278 As this specification revises the STARTTLS and LOGINDISABLED 5279 extensions previously defined in [IMAP-TLS], IANA is requested to 5280 update registry entries for these 2 extensions to point to this 5281 document. 5283 12.2. GSSAPI/SASL service name 5285 GSSAPI/Kerberos/SASL service names are registered by publishing a 5286 standards track or IESG approved experimental RFC. The registry is 5287 currently located at: http://www.iana.org/assignments/gssapi-service- 5288 names 5290 IANA is requested to update the "imap" service name previously 5291 registered in RFC 3501, to point to this document. 5293 13. References 5295 13.1. Normative References 5297 [ABNF] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 5298 Specifications: ABNF", STD 68, RFC 5234, January 2008, 5299 . 5301 [ANONYMOUS] 5302 Zeilenga, K., "Anonymous Simple Authentication and 5303 Security Layer (SASL) Mechanism", RFC 4505, June 2006, 5304 . 5306 [CHARSET] Freed, N. and J. Postel, "IANA Charset Registration 5307 Procedures", BCP 19, RFC 2978, October 2000, 5308 . 5310 [DIGEST-MD5] 5311 Leach, P. and C. Newman, "Using Digest Authentication as a 5312 SASL Mechanism", RFC 2831, May 2000, 5313 . 5315 [DISPOSITION] 5316 Troost, R., Dorner, S., and K. Moore, Ed., "Communicating 5317 Presentation Information in Internet Messages: The 5318 Content-Disposition Header Field", RFC 2183, August 1997, 5319 . 5321 [PLAIN] Zeilenga, K., Ed., "The PLAIN Simple Authentication and 5322 Security Layer (SASL) Mechanism", RFC 4616, August 2006, 5323 . 5325 [KEYWORDS] 5326 Bradner, S., "Key words for use in RFCs to Indicate 5327 Requirement Levels", BCP 14, RFC 2119, March 1997, 5328 . 5330 [LANGUAGE-TAGS] 5331 Alvestrand, H., "Content Language Headers", RFC 3282, May 5332 2002, . 5334 [LOCATION] 5335 Palme, J., Hopmann, A., and N. Shelness, "MIME 5336 Encapsulation of Aggregate Documents, such as HTML 5337 (MHTML)", RFC 2557, March 1999, 5338 . 5340 [MD5] Myers, J. and M. Rose, "The Content-MD5 Header Field", 5341 RFC 1864, October 1995, 5342 . 5344 [MIME-HDRS] 5345 Moore, K., "MIME (Multipurpose Internet Mail Extensions) 5346 Part Three: Message Header Extensions for Non-ASCII Text", 5347 RFC 2047, November 1996, 5348 . 5350 [MIME-IMB] 5351 Freed, N. and N. Borenstein, "Multipurpose Internet Mail 5352 Extensions (MIME) Part One: Format of Internet Message 5353 Bodies", RFC 2045, November 1996, 5354 . 5356 [MIME-IMT] 5357 Freed, N. and N. Borenstein, "Multipurpose Internet Mail 5358 Extensions (MIME) Part Two: Media Types", RFC 2046, 5359 November 1996, . 5361 [RFC-5322] 5362 Resnick, P., Ed., "Internet Message Format", RFC 5322, 5363 October 2008, . 5365 [SASL] Melnikov, A., Ed. and K. Zeilenga, Ed., "Simple 5366 Authentication and Security Layer (SASL)", RFC 4422, June 5367 2006, . 5369 [TLS] Dierks, T. and E. Rescorla, "The Transport Layer Security 5370 (TLS) Protocol Version 1.2", RFC 5246, August 2008, 5371 . 5373 [UTF-7] Goldsmith, D. and M. Davis, "UTF-7 A Mail-Safe 5374 Transformation Format of Unicode", RFC 2152, May 1997, 5375 . 5377 [MULTIAPPEND] 5378 Crispin, M., "Internet Message Access Protocol (IMAP) - 5379 MULTIAPPEND Extension", RFC 3502, March 2003, 5380 . 5382 [IMAP-IMPLEMENTATION] 5383 Leiba, B., "IMAP4 Implementation Recommendations", 5384 RFC 2683, September 1999, 5385 . 5387 [IMAP-MULTIACCESS] 5388 Gahrns, M., "IMAP4 Multi-Accessed Mailbox Practice", 5389 RFC 2180, July 1997, 5390 . 5392 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 5393 Encodings", RFC 4648, DOI 10.17487/RFC4648, October 2006, 5394 . 5396 [RFC7817] Melnikov, A., "Updated Transport Layer Security (TLS) 5397 Server Identity Check Procedure for Email-Related 5398 Protocols", RFC 7817, DOI 10.17487/RFC7817, March 2016, 5399 . 5401 [RFC8314] Moore, K. and C. Newman, "Cleartext Considered Obsolete: 5402 Use of Transport Layer Security (TLS) for Email Submission 5403 and Access", RFC 8314, DOI 10.17487/RFC8314, January 2018, 5404 . 5406 13.2. Informative References (related protocols) 5408 [IMAP-DISC] 5409 Melnikov, A., Ed., "Synchronization Operations for 5410 Disconnected IMAP4 Clients", RFC 4549, June 2006, 5411 . 5413 [IMAP-MODEL] 5414 Crispin, M., "Distributed Electronic Mail Models in 5415 IMAP4", RFC 1733, December 1994, 5416 . 5418 [ACAP] Newman, C. and J. G. Myers, "ACAP -- Application 5419 Configuration Access Protocol", RFC 2244, November 1997, 5420 . 5422 [SMTP] Klensin, J., "Simple Mail Transfer Protocol", RFC 5321, 5423 October 2008, . 5425 [RFC4314] Melnikov, A., "IMAP4 Access Control List (ACL) Extension", 5426 RFC 4314, December 2005, 5427 . 5429 [RFC2087] Myers, J., "IMAP4 QUOTA extension", RFC 2087, January 5430 1997, . 5432 [IMAP-URL] 5433 Melnikov, A., Ed. and C. Newman, "IMAP URL Scheme", 5434 RFC 5092, DOI 10.17487/RFC5092, November 2007, 5435 . 5437 13.3. Informative References (historical aspects of IMAP and related 5438 protocols) 5440 [IMAP-COMPAT] 5441 Crispin, M., "IMAP4 Compatibility with IMAP2bis", 5442 RFC 2061, December 1996, 5443 . 5445 [IMAP-HISTORICAL] 5446 Crispin, M., "IMAP4 Compatibility with IMAP2 and 5447 IMAP2bis", RFC 1732, December 1994, 5448 . 5450 [IMAP-OBSOLETE] 5451 Crispin, M., "Internet Message Access Protocol - Obsolete 5452 Syntax", RFC 2062, December 1996, 5453 . 5455 [IMAP2] Crispin, M., "Interactive Mail Access Protocol: Version 5456 2", RFC 1176, August 1990, 5457 . 5459 [RFC-822] Crocker, D., "STANDARD FOR THE FORMAT OF ARPA INTERNET 5460 TEXT MESSAGES", STD 11, RFC 822, August 1982, 5461 . 5463 [RFC-821] Postel, J., "Simple Mail Transfer Protocol", STD 10, 5464 RFC 821, August 1982, 5465 . 5467 [IMAP-TLS] 5468 Newman, C., "Using TLS with IMAP, POP3 and ACAP", 5469 RFC 2595, June 1999, 5470 . 5472 Appendix A. Backward compatibility with IMAP4rev1 5474 An implementation that wants to remain compatible with IMAP4rev1 can 5475 advertise both IMAP4rev1 and IMAP4rev2 in its CAPABILITY response/ 5476 response code. While some IMAP4rev1 response were removed in 5477 IMAP4rev2, their presence will not break IMAP4rev2-only clients. 5479 If both IMAP4rev1 and IMAP4rev2 are advertised, an IMAP client that 5480 wants to use IMAP4rev2 MUST issue "ENABLE IMAP4rev2" command. 5482 Appendix B. Changes from RFC 3501 / IMAP4rev1 5484 The following is the plan for remaining changes. The plan might 5485 change over time. 5487 1. Fold in the following extensions/RFC: RFC 5530 (IMAP Response 5488 Codes, done), UIDPLUS (done), ENABLE (done), ESEARCH (done), 5489 SPECIAL-USE (list of new mailbox attributes is done), LITERAL-, 5490 NAMESPACE (done), SASL-IR (done). 5492 2. Add CLOSED response code (from CONDSTORE) - done 5494 3. Add support for $MDNSent and $Forwarded IMAP keywords - done. 5495 Add more examples showing their use? 5497 4. Require all unsolicited updates to include UID (?) 5499 5. Update recommendations on TLS ciphers to match UTA WG work (as 5500 per RFC 8314, RFC 7525 and RFC 7817) - done. 5502 6. Possibly fold in the following extensions/RFC: Base LIST- 5503 EXTENDED syntax + deprecate LSUB (replace it with LIST 5504 \Subscribed) - multiple list patterns, STATUS-in-LIST, Unique 5505 mailstore IDs for messages (a la Gmail and Cyrus) - if there is 5506 an implemented draft by the time this effort finishes, IDLE 5507 (done), SEARCHRES, BINARY. 5509 7. Add STATUS SIZE (total mailbox size)? STATUS DELETED (number of 5510 messages with \Deleted flag set)? 5512 8. Deprecate features: RECENT response on SELECT/EXAMINE, \Recent 5513 flag, RECENT STATUS item. UNSEEN response code on SELECT/ 5514 EXAMINE. SEARCH response (use ESEARCH instead). 5516 9. Drop UTF-7, all mailboxes are always in UTF-8. 5518 10. Revise IANA registration of IMAP extensions and advice on use of 5519 "X-" convention. 5521 The following changes since RFC 3501 were done so far: 5523 1. Folded in IMAP UNSELECT (RFC 3691), UIDPLUS (RFC 4315), ESEARCH 5524 (RFC 4731), ENABLE (RFC 5161), IDLE (RFC 2177) and SASL-IR (RFC 5525 4959) extensions. Also folded RFC 5530. 5527 2. Added CLOSED response code from RFC 7162. 5529 3. Updated to use modern TLS-related recommendations as per RFC 5530 8314, RFC 7817, RFC 7525. 5532 4. For future extensibility extended ABNF for tagged-ext-simple to 5533 allow for bare number64. 5535 5. Add SHOULD level requirement on IMAP servers to support $MDNSent 5536 and $Forwarded keywords. 5538 Appendix C. Acknowledgement 5540 Earlier versions of this document were edited by Mark Crispin. 5541 Sadly, he is no longer available to help with this work. Editor of 5542 this revisions is hoping that Mark would have approved. 5544 Thank you to Tony Hansen for helping with the index generation. 5546 This document incorporate text from RFC 4315, RFC 4466, RFC 4731, RFC 5547 5161, RFC 6154 so work done by authors/editors of these documents is 5548 appreciated. 5550 Index 5552 $ 5553 $Forwarded (predefined flag) 12 5554 $MDNSent (predefined flag) 12 5556 + 5557 +FLAGS 68 5558 +FLAGS.SILENT 68 5560 - 5561 -FLAGS 68 5562 -FLAGS.SILENT 68 5564 A 5565 ALERT (response code) 74 5566 ALL (fetch item) 64 5567 ALL (search key) 61 5568 ALL (search result option) 60 5569 ALREADYEXISTS (response code) 74 5570 ANSWERED (search key) 61 5571 APPEND (command) 52 5572 APPENDUID (response code) 74 5573 AUTHENTICATE (command) 28 5574 AUTHENTICATIONFAILED (response code) 74 5575 AUTHORIZATIONFAILED (response code) 75 5577 B 5578 BAD (response) 81 5579 BADCHARSET (response code) 75 5580 BCC (search key) 61 5581 BEFORE (search key) 61 5582 BODY (fetch item) 65 5583 BODY (fetch result) 91 5584 BODY (search key) 61 5585 BODY.PEEK[
]<> (fetch item) 67 5586 BODYSTRUCTURE (fetch item) 67 5587 BODYSTRUCTURE (fetch result) 91 5588 BODY[
]<> (fetch result) 91 5589 BODY[
]<> (fetch item) 65 5590 BYE (response) 82 5591 Body Structure (message attribute) 13 5593 C 5594 CANNOT (response code) 75 5595 CAPABILITY (command) 25 5596 CAPABILITY (response code) 75 5597 CAPABILITY (response) 83 5598 CC (search key) 61 5599 CHECK (command) 56 5600 CLIENTBUG (response code) 75 5601 CLOSE (command) 57 5602 CLOSED (response code) 76 5603 CONTACTADMIN (response code) 76 5604 COPY (command) 69 5605 COPYUID (response code) 76 5606 CORRUPTION (response code) 77 5607 COUNT (search result option) 60 5608 CREATE (command) 37 5610 D 5611 DELETE (command) 38 5612 DELETED (search key) 61 5613 DRAFT (search key) 61 5615 E 5616 ENABLE (command) 32 5617 ENVELOPE (fetch item) 67 5618 ENVELOPE (fetch result) 94 5619 ESEARCH (response) 88 5620 EXAMINE (command) 36 5621 EXPIRED (response code) 77 5622 EXPUNGE (command) 58 5623 EXPUNGE (response) 90 5624 EXPUNGEISSUED (response code) 77 5625 Envelope Structure (message attribute) 13 5627 F 5628 FAST (fetch item) 64 5629 FETCH (command) 64 5630 FETCH (response) 91 5631 FLAGGED (search key) 61 5632 FLAGS (fetch item) 67 5633 FLAGS (fetch result) 95 5634 FLAGS (response) 88 5635 FLAGS (store command data item) 68 5636 FLAGS.SILENT (store command data item) 68 5637 FROM (search key) 61 5638 FULL (fetch item) 65 5639 Flags (message attribute) 11 5641 H 5642 HEADER (part specifier) 65 5643 HEADER (search key) 61 5644 HEADER.FIELDS (part specifier) 65 5645 HEADER.FIELDS.NOT (part specifier) 65 5647 I 5648 IDLE (command) 54 5649 INTERNALDATE (fetch item) 67 5650 INTERNALDATE (fetch result) 95 5651 INUSE (response code) 77 5652 Internal Date (message attribute) 13 5654 K 5655 KEYWORD (search key) 61 5656 Keyword (type of flag) 12 5658 L 5659 LARGER (search key) 62 5660 LIMIT (response code) 77 5661 LIST (command) 42 5662 LIST (response) 84 5663 LOGOUT (command) 26 5664 LSUB (command) 45 5665 LSUB (response) 87 5667 M 5668 MAX (search result option) 59 5669 MAY (specification requirement term) 5 5670 MESSAGES (status item) 51 5671 MIME (part specifier) 66 5672 MIN (search result option) 59 5673 MUST (specification requirement term) 5 5674 MUST NOT (specification requirement term) 5 5675 Message Sequence Number (message attribute) 11 5677 N 5678 NAMESPACE (command) 46 5679 NAMESPACE (response) 87 5680 NEW (search key) 62 5681 NO (response) 81 5682 NONEXISTENT (response code) 78 5683 NOOP (command) 26 5684 NOPERM (response code) 78 5685 NOT (search key) 62 5687 O 5688 OK (response) 80 5689 OLD (search key) 62 5690 ON (search key) 62 5691 OPTIONAL (specification requirement term) 5 5692 OR (search key) 62 5693 OVERQUOTA (response code) 78 5695 P 5696 PARSE (response code) 78 5697 PERMANENTFLAGS (response code) 78 5698 PREAUTH (response) 82 5699 PRIVACYREQUIRED (response code) 79 5700 Permanent Flag (class of flag) 12 5701 Predefined keywords 12 5703 R 5704 READ-ONLY (response code) 79 5705 READ-WRITE (response code) 79 5706 RECENT (search key) 62 5707 RECENT (status item) 51 5708 RECOMMENDED (specification requirement term) 5 5709 RENAME (command) 39 5710 REQUIRED (specification requirement term) 5 5711 RFC822 (fetch item) 67 5712 RFC822 (fetch result) 95 5713 RFC822.HEADER (fetch item) 67 5714 RFC822.HEADER (fetch result) 95 5715 RFC822.SIZE (fetch item) 67 5716 RFC822.SIZE (fetch result) 95 5717 RFC822.TEXT (fetch item) 67 5718 RFC822.TEXT (fetch result) 95 5720 S 5721 SEARCH (command) 59 5722 SEEN (search key) 62 5723 SELECT (command) 34 5724 SENTBEFORE (search key) 62 5725 SENTON (search key) 62 5726 SENTSINCE (search key) 62 5727 SERVERBUG (response code) 79 5728 SHOULD (specification requirement term) 5 5729 SHOULD NOT (specification requirement term) 5 5730 SINCE (search key) 62 5731 SMALLER (search key) 62 5732 STARTTLS (command) 27 5733 STATUS (command) 50 5734 STATUS (response) 87 5735 STORE (command) 67 5736 SUBJECT (search key) 62 5737 SUBSCRIBE (command) 41 5738 Session Flag (class of flag) 12 5739 System Flag (type of flag) 11 5741 T 5742 TEXT (part specifier) 65 5743 TEXT (search key) 62 5744 TO (search key) 62 5745 TRYCREATE (response code) 79 5747 U 5748 UID (command) 70 5749 UID (fetch item) 67 5750 UID (fetch result) 95 5751 UID (search key) 63 5752 UIDNEXT (response code) 79 5753 UIDNEXT (status item) 51 5754 UIDNOTSTICKY (response code) 79 5755 UIDVALIDITY (response code) 80 5756 UIDVALIDITY (status item) 51 5757 UNANSWERED (search key) 63 5758 UNAVAILABLE (response code) 80 5759 UNDELETED (search key) 63 5760 UNDRAFT (search key) 63 5761 UNFLAGGED (search key) 63 5762 UNKEYWORD (search key) 63 5763 UNSEEN (response code) 80 5764 UNSEEN (search key) 63 5765 UNSEEN (status item) 52 5766 UNSELECT (command) 58 5767 UNSUBSCRIBE (command) 42 5768 Unique Identifier (UID) (message attribute) 9 5770 X 5771 X (command) 72 5773 [ 5774 [RFC-5322] Size (message attribute) 13 5776 \ 5777 \All (mailbox name attribute) 85 5778 \Answered (system flag) 11 5779 \Archive (mailbox name attribute) 85 5780 \Deleted (system flag) 11 5781 \Draft (system flag) 12 5782 \Drafts (mailbox name attribute) 85 5783 \Flagged (mailbox name attribute) 86 5784 \Flagged (system flag) 11 5785 \HasChildren (mailbox name attribute) 84 5786 \HasNoChildren (mailbox name attribute) 85 5787 \Junk (mailbox name attribute) 86 5788 \Marked (mailbox name attribute) 85 5789 \Noinferiors (mailbox name attribute) 84 5790 \Noselect (mailbox name attribute) 84 5791 \Recent (system flag) 12 5792 \Seen (system flag) 11 5793 \Sent (mailbox name attribute) 86 5794 \Trash (mailbox name attribute) 86 5795 \Unmarked (mailbox name attribute) 85 5797 Author's Address 5798 Alexey Melnikov (editor) 5799 Isode Ltd 5800 14 Castle Mews 5801 Hampton, Middlesex TW12 2NP 5802 UK 5804 Email: Alexey.Melnikov@isode.com