idnits 2.17.00 (12 Aug 2021) /tmp/idnits7838/draft-ietf-extra-imap4rev2-29.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 6 instances of too long lines in the document, the longest one being 6 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 (February 13, 2021) is 461 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: 'RFC3501' is mentioned on line 7427, but not defined ** Obsolete undefined reference: RFC 3501 (Obsoleted by RFC 9051) == Missing Reference: 'IMAP2' is mentioned on line 7452, but not defined == Missing Reference: 'IMAP2BIS' is mentioned on line 7441, but not defined == Missing Reference: 'IMAP-OBSOLETE' is mentioned on line 7447, but not defined == Missing Reference: 'IMAP-COMPAT' is mentioned on line 7431, but not defined == Missing Reference: 'IMAP-HISTORICAL' is mentioned on line 7436, but not defined == Missing Reference: 'RFC-822' is mentioned on line 7456, but not defined ** Obsolete undefined reference: RFC 822 (Obsoleted by RFC 2822) == Missing Reference: 'IMAP-MODEL' is mentioned on line 7355, but not defined == Missing Reference: 'IMAP-DISC' is mentioned on line 7344, but not defined == Missing Reference: 'IMAP-KEYWORDS-REG' is mentioned on line 7409, but not defined == Missing Reference: 'SMTP' is mentioned on line 7370, but not defined == Missing Reference: 'RFC7888' is mentioned on line 7336, but not defined -- Looks like a reference, but probably isn't: '1' on line 911 == Missing Reference: 'IMAP-URL' is mentioned on line 7384, but not defined == Missing Reference: 'TLS' is mentioned on line 1521, but not defined == Missing Reference: 'ANONYMOUS' is mentioned on line 7365, but not defined == Missing Reference: 'CERT-555316' is mentioned on line 7297, but not defined == Missing Reference: 'RFC7162' is mentioned on line 7716, but not defined == Missing Reference: 'UIDVALIDITY 3857529045' is mentioned on line 3373, but not defined == Missing Reference: 'UIDNEXT 4392' is mentioned on line 1815, but not defined == Missing Reference: 'RFC2193' is mentioned on line 7307, but not defined == Missing Reference: 'RFC3348' is mentioned on line 7748, but not defined ** Obsolete undefined reference: RFC 3348 (Obsoleted by RFC 5258) == Missing Reference: 'RFC4314' is mentioned on line 7377, but not defined == Missing Reference: 'UIDNEXT 2' is mentioned on line 3374, but not defined == Missing Reference: 'UIDVALIDITY 1' is mentioned on line 3446, but not defined == Missing Reference: 'UIDNEXT 1' is mentioned on line 3447, but not defined == Missing Reference: 'CHARSET-REG' is mentioned on line 7419, but not defined == Missing Reference: 'IMAP-I18N' is mentioned on line 7349, but not defined == Missing Reference: 'HEADER' is mentioned on line 3983, but not defined == Missing Reference: 'BADCHARSET UTF-8' is mentioned on line 4033, but not defined == Missing Reference: 'UID' is mentioned on line 4456, but not defined == Missing Reference: 'RFC2087' is mentioned on line 7381, but not defined ** Obsolete undefined reference: RFC 2087 (Obsoleted by RFC 9208) == Missing Reference: 'IMAP-MAILBOX-NAME-ATTRS-REG' is mentioned on line 7414, but not defined == Missing Reference: 'RFC4422' is mentioned on line 6344, but not defined == Missing Reference: 'IMAP4' is mentioned on line 6433, but not defined == Missing Reference: 'IMAP-TLS' is mentioned on line 7460, but not defined == Missing Reference: 'RFC6186' is mentioned on line 7325, but not defined == Missing Reference: 'RFC8305' is mentioned on line 7389, but not defined == Missing Reference: 'RFC6151' is mentioned on line 7302, but not defined == Missing Reference: 'RFC6376' is mentioned on line 7394, but not defined == Missing Reference: 'RFC8550' is mentioned on line 7399, but not defined == Missing Reference: 'RFCXXXX' is mentioned on line 7119, but not defined == Missing Reference: 'RFC5465' is mentioned on line 7321, but not defined == Missing Reference: 'RFC5256' is mentioned on line 7316, but not defined == Missing Reference: 'RFC8474' is mentioned on line 7720, but not defined == Missing Reference: 'IMAP-UTF-8' is mentioned on line 7480, but not defined == Missing Reference: 'RFC3516' is mentioned on line 7576, but not defined == Missing Reference: 'RFC8551' is mentioned on line 7404, but not defined ** Downref: Normative reference to an Informational RFC: RFC 2152 (ref. 'UTF-7') ** Downref: Normative reference to an Informational RFC: RFC 2683 (ref. 'IMAP-IMPLEMENTATION') ** Downref: Normative reference to an Informational RFC: RFC 2180 (ref. 'IMAP-MULTIACCESS') Summary: 9 errors (**), 0 flaws (~~), 49 warnings (==), 4 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group A. Melnikov, Ed. 3 Internet-Draft Isode Ltd 4 Obsoletes: 3501 (if approved) B. Leiba, Ed. 5 Intended status: Standards Track Futurewei Technologies 6 Expires: August 17, 2021 February 13, 2021 8 Internet Message Access Protocol (IMAP) - Version 4rev2 9 draft-ietf-extra-imap4rev2-29 11 Abstract 13 The Internet Message Access Protocol, Version 4rev2 (IMAP4rev2) 14 allows a client to access and manipulate electronic mail messages on 15 a server. IMAP4rev2 permits manipulation of mailboxes (remote 16 message folders) in a way that is functionally equivalent to local 17 folders. IMAP4rev2 also provides the capability for an offline 18 client to resynchronize with the server. 20 IMAP4rev2 includes operations for creating, deleting, and renaming 21 mailboxes, checking for new messages, permanently removing messages, 22 setting and clearing flags, RFC 5322, RFC 2045 and RFC 2231 parsing, 23 searching, and selective fetching of message attributes, texts, and 24 portions thereof. Messages in IMAP4rev2 are accessed by the use of 25 numbers. These numbers are either message sequence numbers or unique 26 identifiers. 28 IMAP4rev2 does not specify a means of posting mail; this function is 29 handled by a mail submission protocol such as the one specified in 30 RFC 6409. 32 Status of This Memo 34 This Internet-Draft is submitted in full conformance with the 35 provisions of BCP 78 and BCP 79. 37 Internet-Drafts are working documents of the Internet Engineering 38 Task Force (IETF). Note that other groups may also distribute 39 working documents as Internet-Drafts. The list of current Internet- 40 Drafts is at https://datatracker.ietf.org/drafts/current/. 42 Internet-Drafts are draft documents valid for a maximum of six months 43 and may be updated, replaced, or obsoleted by other documents at any 44 time. It is inappropriate to use Internet-Drafts as reference 45 material or to cite them other than as "work in progress." 47 This Internet-Draft will expire on August 17, 2021. 49 Copyright Notice 51 Copyright (c) 2021 IETF Trust and the persons identified as the 52 document authors. All rights reserved. 54 This document is subject to BCP 78 and the IETF Trust's Legal 55 Provisions Relating to IETF Documents 56 (https://trustee.ietf.org/license-info) in effect on the date of 57 publication of this document. Please review these documents 58 carefully, as they describe your rights and restrictions with respect 59 to this document. Code Components extracted from this document must 60 include Simplified BSD License text as described in Section 4.e of 61 the Trust Legal Provisions and are provided without warranty as 62 described in the Simplified BSD License. 64 This document may contain material from IETF Documents or IETF 65 Contributions published or made publicly available before November 66 10, 2008. The person(s) controlling the copyright in some of this 67 material may not have granted the IETF Trust the right to allow 68 modifications of such material outside the IETF Standards Process. 69 Without obtaining an adequate license from the person(s) controlling 70 the copyright in such materials, this document may not be modified 71 outside the IETF Standards Process, and derivative works of it may 72 not be created outside the IETF Standards Process, except to format 73 it for publication as an RFC or to translate it into languages other 74 than English. 76 Table of Contents 78 1. How to Read This Document . . . . . . . . . . . . . . . . . . 5 79 1.1. Organization of This Document . . . . . . . . . . . . . . 5 80 1.2. Conventions Used in This Document . . . . . . . . . . . . 5 81 1.3. Special Notes to Implementors . . . . . . . . . . . . . . 6 82 2. Protocol Overview . . . . . . . . . . . . . . . . . . . . . . 7 83 2.1. Link Level . . . . . . . . . . . . . . . . . . . . . . . 7 84 2.2. Commands and Responses . . . . . . . . . . . . . . . . . 7 85 2.2.1. Client Protocol Sender and Server Protocol Receiver . 8 86 2.2.2. Server Protocol Sender and Client Protocol Receiver . 8 87 2.3. Message Attributes . . . . . . . . . . . . . . . . . . . 9 88 2.3.1. Message Numbers . . . . . . . . . . . . . . . . . . . 9 89 2.3.2. Flags Message Attribute . . . . . . . . . . . . . . . 12 90 2.3.3. Internal Date Message Attribute . . . . . . . . . . . 14 91 2.3.4. [RFC-5322] Size Message Attribute . . . . . . . . . . 14 92 2.3.5. Envelope Structure Message Attribute . . . . . . . . 14 93 2.3.6. Body Structure Message Attribute . . . . . . . . . . 14 94 2.4. Message Texts . . . . . . . . . . . . . . . . . . . . . . 15 95 3. State and Flow Diagram . . . . . . . . . . . . . . . . . . . 15 96 3.1. Not Authenticated State . . . . . . . . . . . . . . . . . 15 97 3.2. Authenticated State . . . . . . . . . . . . . . . . . . . 15 98 3.3. Selected State . . . . . . . . . . . . . . . . . . . . . 15 99 3.4. Logout State . . . . . . . . . . . . . . . . . . . . . . 15 100 4. Data Formats . . . . . . . . . . . . . . . . . . . . . . . . 18 101 4.1. Atom . . . . . . . . . . . . . . . . . . . . . . . . . . 18 102 4.1.1. Sequence set and UID set . . . . . . . . . . . . . . 18 103 4.2. Number . . . . . . . . . . . . . . . . . . . . . . . . . 18 104 4.3. String . . . . . . . . . . . . . . . . . . . . . . . . . 18 105 4.3.1. 8-bit and Binary Strings . . . . . . . . . . . . . . 19 106 4.4. Parenthesized List . . . . . . . . . . . . . . . . . . . 20 107 4.5. NIL . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 108 5. Operational Considerations . . . . . . . . . . . . . . . . . 21 109 5.1. Mailbox Naming . . . . . . . . . . . . . . . . . . . . . 21 110 5.1.1. Mailbox Hierarchy Naming . . . . . . . . . . . . . . 22 111 5.1.2. Namespaces . . . . . . . . . . . . . . . . . . . . . 22 112 5.2. Mailbox Size and Message Status Updates . . . . . . . . . 24 113 5.3. Response when no Command in Progress . . . . . . . . . . 24 114 5.4. Autologout Timer . . . . . . . . . . . . . . . . . . . . 24 115 5.5. Multiple Commands in Progress (Command Pipelining) . . . 25 116 6. Client Commands . . . . . . . . . . . . . . . . . . . . . . . 26 117 6.1. Client Commands - Any State . . . . . . . . . . . . . . . 27 118 6.1.1. CAPABILITY Command . . . . . . . . . . . . . . . . . 27 119 6.1.2. NOOP Command . . . . . . . . . . . . . . . . . . . . 28 120 6.1.3. LOGOUT Command . . . . . . . . . . . . . . . . . . . 28 121 6.2. Client Commands - Not Authenticated State . . . . . . . . 29 122 6.2.1. STARTTLS Command . . . . . . . . . . . . . . . . . . 29 123 6.2.2. AUTHENTICATE Command . . . . . . . . . . . . . . . . 31 124 6.2.3. LOGIN Command . . . . . . . . . . . . . . . . . . . . 35 125 6.3. Client Commands - Authenticated State . . . . . . . . . . 35 126 6.3.1. ENABLE Command . . . . . . . . . . . . . . . . . . . 36 127 6.3.2. SELECT Command . . . . . . . . . . . . . . . . . . . 38 128 6.3.3. EXAMINE Command . . . . . . . . . . . . . . . . . . . 40 129 6.3.4. CREATE Command . . . . . . . . . . . . . . . . . . . 41 130 6.3.5. DELETE Command . . . . . . . . . . . . . . . . . . . 42 131 6.3.6. RENAME Command . . . . . . . . . . . . . . . . . . . 44 132 6.3.7. SUBSCRIBE Command . . . . . . . . . . . . . . . . . . 47 133 6.3.8. UNSUBSCRIBE Command . . . . . . . . . . . . . . . . . 47 134 6.3.9. LIST Command . . . . . . . . . . . . . . . . . . . . 48 135 6.3.10. NAMESPACE Command . . . . . . . . . . . . . . . . . . 66 136 6.3.11. STATUS Command . . . . . . . . . . . . . . . . . . . 71 137 6.3.12. APPEND Command . . . . . . . . . . . . . . . . . . . 73 138 6.3.13. IDLE Command . . . . . . . . . . . . . . . . . . . . 76 139 6.4. Client Commands - Selected State . . . . . . . . . . . . 77 140 6.4.1. CLOSE Command . . . . . . . . . . . . . . . . . . . . 78 141 6.4.2. UNSELECT Command . . . . . . . . . . . . . . . . . . 78 142 6.4.3. EXPUNGE Command . . . . . . . . . . . . . . . . . . . 79 143 6.4.4. SEARCH Command . . . . . . . . . . . . . . . . . . . 79 144 6.4.5. FETCH Command . . . . . . . . . . . . . . . . . . . . 92 145 6.4.6. STORE Command . . . . . . . . . . . . . . . . . . . . 97 146 6.4.7. COPY Command . . . . . . . . . . . . . . . . . . . . 98 147 6.4.8. MOVE Command . . . . . . . . . . . . . . . . . . . . 99 148 6.4.9. UID Command . . . . . . . . . . . . . . . . . . . . . 101 149 6.5. Client Commands - Experimental/Expansion . . . . . . . . 103 150 7. Server Responses . . . . . . . . . . . . . . . . . . . . . . 103 151 7.1. Server Responses - Generic Status Responses . . . . . . . 104 152 7.1.1. OK Response . . . . . . . . . . . . . . . . . . . . . 113 153 7.1.2. NO Response . . . . . . . . . . . . . . . . . . . . . 113 154 7.1.3. BAD Response . . . . . . . . . . . . . . . . . . . . 113 155 7.1.4. PREAUTH Response . . . . . . . . . . . . . . . . . . 114 156 7.1.5. BYE Response . . . . . . . . . . . . . . . . . . . . 114 157 7.2. Server Responses - Server Status . . . . . . . . . . . . 115 158 7.2.1. ENABLED Response . . . . . . . . . . . . . . . . . . 115 159 7.2.2. CAPABILITY Response . . . . . . . . . . . . . . . . . 115 160 7.3. Server Responses - Mailbox Status . . . . . . . . . . . . 117 161 7.3.1. LIST Response . . . . . . . . . . . . . . . . . . . . 117 162 7.3.2. NAMESPACE Response . . . . . . . . . . . . . . . . . 121 163 7.3.3. STATUS Response . . . . . . . . . . . . . . . . . . . 121 164 7.3.4. ESEARCH Response . . . . . . . . . . . . . . . . . . 121 165 7.3.5. FLAGS Response . . . . . . . . . . . . . . . . . . . 123 166 7.4. Server Responses - Mailbox Size . . . . . . . . . . . . . 123 167 7.4.1. EXISTS Response . . . . . . . . . . . . . . . . . . . 123 168 7.5. Server Responses - Message Status . . . . . . . . . . . . 123 169 7.5.1. EXPUNGE Response . . . . . . . . . . . . . . . . . . 123 170 7.5.2. FETCH Response . . . . . . . . . . . . . . . . . . . 124 171 7.6. Server Responses - Command Continuation Request . . . . . 130 172 8. Sample IMAP4rev2 connection . . . . . . . . . . . . . . . . . 131 173 9. Formal Syntax . . . . . . . . . . . . . . . . . . . . . . . . 132 174 10. Author's Note . . . . . . . . . . . . . . . . . . . . . . . . 150 175 11. Security Considerations . . . . . . . . . . . . . . . . . . . 150 176 11.1. TLS related Security Considerations . . . . . . . . . . 151 177 11.2. STARTTLS command versa use of Implicit TLS port . . . . 151 178 11.3. Client handling of unsolicited responses not suitable 179 for the current connection state . . . . . . . . . . . . 152 180 11.4. COPYUID and APPENDUID response codes . . . . . . . . . . 152 181 11.5. LIST command and Other Users' namespace . . . . . . . . 153 182 11.6. Use of MD5 . . . . . . . . . . . . . . . . . . . . . . . 153 183 11.7. Other Security Considerations . . . . . . . . . . . . . 153 184 12. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 154 185 12.1. Updates to IMAP4 Capabilities registry . . . . . . . . . 154 186 12.2. GSSAPI/SASL service name . . . . . . . . . . . . . . . . 155 187 12.3. LIST Selection Options, LIST Return Options, LIST 188 extended data items . . . . . . . . . . . . . . . . . . 155 189 12.4. IMAP Mailbox Name Attributes and IMAP Response Codes . . 155 190 13. References . . . . . . . . . . . . . . . . . . . . . . . . . 155 191 13.1. Normative References . . . . . . . . . . . . . . . . . . 156 192 13.2. Informative References (related protocols) . . . . . . . 159 193 13.3. Informative References (historical aspects of IMAP and 194 related protocols) . . . . . . . . . . . . . . . . . . . 162 195 Appendix A. Backward compatibility with IMAP4rev1 . . . . . . . 163 196 A.1. Mailbox International Naming Convention for compatibility 197 with IMAP4rev1 . . . . . . . . . . . . . . . . . . . . . 163 198 Appendix B. Backward compatibility with BINARY extension . . . . 165 199 Appendix C. Backward compatibility with LIST-EXTENDED extension 165 200 Appendix D. 63 bit body part and message sizes . . . . . . . . . 165 201 Appendix E. Changes from RFC 3501 / IMAP4rev1 . . . . . . . . . 166 202 Appendix F. Other Recommended IMAP Extensions . . . . . . . . . 168 203 Appendix G. Acknowledgement . . . . . . . . . . . . . . . . . . 168 204 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 205 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 174 207 1. How to Read This Document 209 1.1. Organization of This Document 211 This document is written from the point of view of the implementor of 212 an IMAP4rev2 client or server. Beyond the protocol overview in 213 section 2, it is not optimized for someone trying to understand the 214 operation of the protocol. The material in sections 3 through 5 215 provides the general context and definitions with which IMAP4rev2 216 operates. 218 Sections 6, 7, and 9 describe the IMAP commands, responses, and 219 syntax, respectively. The relationships among these are such that it 220 is almost impossible to understand any of them separately. In 221 particular, do not attempt to deduce command syntax from the command 222 section alone; instead refer to the Formal Syntax (Section 9). 224 1.2. Conventions Used in This Document 226 "Conventions" are basic principles or procedures. Document 227 conventions are noted in this section. 229 In examples, "C:" and "S:" indicate lines sent by the client and 230 server respectively. Note that each line includes the terminating 231 CRLF. 233 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 234 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 235 "OPTIONAL" in this document are to be interpreted as described in BCP 236 14 [RFC2119] [RFC8174] when, and only when, they appear in all 237 capitals, as shown here. 239 The word "can" (not "may") is used to refer to a possible 240 circumstance or situation, as opposed to an optional facility of the 241 protocol. 243 "User" is used to refer to a human user, whereas "client" refers to 244 the software being run by the user. 246 "Connection" refers to the entire sequence of client/server 247 interaction from the initial establishment of the network connection 248 until its termination. 250 "Session" refers to the sequence of client/server interaction from 251 the time that a mailbox is selected (SELECT or EXAMINE command) until 252 the time that selection ends (SELECT or EXAMINE of another mailbox, 253 CLOSE command, UNSELECT command, or connection termination). 255 The term "Implicit TLS" refers to the automatic negotiation of TLS 256 whenever a TCP connection is made on a particular TCP port that is 257 used exclusively by that server for TLS connections. The term 258 "Implicit TLS" is intended to contrast with the use of STARTTLS 259 command in IMAP that is used by the client and the server to 260 explicitly negotiate TLS on an established cleartext TCP connection. 262 Characters are 8-bit UTF-8 (of which 7-bit US-ASCII is a subset) 263 unless otherwise specified. Other character sets are indicated using 264 a "CHARSET", as described in [MIME-IMT] and defined in [CHARSET]. 265 CHARSETs have important additional semantics in addition to defining 266 character set; refer to these documents for more detail. 268 There are several protocol conventions in IMAP. These refer to 269 aspects of the specification which are not strictly part of the IMAP 270 protocol, but reflect generally-accepted practice. Implementations 271 need to be aware of these conventions, and avoid conflicts whether or 272 not they implement the convention. For example, "&" may not be used 273 as a hierarchy delimiter since it conflicts with the Mailbox 274 International Naming Convention, and other uses of "&" in mailbox 275 names are impacted as well. 277 1.3. Special Notes to Implementors 279 Implementors of the IMAP protocol are strongly encouraged to read the 280 IMAP implementation recommendations document [IMAP-IMPLEMENTATION] in 281 conjunction with this document, to help understand the intricacies of 282 this protocol and how best to build an interoperable product. 284 IMAP4rev2 is designed to be upwards compatible from the IMAP4rev1 285 [RFC3501], the [IMAP2] and unpublished IMAP2bis [IMAP2BIS] protocols. 286 IMAP4rev2 is largely compatible with the IMAP4rev1 protocol described 287 in RFC 3501 and the IMAP4 protocol described in RFC 1730; the 288 exception being in certain facilities added in RFC 1730 and RFC 3501 289 that proved problematic and were subsequently removed or replaced by 290 better alternatives. In the course of the evolution of IMAP4rev2, 291 some aspects in the earlier protocols have become obsolete. Obsolete 292 commands, responses, and data formats which an IMAP4rev2 293 implementation can encounter when used with an earlier implementation 294 are described in Appendix E, Appendix A and [IMAP-OBSOLETE]. 295 IMAP4rev2 supports 63bit body part and message sizes. IMAP4rev2 296 compatibility with BINARY and LIST-EXTENDED IMAP extensions are 297 described in Appendix B and Appendix C respectively. 299 Other compatibility issues with IMAP2bis, the most common variant of 300 the earlier protocol, are discussed in [IMAP-COMPAT]. A full 301 discussion of compatibility issues with rare (and presumed extinct) 302 variants of [IMAP2] is in [IMAP-HISTORICAL]; this document is 303 primarily of historical interest. 305 IMAP was originally developed for the older [RFC-822] standard, and 306 as a consequence, "RFC822.SIZE" fetch item in IMAP incorporates 307 "RFC822" in its name. "RFC822" should be interpreted as a reference 308 to the updated [RFC-5322] standard. 310 2. Protocol Overview 312 2.1. Link Level 314 The IMAP4rev2 protocol assumes a reliable data stream such as that 315 provided by TCP. When TCP is used, an IMAP4rev2 server listens on 316 port 143 (cleartext port) or port 993 (Implicit TLS port). 318 2.2. Commands and Responses 320 An IMAP4rev2 connection consists of the establishment of a client/ 321 server network connection, an initial greeting from the server, and 322 client/server interactions. These client/server interactions consist 323 of a client command, server data, and a server completion result 324 response. 326 All interactions transmitted by client and server are in the form of 327 lines, that is, strings that end with a CRLF. The protocol receiver 328 of an IMAP4rev2 client or server is either reading a line, or is 329 reading a sequence of octets with a known count followed by a line. 331 2.2.1. Client Protocol Sender and Server Protocol Receiver 333 The client command begins an operation. Each client command is 334 prefixed with an identifier (typically a short alphanumeric string, 335 e.g., A0001, A0002, etc.) called a "tag". A different tag is 336 generated by the client for each command. More formally: the client 337 SHOULD generate a unique tag for every command, but a server MUST 338 accept tag reuse. 340 Clients MUST follow the syntax outlined in this specification 341 strictly. It is a syntax error to send a command with missing or 342 extraneous spaces or arguments. 344 There are two cases in which a line from the client does not 345 represent a complete command. In one case, a command argument is 346 quoted with an octet count (see the description of literal in 347 Section 4.3); in the other case, the command arguments require server 348 feedback (see the AUTHENTICATE command in Section 6.2.2). In either 349 case, the server sends a command continuation request response if it 350 is ready for the octets (if appropriate) and the remainder of the 351 command. This response is prefixed with the token "+". 353 Note: If, instead, the server detected an error in the command, it 354 sends a BAD completion response with a tag matching the command 355 (as described below) to reject the command and prevent the client 356 from sending any more of the command. 358 It is also possible for the server to send a completion response 359 for some other command (if multiple commands are in progress), or 360 untagged data. In either case, the command continuation request 361 is still pending; the client takes the appropriate action for the 362 response, and reads another response from the server. In all 363 cases, the client MUST send a complete command (including 364 receiving all command continuation request responses and sending 365 command continuations for the command) before initiating a new 366 command. 368 The protocol receiver of an IMAP4rev2 server reads a command line 369 from the client, parses the command and its arguments, and transmits 370 server data and a server command completion result response. 372 2.2.2. Server Protocol Sender and Client Protocol Receiver 374 Data transmitted by the server to the client and status responses 375 that do not indicate command completion are prefixed with the token 376 "*", and are called untagged responses. 378 Server data MAY be sent as a result of a client command, or MAY be 379 sent unilaterally by the server. There is no syntactic difference 380 between server data that resulted from a specific command and server 381 data that were sent unilaterally. 383 The server completion result response indicates the success or 384 failure of the operation. It is tagged with the same tag as the 385 client command which began the operation. Thus, if more than one 386 command is in progress, the tag in a server completion response 387 identifies the command to which the response applies. There are 388 three possible server completion responses: OK (indicating success), 389 NO (indicating failure), or BAD (indicating a protocol error such as 390 unrecognized command or command syntax error). 392 Servers SHOULD enforce the syntax outlined in this specification 393 strictly. Any client command with a protocol syntax error, including 394 (but not limited to) missing or extraneous spaces or arguments, 395 SHOULD be rejected, and the client given a BAD server completion 396 response. 398 The protocol receiver of an IMAP4rev2 client reads a response line 399 from the server. It then takes action on the response based upon the 400 first token of the response, which can be a tag, a "*", or a "+". 402 A client MUST be prepared to accept any server response at all times. 403 This includes server data that was not requested. Server data SHOULD 404 be remembered (cached), so that the client can reference its 405 remembered copy rather than sending a command to the server to 406 request the data. In the case of certain server data, the data MUST 407 be remembered, as specified elsewhere in this document. 409 This topic is discussed in greater detail in the Server Responses 410 section. 412 2.3. Message Attributes 414 In addition to message text, each message has several attributes 415 associated with it. These attributes can be retrieved individually 416 or in conjunction with other attributes or message texts. 418 2.3.1. Message Numbers 420 Messages in IMAP4rev2 are accessed by one of two numbers; the unique 421 identifier (UID) or the message sequence number. 423 2.3.1.1. Unique Identifier (UID) Message Attribute 425 A UID is an unsigned non-zero 32-bit value assigned to each message, 426 which when used with the unique identifier validity value (see below) 427 forms a 64-bit value that MUST NOT refer to any other message in the 428 mailbox or any subsequent mailbox with the same name forever. Unique 429 identifiers are assigned in a strictly ascending fashion in the 430 mailbox; as each message is added to the mailbox it is assigned a 431 higher UID than the message(s) which were added previously. Unlike 432 message sequence numbers, unique identifiers are not necessarily 433 contiguous. 435 The unique identifier of a message MUST NOT change during the 436 session, and SHOULD NOT change between sessions. Any change of 437 unique identifiers between sessions MUST be detectable using the 438 UIDVALIDITY mechanism discussed below. Persistent unique identifiers 439 are required for a client to resynchronize its state from a previous 440 session with the server (e.g., disconnected or offline access clients 441 [IMAP-MODEL]); this is discussed further in [IMAP-DISC]. 443 Associated with every mailbox are two 32-bit unsigned non-zero values 444 which aid in unique identifier handling: the next unique identifier 445 value (UIDNEXT) and the unique identifier validity value 446 (UIDVALIDITY). 448 The next unique identifier value is the predicted value that will be 449 assigned to a new message in the mailbox. Unless the unique 450 identifier validity also changes (see below), the next unique 451 identifier value MUST have the following two characteristics. First, 452 the next unique identifier value MUST NOT change unless new messages 453 are added to the mailbox; and second, the next unique identifier 454 value MUST change whenever new messages are added to the mailbox, 455 even if those new messages are subsequently expunged. 457 Note: The next unique identifier value is intended to provide a 458 means for a client to determine whether any messages have been 459 delivered to the mailbox since the previous time it checked this 460 value. It is not intended to provide any guarantee that any 461 message will have this unique identifier. A client can only 462 assume, at the time that it obtains the next unique identifier 463 value, that messages arriving after that time will have a UID 464 greater than or equal to that value. 466 The unique identifier validity value is sent in a UIDVALIDITY 467 response code in an OK untagged response at mailbox selection time. 468 If unique identifiers from an earlier session fail to persist in this 469 session, the unique identifier validity value MUST be greater than 470 the one used in the earlier session. A good UIDVALIDITY value to use 471 is a 32-bit representation of the current date/time when the value is 472 assigned: this ensures that the value is unique and always increases. 473 Another possible alternative is a global counter that gets 474 incremented every time a mailbox is created. 476 Note: Ideally, unique identifiers SHOULD persist at all times. 477 Although this specification recognizes that failure to persist can 478 be unavoidable in certain server environments, it strongly 479 encourages message store implementation techniques that avoid this 480 problem. For example: 482 1. Unique identifiers MUST be strictly ascending in the mailbox 483 at all times. If the physical message store is re-ordered by 484 a non-IMAP agent, this requires that the unique identifiers in 485 the mailbox be regenerated, since the former unique 486 identifiers are no longer strictly ascending as a result of 487 the re-ordering. 489 2. If the message store has no mechanism to store unique 490 identifiers, it must regenerate unique identifiers at each 491 session, and each session must have a unique UIDVALIDITY 492 value. 494 3. If the mailbox is deleted/renamed and a new mailbox with the 495 same name is created at a later date, the server must either 496 keep track of unique identifiers from the previous instance of 497 the mailbox, or it must assign a new UIDVALIDITY value to the 498 new instance of the mailbox. 500 4. The combination of mailbox name, UIDVALIDITY, and UID must 501 refer to a single immutable (or expunged) message on that 502 server forever. In particular, the internal date, [RFC-5322] 503 size, envelope, body structure, and message texts (all 504 BODY[...] fetch data items) MUST never change. This does not 505 include message numbers, nor does it include attributes that 506 can be set by a STORE command (e.g., FLAGS). When a message 507 is expunged, its UID MUST NOT be reused under the same 508 UIDVALIDITY value. 510 2.3.1.2. Message Sequence Number Message Attribute 512 A Message Sequence Number is a relative position from 1 to the number 513 of messages in the mailbox. This position MUST be ordered by 514 ascending unique identifier. As each new message is added, it is 515 assigned a message sequence number that is 1 higher than the number 516 of messages in the mailbox before that new message was added. 518 Message sequence numbers can be reassigned during the session. For 519 example, when a message is permanently removed (expunged) from the 520 mailbox, the message sequence number for all subsequent messages is 521 decremented. The number of messages in the mailbox is also 522 decremented. Similarly, a new message can be assigned a message 523 sequence number that was once held by some other message prior to an 524 expunge. 526 In addition to accessing messages by relative position in the 527 mailbox, message sequence numbers can be used in mathematical 528 calculations. For example, if an untagged "11 EXISTS" is received, 529 and previously an untagged "8 EXISTS" was received, three new 530 messages have arrived with message sequence numbers of 9, 10, and 11. 531 Another example, if message 287 in a 523 message mailbox has UID 532 12345, there are exactly 286 messages which have lesser UIDs and 236 533 messages which have greater UIDs. 535 2.3.2. Flags Message Attribute 537 A message has associated with it a list of zero or more named tokens, 538 known as "flags". A flag is set by its addition to this list, and is 539 cleared by its removal. There are two types of flags in IMAP4rev2: 540 system flags, and keywords. A flag of either type can also be 541 permanent or session-only. 543 A system flag is a flag name that is pre-defined in this 544 specification and begins with "\". Certain system flags (\Deleted 545 and \Seen) have special semantics described elsewhere in this 546 document. The currently-defined system flags are: 548 \Seen Message has been read 550 \Answered Message has been answered 552 \Flagged Message is "flagged" for urgent/special attention 554 \Deleted Message is "deleted" for removal by later EXPUNGE 556 \Draft Message has not completed composition (marked as a draft). 558 \Recent This flag was in use in IMAP4rev1 and is now deprecated. 560 A keyword is defined by the server implementation. Keywords do not 561 begin with "\". Servers MAY permit the client to define new keywords 562 in the mailbox (see the description of the PERMANENTFLAGS response 563 code for more information). Some keywords that start with "$" are 564 also defined in this specification. 566 This document defines several keywords that were not originally 567 defined in RFC 3501, but which were found to be useful by client 568 implementations. These keywords SHOULD be supported (i.e. allowed in 569 SEARCH, allowed and preserved in APPEND, COPY, MOVE commands) by 570 server implementations: 572 $Forwarded Message has been forwarded to another email address, 573 embedded within or attached to a new message. An email client 574 sets this keyword when it successfully forwards the message to 575 another email address. Typical usage of this keyword is to show a 576 different (or additional) icon for a message that has been 577 forwarded. Once set, the flag SHOULD NOT be cleared. 579 $MDNSent Message Disposition Notification [RFC8098] was generated 580 and sent for this message. See [RFC3503] for more details on how 581 this keyword is used and for requirements on clients and servers. 583 $Junk The user (or a delivery agent on behalf of the user) may 584 choose to mark a message as definitely containing junk ($Junk; see 585 also the related keyword $NotJunk). The $Junk keyword can be used 586 to mark (and potentially move/delete messages later), group or 587 hide undesirable messages. See [IMAP-KEYWORDS-REG] for more 588 information. 590 $NotJunk The user (or a delivery agent on behalf of the user) may 591 choose to mark a message as definitely not containing junk 592 ($NotJunk; see also the related keyword $Junk). The $NotJunk 593 keyword can be used to mark, group or show messages that the user 594 wants to see. See [IMAP-KEYWORDS-REG] for more information. 596 $Phishing The $Phishing keyword can be used by a delivery agent to 597 mark a message as highly likely to be a phishing email. An email 598 that's determined to be a phishing email by the delivery agent 599 should also be considered a junk email and have the appropriate 600 junk filtering applied, including setting the $Junk flag and 601 placing in the \Junk special-use mailbox (see Section 7.3.1) if 602 available. 603 If both the $Phishing flag and the $Junk flag are set, the user 604 agent should display an additional warning message to the user. 605 Additionally the user agent may display a warning when clicking on 606 any hyperlinks within the message. 607 The requirement for both $Phishing and $Junk to be set before a 608 user agent displays a warning is for better backwards 609 compatibility with existing clients that understand the $Junk flag 610 but not the $Phishing flag. This is so that when an unextended 611 client removes the $Junk flag, an extended client will also show 612 the correct state. See [IMAP-KEYWORDS-REG] for more information. 614 $Junk and $NotJunk are mutually exclusive. If more than one of them 615 is set for a message, the client MUST treat this as if none of them 616 is set and SHOULD unset both of them on the IMAP server. 618 Other registered keywords can be found in the "IMAP and JMAP 619 Keywords" registry [IMAP-KEYWORDS-REG]. New keywords SHOULD be 620 registered in this registry using the procedure specified in 621 [RFC5788]. 623 A flag can be permanent or session-only on a per-flag basis. 624 Permanent flags are those which the client can add or remove from the 625 message flags permanently; that is, concurrent and subsequent 626 sessions will see any change in permanent flags. Changes to session 627 flags are valid only in that session. 629 2.3.3. Internal Date Message Attribute 631 An Internal Date message attribute is the internal date and time of 632 the message on the server. This is not the date and time in the 633 [RFC-5322] header, but rather a date and time which reflects when the 634 message was received. In the case of messages delivered via [SMTP], 635 this is the date and time of final delivery of the message as defined 636 by [SMTP]. In the case of messages delivered by the IMAP4rev2 COPY 637 or MOVE command, this SHOULD be the internal date and time of the 638 source message. In the case of messages delivered by the IMAP4rev2 639 APPEND command, this SHOULD be the date and time as specified in the 640 APPEND command description. All other cases are implementation 641 defined. 643 2.3.4. [RFC-5322] Size Message Attribute 645 An RFC 5322 size is the number of octets in the message, as expressed 646 in [RFC-5322] format. 648 2.3.5. Envelope Structure Message Attribute 650 An Envelope Structure is a parsed representation of the [RFC-5322] 651 header of the message. Note that the IMAP Envelope structure is not 652 the same as an [SMTP] envelope. 654 2.3.6. Body Structure Message Attribute 656 A Body Structure is a parsed representation of the [MIME-IMB] body 657 structure information of the message. 659 2.4. Message Texts 661 In addition to being able to fetch the full [RFC-5322] text of a 662 message, IMAP4rev2 permits the fetching of portions of the full 663 message text. Specifically, it is possible to fetch the [RFC-5322] 664 message header, [RFC-5322] message body, a [MIME-IMB] body part, or a 665 [MIME-IMB] header. 667 3. State and Flow Diagram 669 Once the connection between client and server is established, an 670 IMAP4rev2 connection is in one of four states. The initial state is 671 identified in the server greeting. Most commands are only valid in 672 certain states. It is a protocol error for the client to attempt a 673 command while the connection is in an inappropriate state, and the 674 server will respond with a BAD or NO (depending upon server 675 implementation) command completion result. 677 3.1. Not Authenticated State 679 In the not authenticated state, the client MUST supply authentication 680 credentials before most commands will be permitted. This state is 681 entered when a connection starts unless the connection has been pre- 682 authenticated. 684 3.2. Authenticated State 686 In the authenticated state, the client is authenticated and MUST 687 select a mailbox to access before commands that affect messages will 688 be permitted. This state is entered when a pre-authenticated 689 connection starts, when acceptable authentication credentials have 690 been provided, after an error in selecting a mailbox, or after a 691 successful CLOSE or UNSELECT command. 693 3.3. Selected State 695 In a selected state, a mailbox has been selected to access. This 696 state is entered when a mailbox has been successfully selected. 698 3.4. Logout State 700 In the logout state, the connection is being terminated. This state 701 can be entered as a result of a client request (via the LOGOUT 702 command) or by unilateral action on the part of either the client or 703 server. 705 If the client requests the logout state, the server MUST send an 706 untagged BYE response and a tagged OK response to the LOGOUT command 707 before the server closes the connection; and the client MUST read the 708 tagged OK response to the LOGOUT command before the client closes the 709 connection. 711 A server SHOULD NOT unilaterally close the connection without sending 712 an untagged BYE response that contains the reason for having done so. 713 A client SHOULD NOT unilaterally close the connection, and instead 714 SHOULD issue a LOGOUT command. If the server detects that the client 715 has unilaterally closed the connection, the server MAY omit the 716 untagged BYE response and simply close its connection. 718 +----------------------+ 719 |connection established| 720 +----------------------+ 721 || 722 \/ 723 +--------------------------------------+ 724 | server greeting | 725 +--------------------------------------+ 726 || (1) || (2) || (3) 727 \/ || || 728 +-----------------+ || || 729 |Not Authenticated| || || 730 +-----------------+ || || 731 || (7) || (4) || || 732 || \/ \/ || 733 || +----------------+ || 734 || | Authenticated |<=++ || 735 || +----------------+ || || 736 || || (7) || (5) || (6) || 737 || || \/ || || 738 || || +--------+ || || 739 || || |Selected|==++ || 740 || || +--------+ || 741 || || || (7) || 742 \/ \/ \/ \/ 743 +--------------------------------------+ 744 | Logout | 745 +--------------------------------------+ 746 || 747 \/ 748 +-------------------------------+ 749 |both sides close the connection| 750 +-------------------------------+ 752 (1) connection without pre-authentication (OK greeting) 753 (2) pre-authenticated connection (PREAUTH greeting) 754 (3) rejected connection (BYE greeting) 755 (4) successful LOGIN or AUTHENTICATE command 756 (5) successful SELECT or EXAMINE command 757 (6) CLOSE or UNSELECT command, unsolicited CLOSED 758 response code or failed SELECT or EXAMINE command 759 (7) LOGOUT command, server shutdown, or connection closed 761 4. Data Formats 763 IMAP4rev2 uses textual commands and responses. Data in IMAP4rev2 can 764 be in one of several forms: atom, number, string, parenthesized list, 765 or NIL. Note that a particular data item may take more than one 766 form; for example, a data item defined as using "astring" syntax may 767 be either an atom or a string. 769 4.1. Atom 771 An atom consists of one or more non-special characters. 773 4.1.1. Sequence set and UID set 775 A set of messages can be referenced by a sequence set containing 776 either message sequence numbers or unique identifiers. See Section 9 777 for details. Sequence sets can contain ranges (e.g. "5:50"), an 778 enumeration of specific message sequence numbers/unique identifiers, 779 a special symbol "*", or a combination of the above. Note that a 780 sequence set never mixes message sequence numbers and unique 781 identifiers in the same representation. 783 A "UID set" is similar to the sequence set of unique identifiers; 784 however, the "*" value for a sequence number is not permitted. 786 4.2. Number 788 A number consists of one or more digit characters, and represents a 789 numeric value. 791 4.3. String 793 A string is in one of three forms: synchronizing literal, non- 794 synchronizing literal or quoted string. The synchronizing literal 795 form is the general form of string. The non-synchronizing literal 796 form is also the general form, but has length limitation. The quoted 797 string form is an alternative that avoids the overhead of processing 798 a literal at the cost of limitations of characters which may be used. 800 When the distinction between synchronizing and non-synchronizing 801 literals is not important, this document only uses the term 802 "literal". 804 A synchronizing literal is a sequence of zero or more octets 805 (including CR and LF), prefix-quoted with an octet count in the form 806 of an open brace ("{"), the number of octets, close brace ("}"), and 807 CRLF. In the case of synchronizing literals transmitted from server 808 to client, the CRLF is immediately followed by the octet data. In 809 the case of synchronizing literals transmitted from client to server, 810 the client MUST wait to receive a command continuation request 811 (described later in this document) before sending the octet data (and 812 the remainder of the command). 814 The non-synchronizing literal is an alternative form of synchronizing 815 literal, and it may appear in communication from client to server 816 instead of the synchonizing form of literal. The non-synchronizing 817 literal form MUST NOT be sent from server to client. The non- 818 synchronizing literal is distinguished from the synchronizing literal 819 by having a plus ("+") between the octet count and the closing brace 820 ("}"). The server does not generate a command continuation request 821 in response to a non-synchronizing literal, and clients are not 822 required to wait before sending the octets of a non- synchronizing 823 literal. Unless specified otherwise in an IMAP extension, non- 824 synchronizing literals MUST NOT be larger than 4096 octets. Any 825 literal larger than 4096 bytes MUST be sent as a synchronizing 826 literal. (Non-synchronizing literals defined in this document are 827 the same as non-synchronizing literals defined by the LITERAL- 828 extension from [RFC7888]. See that document for details on how to 829 handle invalid non-synchronizing literals longer than 4096 octets and 830 for interaction with other IMAP extensions.) 832 A quoted string is a sequence of zero or more Unicode characters, 833 excluding CR and LF, encoded in UTF-8, with double quote (<">) 834 characters at each end. 836 The empty string is represented as "" (a quoted string with zero 837 characters between double quotes), as {0} followed by CRLF (a 838 synchronizing literal with an octet count of 0) or as {0+} followed 839 by CRLF (a non-synchronizing literal with an octet count of 0). 841 Note: Even if the octet count is 0, a client transmitting a 842 synchronizing literal MUST wait to receive a command continuation 843 request. 845 4.3.1. 8-bit and Binary Strings 847 8-bit textual and binary mail is supported through the use of a 848 [MIME-IMB] content transfer encoding. IMAP4rev2 implementations MAY 849 transmit 8-bit or multi-octet characters in literals, but SHOULD do 850 so only when the [CHARSET] is identified. 852 IMAP4rev2 is compatible with [I18N-HDRS]. As a result, the 853 identified charset for header-field values with 8-bit content is 854 UTF-8 [UTF-8]. IMAP4rev2 implementations MUST accept and MAY 855 transmit [UTF-8] text in quoted-strings as long as the string does 856 not contain NUL, CR, or LF. This differs from IMAP4rev1 857 implementations. 859 Although a BINARY content transfer encoding is defined, unencoded 860 binary strings are not permitted, unless returned in a in 861 response to BINARY.PEEK[]<> or 862 BINARY[]<> FETCH data item. A "binary 863 string" is any string with NUL characters. A string with an 864 excessive amount of CTL characters MAY also be considered to be 865 binary. Unless returned in response to BINARY.PEEK[...]/BINARY[...] 866 FETCH, client and server implementations MUST encode binary data into 867 a textual form, such as BASE64, before transmitting the data. 869 4.4. Parenthesized List 871 Data structures are represented as a "parenthesized list"; a sequence 872 of data items, delimited by space, and bounded at each end by 873 parentheses. A parenthesized list can contain other parenthesized 874 lists, using multiple levels of parentheses to indicate nesting. 876 The empty list is represented as () -- a parenthesized list with no 877 members. 879 4.5. NIL 881 The special form "NIL" represents the non-existence of a particular 882 data item that is represented as a string or parenthesized list, as 883 distinct from the empty string "" or the empty parenthesized list (). 885 Note: NIL is never used for any data item which takes the form of 886 an atom. For example, a mailbox name of "NIL" is a mailbox named 887 NIL as opposed to a non-existent mailbox name. This is because 888 mailbox uses "astring" syntax which is an atom or a string. 889 Conversely, an addr-name of NIL is a non-existent personal name, 890 because addr-name uses "nstring" syntax which is NIL or a string, 891 but never an atom. 893 Examples: 895 The following LIST response: 897 * LIST () "/" NIL 899 is equivalent to: 901 * LIST () "/" "NIL" 903 as LIST response ABNF is using "astring" for mailbox name. 905 However, the following response 907 * FETCH 1 (BODY[1] NIL) 909 is not equivalent to: 911 * FETCH 1 (BODY[1] "NIL") 913 The former means absence of the body part, while the latter 914 means that it contains literal sequence of characters "NIL". 916 5. Operational Considerations 918 The following rules are listed here to ensure that all IMAP4rev2 919 implementations interoperate properly. 921 5.1. Mailbox Naming 923 In IMAP4rev2, Mailbox names are encoded in Net-Unicode [NET-UNICODE] 924 (this differs from IMAP4rev1). Client implementations MAY attempt to 925 create Net-Unicode mailbox names, and MUST interpret any 8-bit 926 mailbox names returned by LIST as [NET-UNICODE]. Server 927 implementations MUST prohibit the creation of 8-bit mailbox names 928 that do not comply with Net-Unicode. However, servers MAY accept a 929 de-normalized UTF-8 mailbox name and convert it to Unicode 930 normalization form "NFC" (as per Net-Unicode requirements) prior to 931 mailbox creation. Servers that choose to accept such de-normalized 932 UTF-8 mailbox names MUST accept them in all IMAP commands that have a 933 mailbox name parameter. In particular SELECT must open the 934 same mailbox that was successfully created with CREATE , even 935 if is a de-normalized UTF-8 mailbox name. 937 The case-insensitive mailbox name INBOX is a special name reserved to 938 mean "the primary mailbox for this user on this server". (Note that 939 this special name may not exist on some servers for some users, for 940 example if the user has no access to personal namespace.) The 941 interpretation of all other names is implementation-dependent. 943 In particular, this specification takes no position on case 944 sensitivity in non-INBOX mailbox names. Some server implementations 945 are fully case-sensitive in ASCII range; others preserve case of a 946 newly-created name but otherwise are case-insensitive; and yet others 947 coerce names to a particular case. Client implementations must be 948 able to interact with any of these. 950 There are certain client considerations when creating a new mailbox 951 name: 953 1. Any character which is one of the atom-specials (see the Formal 954 Syntax in Section 9) will require that the mailbox name be 955 represented as a quoted string or literal. 957 2. CTL and other non-graphic characters are difficult to represent 958 in a user interface and are best avoided. Servers MAY refuse to 959 create mailbox names containing Unicode CTL characters. 961 3. Although the list-wildcard characters ("%" and "*") are valid in 962 a mailbox name, it is difficult to use such mailbox names with 963 the LIST command due to the conflict with wildcard 964 interpretation. 966 4. Usually, a character (determined by the server implementation) is 967 reserved to delimit levels of hierarchy. 969 5. Two characters, "#" and "&", have meanings by convention, and 970 should be avoided except when used in that convention. See 971 Section 5.1.2.1 and Appendix A.1 respectively. 973 5.1.1. Mailbox Hierarchy Naming 975 If it is desired to export hierarchical mailbox names, mailbox names 976 MUST be left-to-right hierarchical using a single character to 977 separate levels of hierarchy. The same hierarchy separator character 978 is used for all levels of hierarchy within a single name. 980 5.1.2. Namespaces 982 Personal Namespace: A namespace that the server considers within the 983 personal scope of the authenticated user on a particular connection. 984 Typically, only the authenticated user has access to mailboxes in 985 their Personal Namespace. It is the part of the namespace that 986 belongs to the user that is allocated for mailboxes. If an INBOX 987 exists for a user, it MUST appear within the user's personal 988 namespace. In the typical case, there SHOULD be only one Personal 989 Namespace per user on a server. 991 Other Users' Namespace: A namespace that consists of mailboxes from 992 the Personal Namespaces of other users. To access mailboxes in the 993 Other Users' Namespace, the currently authenticated user MUST be 994 explicitly granted access rights. For example, it is common for a 995 manager to grant to their administrative support staff access rights 996 to their mailbox. In the typical case, there SHOULD be only one 997 Other Users' Namespace per user on a server. 999 Shared Namespace: A namespace that consists of mailboxes that are 1000 intended to be shared amongst users and do not exist within a user's 1001 Personal Namespace. 1003 The namespaces a server uses MAY differ on a per-user basis. 1005 5.1.2.1. Historic Mailbox Namespace Naming Convention 1007 By convention, the first hierarchical element of any mailbox name 1008 which begins with "#" identifies the "namespace" of the remainder of 1009 the name. This makes it possible to disambiguate between different 1010 types of mailbox stores, each of which have their own namespaces. 1012 For example, implementations which offer access to USENET 1013 newsgroups MAY use the "#news" namespace to partition the USENET 1014 newsgroup namespace from that of other mailboxes. Thus, the 1015 comp.mail.misc newsgroup would have a mailbox name of 1016 "#news.comp.mail.misc", and the name "comp.mail.misc" can refer to 1017 a different object (e.g., a user's private mailbox). 1019 Namespaces that include the "#" character are not IMAP URL [IMAP-URL] 1020 friendly requiring the "#" character to be represented as %23 when 1021 within URLs. As such, server implementors MAY instead consider using 1022 namespace prefixes that do not contain the "#" character. 1024 5.1.2.2. Common namespace models 1026 The previous version of this protocol did not define a default server 1027 namespace. Two common namespace models have evolved: 1029 The "Personal Mailbox" model, in which the default namespace that is 1030 presented consists of only the user's personal mailboxes. To access 1031 shared mailboxes, the user must use an escape mechanism to reach 1032 another namespace. 1034 The "Complete Hierarchy" model, in which the default namespace that 1035 is presented includes the user's personal mailboxes along with any 1036 other mailboxes they have access to. 1038 5.2. Mailbox Size and Message Status Updates 1040 At any time, a server can send data that the client did not request. 1041 Sometimes, such behavior is required by this specification and/or 1042 extensions. For example, agents other than the server MAY add 1043 messages to the mailbox (e.g., new message delivery), change the 1044 flags of the messages in the mailbox (e.g., simultaneous access to 1045 the same mailbox by multiple agents), or even remove messages from 1046 the mailbox. A server MUST send mailbox size updates automatically 1047 if a mailbox size change is observed during the processing of a 1048 command. A server SHOULD send message flag updates automatically, 1049 without requiring the client to request such updates explicitly. 1051 Special rules exist for server notification of a client about the 1052 removal of messages to prevent synchronization errors; see the 1053 description of the EXPUNGE response (Section 7.5.1) for more detail. 1054 In particular, it is NOT permitted to send an EXISTS response that 1055 would reduce the number of messages in the mailbox; only the EXPUNGE 1056 response can do this. 1058 Regardless of what implementation decisions a client makes on 1059 remembering data from the server, a client implementation MUST 1060 remember mailbox size updates. It MUST NOT assume that any command 1061 after the initial mailbox selection will return the size of the 1062 mailbox. 1064 5.3. Response when no Command in Progress 1066 Server implementations are permitted to send an untagged response 1067 (except for EXPUNGE) while there is no command in progress. Server 1068 implementations that send such responses MUST deal with flow control 1069 considerations. Specifically, they MUST either (1) verify that the 1070 size of the data does not exceed the underlying transport's available 1071 window size, or (2) use non-blocking writes. 1073 5.4. Autologout Timer 1075 If a server has an inactivity autologout timer that applies to 1076 sessions after authentication, the duration of that timer MUST be at 1077 least 30 minutes. The receipt of any command from the client during 1078 that interval resets the autologout timer. 1080 Note that this specification doesn't have any restrictions on 1081 autologout timer used before successful client authentication. In 1082 particular, servers are allowed to use shortened pre-authentication 1083 timer to protect themselves from Denial of Service attacks. 1085 5.5. Multiple Commands in Progress (Command Pipelining) 1087 The client MAY send another command without waiting for the 1088 completion result response of a command, subject to ambiguity rules 1089 (see below) and flow control constraints on the underlying data 1090 stream. Similarly, a server MAY begin processing another command 1091 before processing the current command to completion, subject to 1092 ambiguity rules. However, any command continuation request responses 1093 and command continuations MUST be negotiated before any subsequent 1094 command is initiated. 1096 The exception is if an ambiguity would result because of a command 1097 that would affect the results of other commands. If the server 1098 detects a possible ambiguity, it MUST execute commands to completion 1099 in the order given by the client. 1101 The most obvious example of ambiguity is when a command would affect 1102 the results of another command, e.g., a FETCH of a message's flags 1103 and a STORE of that same message's flags. 1105 A non-obvious ambiguity occurs with commands that permit an untagged 1106 EXPUNGE response (commands other than FETCH, STORE, and SEARCH), 1107 since an untagged EXPUNGE response can invalidate sequence numbers in 1108 a subsequent command. This is not a problem for FETCH, STORE, or 1109 SEARCH commands because servers are prohibited from sending EXPUNGE 1110 responses while any of those commands are in progress. Therefore, if 1111 the client sends any command other than FETCH, STORE, or SEARCH, it 1112 MUST wait for the completion result response before sending a command 1113 with message sequence numbers. 1115 Note: EXPUNGE responses are permitted while UID FETCH, UID STORE, 1116 and UID SEARCH are in progress. If the client sends a UID 1117 command, it MUST wait for a completion result response before 1118 sending a command which uses message sequence numbers (this may 1119 include UID SEARCH). Any message sequence numbers in an argument 1120 to UID SEARCH are associated with messages prior to the effect of 1121 any untagged EXPUNGE returned by the UID SEARCH. 1123 For example, the following non-waiting command sequences are invalid: 1125 FETCH + NOOP + STORE 1127 STORE + COPY + FETCH 1129 COPY + COPY 1131 The following are examples of valid non-waiting command sequences: 1133 FETCH + STORE + SEARCH + NOOP 1135 STORE + COPY + EXPUNGE 1137 UID SEARCH + UID SEARCH may be valid or invalid as a non-waiting 1138 command sequence, depending upon whether or not the second UID 1139 SEARCH contains message sequence numbers. 1141 Use of SEARCH result variable (see Section 6.4.4.1) creates direct 1142 dependency between two commands. See Section 6.4.4.2 for more 1143 considerations about pipelining such dependent commands. 1145 6. Client Commands 1147 IMAP4rev2 commands are described in this section. Commands are 1148 organized by the state in which the command is permitted. Commands 1149 which are permitted in multiple states are listed in the minimum 1150 permitted state (for example, commands valid in authenticated and 1151 selected state are listed in the authenticated state commands). 1153 Command arguments, identified by "Arguments:" in the command 1154 descriptions below, are described by function, not by syntax. The 1155 precise syntax of command arguments is described in the Formal Syntax 1156 (Section 9). 1158 Some commands cause specific server responses to be returned; these 1159 are identified by "Responses:" in the command descriptions below. 1160 See the response descriptions in the Responses section (Section 7) 1161 for information on these responses, and the Formal Syntax (Section 9) 1162 for the precise syntax of these responses. It is possible for server 1163 data to be transmitted as a result of any command. Thus, commands 1164 that do not specifically require server data specify "no specific 1165 responses for this command" instead of "none". 1167 The "Result:" in the command description refers to the possible 1168 tagged status responses to a command, and any special interpretation 1169 of these status responses. 1171 The state of a connection is only changed by successful commands 1172 which are documented as changing state. A rejected command (BAD 1173 response) never changes the state of the connection or of the 1174 selected mailbox. A failed command (NO response) generally does not 1175 change the state of the connection or of the selected mailbox; the 1176 exception being the SELECT and EXAMINE commands. 1178 6.1. Client Commands - Any State 1180 The following commands are valid in any state: CAPABILITY, NOOP, and 1181 LOGOUT. 1183 6.1.1. CAPABILITY Command 1185 Arguments: none 1187 Responses: REQUIRED untagged response: CAPABILITY 1189 Result: OK - capability completed 1190 BAD - arguments invalid 1192 The CAPABILITY command requests a listing of capabilities (e.g. 1193 extensions and/or modifications of server behaviour) that the server 1194 supports. The server MUST send a single untagged CAPABILITY response 1195 with "IMAP4rev2" as one of the listed capabilities before the 1196 (tagged) OK response. 1198 A capability name which begins with "AUTH=" indicates that the server 1199 supports that particular authentication mechanism as defined in 1200 [SASL]. All such names are, by definition, part of this 1201 specification. 1203 Other capability names refer to extensions, revisions, or amendments 1204 to this specification. See the documentation of the CAPABILITY 1205 response in Section 7.2.2 for additional information. If IMAP4rev1 1206 capability is not advertised, no capabilities, beyond the base 1207 IMAP4rev2 set defined in this specification, are enabled without 1208 explicit client action to invoke the capability. If both IMAP4rev1 1209 and IMAP4rev2 capabilities are advertised, no capabilities, beyond 1210 the base IMAP4rev1 set specified in RFC 3501, are enabled without 1211 explicit client action to invoke the capability. 1213 Client and server implementations MUST implement the STARTTLS 1214 Section 6.2.1 and LOGINDISABLED capabilities on cleartext ports. 1215 Client and server implementations MUST also implement AUTH=PLAIN 1216 (described in [PLAIN]) capability on both cleartext and Implicit TLS 1217 ports. See the Security Considerations (Section 11) for important 1218 information. 1220 Unless specified otherwise, all registered extensions to IMAP4rev1 1221 are also valid extensions to IMAP4rev2. 1223 Example: C: abcd CAPABILITY 1224 S: * CAPABILITY IMAP4rev2 STARTTLS AUTH=GSSAPI 1225 LOGINDISABLED 1226 S: abcd OK CAPABILITY completed 1227 C: efgh STARTTLS 1228 S: efgh OK STARTLS completed 1229 1230 C: ijkl CAPABILITY 1231 S: * CAPABILITY IMAP4rev2 AUTH=GSSAPI AUTH=PLAIN 1232 S: ijkl OK CAPABILITY completed 1234 6.1.2. NOOP Command 1236 Arguments: none 1238 Responses: no specific responses for this command (but see below) 1240 Result: OK - noop completed 1241 BAD - command unknown or arguments invalid 1243 The NOOP command always succeeds. It does nothing. 1245 Since any command can return a status update as untagged data, the 1246 NOOP command can be used as a periodic poll for new messages or 1247 message status updates during a period of inactivity (the IDLE 1248 command Section 6.3.13 should be used instead of NOOP if real-time 1249 updates to mailbox state are desirable). The NOOP command can also 1250 be used to reset any inactivity autologout timer on the server. 1252 Example: C: a002 NOOP 1253 S: a002 OK NOOP completed 1254 . . . 1255 C: a047 NOOP 1256 S: * 22 EXPUNGE 1257 S: * 23 EXISTS 1258 S: * 14 FETCH (UID 1305 FLAGS (\Seen \Deleted)) 1259 S: a047 OK NOOP completed 1261 6.1.3. LOGOUT Command 1263 Arguments: none 1265 Responses: REQUIRED untagged response: BYE 1267 Result: OK - logout completed 1268 BAD - command unknown or arguments invalid 1270 The LOGOUT command informs the server that the client is done with 1271 the connection. The server MUST send a BYE untagged response before 1272 the (tagged) OK response, and then close the network connection. 1274 Example: C: A023 LOGOUT 1275 S: * BYE IMAP4rev2 Server logging out 1276 S: A023 OK LOGOUT completed 1277 (Server and client then close the connection) 1279 6.2. Client Commands - Not Authenticated State 1281 In the not authenticated state, the AUTHENTICATE or LOGIN command 1282 establishes authentication and enters the authenticated state. The 1283 AUTHENTICATE command provides a general mechanism for a variety of 1284 authentication techniques, privacy protection, and integrity 1285 checking; whereas the LOGIN command uses a traditional user name and 1286 plaintext password pair and has no means of establishing privacy 1287 protection or integrity checking. 1289 The STARTTLS command is an alternative form of establishing session 1290 privacy protection and integrity checking, but does not by itself 1291 establish authentication or enter the authenticated state. 1293 Server implementations MAY allow access to certain mailboxes without 1294 establishing authentication. This can be done by means of the 1295 ANONYMOUS [SASL] authenticator described in [ANONYMOUS]. An older 1296 convention is a LOGIN command using the userid "anonymous"; in this 1297 case, a password is required although the server may choose to accept 1298 any password. The restrictions placed on anonymous users are 1299 implementation-dependent. 1301 Once authenticated (including as anonymous), it is not possible to 1302 re-enter not authenticated state. 1304 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 1305 the following commands are valid in the not authenticated state: 1306 STARTTLS, AUTHENTICATE and LOGIN. See the Security Considerations 1307 (Section 11) for important information about these commands. 1309 6.2.1. STARTTLS Command 1311 Arguments: none 1313 Responses: no specific response for this command 1315 Result: OK - starttls completed, begin TLS negotiation 1316 NO - TLS negotiation can't be initiated, due to server 1317 configuration error 1318 BAD - STARTTLS received after a successful TLS 1319 negotiation or arguments invalid 1321 Note that STARTTLS command is available only on cleartext ports. The 1322 server MUST always respond with tagged BAD response when STARTTLS 1323 command is received on Implicit TLS port. 1325 A TLS [TLS-1.3] negotiation begins immediately after the CRLF at the 1326 end of the tagged OK response from the server. Once a client issues 1327 a STARTTLS command, it MUST NOT issue further commands until a server 1328 response is seen and the TLS negotiation is complete. Some past 1329 server implementation incorrectly implemented STARTTLS processing and 1330 are known to contain STARTTLS plaintext command injection 1331 vulnerability [CERT-555316]. In order to avoid this vulnerability, 1332 server implementations MUST do one of the following If any data is 1333 received in the same TCP buffer after the CRLF that starts the 1334 STARTTLS command: 1336 1. Extra data from the TCP buffer is interpreted as beginning of the 1337 TLS handshake. (If the data is in cleartext, this will result in 1338 the TLS handshake failing.) 1340 2. Extra data from the TCP buffer is thrown away. 1342 Note that the first option is friendlier to clients that pipeline 1343 beginning of STARTTLS command with TLS handshake data. 1345 After successful TLS negotiation the server remains in the non- 1346 authenticated state, even if client credentials are supplied during 1347 the TLS negotiation. This does not preclude an authentication 1348 mechanism such as EXTERNAL (defined in [SASL]) from using client 1349 identity determined by the TLS negotiation. 1351 Once TLS has been started, the client MUST discard cached information 1352 about server capabilities and SHOULD re-issue the CAPABILITY command. 1353 This is necessary to protect against man-in- the-middle attacks which 1354 alter the capabilities list prior to STARTTLS. The server MAY 1355 advertise different capabilities, and in particular SHOULD NOT 1356 advertise the STARTTLS capability, after a successful STARTTLS 1357 command. 1359 Example: C: a001 CAPABILITY 1360 S: * CAPABILITY IMAP4rev2 STARTTLS LOGINDISABLED 1361 S: a001 OK CAPABILITY completed 1362 C: a002 STARTTLS 1363 S: a002 OK Begin TLS negotiation now 1364 1365 C: a003 CAPABILITY 1366 S: * CAPABILITY IMAP4rev2 AUTH=PLAIN 1367 S: a003 OK CAPABILITY completed 1368 C: a004 AUTHENTICATE PLAIN dGVzdAB0ZXN0AHRlc3Q= 1369 S: a004 OK Success (tls protection) 1371 6.2.2. AUTHENTICATE Command 1373 Arguments: SASL authentication mechanism name 1374 OPTIONAL initial response 1376 Responses: continuation data can be requested 1378 Result: OK - authenticate completed, now in authenticated state 1379 NO - authenticate failure: unsupported authentication 1380 mechanism, credentials rejected 1381 BAD - command unknown or arguments invalid, 1382 authentication exchange cancelled 1384 The AUTHENTICATE command indicates a [SASL] authentication mechanism 1385 to the server. If the server supports the requested authentication 1386 mechanism, it performs an authentication protocol exchange to 1387 authenticate and identify the client. It MAY also negotiate an 1388 OPTIONAL security layer for subsequent protocol interactions. If the 1389 requested authentication mechanism is not supported, the server 1390 SHOULD reject the AUTHENTICATE command by sending a tagged NO 1391 response. 1393 The AUTHENTICATE command supports the optional "initial response" 1394 feature defined in Section 5.1 of [SASL]. The client doesn't need to 1395 use it. If a SASL mechanism supports "initial response", but it is 1396 not specified by the client, the server handles this as specified in 1397 Section 3 of [SASL]. 1399 The service name specified by this protocol's profile of [SASL] is 1400 "imap". 1402 The authentication protocol exchange consists of a series of server 1403 challenges and client responses that are specific to the 1404 authentication mechanism. A server challenge consists of a command 1405 continuation request response with the "+" token followed by a BASE64 1406 encoded (see Section 4 of [RFC4648]) string. The client response 1407 consists of a single line consisting of a BASE64 encoded string. If 1408 the client wishes to cancel an authentication exchange, it issues a 1409 line consisting of a single "*". If the server receives such a 1410 response, or if it receives an invalid BASE64 string (e.g. 1411 characters outside the BASE64 alphabet, or non-terminal "="), it MUST 1412 reject the AUTHENTICATE command by sending a tagged BAD response. 1414 As with any other client response, the initial response MUST be 1415 encoded as BASE64. It also MUST be transmitted outside of a quoted 1416 string or literal. To send a zero-length initial response, the 1417 client MUST send a single pad character ("="). This indicates that 1418 the response is present, but is a zero-length string. 1420 When decoding the BASE64 data in the initial response, decoding 1421 errors MUST be treated as in any normal SASL client response, i.e. 1422 with a tagged BAD response. In particular, the server should check 1423 for any characters not explicitly allowed by the BASE64 alphabet, as 1424 well as any sequence of BASE64 characters that contains the pad 1425 character ('=') anywhere other than the end of the string (e.g., 1426 "=AAA" and "AAA=BBB" are not allowed). 1428 If the client uses an initial response with a SASL mechanism that 1429 does not support an initial response, the server MUST reject the 1430 command with a tagged BAD response. 1432 If a security layer is negotiated through the [SASL] authentication 1433 exchange, it takes effect immediately following the CRLF that 1434 concludes the authentication exchange for the client, and the CRLF of 1435 the tagged OK response for the server. 1437 While client and server implementations MUST implement the 1438 AUTHENTICATE command itself, it is not required to implement any 1439 authentication mechanisms other than the PLAIN mechanism described in 1440 [PLAIN]. Also, an authentication mechanism is not required to 1441 support any security layers. 1443 Note: a server implementation MUST implement a configuration in 1444 which it does NOT permit any plaintext password mechanisms, unless 1445 either the STARTTLS command has been negotiated, TLS has been 1446 negotiated on an Implicit TLS port, or some other mechanism that 1447 protects the session from password snooping has been provided. 1448 Server sites SHOULD NOT use any configuration which permits a 1449 plaintext password mechanism without such a protection mechanism 1450 against password snooping. Client and server implementations 1451 SHOULD implement additional [SASL] mechanisms that do not use 1452 plaintext passwords, such the GSSAPI mechanism described in 1453 [RFC4752], the SCRAM-SHA-256/SCRAM-SHA-256-PLUS [SCRAM-SHA-256] 1454 mechanisms and/or EXTERNAL [SASL] mechanism for mutual TLS 1455 authentication. (Note that SASL framework allows creation of SASL 1456 mechanisms that support 2FA (2-factor authentication), however 1457 none are fully ready to be recommended by this document.) 1459 Servers and clients can support multiple authentication mechanisms. 1460 The server SHOULD list its supported authentication mechanisms in the 1461 response to the CAPABILITY command so that the client knows which 1462 authentication mechanisms to use. 1464 A server MAY include a CAPABILITY response code in the tagged OK 1465 response of a successful AUTHENTICATE command in order to send 1466 capabilities automatically. It is unnecessary for a client to send a 1467 separate CAPABILITY command if it recognizes these automatic 1468 capabilities. This should only be done if a security layer was not 1469 negotiated by the AUTHENTICATE command, because the tagged OK 1470 response as part of an AUTHENTICATE command is not protected by 1471 encryption/integrity checking. [SASL] requires the client to re- 1472 issue a CAPABILITY command in this case. The server MAY advertise 1473 different capabilities after a successful AUTHENTICATE command. 1475 If an AUTHENTICATE command fails with a NO response, the client MAY 1476 try another authentication mechanism by issuing another AUTHENTICATE 1477 command. It MAY also attempt to authenticate by using the LOGIN 1478 command (see Section 6.2.3 for more detail). In other words, the 1479 client MAY request authentication types in decreasing order of 1480 preference, with the LOGIN command as a last resort. 1482 The authorization identity passed from the client to the server 1483 during the authentication exchange is interpreted by the server as 1484 the user name whose privileges the client is requesting. 1486 Example: S: * OK [CAPABILITY IMAP4rev2 STARTTLS AUTH=GSSAPI] 1487 Capabilities 1488 C: A001 AUTHENTICATE GSSAPI 1489 S: + 1490 C: YIIB+wYJKoZIhvcSAQICAQBuggHqMIIB5qADAgEFoQMCAQ6iBw 1491 MFACAAAACjggEmYYIBIjCCAR6gAwIBBaESGxB1Lndhc2hpbmd0 1492 b24uZWR1oi0wK6ADAgEDoSQwIhsEaW1hcBsac2hpdmFtcy5jYW 1493 Mud2FzaGluZ3Rvbi5lZHWjgdMwgdCgAwIBAaEDAgEDooHDBIHA 1494 cS1GSa5b+fXnPZNmXB9SjL8Ollj2SKyb+3S0iXMljen/jNkpJX 1495 AleKTz6BQPzj8duz8EtoOuNfKgweViyn/9B9bccy1uuAE2HI0y 1496 C/PHXNNU9ZrBziJ8Lm0tTNc98kUpjXnHZhsMcz5Mx2GR6dGknb 1497 I0iaGcRerMUsWOuBmKKKRmVMMdR9T3EZdpqsBd7jZCNMWotjhi 1498 vd5zovQlFqQ2Wjc2+y46vKP/iXxWIuQJuDiisyXF0Y8+5GTpAL 1499 pHDc1/pIGmMIGjoAMCAQGigZsEgZg2on5mSuxoDHEA1w9bcW9n 1500 FdFxDKpdrQhVGVRDIzcCMCTzvUboqb5KjY1NJKJsfjRQiBYBdE 1501 NKfzK+g5DlV8nrw81uOcP8NOQCLR5XkoMHC0Dr/80ziQzbNqhx 1502 O6652Npft0LQwJvenwDI13YxpwOdMXzkWZN/XrEqOWp6GCgXTB 1503 vCyLWLlWnbaUkZdEYbKHBPjd8t/1x5Yg== 1504 S: + YGgGCSqGSIb3EgECAgIAb1kwV6ADAgEFoQMCAQ+iSzBJoAMC 1505 AQGiQgRAtHTEuOP2BXb9sBYFR4SJlDZxmg39IxmRBOhXRKdDA0 1506 uHTCOT9Bq3OsUTXUlk0CsFLoa8j+gvGDlgHuqzWHPSQg== 1507 C: 1508 S: + YDMGCSqGSIb3EgECAgIBAAD/////6jcyG4GE3KkTzBeBiVHe 1509 ceP2CWY0SR0fAQAgAAQEBAQ= 1510 C: YDMGCSqGSIb3EgECAgIBAAD/////3LQBHXTpFfZgrejpLlLImP 1511 wkhbfa2QteAQAgAG1yYwE= 1512 S: A001 OK GSSAPI authentication successful 1514 The following example demonstrates use of initial response 1516 Example: 1517 S: * OK [CAPABILITY IMAP4rev2 STARTTLS AUTH=GSSAPI 1518 LOGINDISABLED] Server ready 1519 C: A01 STARTTLS 1520 S: A01 OK STARTLS completed 1521 1522 C: A02 CAPABILITY 1523 S: * CAPABILITY IMAP4rev2 AUTH=GSSAPI AUTH=PLAIN 1524 S: A02 OK CAPABILITY completed 1525 C: A03 AUTHENTICATE PLAIN dGVzdAB0ZXN0AHRlc3Q= 1526 S: A03 OK Success (tls protection) 1528 Note: The line breaks within server challenges and client responses 1529 are for editorial clarity and are not in real authenticators. 1531 6.2.3. LOGIN Command 1533 Arguments: user name 1534 password 1536 Responses: no specific responses for this command 1538 Result: OK - login completed, now in authenticated state 1539 NO - login failure: user name or password rejected 1540 BAD - command unknown or arguments invalid 1542 The LOGIN command identifies the client to the server and carries the 1543 plaintext password authenticating this user. The LOGIN command 1544 SHOULD NOT be used except as a last resort (after attempting and 1545 failing to authenticate using the AUTHENTICATE command one or more 1546 times), and it is recommended that client implementations have a 1547 means to disable any automatic use of the LOGIN command. 1549 A server MAY include a CAPABILITY response code in the tagged OK 1550 response to a successful LOGIN command in order to send capabilities 1551 automatically. It is unnecessary for a client to send a separate 1552 CAPABILITY command if it recognizes these automatic capabilities. 1554 Example: C: a001 LOGIN SMITH SESAME 1555 S: a001 OK LOGIN completed 1557 Note: Use of the LOGIN command over an insecure network (such as the 1558 Internet) is a security risk, because anyone monitoring network 1559 traffic can obtain plaintext passwords. For that reason clients MUST 1560 NOT use LOGIN on unsecure networks. 1562 Unless either the client is accessing IMAP service on Implicit TLS 1563 port [RFC8314], the STARTTLS command has been negotiated or some 1564 other mechanism that protects the session from password snooping has 1565 been provided, a server implementation MUST implement a configuration 1566 in which it advertises the LOGINDISABLED capability and does NOT 1567 permit the LOGIN command. Server sites SHOULD NOT use any 1568 configuration which permits the LOGIN command without such a 1569 protection mechanism against password snooping. A client 1570 implementation MUST NOT send a LOGIN command if the LOGINDISABLED 1571 capability is advertised. 1573 6.3. Client Commands - Authenticated State 1575 In the authenticated state, commands that manipulate mailboxes as 1576 atomic entities are permitted. Of these commands, the SELECT and 1577 EXAMINE commands will select a mailbox for access and enter the 1578 selected state. 1580 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 1581 the following commands are valid in the authenticated state: ENABLE, 1582 SELECT, EXAMINE, NAMESPACE, CREATE, DELETE, RENAME, SUBSCRIBE, 1583 UNSUBSCRIBE, LIST, STATUS, APPEND and IDLE. 1585 6.3.1. ENABLE Command 1587 Arguments: capability names 1589 Responses: no specific responses for this command 1591 Result: OK - Relevant capabilities enabled 1592 BAD - No arguments, or syntax error in an argument 1594 Several IMAP extensions allow the server to return unsolicited 1595 responses specific to these extensions in certain circumstances. 1596 However, servers cannot send those unsolicited responses (with the 1597 exception of response codes (see Section 7.1) included in tagged or 1598 untagged OK/NO/BAD responses, which can always be sent) until they 1599 know that the clients support such extensions and thus won't choke on 1600 the extension response data. 1602 The ENABLE command provides an explicit indication from the client 1603 that it supports particular extensions. It is designed such that the 1604 client can send a simple constant string with the extensions it 1605 supports, and the server will enable the shared subset that both 1606 support. 1608 The ENABLE command takes a list of capability names, and requests the 1609 server to enable the named extensions. Once enabled using ENABLE, 1610 each extension remains active until the IMAP connection is closed. 1611 For each argument, the server does the following: 1613 o If the argument is not an extension known to the server, the 1614 server MUST ignore the argument. 1616 o If the argument is an extension known to the server, and it is not 1617 specifically permitted to be enabled using ENABLE, the server MUST 1618 ignore the argument. (Note that knowing about an extension 1619 doesn't necessarily imply supporting that extension.) 1621 o If the argument is an extension that is supported by the server 1622 and that needs to be enabled, the server MUST enable the extension 1623 for the duration of the connection. Note that once an extension 1624 is enabled, there is no way to disable it. 1626 If the ENABLE command is successful, the server MUST send an untagged 1627 ENABLED response Section 7.2.1, which includes all enabled extensions 1628 as specified above. The ENABLED response is sent even if no 1629 extensions were enabled. 1631 Clients SHOULD only include extensions that need to be enabled by the 1632 server. For example, a client can enable IMAP4rev2 specific 1633 behaviour when both IMAP4rev1 and IMAP4rev2 are advertised in the 1634 CAPABILITY response. Future RFCs may add to this list. 1636 The ENABLE command is only valid in the authenticated state, before 1637 any mailbox is selected. Clients MUST NOT issue ENABLE once they 1638 SELECT/EXAMINE a mailbox; however, server implementations don't have 1639 to check that no mailbox is selected or was previously selected 1640 during the duration of a connection. 1642 The ENABLE command can be issued multiple times in a session. It is 1643 additive; i.e., "ENABLE a b", followed by "ENABLE c" is the same as a 1644 single command "ENABLE a b c". When multiple ENABLE commands are 1645 issued, each corresponding ENABLED response SHOULD only contain 1646 extensions enabled by the corresponding ENABLE command, i.e. for the 1647 above example, the ENABLED response to "ENABLE c" should not contain 1648 "a" or "b". 1650 There are no limitations on pipelining ENABLE. For example, it is 1651 possible to send ENABLE and then immediately SELECT, or a LOGIN 1652 immediately followed by ENABLE. 1654 The server MUST NOT change the CAPABILITY list as a result of 1655 executing ENABLE; i.e., a CAPABILITY command issued right after an 1656 ENABLE command MUST list the same capabilities as a CAPABILITY 1657 command issued before the ENABLE command. This is demonstrated in 1658 the following example. Note that below "X-GOOD-IDEA" is a fictitious 1659 extension capability that can be ENABLEd. 1661 C: t1 CAPABILITY 1662 S: * CAPABILITY IMAP4rev2 ID LITERAL+ X-GOOD-IDEA 1663 S: t1 OK foo 1664 C: t2 ENABLE CONDSTORE X-GOOD-IDEA 1665 S: * ENABLED X-GOOD-IDEA 1666 S: t2 OK foo 1667 C: t3 CAPABILITY 1668 S: * CAPABILITY IMAP4rev2 ID LITERAL+ X-GOOD-IDEA 1669 S: t3 OK foo again 1671 In the following example, the client enables CONDSTORE extension 1672 [RFC7162]: 1674 C: a1 ENABLE CONDSTORE 1675 S: * ENABLED CONDSTORE 1676 S: a1 OK Conditional Store enabled 1678 6.3.1.1. Note to Designers of Extensions That May Use the ENABLE 1679 Command 1681 Designers of IMAP extensions are discouraged from creating extensions 1682 that require ENABLE unless there is no good alternative design. 1683 Specifically, extensions that cause potentially incompatible behavior 1684 changes to deployed server responses (and thus benefit from ENABLE) 1685 have a higher complexity cost than extensions that do not. 1687 6.3.2. SELECT Command 1689 Arguments: mailbox name 1691 Responses: REQUIRED untagged responses: FLAGS, EXISTS, LIST 1692 REQUIRED OK untagged responses: PERMANENTFLAGS, 1693 UIDNEXT, UIDVALIDITY 1695 Result: OK - select completed, now in selected state 1696 NO - select failure, now in authenticated state: no 1697 such mailbox, can't access mailbox 1698 BAD - command unknown or arguments invalid 1700 The SELECT command selects a mailbox so that messages in the mailbox 1701 can be accessed. Before returning an OK to the client, the server 1702 MUST send the following untagged data to the client. (The order of 1703 individual responses is not important.) Note that earlier versions 1704 of this protocol (e.g. IMAP4rev1 version specified in RFC 2060) only 1705 required the FLAGS and EXISTS untagged responses and UIDVALIDITY 1706 response code; consequently, client implementations SHOULD implement 1707 default behavior for missing data as discussed with the individual 1708 item. 1710 FLAGS Defined flags in the mailbox. See the description of the 1711 FLAGS response in Section 7.3.5 for more detail. 1713 EXISTS The number of messages in the mailbox. See the 1714 description of the EXISTS response in Section 7.4.1 for more 1715 detail. 1717 LIST The server MUST return a LIST response with the mailbox name. 1718 The list of mailbox attributes MUST be accurate. If the server 1719 allows de-normalized UTF-8 mailbox names (see Section 5.1) and the 1720 supplied mailbox name differs from the normalized version, the 1721 server MUST return LIST with the OLDNAME extended data item. See 1722 Section 6.3.9.7 for more details. 1724 OK [PERMANENTFLAGS ()] A list of message flags that 1725 the client can change permanently. If this is missing, the client 1726 should assume that all flags can be changed permanently. 1728 OK [UIDNEXT ] The next unique identifier value. Refer to 1729 Section 2.3.1.1 for more information. 1731 OK [UIDVALIDITY ] The unique identifier validity value. Refer to 1732 Section 2.3.1.1 for more information. 1734 Only one mailbox can be selected at a time in a connection; 1735 simultaneous access to multiple mailboxes requires multiple 1736 connections. The SELECT command automatically deselects any 1737 currently selected mailbox before attempting the new selection. 1738 Consequently, if a mailbox is selected and a SELECT command that 1739 fails is attempted, no mailbox is selected. When deselecting a 1740 selected mailbox, the server MUST return an untagged OK response with 1741 the "[CLOSED]" response code when the currently selected mailbox is 1742 closed (see Paragraph 10). 1744 If the client is permitted to modify the mailbox, the server SHOULD 1745 prefix the text of the tagged OK response with the "[READ-WRITE]" 1746 response code. 1748 If the client is not permitted to modify the mailbox but is permitted 1749 read access, the mailbox is selected as read-only, and the server 1750 MUST prefix the text of the tagged OK response to SELECT with the 1751 "[READ-ONLY]" response code. Read-only access through SELECT differs 1752 from the EXAMINE command in that certain read-only mailboxes MAY 1753 permit the change of permanent state on a per-user (as opposed to 1754 global) basis. Netnews messages marked in a server-based .newsrc 1755 file are an example of such per-user permanent state that can be 1756 modified with read-only mailboxes. 1758 Example: C: A142 SELECT INBOX 1759 S: * 172 EXISTS 1760 S: * OK [UIDVALIDITY 3857529045] UIDs valid 1761 S: * OK [UIDNEXT 4392] Predicted next UID 1762 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1763 S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited 1764 S: * LIST () "/" INBOX 1765 S: A142 OK [READ-WRITE] SELECT completed 1767 Example: C: A142 SELECT INBOX 1768 S: * 172 EXISTS 1769 S: * OK [UIDVALIDITY 3857529045] UIDs valid 1770 S: * OK [UIDNEXT 4392] Predicted next UID 1771 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1772 S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited 1773 S: A142 OK [READ-WRITE] SELECT completed 1774 [...some time later...] 1775 C: A143 SELECT Drafts 1776 S: * OK [CLOSED] Previous mailbox is now closed 1777 S: * 5 EXISTS 1778 S: * OK [UIDVALIDITY 9877410381] UIDs valid 1779 S: * OK [UIDNEXT 102] Predicted next UID 1780 S: * LIST () "/" Drafts 1781 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1782 S: * OK [PERMANENTFLAGS (\Deleted \Seen \Answered 1783 \Flagged \Draft \*)] System flags and keywords allowed 1784 S: A143 OK [READ-WRITE] SELECT completed 1786 Note that IMAP4rev1 compliant servers can also send the untagged 1787 RECENT response which was deprecated in IMAP4rev2. E.g. "* 0 1788 RECENT". Pure IMAP4rev2 clients are advised to ignore the untagged 1789 RECENT response. 1791 6.3.3. EXAMINE Command 1793 Arguments: mailbox name 1795 Responses: REQUIRED untagged responses: FLAGS, EXISTS, LIST 1796 REQUIRED OK untagged responses: PERMANENTFLAGS, 1797 UIDNEXT, UIDVALIDITY 1799 Result: OK - examine completed, now in selected state 1800 NO - examine failure, now in authenticated state: no 1801 such mailbox, can't access mailbox BAD - command unknown 1802 or arguments invalid 1804 The EXAMINE command is identical to SELECT and returns the same 1805 output; however, the selected mailbox is identified as read-only. No 1806 changes to the permanent state of the mailbox, including per-user 1807 state, are permitted. 1809 The text of the tagged OK response to the EXAMINE command MUST begin 1810 with the "[READ-ONLY]" response code. 1812 Example: C: A932 EXAMINE blurdybloop 1813 S: * 17 EXISTS 1814 S: * OK [UIDVALIDITY 3857529045] UIDs valid 1815 S: * OK [UIDNEXT 4392] Predicted next UID 1816 S: * LIST () "/" blurdybloop 1817 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1818 S: * OK [PERMANENTFLAGS ()] No permanent flags permitted 1819 S: A932 OK [READ-ONLY] EXAMINE completed 1821 6.3.4. CREATE Command 1823 Arguments: mailbox name 1825 Responses: OPTIONAL untagged response: LIST 1827 Result: OK - create completed 1828 NO - create failure: can't create mailbox with that name 1829 BAD - command unknown or arguments invalid 1831 The CREATE command creates a mailbox with the given name. An OK 1832 response is returned only if a new mailbox with that name has been 1833 created. It is an error to attempt to create INBOX or a mailbox with 1834 a name that refers to an extant mailbox. Any error in creation will 1835 return a tagged NO response. If a client attempts to create a UTF-8 1836 mailbox name that is not a valid Net-Unicode name, the server MUST 1837 reject the creation or convert the name to Net-Unicode prior to 1838 creating the mailbox. If the server decides to convert (normalize) 1839 the name, it SHOULD return an untagged LIST with OLDNAME extended 1840 data item, with the OLDNAME value being the supplied mailbox name and 1841 the name parameter being the normalized mailbox name. (See 1842 Section 6.3.9.7 for more details.) 1844 Mailboxes created in one IMAP session MAY be announced to other IMAP 1845 sessions using unsolicited LIST response. If the server 1846 automatically subscribes a mailbox when it is created, then the 1847 unsolicited LIST response for each affected subscribed mailbox name 1848 MUST include the \Subscribed attribute. 1850 If the mailbox name is suffixed with the server's hierarchy separator 1851 character (as returned from the server by a LIST command), this is a 1852 declaration that the client intends to create mailbox names under 1853 this name in the hierarchy. Server implementations that do not 1854 require this declaration MUST ignore the declaration. In any case, 1855 the name created is without the trailing hierarchy delimiter. 1857 If the server's hierarchy separator character appears elsewhere in 1858 the name, the server SHOULD create any superior hierarchical names 1859 that are needed for the CREATE command to be successfully completed. 1861 In other words, an attempt to create "foo/bar/zap" on a server in 1862 which "/" is the hierarchy separator character SHOULD create foo/ and 1863 foo/bar/ if they do not already exist. 1865 If a new mailbox is created with the same name as a mailbox which was 1866 deleted, its unique identifiers MUST be greater than any unique 1867 identifiers used in the previous incarnation of the mailbox unless 1868 the new incarnation has a different unique identifier validity value. 1869 See the description of the UID command in Section 6.4.9 for more 1870 detail. 1872 Example: C: A003 CREATE owatagusiam/ 1873 S: A003 OK CREATE completed 1874 C: A004 CREATE owatagusiam/blurdybloop 1875 S: A004 OK CREATE completed 1876 C: A005 CREATE NonNormalized 1877 S: * LIST () "/" "Normalized" ("OLDNAME" ("NonNormalized")) 1878 S: A005 OK CREATE completed 1880 (in the last example imagine that "NonNormalized" is 1881 a non NFC normalized Unicode mailbox name and that 1882 "Normalized" is its NFC normalized version.) 1884 Note: The interpretation of this example depends on whether "/" 1885 was returned as the hierarchy separator from LIST. If "/" is the 1886 hierarchy separator, a new level of hierarchy named "owatagusiam" 1887 with a member called "blurdybloop" is created. Otherwise, two 1888 mailboxes at the same hierarchy level are created. 1890 6.3.5. DELETE Command 1892 Arguments: mailbox name 1894 Responses: OPTIONAL untagged response: LIST 1896 Result: OK - delete completed 1897 NO - delete failure: can't delete mailbox with that name 1898 BAD - command unknown or arguments invalid 1900 The DELETE command permanently removes the mailbox with the given 1901 name. A tagged OK response is returned only if the mailbox has been 1902 deleted. It is an error to attempt to delete INBOX or a mailbox name 1903 that does not exist. 1905 The DELETE command MUST NOT remove inferior hierarchical names. For 1906 example, if a mailbox "foo" has an inferior "foo.bar" (assuming "." 1907 is the hierarchy delimiter character), removing "foo" MUST NOT remove 1908 "foo.bar". It is an error to attempt to delete a name that has 1909 inferior hierarchical names and also has the \Noselect mailbox name 1910 attribute (see the description of the LIST response (Section 7.3.1) 1911 for more details). 1913 It is permitted to delete a name that has inferior hierarchical names 1914 and does not have the \Noselect mailbox name attribute. If the 1915 server implementation does not permit deleting the name while 1916 inferior hierarchical names exists then it SHOULD disallow the DELETE 1917 command by returning a tagged NO response. The NO response SHOULD 1918 include the HASCHILDREN response code. Alternatively the server MAY 1919 allow the DELETE command, but sets the \Noselect mailbox name 1920 attribute for that name. 1922 If the server returns OK response, all messages in that mailbox are 1923 removed by the DELETE command. 1925 The value of the highest-used unique identifier of the deleted 1926 mailbox MUST be preserved so that a new mailbox created with the same 1927 name will not reuse the identifiers of the former incarnation, unless 1928 the new incarnation has a different unique identifier validity value. 1929 See the description of the UID command in Section 6.4.9 for more 1930 detail. 1932 If the server decides to convert (normalize) the mailbox name, it 1933 SHOULD return an untagged LIST with the "\NonExistent" attribute and 1934 OLDNAME extended data item, with the OLDNAME value being the supplied 1935 mailbox name and the name parameter being the normalized mailbox 1936 name. (See Section 6.3.9.7 for more details.) 1938 Mailboxes deleted in one IMAP session MAY be announced to other IMAP 1939 sessions using unsolicited LIST response, containing the 1940 "\NonExistent" attribute. 1942 Example: C: A682 LIST "" * 1943 S: * LIST () "/" blurdybloop 1944 S: * LIST (\Noselect) "/" foo 1945 S: * LIST () "/" foo/bar 1946 S: A682 OK LIST completed 1947 C: A683 DELETE blurdybloop 1948 S: A683 OK DELETE completed 1949 C: A684 DELETE foo 1950 S: A684 NO Name "foo" has inferior hierarchical names 1951 C: A685 DELETE foo/bar 1952 S: A685 OK DELETE Completed 1953 C: A686 LIST "" * 1954 S: * LIST (\Noselect) "/" foo 1955 S: A686 OK LIST completed 1956 C: A687 DELETE foo 1957 S: A687 OK DELETE Completed 1959 Example: C: A82 LIST "" * 1960 S: * LIST () "." blurdybloop 1961 S: * LIST () "." foo 1962 S: * LIST () "." foo.bar 1963 S: A82 OK LIST completed 1964 C: A83 DELETE blurdybloop 1965 S: A83 OK DELETE completed 1966 C: A84 DELETE foo 1967 S: A84 OK DELETE Completed 1968 C: A85 LIST "" * 1969 S: * LIST () "." foo.bar 1970 S: A85 OK LIST completed 1971 C: A86 LIST "" % 1972 S: * LIST (\Noselect) "." foo 1973 S: A86 OK LIST completed 1975 6.3.6. RENAME Command 1977 Arguments: existing mailbox name 1978 new mailbox name 1980 Responses: OPTIONAL untagged response: LIST 1982 Result: OK - rename completed 1983 NO - rename failure: can't rename mailbox with that name, 1984 can't rename to mailbox with that name 1985 BAD - command unknown or arguments invalid 1987 The RENAME command changes the name of a mailbox. A tagged OK 1988 response is returned only if the mailbox has been renamed. It is an 1989 error to attempt to rename from a mailbox name that does not exist or 1990 to a mailbox name that already exists. Any error in renaming will 1991 return a tagged NO response. 1993 If the name has inferior hierarchical names, then the inferior 1994 hierarchical names MUST also be renamed. For example, a rename of 1995 "foo" to "zap" will rename "foo/bar" (assuming "/" is the hierarchy 1996 delimiter character) to "zap/bar". 1998 If the server's hierarchy separator character appears in the new 1999 mailbox name, the server SHOULD create any superior hierarchical 2000 names that are needed for the RENAME command to complete 2001 successfully. In other words, an attempt to rename "foo/bar/zap" to 2002 baz/rag/zowie on a server in which "/" is the hierarchy separator 2003 character in the corresponding namespace SHOULD create baz/ and baz/ 2004 rag/ if they do not already exist. 2006 The value of the highest-used unique identifier of the old mailbox 2007 name MUST be preserved so that a new mailbox created with the same 2008 name will not reuse the identifiers of the former incarnation, unless 2009 the new incarnation has a different unique identifier validity value. 2010 See the description of the UID command in Section 6.4.9 for more 2011 detail. 2013 Renaming INBOX is permitted (i.e. it doesn't result in a tagged BAD 2014 response), and has special behavior. (Note that some servers 2015 disallow renaming INBOX by returning a tagged NO response, so clients 2016 need to be able to handle such RENAME failing). It moves all 2017 messages in INBOX to a new mailbox with the given name, leaving INBOX 2018 empty. If the server implementation supports inferior hierarchical 2019 names of INBOX, these are unaffected by a rename of INBOX. 2021 If the server allows creation of mailboxes with names that are not 2022 valid Net-Unicode names, the server normalizes both the existing 2023 mailbox name parameter and the new mailbox name parameter. If the 2024 normalized version of any of these 2 parameters differs from the 2025 corresponding supplied version, the server SHOULD return an untagged 2026 LIST response with OLDNAME extended data item, with the OLDNAME value 2027 being the supplied existing mailbox name and the name parameter being 2028 the normalized new mailbox name (see Section 6.3.9.7). This would 2029 allow the client to correlate the supplied name with the normalized 2030 name. 2032 Mailboxes renamed in one IMAP session MAY be announced to other IMAP 2033 sessions using unsolicited LIST response with OLDNAME extended data 2034 item. 2036 In both of the above cases: if the server automatically subscribes a 2037 mailbox when it is renamed, then the unsolicited LIST response for 2038 each affected subscribed mailbox name MUST include the \Subscribed 2039 attribute. No unsolicited LIST responses need to be sent for 2040 children mailboxes, if any. When INBOX is successfully renamed, a 2041 new INBOX is assumed to be created. No unsolicited LIST responses 2042 need to be sent for INBOX in this case. 2044 Examples: C: A682 LIST "" * 2045 S: * LIST () "/" blurdybloop 2046 S: * LIST (\Noselect) "/" foo 2047 S: * LIST () "/" foo/bar 2048 S: A682 OK LIST completed 2049 C: A683 RENAME blurdybloop sarasoop 2050 S: A683 OK RENAME completed 2051 C: A684 RENAME foo zowie 2052 S: A684 OK RENAME Completed 2053 C: A685 LIST "" * 2054 S: * LIST () "/" sarasoop 2055 S: * LIST (\Noselect) "/" zowie 2056 S: * LIST () "/" zowie/bar 2057 S: A685 OK LIST completed 2059 C: Z432 LIST "" * 2060 S: * LIST () "." INBOX 2061 S: * LIST () "." INBOX.bar 2062 S: Z432 OK LIST completed 2063 C: Z433 RENAME INBOX old-mail 2064 S: Z433 OK RENAME completed 2065 C: Z434 LIST "" * 2066 S: * LIST () "." INBOX 2067 S: * LIST () "." INBOX.bar 2068 S: * LIST () "." old-mail 2069 S: Z434 OK LIST completed 2071 Note that renaming a mailbox doesn't update subscription information 2072 on the original name. To keep subscription information in sync, the 2073 following sequence of commands can be used: 2075 C: 1001 RENAME X Y 2076 C: 1002 SUBSCRIBE Y 2077 C: 1003 UNSUBSCRIBE X 2079 Note that the above sequence of commands doesn't account for updating 2080 subscription for any children mailboxes of mailbox X. 2082 6.3.7. SUBSCRIBE Command 2084 Arguments: mailbox 2086 Responses: no specific responses for this command 2088 Result: OK - subscribe completed 2089 NO - subscribe failure: can't subscribe to that name 2090 BAD - command unknown or arguments invalid 2092 The SUBSCRIBE command adds the specified mailbox name to the server's 2093 set of "active" or "subscribed" mailboxes as returned by the LIST 2094 (SUBSCRIBED) command. This command returns a tagged OK response if 2095 the subscription is successful or if the mailbox is already 2096 subscribed. 2098 A server MAY validate the mailbox argument to SUBSCRIBE to verify 2099 that it exists. However, it SHOULD NOT unilaterally remove an 2100 existing mailbox name from the subscription list even if a mailbox by 2101 that name no longer exists. 2103 Note: This requirement is because a server site can choose to 2104 routinely remove a mailbox with a well-known name (e.g., "system- 2105 alerts") after its contents expire, with the intention of 2106 recreating it when new contents are appropriate. 2108 Example: C: A002 SUBSCRIBE #news.comp.mail.mime 2109 S: A002 OK SUBSCRIBE completed 2111 6.3.8. UNSUBSCRIBE Command 2113 Arguments: mailbox name 2115 Responses: no specific responses for this command 2117 Result: OK - unsubscribe completed 2118 NO - unsubscribe failure: can't unsubscribe that name 2119 BAD - command unknown or arguments invalid 2121 The UNSUBSCRIBE command removes the specified mailbox name from the 2122 server's set of "active" or "subscribed" mailboxes as returned by the 2123 LIST (SUBSCRIBED) command. This command returns a tagged OK response 2124 if the unsubscription is successful or if the mailbox is not 2125 subscribed. 2127 Example: C: A002 UNSUBSCRIBE #news.comp.mail.mime 2128 S: A002 OK UNSUBSCRIBE completed 2130 6.3.9. LIST Command 2132 Arguments (basic): reference name 2133 mailbox name with possible wildcards 2135 Arguments (extended): selection options (OPTIONAL) 2136 reference name 2137 mailbox patterns 2138 return options (OPTIONAL) 2140 Responses: untagged responses: LIST 2142 Result: OK - list completed 2143 NO - list failure: can't list that reference or mailbox 2144 name 2145 BAD - command unknown or arguments invalid 2147 The LIST command returns a subset of mailbox names from the complete 2148 set of all mailbox names available to the client. Zero or more 2149 untagged LIST responses are returned, containing the name attributes, 2150 hierarchy delimiter, name, and possible extension information; see 2151 the description of the LIST response (Section 7.3.1) for more detail. 2153 The LIST command SHOULD return its data quickly, without undue delay. 2154 For example, it should not go to excess trouble to calculate the 2155 \Marked or \Unmarked status or perform other processing; if each name 2156 requires 1 second of processing, then a list of 1200 names would take 2157 20 minutes! 2159 The extended LIST command, originally introduced in [RFC5258], 2160 provides capabilities beyond that of the original IMAP LIST command. 2161 The extended syntax is being used if one or more of the following 2162 conditions is true: 2164 1. if the first word after the command name begins with a 2165 parenthesis ("LIST selection options"); 2167 2. if the second word after the command name begins with a 2168 parenthesis; 2170 3. if the LIST command has more than 2 parameters ("LIST return 2171 options") 2173 An empty ("" string) reference name argument indicates that the 2174 mailbox name is interpreted as by SELECT. The returned mailbox names 2175 MUST match the supplied mailbox name pattern(s). A non-empty 2176 reference name argument is the name of a mailbox or a level of 2177 mailbox hierarchy, and indicates the context in which the mailbox 2178 name is interpreted. Clients SHOULD use the empty reference 2179 argument. 2181 In the basic syntax only, an empty ("" string) mailbox name argument 2182 is a special request to return the hierarchy delimiter and the root 2183 name of the name given in the reference. The value returned as the 2184 root MAY be the empty string if the reference is non-rooted or is an 2185 empty string. In all cases, a hierarchy delimiter (or NIL if there 2186 is no hierarchy) is returned. This permits a client to get the 2187 hierarchy delimiter (or find out that the mailbox names are flat) 2188 even when no mailboxes by that name currently exist. 2190 In the extended syntax, any mailbox name arguments that are empty 2191 strings are ignored. There is no special meaning for empty mailbox 2192 names when the extended syntax is used. 2194 The reference and mailbox name arguments are interpreted into a 2195 canonical form that represents an unambiguous left-to-right 2196 hierarchy. The returned mailbox names will be in the interpreted 2197 form, that we call "canonical LIST pattern" later in this document. 2198 To define the term "canonical LIST pattern" formally: it refers to 2199 the canonical pattern constructed internally by the server from the 2200 reference and mailbox name arguments. 2202 Note: The interpretation of the reference argument is 2203 implementation-defined. It depends upon whether the server 2204 implementation has a concept of the "current working directory" 2205 and leading "break out characters", which override the current 2206 working directory. 2208 For example, on a server which exports a UNIX or NT filesystem, 2209 the reference argument contains the current working directory, and 2210 the mailbox name argument would contain the name as interpreted in 2211 the current working directory. 2213 If a server implementation has no concept of break out characters, 2214 the canonical form is normally the reference name appended with 2215 the mailbox name. Note that if the server implements the 2216 namespace convention (Section 5.1.2.1), "#" is a break out 2217 character and must be treated as such. 2219 If the reference argument is not a level of mailbox hierarchy 2220 (that is, it is a \NoInferiors name), and/or the reference 2221 argument does not end with the hierarchy delimiter, it is 2222 implementation-dependent how this is interpreted. For example, a 2223 reference of "foo/bar" and mailbox name of "rag/baz" could be 2224 interpreted as "foo/bar/rag/baz", "foo/barrag/baz", or "foo/rag/ 2225 baz". A client SHOULD NOT use such a reference argument except at 2226 the explicit request of the user. A hierarchical browser MUST NOT 2227 make any assumptions about server interpretation of the reference 2228 unless the reference is a level of mailbox hierarchy AND ends with 2229 the hierarchy delimiter. 2231 Any part of the reference argument that is included in the 2232 interpreted form SHOULD prefix the interpreted form. It SHOULD also 2233 be in the same form as the reference name argument. This rule 2234 permits the client to determine if the returned mailbox name is in 2235 the context of the reference argument, or if something about the 2236 mailbox argument overrode the reference argument. Without this rule, 2237 the client would have to have knowledge of the server's naming 2238 semantics including what characters are "breakouts" that override a 2239 naming context. 2241 Here are some examples of how references 2242 and mailbox names might be interpreted on a UNIX-based 2243 server: 2245 Reference Mailbox Name Interpretation 2246 ------------ ------------ -------------- 2247 ~smith/Mail/ foo.* ~smith/Mail/foo.* 2248 archive/ % archive/% 2249 #news. comp.mail.* #news.comp.mail.* 2250 ~smith/Mail/ /usr/doc/foo /usr/doc/foo 2251 archive/ ~fred/Mail/* ~fred/Mail/* 2253 The first three examples demonstrate interpretations in 2254 the context of the reference argument. Note that 2255 "~smith/Mail" SHOULD NOT be transformed into something 2256 like "/u2/users/smith/Mail", or it would be impossible 2257 for the client to determine that the interpretation was 2258 in the context of the reference. 2260 The character "*" is a wildcard, and matches zero or more characters 2261 at this position. The character "%" is similar to "*", but it does 2262 not match a hierarchy delimiter. If the "%" wildcard is the last 2263 character of a mailbox name argument, matching levels of hierarchy 2264 are also returned. If these levels of hierarchy are not also 2265 selectable mailboxes, they are returned with the \Noselect mailbox 2266 name attribute (see the description of the LIST response 2267 (Section 7.3.1) for more details). 2269 Any syntactically valid pattern that is not accepted by a server for 2270 any reason MUST be silently ignored. I.e. it results in no LIST 2271 responses and the LIST command still returns tagged OK response. 2273 Selection options tell the server to limit the mailbox names that are 2274 selected by the LIST operation. If selection options are used, the 2275 mailboxes returned are those that match both the list of canonical 2276 LIST patterns and the selection options. Unless a particular 2277 selection option provides special rules, the selection options are 2278 cumulative: a mailbox that matches the mailbox patterns is selected 2279 only if it also matches all of the selection options. (An example of 2280 a selection option with special rules is the RECURSIVEMATCH option.) 2282 Return options control what information is returned for each matched 2283 mailbox. Return options MUST NOT cause the server to report 2284 information about additional mailbox names other than those that 2285 match the canonical LIST patterns and selection options. If no 2286 return options are specified, the client is only expecting 2287 information about mailbox attributes. The server MAY return other 2288 information about the matched mailboxes, and clients MUST be able to 2289 handle that situation. 2291 Initial selection options and return options are defined in the 2292 following subsections, and new ones will also be defined in 2293 extensions. Initial options defined in this document MUST be 2294 supported. Each non-initial option will be enabled by a capability 2295 string (one capability may enable multiple options), and a client 2296 MUST NOT send an option for which the server has not advertised 2297 support. A server MUST respond to options it does not recognize with 2298 a BAD response. The client SHOULD NOT specify any option more than 2299 once; however, if the client does this, the server MUST act as if it 2300 received the option only once. The order in which options are 2301 specified by the client is not significant. 2303 In general, each selection option except RECURSIVEMATCH will have a 2304 corresponding return option with the same name. The REMOTE selection 2305 option is an anomaly in this regard, and does not have a 2306 corresponding return option. That is because it expands, rather than 2307 restricts, the set of mailboxes that are returned. Future extensions 2308 to this specification should keep this parallelism in mind and define 2309 a pair of corresponding selection and return options. 2311 Server implementations are permitted to "hide" otherwise accessible 2312 mailboxes from the wildcard characters, by preventing certain 2313 characters or names from matching a wildcard in certain situations. 2314 For example, a UNIX-based server might restrict the interpretation of 2315 "*" so that an initial "/" character does not match. 2317 The special name INBOX is included in the output from LIST, if INBOX 2318 is supported by this server for this user and if the uppercase string 2319 "INBOX" matches the interpreted reference and mailbox name arguments 2320 with wildcards as described above. The criteria for omitting INBOX 2321 is whether SELECT INBOX will return failure; it is not relevant 2322 whether the user's real INBOX resides on this or some other server. 2324 6.3.9.1. LIST Selection Options 2326 The selection options defined in this specification are as follows: 2328 SUBSCRIBED - causes the LIST command to list subscribed names, 2329 rather than the existing mailboxes. This will often be a subset 2330 of the actual mailboxes. It's also possible for this list to 2331 contain the names of mailboxes that don't exist. In any case, the 2332 list MUST include exactly those mailbox names that match the 2333 canonical list pattern and are subscribed to. 2335 This option defines a mailbox attribute, "\Subscribed", that 2336 indicates that a mailbox name is subscribed to. The "\Subscribed" 2337 attribute MUST be supported and MUST be accurately computed when 2338 the SUBSCRIBED selection option is specified. 2340 Note that the SUBSCRIBED selection option implies the SUBSCRIBED 2341 return option (see below). 2343 REMOTE - causes the LIST command to show remote mailboxes as well as 2344 local ones, as described in [RFC2193]. This option is intended to 2345 replace the RLIST command and, in conjunction with the SUBSCRIBED 2346 selection option, the RLSUB command. Servers that don't support 2347 the concept of remote mailboxes just ignore this option. 2349 This option defines a mailbox attribute, "\Remote", that indicates 2350 that a mailbox is a remote mailbox. The "\Remote" attribute MUST 2351 be accurately computed when the REMOTE option is specified. 2353 The REMOTE selection option has no interaction with other options. 2354 Its effect is to tell the server to apply the other options, if 2355 any, to remote mailboxes, in addition to local ones. In 2356 particular, it has no interaction with RECURSIVEMATCH (see below). 2357 A request for (REMOTE RECURSIVEMATCH) is invalid, because a 2358 request for (RECURSIVEMATCH) is also invalid. A request for 2359 (REMOTE RECURSIVEMATCH SUBSCRIBED) is asking for all subscribed 2360 mailboxes, both local and remote. 2362 RECURSIVEMATCH - this option forces the server to return information 2363 about parent mailboxes that don't match other selection options, 2364 but have some submailboxes that do. Information about children is 2365 returned in the CHILDINFO extended data item, as described in 2366 Section 6.3.9.6. 2368 Note 1: In order for a parent mailbox to be returned, it still has 2369 to match the canonical LIST pattern. 2371 Note 2: When returning the CHILDINFO extended data item, it 2372 doesn't matter whether or not the submailbox matches the canonical 2373 LIST pattern. See also example 9 in Section 6.3.9.8. 2375 The RECURSIVEMATCH option MUST NOT occur as the only selection 2376 option (or only with REMOTE), as it only makes sense when other 2377 selection options are also used. The server MUST return BAD 2378 tagged response in such case. 2380 Note that even if the RECURSIVEMATCH option is specified, the 2381 client MUST still be able to handle a case when a CHILDINFO 2382 extended data item is returned and there are no submailboxes that 2383 meet the selection criteria of the subsequent LIST command, as 2384 they can be deleted/renamed after the LIST response was sent, but 2385 before the client had a chance to access them. 2387 6.3.9.2. LIST Return Options 2389 The return options defined in this specification are as follows: 2391 SUBSCRIBED - causes the LIST command to return subscription state 2392 for all matching mailbox names. The "\Subscribed" attribute MUST 2393 be supported and MUST be accurately computed when the SUBSCRIBED 2394 return option is specified. Further, all other mailbox attributes 2395 MUST be accurately computed (this differs from the behavior of the 2396 obsolete LSUB command from RFC 3501). Note that the above 2397 requirements don't override the requirement for the LIST command 2398 to return results quickly (see Section 6.3.9), i.e. server 2399 implementations need to compute results quickly and accurately. 2400 For example, server implementors might need to create quick access 2401 indices. 2403 CHILDREN - requests mailbox child information as originally proposed 2404 in [RFC3348]. See Section 6.3.9.5, below, for details. 2406 STATUS - requests STATUS response for each matching mailbox. 2408 This option takes STATUS data items as parameters. For each 2409 selectable mailbox matching the list pattern and selection 2410 options, the server MUST return an untagged LIST response 2411 followed by an untagged STATUS response containing the 2412 information requested in the STATUS return option, except for 2413 some cases described below. 2415 If an attempted STATUS for a listed mailbox fails because the 2416 mailbox can't be selected (e.g., if the "l" ACL right [RFC4314] 2417 is granted to the mailbox and the "r" right is not granted, or 2418 due to a race condition between LIST and STATUS changing the 2419 mailbox to \NoSelect), the STATUS response MUST NOT be returned 2420 and the LIST response MUST include the \NoSelect attribute. 2421 This means the server may have to buffer the LIST reply until 2422 it has successfully looked up the necessary STATUS information. 2424 If the server runs into unexpected problems while trying to 2425 look up the STATUS information, it MAY drop the corresponding 2426 STATUS reply. In such a situation, the LIST command would 2427 still return a tagged OK reply. 2429 6.3.9.3. General Principles for Returning LIST Responses 2431 This section outlines several principles that can be used by server 2432 implementations of this document to decide whether a LIST response 2433 should be returned, as well as how many responses and what kind of 2434 information they may contain. 2436 1. At most one LIST response should be returned for each mailbox 2437 name that matches the canonical LIST pattern. Server 2438 implementors must not assume that clients will be able to 2439 assemble mailbox attributes and other information returned in 2440 multiple LIST responses. 2442 2. There are only two reasons for including a matching mailbox name 2443 in the responses to the LIST command (note that the server is 2444 allowed to return unsolicited responses at any time, and such 2445 responses are not governed by this rule): 2447 A. The mailbox name also satisfies the selection criteria. 2449 B. The mailbox name doesn't satisfy the selection criteria, but 2450 it has at least one descendant mailbox name that satisfies 2451 the selection criteria and that doesn't match the canonical 2452 LIST pattern. 2454 For more information on this case, see the CHILDINFO extended 2455 data item described in Section 6.3.9.6. Note that the 2456 CHILDINFO extended data item can only be returned when the 2457 RECURSIVEMATCH selection option is specified. 2459 3. Attributes returned in the same LIST response are treated 2460 additively. For example, the following response 2462 S: * LIST (\Subscribed \NonExistent) "/" "Fruit/Peach" 2464 means that the "Fruit/Peach" mailbox doesn't exist, but it is 2465 subscribed. 2467 6.3.9.4. Additional LIST-related Requirements on Clients 2469 All clients MUST treat a LIST attribute with a stronger meaning as 2470 implying any attribute that can be inferred from it. (See 2471 Section 7.3.1 for the list of currently defined attributes). For 2472 example, the client must treat the presence of the \NoInferiors 2473 attribute as if the \HasNoChildren attribute was also sent by the 2474 server. 2476 The following table summarizes inference rules. 2478 +--------------------+-------------------+ 2479 | returned attribute | implied attribute | 2480 +--------------------+-------------------+ 2481 | \NoInferiors | \HasNoChildren | 2482 | \NonExistent | \NoSelect | 2483 +--------------------+-------------------+ 2485 6.3.9.5. The CHILDREN Return Option 2487 The CHILDREN return option is simply an indication that the client 2488 wants information about whether or not mailboxes contain children 2489 mailboxes; a server MAY provide it even if the option is not 2490 specified. 2492 Many IMAP4 clients present to the user a hierarchical view of the 2493 mailboxes that a user has access to. Rather than initially 2494 presenting to the user the entire mailbox hierarchy, it is often 2495 preferable to show to the user a collapsed outline list of the 2496 mailbox hierarchy (particularly if there is a large number of 2497 mailboxes). The user can then expand the collapsed outline hierarchy 2498 as needed. It is common to include within the collapsed hierarchy a 2499 visual clue (such as a ''+'') to indicate that there are child 2500 mailboxes under a particular mailbox. When the visual clue is 2501 clicked, the hierarchy list is expanded to show the child mailboxes. 2502 The CHILDREN return option provides a mechanism for a client to 2503 efficiently determine whether a particular mailbox has children, 2504 without issuing a LIST "" * or a LIST "" % for each mailbox name. 2505 The CHILDREN return option defines two new attributes that MUST be 2506 returned within a LIST response: \HasChildren and \HasNoChildren. 2507 Although these attributes MAY be returned in response to any LIST 2508 command, the CHILDREN return option is provided to indicate that the 2509 client particularly wants this information. If the CHILDREN return 2510 option is present, the server MUST return these attributes even if 2511 their computation is expensive. 2513 \HasChildren 2515 The presence of this attribute indicates that the mailbox has 2516 child mailboxes. A server SHOULD NOT set this attribute if 2517 there are child mailboxes and the user does not have permission 2518 to access any of them. In this case, \HasNoChildren SHOULD be 2519 used. In many cases, however, a server may not be able to 2520 efficiently compute whether a user has access to any child 2521 mailbox. Note that even though the \HasChildren attribute for a 2522 mailbox must be correct at the time of processing of the 2523 mailbox, a client must be prepared to deal with a situation when 2524 a mailbox is marked with the \HasChildren attribute, but no 2525 child mailbox appears in the response to the LIST command. This 2526 might happen, for example, due to children mailboxes being 2527 deleted or made inaccessible to the user (using access control) 2528 by another client before the server is able to list them. 2530 \HasNoChildren 2532 The presence of this attribute indicates that the mailbox has NO 2533 child mailboxes that are accessible to the currently 2534 authenticated user. 2536 It is an error for the server to return both a \HasChildren and a 2537 \HasNoChildren attribute in the same LIST response. 2539 Note: the \HasNoChildren attribute should not be confused with the 2540 the \NoInferiors attribute, which indicates that no child mailboxes 2541 exist now and none can be created in the future. 2543 6.3.9.6. CHILDINFO Extended Data Item 2545 The CHILDINFO extended data item MUST NOT be returned unless the 2546 client has specified the RECURSIVEMATCH selection option. 2548 The CHILDINFO extended data item in a LIST response describes the 2549 selection criteria that has caused it to be returned and indicates 2550 that the mailbox has at least one descendant mailbox that matches the 2551 selection criteria. 2553 Note: Some servers allow for mailboxes to exist without requiring 2554 their parent to exist. For example, a mailbox "Customers/ABC" can 2555 exist while the mailbox "Customers" does not. As CHILDINFO extended 2556 data item is not allowed if the RECURSIVEMATCH selection option is 2557 not specified, such servers SHOULD use the "\NonExistent 2558 \HasChildren" attribute pair to signal to the client that there is a 2559 descendant mailbox that matches the selection criteria. See example 2560 11 in Section 6.3.9.8. 2562 The returned selection criteria allow the client to distinguish a 2563 solicited response from an unsolicited one, as well as to distinguish 2564 among solicited responses caused by multiple pipelined LIST commands 2565 that specify different criteria. 2567 Servers SHOULD only return a non-matching mailbox name along with 2568 CHILDINFO if at least one matching child is not also being returned. 2569 That is, servers SHOULD suppress redundant CHILDINFO responses. 2571 Examples 8 and 10 in Section 6.3.9.8 demonstrate the difference 2572 between present CHILDINFO extended data item and the "\HasChildren" 2573 attribute. 2575 The following table summarizes interaction between the "\NonExistent" 2576 attribute and CHILDINFO (the first column indicates whether the 2577 parent mailbox exists): 2579 +--------+-------------+------------------+-------------------------+ 2580 | exists | meets the | has a child that | returned | 2581 | | selection | meets the | IMAP4rev2/LIST-EXTENDED | 2582 | | criteria | selection | attributes and | 2583 | | | criteria | CHILDINFO | 2584 +--------+-------------+------------------+-------------------------+ 2585 | no | no | no | no LIST response | 2586 | | | | returned | 2587 | yes | no | no | no LIST response | 2588 | | | | returned | 2589 | no | yes | no | (\NonExistent ) | 2590 | yes | yes | no | () | 2591 | no | no | yes | (\NonExistent) + | 2592 | | | | CHILDINFO | 2593 | yes | no | yes | () + CHILDINFO | 2594 | no | yes | yes | (\NonExistent ) + | 2595 | | | | CHILDINFO | 2596 | yes | yes | yes | () + CHILDINFO | 2597 +--------+-------------+------------------+-------------------------+ 2599 where is one or more attributes that correspond to the 2600 selection criteria; for example, for the SUBSCRIBED option the 2601 is \Subscribed. 2603 6.3.9.7. OLDNAME Extended Data Item 2605 The OLDNAME extended data item is included when a mailbox name is 2606 created (with CREATE command), renamed (with RENAME command) or 2607 deleted (with DELETE command). (When a mailbox is deleted the 2608 "\NonExistent" attribute is also included.) IMAP extensions can 2609 specify other conditions when OLDNAME extended data item should be 2610 included. 2612 If the server allows de-normalized mailbox names (see Section 5.1) in 2613 SELECT/EXAMINE, CREATE, RENAME or DELETE, it SHOULD return an 2614 unsolicited LIST response that includes OLDNAME extended data item, 2615 whenever the supplied mailbox name differs from the resulting 2616 normalized mailbox name. From the client point of view this is 2617 indistinguishable from another user renaming or deleting the mailbox, 2618 as specified in the previous paragraph. 2620 A deleted mailbox can be announced like this: 2622 S: * LIST (\NonExistent) "." "INBOX.DeletedMailbox" 2624 Example of a renamed mailbox: 2626 S: * LIST () "/" "NewMailbox" ("OLDNAME" ("OldMailbox")) 2628 6.3.9.8. LIST Command Examples 2630 This example shows some uses of the basic LIST command: 2632 Example: C: A101 LIST "" "" 2633 S: * LIST (\Noselect) "/" "" 2634 S: A101 OK LIST Completed 2635 C: A102 LIST #news.comp.mail.misc "" 2636 S: * LIST (\Noselect) "." #news. 2637 S: A102 OK LIST Completed 2638 C: A103 LIST /usr/staff/jones "" 2639 S: * LIST (\Noselect) "/" / 2640 S: A103 OK LIST Completed 2641 C: A202 LIST ~/Mail/ % 2642 S: * LIST (\Noselect) "/" ~/Mail/foo 2643 S: * LIST () "/" ~/Mail/meetings 2644 S: A202 OK LIST completed 2646 Extended examples: 2648 1: The first example shows the complete local hierarchy that will 2649 be used for the other examples. 2651 C: A01 LIST "" "*" 2652 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2653 S: * LIST () "/" "Fruit" 2654 S: * LIST () "/" "Fruit/Apple" 2655 S: * LIST () "/" "Fruit/Banana" 2656 S: * LIST () "/" "Tofu" 2657 S: * LIST () "/" "Vegetable" 2658 S: * LIST () "/" "Vegetable/Broccoli" 2659 S: * LIST () "/" "Vegetable/Corn" 2660 S: A01 OK done 2662 2: In the next example, we will see the subscribed mailboxes. This 2663 is similar to, but not equivalent with now deprecated, (see [RFC3501] for more details on LSUB command). Note 2665 that the mailbox called "Fruit/Peach" is subscribed to, but does 2666 not actually exist (perhaps it was deleted while still 2667 subscribed). The "Fruit" mailbox is not subscribed to, but it 2668 has two subscribed children. The "Vegetable" mailbox is 2669 subscribed and has two children; one of them is subscribed as 2670 well. 2672 C: A02 LIST (SUBSCRIBED) "" "*" 2673 S: * LIST (\Marked \NoInferiors \Subscribed) "/" "inbox" 2674 S: * LIST (\Subscribed) "/" "Fruit/Banana" 2675 S: * LIST (\Subscribed \NonExistent) "/" "Fruit/Peach" 2676 S: * LIST (\Subscribed) "/" "Vegetable" 2677 S: * LIST (\Subscribed) "/" "Vegetable/Broccoli" 2678 S: A02 OK done 2680 3: The next example shows the use of the CHILDREN option. The 2681 client, without having to list the second level of hierarchy, 2682 now knows which of the top-level mailboxes have submailboxes 2683 (children) and which do not. Note that it's not necessary for 2684 the server to return the \HasNoChildren attribute for the inbox, 2685 because the \NoInferiors attribute already implies that, and has 2686 a stronger meaning. 2688 C: A03 LIST () "" "%" RETURN (CHILDREN) 2689 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2690 S: * LIST (\HasChildren) "/" "Fruit" 2691 S: * LIST (\HasNoChildren) "/" "Tofu" 2692 S: * LIST (\HasChildren) "/" "Vegetable" 2693 S: A03 OK done 2695 4: In this example, we see more mailboxes that reside on another 2696 server. This is similar to the command . 2698 C: A04 LIST (REMOTE) "" "%" RETURN (CHILDREN) 2699 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2700 S: * LIST (\HasChildren) "/" "Fruit" 2701 S: * LIST (\HasNoChildren) "/" "Tofu" 2702 S: * LIST (\HasChildren) "/" "Vegetable" 2703 S: * LIST (\Remote \HasNoChildren) "/" "Bread" 2704 S: * LIST (\HasChildren \Remote) "/" "Meat" 2705 S: A04 OK done 2707 5: The following example also requests the server to include 2708 mailboxes that reside on another server. The server returns 2709 information about all mailboxes that are subscribed. This is 2710 similar to the command (see [RFC2193] for more 2711 details on RLSUB). We also see the use of two selection 2712 options. 2714 C: A05 LIST (REMOTE SUBSCRIBED) "" "*" 2715 S: * LIST (\Marked \NoInferiors \Subscribed) "/" "inbox" 2716 S: * LIST (\Subscribed) "/" "Fruit/Banana" 2717 S: * LIST (\Subscribed \NonExistent) "/" "Fruit/Peach" 2718 S: * LIST (\Subscribed) "/" "Vegetable" 2719 S: * LIST (\Subscribed) "/" "Vegetable/Broccoli" 2720 S: * LIST (\Remote \Subscribed) "/" "Bread" 2721 S: A05 OK done 2723 6: The following example requests the server to include mailboxes 2724 that reside on another server. The server is asked to return 2725 subscription information for all returned mailboxes. This is 2726 different from the example above. 2728 Note that the output of this command is not a superset of the 2729 output in the previous example, as it doesn't include LIST 2730 response for the non-existent "Fruit/Peach". 2732 C: A06 LIST (REMOTE) "" "*" RETURN (SUBSCRIBED) 2733 S: * LIST (\Marked \NoInferiors \Subscribed) "/" "inbox" 2734 S: * LIST () "/" "Fruit" 2735 S: * LIST () "/" "Fruit/Apple" 2736 S: * LIST (\Subscribed) "/" "Fruit/Banana" 2737 S: * LIST () "/" "Tofu" 2738 S: * LIST (\Subscribed) "/" "Vegetable" 2739 S: * LIST (\Subscribed) "/" "Vegetable/Broccoli" 2740 S: * LIST () "/" "Vegetable/Corn" 2741 S: * LIST (\Remote \Subscribed) "/" "Bread" 2742 S: * LIST (\Remote) "/" "Meat" 2743 S: A06 OK done 2745 7: The following example demonstrates the difference between the 2746 \HasChildren attribute and the CHILDINFO extended data item. 2748 Let's assume there is the following hierarchy: 2750 C: C01 LIST "" "*" 2751 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2752 S: * LIST () "/" "Foo" 2753 S: * LIST () "/" "Foo/Bar" 2754 S: * LIST () "/" "Foo/Baz" 2755 S: * LIST () "/" "Moo" 2756 S: C01 OK done 2758 If the client asks RETURN (CHILDREN), it will get this: 2760 C: CA3 LIST "" "%" RETURN (CHILDREN) 2761 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2762 S: * LIST (\HasChildren) "/" "Foo" 2763 S: * LIST (\HasNoChildren) "/" "Moo" 2764 S: CA3 OK done 2766 A) Let's also assume that the mailbox "Foo/Baz" is the only 2767 subscribed mailbox. Then we get this result: 2769 C: C02 LIST (SUBSCRIBED) "" "*" 2770 S: * LIST (\Subscribed) "/" "Foo/Baz" 2771 S: C02 OK done 2773 Now, if the client issues , the server 2774 will return no mailboxes (as the mailboxes "Moo", "Foo", and 2775 "Inbox" are NOT subscribed). However, if the client issues 2776 this: 2778 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2779 S: * LIST () "/" "Foo" ("CHILDINFO" ("SUBSCRIBED")) 2780 S: C04 OK done 2782 (i.e., the mailbox "Foo" is not subscribed, but it has a child 2783 that is.) 2785 A1) If the mailbox "Foo" had also been subscribed, the last 2786 command would return this: 2788 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2789 S: * LIST (\Subscribed) "/" "Foo" ("CHILDINFO" ("SUBSCRIBED")) 2790 S: C04 OK done 2792 or even this: 2794 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2795 S: * LIST (\Subscribed \HasChildren) "/" "Foo" ("CHILDINFO" 2796 ("SUBSCRIBED")) 2797 S: C04 OK done 2799 A2) If we assume instead that the mailbox "Foo" is not part of 2800 the original hierarchy and is not subscribed, the last command 2801 will give this result: 2803 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" 2804 S: * LIST (\NonExistent) "/" "Foo" ("CHILDINFO" ("SUBSCRIBED")) 2805 S: C04 OK done 2807 B) Now, let's assume that no mailbox is subscribed. In this 2808 case, the command will 2809 return no responses, as there are no subscribed children (even 2810 though "Foo" has children). 2812 C) And finally, suppose that only the mailboxes "Foo" and "Moo" 2813 are subscribed. In that case, we see this result: 2815 C: C04 LIST (SUBSCRIBED RECURSIVEMATCH) "" "%" RETURN (CHILDREN) 2816 S: * LIST (\HasChildren \Subscribed) "/" "Foo" 2817 S: * LIST (\HasNoChildren \Subscribed) "/" "Moo" 2818 S: C04 OK done 2820 (which means that the mailbox "Foo" has children, but none of 2821 them is subscribed). 2823 8: The following example demonstrates that the CHILDINFO extended 2824 data item is returned whether or not children mailboxes match 2825 the canonical LIST pattern. 2827 Let's assume there is the following hierarchy: 2829 C: D01 LIST "" "*" 2830 S: * LIST (\Marked \NoInferiors) "/" "inbox" 2831 S: * LIST () "/" "foo2" 2832 S: * LIST () "/" "foo2/bar1" 2833 S: * LIST () "/" "foo2/bar2" 2834 S: * LIST () "/" "baz2" 2835 S: * LIST () "/" "baz2/bar2" 2836 S: * LIST () "/" "baz2/bar22" 2837 S: * LIST () "/" "baz2/bar222" 2838 S: * LIST () "/" "eps2" 2839 S: * LIST () "/" "eps2/mamba" 2840 S: * LIST () "/" "qux2/bar2" 2841 S: D01 OK done 2842 And that the following mailboxes are subscribed: 2844 C: D02 LIST (SUBSCRIBED) "" "*" 2845 S: * LIST (\Subscribed) "/" "foo2/bar1" 2846 S: * LIST (\Subscribed) "/" "foo2/bar2" 2847 S: * LIST (\Subscribed) "/" "baz2/bar2" 2848 S: * LIST (\Subscribed) "/" "baz2/bar22" 2849 S: * LIST (\Subscribed) "/" "baz2/bar222" 2850 S: * LIST (\Subscribed) "/" "eps2" 2851 S: * LIST (\Subscribed) "/" "eps2/mamba" 2852 S: * LIST (\Subscribed) "/" "qux2/bar2" 2853 S: D02 OK done 2855 The client issues the following command first: 2857 C: D03 LIST (RECURSIVEMATCH SUBSCRIBED) "" "*2" 2858 S: * LIST () "/" "foo2" ("CHILDINFO" ("SUBSCRIBED")) 2859 S: * LIST (\Subscribed) "/" "foo2/bar2" 2860 S: * LIST (\Subscribed) "/" "baz2/bar2" 2861 S: * LIST (\Subscribed) "/" "baz2/bar22" 2862 S: * LIST (\Subscribed) "/" "baz2/bar222" 2863 S: * LIST (\Subscribed) "/" "eps2" ("CHILDINFO" ("SUBSCRIBED")) 2864 S: * LIST (\Subscribed) "/" "qux2/bar2" 2865 S: D03 OK done 2867 and the server may also include (but this would violate a SHOULD 2868 NOT in Section 3.5, because CHILDINFO is redundant) 2870 S: * LIST () "/" "baz2" ("CHILDINFO" ("SUBSCRIBED")) 2871 S: * LIST (\NonExistent) "/" "qux2" ("CHILDINFO" ("SUBSCRIBED")) 2873 The CHILDINFO extended data item is returned for mailboxes 2874 "foo2", "baz2", and "eps2", because all of them have subscribed 2875 children, even though for the mailbox "foo2" only one of the two 2876 subscribed children matches the pattern, for the mailbox "baz2" 2877 all the subscribed children match the pattern, and for the 2878 mailbox "eps2" none of the subscribed children matches the 2879 pattern. 2881 Note that if the client issues 2883 C: D03 LIST (RECURSIVEMATCH SUBSCRIBED) "" "*" 2884 S: * LIST () "/" "foo2" ("CHILDINFO" ("SUBSCRIBED")) 2885 S: * LIST (\Subscribed) "/" "foo2/bar1" 2886 S: * LIST (\Subscribed) "/" "foo2/bar2" 2887 S: * LIST () "/" "baz2" ("CHILDINFO" ("SUBSCRIBED")) 2888 S: * LIST (\Subscribed) "/" "baz2/bar2" 2889 S: * LIST (\Subscribed) "/" "baz2/bar22" 2890 S: * LIST (\Subscribed) "/" "baz2/bar222" 2891 S: * LIST (\Subscribed) "/" "eps2" ("CHILDINFO" ("SUBSCRIBED")) 2892 S: * LIST (\Subscribed) "/" "eps2/mamba" 2893 S: * LIST (\Subscribed) "/" "qux2/bar2" 2894 S: D03 OK done 2896 The LIST responses for mailboxes "foo2", "baz2", and "eps2" 2897 still have the CHILDINFO extended data item, even though this 2898 information is redundant and the client can determine it by 2899 itself. 2901 9: The following example shows usage of extended syntax for mailbox 2902 pattern. It also demonstrates that the presence of the 2903 CHILDINFO extended data item doesn't necessarily imply 2904 \HasChildren. 2906 C: a1 LIST "" ("foo") 2907 S: * LIST () "/" foo 2908 S: a1 OK done 2910 C: a2 LIST (SUBSCRIBED) "" "foo/*" 2911 S: * LIST (\Subscribed \NonExistent) "/" foo/bar 2912 S: a2 OK done 2914 C: a3 LIST (SUBSCRIBED RECURSIVEMATCH) "" foo RETURN (CHILDREN) 2915 S: * LIST (\HasNoChildren) "/" foo ("CHILDINFO" ("SUBSCRIBED")) 2916 S: a3 OK done 2918 10: The following example shows how a server that supports missing 2919 mailbox hierarchy elements can signal to a client that didn't 2920 specify the RECURSIVEMATCH selection option that there is a 2921 child mailbox that matches the selection criteria. 2923 C: a1 LIST (REMOTE) "" * 2924 S: * LIST () "/" music/rock 2925 S: * LIST (\Remote) "/" also/jazz 2926 S: a1 OK done 2928 C: a2 LIST () "" % 2929 S: * LIST (\NonExistent \HasChildren) "/" music 2930 S: a2 OK done 2932 C: a3 LIST (REMOTE) "" % 2933 S: * LIST (\NonExistent \HasChildren) "/" music 2934 S: * LIST (\NonExistent \HasChildren) "/" also 2935 S: a3 OK done 2937 C: a3.1 LIST "" (% music/rock) 2938 S: * LIST () "/" music/rock 2939 S: a3.1 OK done 2941 Because "music/rock" is the only mailbox under "music", there's 2942 no need for the server to also return "music". However clients 2943 must handle both cases. 2945 11: The following examples show use of STATUS return option. 2947 C: A01 LIST "" % RETURN (STATUS (MESSAGES UNSEEN)) 2948 S: * LIST () "." "INBOX" 2949 S: * STATUS "INBOX" (MESSAGES 17 UNSEEN 16) 2950 S: * LIST () "." "foo" 2951 S: * STATUS "foo" (MESSAGES 30 UNSEEN 29) 2952 S: * LIST (\NoSelect) "." "bar" 2953 S: A01 OK List completed. 2955 The "bar" mailbox isn't selectable, so it has no STATUS reply. 2957 C: A02 LIST (SUBSCRIBED RECURSIVEMATCH) "" % RETURN (STATUS 2958 (MESSAGES)) 2959 S: * LIST (\Subscribed) "." "INBOX" 2960 S: * STATUS "INBOX" (MESSAGES 17) 2961 S: * LIST () "." "foo" (CHILDINFO ("SUBSCRIBED")) 2962 S: A02 OK List completed. 2964 The LIST reply for "foo" is returned because it has matching 2965 children, but no STATUS reply is returned because "foo" itself 2966 doesn't match the selection criteria. 2968 6.3.10. NAMESPACE Command 2970 Arguments: none 2972 Responses: REQUIRED untagged responses: NAMESPACE 2974 Result: OK - command completed 2975 NO - Can't complete the command 2976 BAD - arguments invalid 2978 The NAMESPACE command causes a single untagged NAMESPACE response to 2979 be returned. The untagged NAMESPACE response contains the prefix and 2980 hierarchy delimiter to the server's Personal Namespace(s), Other 2981 Users' Namespace(s), and Shared Namespace(s) that the server wishes 2982 to expose. The response will contain a NIL for any namespace class 2983 that is not available. The namespace-response-extensions ABNF non 2984 terminal is defined for extensibility and MAY be included in the 2985 NAMESPACE response. 2987 Example 1: 2989 In this example a server supports a single personal namespace. No 2990 leading prefix is used on personal mailboxes and "/" is the hierarchy 2991 delimiter. 2993 C: A001 NAMESPACE 2994 S: * NAMESPACE (("" "/")) NIL NIL 2995 S: A001 OK NAMESPACE command completed 2997 Example 2: 2999 A user logged on anonymously to a server. No personal mailboxes are 3000 associated with the anonymous user and the user does not have access 3001 to the Other Users' Namespace. No prefix is required to access 3002 shared mailboxes and the hierarchy delimiter is "." 3004 C: A001 NAMESPACE 3005 S: * NAMESPACE NIL NIL (("" ".")) 3006 S: A001 OK NAMESPACE command completed 3008 Example 3: 3010 A server that contains a Personal Namespace and a single Shared 3011 Namespace. 3013 C: A001 NAMESPACE 3014 S: * NAMESPACE (("" "/")) NIL (("Public Folders/" "/")) 3015 S: A001 OK NAMESPACE command completed 3017 Example 4: 3019 A server that contains a Personal Namespace, Other Users' Namespace 3020 and multiple Shared Namespaces. Note that the hierarchy delimiter 3021 used within each namespace can be different. 3023 C: A001 NAMESPACE 3024 S: * NAMESPACE (("" "/")) (("~" "/")) (("#shared/" "/") 3025 ("#public/" "/")("#ftp/" "/")("#news." ".")) 3026 S: A001 OK NAMESPACE command completed 3028 The prefix string allows a client to do things such as automatically 3029 creating personal mailboxes or LISTing all available mailboxes within 3030 a namespace. 3032 Example 5: 3034 A server that supports only the Personal Namespace, with a leading 3035 prefix of INBOX to personal mailboxes and a hierarchy delimiter of 3036 "." 3038 C: A001 NAMESPACE 3039 S: * NAMESPACE (("INBOX." ".")) NIL NIL 3040 S: A001 OK NAMESPACE command completed 3042 < Automatically create a mailbox to store sent items.> 3044 C: A002 CREATE "INBOX.Sent Mail" 3045 S: A002 OK CREATE command completed 3047 Although typically a server will support only a single Personal 3048 Namespace, and a single Other User's Namespace, circumstances exist 3049 where there MAY be multiples of these, and a client MUST be prepared 3050 for them. If a client is configured such that it is required to 3051 create a certain mailbox, there can be circumstances where it is 3052 unclear which Personal Namespaces it should create the mailbox in. 3053 In these situations a client SHOULD let the user select which 3054 namespaces to create the mailbox in or just use the first personal 3055 namespace. 3057 Example 6: 3059 In this example, a server supports two Personal Namespaces. In 3060 addition to the regular Personal Namespace, the user has an 3061 additional personal namespace to allow access to mailboxes in an MH 3062 format mailstore. 3064 The client is configured to save a copy of all mail sent by the user 3065 into a mailbox with the \Sent attribute. Furthermore, after a 3066 message is deleted from a mailbox, the client is configured to move 3067 that message to a mailbox with the \Trash attribute. The server 3068 signals specific mailbox names that should be used for these purposed 3069 by returning LIST responses with \NonExistent attribute. I.e. the 3070 server is hinting to the client which mailbox names to use for sent 3071 and deleted messages. 3073 Note that this example demonstrates how some extension parameters can 3074 be passed to further describe the #mh namespace. See the fictitious 3075 "X-PARAM" extension parameter. 3077 C: A001 NAMESPACE 3078 S: * NAMESPACE (("" "/")("#mh/" "/" "X-PARAM" 3079 ("FLAG1" "FLAG2"))) NIL NIL 3080 S: A001 OK NAMESPACE command completed 3082 C: A002 LIST (SPECIAL-USE) "" "*" 3083 S: * LIST (\NonExistent \Archive) "/" Archives 3084 S: * LIST (\NonExistent \Drafts) "/" Drafts 3085 S: * LIST (\NonExistent \Junk) "/" Junk 3086 S: * LIST (\NonExistent \Sent) "/" "Sent Mail" 3087 S: * LIST (\NonExistent \Trash) "/" "Deleted Items" 3088 S: A002 OK LIST Completed 3090 C: A003 LIST (SPECIAL-USE) "#mh/" "*" 3091 S: * LIST (\NonExistent \Archive) "/" "#mh/Archives" 3092 S: * LIST (\NonExistent \Drafts) "/" "#mh/Drafts" 3093 S: * LIST (\NonExistent \Junk) "/" "#mh/Junk" 3094 S: * LIST (\NonExistent \Sent) "/" "#mh/Sent Mail" 3095 S: * LIST (\NonExistent \Trash) "/" "#mh/Deleted Items" 3096 S: A003 OK LIST Completed 3098 < It is desired to keep only one copy of sent mail. 3099 It is unclear which Personal Namespace the client 3100 should use to create the 'Sent Mail' mailbox. 3101 The user is prompted to select a namespace and only 3102 one 'Sent Mail' mailbox is created. > 3104 C: A004 CREATE "Sent Mail" 3105 S: A004 OK CREATE command completed 3107 < The client is designed so that it keeps two 3108 'Deleted Items' mailboxes, one for each namespace. > 3110 C: A005 CREATE "Delete Items" 3111 S: A005 OK CREATE command completed 3113 C: A006 CREATE "#mh/Deleted Items" 3114 S: A006 OK CREATE command completed 3116 The next level of hierarchy following the Other Users' Namespace 3117 prefix SHOULD consist of , where is a user name 3118 as per the LOGIN or AUTHENTICATE command. 3120 A client can construct a LIST command by appending a "%" to the Other 3121 Users' Namespace prefix to discover the Personal Namespaces of other 3122 users that are available to the currently authenticated user. 3124 In response to such a LIST command, a server SHOULD NOT return user 3125 names that have not granted access to their personal mailboxes to the 3126 user in question. 3128 A server MAY return a LIST response containing only the names of 3129 users that have explicitly granted access to the user in question. 3131 Alternatively, a server MAY return NO to such a LIST command, 3132 requiring that a user name be included with the Other Users' 3133 Namespace prefix before listing any other user's mailboxes. 3135 Example 7: 3137 A server that supports providing a list of other user's mailboxes 3138 that are accessible to the currently logged on user. 3140 C: A001 NAMESPACE 3141 S: * NAMESPACE (("" "/")) (("Other Users/" "/")) NIL 3142 S: A001 OK NAMESPACE command completed 3144 C: A002 LIST "" "Other Users/%" 3145 S: * LIST () "/" "Other Users/Mike" 3146 S: * LIST () "/" "Other Users/Karen" 3147 S: * LIST () "/" "Other Users/Matthew" 3148 S: * LIST () "/" "Other Users/Tesa" 3149 S: A002 OK LIST command completed 3151 Example 8: 3153 A server that does not support providing a list of other user's 3154 mailboxes that are accessible to the currently logged on user. The 3155 mailboxes are listable if the client includes the name of the other 3156 user with the Other Users' Namespace prefix. 3158 C: A001 NAMESPACE 3159 S: * NAMESPACE (("" "/")) (("#Users/" "/")) NIL 3160 S: A001 OK NAMESPACE command completed 3162 < In this example, the currently logged on user has access to 3163 the Personal Namespace of user Mike, but the server chose to 3164 suppress this information in the LIST response. However, 3165 by appending the user name Mike (received through user input) 3166 to the Other Users' Namespace prefix, the client is able 3167 to get a listing of the personal mailboxes of user Mike. > 3169 C: A002 LIST "" "#Users/%" 3170 S: A002 NO The requested item could not be found. 3172 C: A003 LIST "" "#Users/Mike/%" 3173 S: * LIST () "/" "#Users/Mike/INBOX" 3174 S: * LIST () "/" "#Users/Mike/Foo" 3175 S: A003 OK LIST command completed. 3177 A prefix string might not contain a hierarchy delimiter, because in 3178 some cases it is not needed as part of the prefix. 3180 Example 9: 3182 A server that allows access to the Other Users' Namespace by 3183 prefixing the others' mailboxes with a '~' followed by , 3184 where is a user name as per the LOGIN or AUTHENTICATE 3185 command. 3187 C: A001 NAMESPACE 3188 S: * NAMESPACE (("" "/")) (("~" "/")) NIL 3189 S: A001 OK NAMESPACE command completed 3191 < List the mailboxes for user mark > 3193 C: A002 LIST "" "~mark/%" 3194 S: * LIST () "/" "~mark/INBOX" 3195 S: * LIST () "/" "~mark/foo" 3196 S: A002 OK LIST command completed 3198 6.3.11. STATUS Command 3200 Arguments: mailbox name 3201 status data item names 3203 Responses: REQUIRED untagged responses: STATUS 3205 Result: OK - status completed 3206 NO - status failure: no status for that name 3207 BAD - command unknown or arguments invalid 3209 The STATUS command requests the status of the indicated mailbox. It 3210 does not change the currently selected mailbox, nor does it affect 3211 the state of any messages in the queried mailbox. 3213 The STATUS command provides an alternative to opening a second 3214 IMAP4rev2 connection and doing an EXAMINE command on a mailbox to 3215 query that mailbox's status without deselecting the current mailbox 3216 in the first IMAP4rev2 connection. 3218 Unlike the LIST command, the STATUS command is not guaranteed to be 3219 fast in its response. Under certain circumstances, it can be quite 3220 slow. In some implementations, the server is obliged to open the 3221 mailbox read-only internally to obtain certain status information. 3222 Also unlike the LIST command, the STATUS command does not accept 3223 wildcards. 3225 Note: The STATUS command is intended to access the status of 3226 mailboxes other than the currently selected mailbox. Because the 3227 STATUS command can cause the mailbox to be opened internally, and 3228 because this information is available by other means on the 3229 selected mailbox, the STATUS command SHOULD NOT be used on the 3230 currently selected mailbox. However, servers MUST be able to 3231 execute STATUS command on the selected mailbox. (This might also 3232 implicitly happen when STATUS return option is used in a LIST 3233 command). 3235 The STATUS command MUST NOT be used as a "check for new messages 3236 in the selected mailbox" operation (refer to Section 7 and 3237 Section 7.4.1 for more information about the proper method for new 3238 message checking). 3240 STATUS SIZE (see below) can take a significant amount of time, 3241 depending upon server implementation. Clients should use STATUS 3242 SIZE cautiously. 3244 The currently defined status data items that can be requested are: 3246 MESSAGES The number of messages in the mailbox. 3248 UIDNEXT The next unique identifier value of the mailbox. Refer to 3249 Section 2.3.1.1 for more information. 3251 UIDVALIDITY The unique identifier validity value of the mailbox. 3252 Refer to Section 2.3.1.1 for more information. 3254 UNSEEN The number of messages which do not have the \Seen flag set. 3256 DELETED The number of messages which have the \Deleted flag set. 3258 SIZE The total size of the mailbox in octets. This is not strictly 3259 required to be an exact value, but it MUST be equal to or greater 3260 than the sum of the values of the RFC822.SIZE FETCH message data 3261 items (see Section 6.4.5) of all messages in the mailbox. 3263 Example: C: A042 STATUS blurdybloop (UIDNEXT MESSAGES) 3264 S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) 3265 S: A042 OK STATUS completed 3267 6.3.12. APPEND Command 3269 Arguments: mailbox name 3270 OPTIONAL flag parenthesized list 3271 OPTIONAL date/time string 3272 message literal 3274 Responses: OPTIONAL untagged response: LIST 3276 Result: OK - append completed 3277 NO - append error: can't append to that mailbox, error 3278 in flags or date/time or message text 3279 BAD - command unknown or arguments invalid 3281 The APPEND command appends the literal argument as a new message to 3282 the end of the specified destination mailbox. This argument SHOULD 3283 be in the format of an [RFC-5322] or [I18N-HDRS] message. 8-bit 3284 characters are permitted in the message. A server implementation 3285 that is unable to preserve 8-bit data properly MUST be able to 3286 reversibly convert 8-bit APPEND data to 7-bit using a [MIME-IMB] 3287 content transfer encoding. 3289 Note: There may be exceptions, e.g., draft messages, in which 3290 required [RFC-5322] header fields are omitted in the message 3291 literal argument to APPEND. The full implications of doing so 3292 must be understood and carefully weighed. 3294 If a flag parenthesized list is specified, the flags SHOULD be set in 3295 the resulting message; otherwise, the flag list of the resulting 3296 message is set to empty by default. 3298 If a date-time is specified, the internal date SHOULD be set in the 3299 resulting message; otherwise, the internal date of the resulting 3300 message is set to the current date and time by default. 3302 If the append is unsuccessful for any reason, the mailbox MUST be 3303 restored to its state before the APPEND attempt (other than possibly 3304 keeping the changed mailbox's UIDNEXT value); no partial appending is 3305 permitted. 3307 If the destination mailbox does not exist, a server MUST return an 3308 error, and MUST NOT automatically create the mailbox. Unless it is 3309 certain that the destination mailbox can not be created, the server 3310 MUST send the response code "[TRYCREATE]" as the prefix of the text 3311 of the tagged NO response. This gives a hint to the client that it 3312 can attempt a CREATE command and retry the APPEND if the CREATE is 3313 successful. 3315 On successful completion of an APPEND, the server returns an 3316 APPENDUID response code (see Section 7.1), unless specified otherwise 3317 below. 3319 In the case of a mailbox that has permissions set so that the client 3320 can APPEND to the mailbox, but not SELECT or EXAMINE it, the server 3321 MUST NOT send an APPENDUID response code as it would disclose 3322 information about the mailbox. 3324 In the case of a mailbox that has UIDNOTSTICKY status (see 3325 Section 7.1), the server MAY omit the APPENDUID response code as it 3326 is not meaningful. 3328 If the mailbox is currently selected, the normal new message actions 3329 SHOULD occur. Specifically, the server SHOULD notify the client 3330 immediately via an untagged EXISTS response. If the server does not 3331 do so, the client MAY issue a NOOP command after one or more APPEND 3332 commands. 3334 If the server decides to convert (normalize) the mailbox name, it 3335 SHOULD return an untagged LIST with OLDNAME extended data item, with 3336 the OLDNAME value being the supplied mailbox name and the name 3337 parameter being the normalized mailbox name. (See Section 6.3.9.7 3338 for more details.) 3339 Example: C: A003 APPEND saved-messages (\Seen) {326} 3340 S: + Ready for literal data 3341 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST) 3342 C: From: Fred Foobar 3343 C: Subject: afternoon meeting 3344 C: To: mooch@owatagu.siam.edu.example 3345 C: Message-Id: 3346 C: MIME-Version: 1.0 3347 C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 3348 C: 3349 C: Hello Joe, do you think we can meet at 3:30 tomorrow? 3350 C: 3351 S: A003 OK APPEND completed 3353 Example: C: A003 APPEND saved-messages (\Seen) {297+} 3354 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST) 3355 C: From: Fred Foobar 3356 C: Subject: afternoon meeting 3357 C: To: mooch@example.com 3358 C: Message-Id: 3359 C: MIME-Version: 1.0 3360 C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 3361 C: 3362 C: Hello Joe, do you think we can meet at 3:30 tomorrow? 3363 C: 3364 S: A003 OK [APPENDUID 38505 3955] APPEND completed 3365 C: A004 COPY 2:4 meeting 3366 S: A004 OK [COPYUID 38505 304,319:320 3956:3958] Done 3367 C: A005 UID COPY 305:310 meeting 3368 S: A005 OK No matching messages, so nothing copied 3369 C: A006 COPY 2 funny 3370 S: A006 OK Done 3371 C: A007 SELECT funny 3372 S: * 1 EXISTS 3373 S: * OK [UIDVALIDITY 3857529045] Validity session-only 3374 S: * OK [UIDNEXT 2] Predicted next UID 3375 S: * NO [UIDNOTSTICKY] Non-persistent UIDs 3376 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 3377 S: * OK [PERMANENTFLAGS (\Deleted \Seen)] Limited 3378 S: * LIST () "." funny 3379 S: A007 OK [READ-WRITE] SELECT completed 3381 In this example, A003 and A004 demonstrate successful appending and 3382 copying to a mailbox that returns the UIDs assigned to the messages. 3383 A005 is an example in which no messages were copied; this is because 3384 in A003, we see that message 2 had UID 304, and message 3 had UID 3385 319; therefore, UIDs 305 through 310 do not exist (refer to 3386 Section 2.3.1.1 for further explanation). A006 is an example of a 3387 message being copied that did not return a COPYUID; and, as expected, 3388 A007 shows that the mail store containing that mailbox does not 3389 support persistent UIDs. 3391 Note: The APPEND command is not used for message delivery, because 3392 it does not provide a mechanism to transfer [SMTP] envelope 3393 information. 3395 6.3.13. IDLE Command 3397 Arguments: none 3399 Responses: continuation data will be requested; the client sends the 3400 continuation data "DONE" to end the command 3402 Result: OK - IDLE completed after client sent "DONE" 3403 NO - failure: the server will not allow the IDLE command 3404 at this time 3405 BAD - command unknown or arguments invalid 3407 Without the IDLE command a client would need to poll the server for 3408 changes to the selected mailbox (new mail, deletions, flag changes). 3409 It's often more desirable to have the server transmit updates to the 3410 client in real time. This allows a user to see new mail immediately. 3411 The IDLE command allows a client to tell the server that it's ready 3412 to accept such real-time updates. 3414 The IDLE command is sent from the client to the server when the 3415 client is ready to accept unsolicited update messages. The server 3416 requests a response to the IDLE command using the continuation ("+") 3417 response. The IDLE command remains active until the client responds 3418 to the continuation, and as long as an IDLE command is active, the 3419 server is now free to send untagged EXISTS, EXPUNGE, FETCH, and other 3420 responses at any time. If the server chooses to send unsolicited 3421 FETCH responses, they MUST include UID FETCH item. 3423 The IDLE command is terminated by the receipt of a "DONE" 3424 continuation from the client; such response satisfies the server's 3425 continuation request. At that point, the server MAY send any 3426 remaining queued untagged responses and then MUST immediately send 3427 the tagged response to the IDLE command and prepare to process other 3428 commands. As for other commands, the processing of any new command 3429 may cause the sending of unsolicited untagged responses, subject to 3430 the ambiguity limitations. The client MUST NOT send a command while 3431 the server is waiting for the DONE, since the server will not be able 3432 to distinguish a command from a continuation. 3434 The server MAY consider a client inactive if it has an IDLE command 3435 running, and if such a server has an inactivity timeout it MAY log 3436 the client off implicitly at the end of its timeout period. Because 3437 of that, clients using IDLE are advised to terminate the IDLE and re- 3438 issue it at least every 29 minutes to avoid being logged off. This 3439 still allows a client to receive immediate mailbox updates even 3440 though it need only "poll" at half hour intervals. 3442 Example: C: A001 SELECT INBOX 3443 S: * FLAGS (\Deleted \Seen \Flagged) 3444 S: * OK [PERMANENTFLAGS (\Deleted \Seen \Flagged)] Limited 3445 S: * 3 EXISTS 3446 S: * OK [UIDVALIDITY 1] 3447 S: * OK [UIDNEXT 1] 3448 S: * LIST () "/" INBOX 3449 S: A001 OK [READ-WRITE] SELECT completed 3450 C: A002 IDLE 3451 S: + idling 3452 ...time passes; new mail arrives... 3453 S: * 4 EXISTS 3454 C: DONE 3455 S: A002 OK IDLE terminated 3456 ...another client expunges message 2 now... 3457 C: A003 FETCH 4 ALL 3458 S: * 4 FETCH (...) 3459 S: A003 OK FETCH completed 3460 C: A004 IDLE 3461 S: * 2 EXPUNGE 3462 S: * 3 EXISTS 3463 S: + idling 3464 ...time passes; another client expunges message 3... 3465 S: * 3 EXPUNGE 3466 S: * 2 EXISTS 3467 ...time passes; new mail arrives... 3468 S: * 3 EXISTS 3469 C: DONE 3470 S: A004 OK IDLE terminated 3471 C: A005 FETCH 3 ALL 3472 S: * 3 FETCH (...) 3473 S: A005 OK FETCH completed 3474 C: A006 IDLE 3476 6.4. Client Commands - Selected State 3478 In the selected state, commands that manipulate messages in a mailbox 3479 are permitted. 3481 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 3482 and the authenticated state commands (SELECT, EXAMINE, NAMESPACE, 3483 CREATE, DELETE, RENAME, SUBSCRIBE, UNSUBSCRIBE, LIST, STATUS, and 3484 APPEND), the following commands are valid in the selected state: 3485 CLOSE, UNSELECT, EXPUNGE, SEARCH, FETCH, STORE, COPY, MOVE, and UID. 3487 6.4.1. CLOSE Command 3489 Arguments: none 3491 Responses: no specific responses for this command 3493 Result: OK - close completed, now in authenticated state 3494 BAD - command unknown or arguments invalid 3496 The CLOSE command permanently removes all messages that have the 3497 \Deleted flag set from the currently selected mailbox, and returns to 3498 the authenticated state from the selected state. No untagged EXPUNGE 3499 responses are sent. 3501 No messages are removed, and no error is given, if the mailbox is 3502 selected by an EXAMINE command or is otherwise selected read-only. 3504 Even if a mailbox is selected, a SELECT, EXAMINE, or LOGOUT command 3505 MAY be issued without previously issuing a CLOSE command. The 3506 SELECT, EXAMINE, and LOGOUT commands implicitly close the currently 3507 selected mailbox without doing an expunge. However, when many 3508 messages are deleted, a CLOSE-LOGOUT or CLOSE-SELECT sequence is 3509 considerably faster than an EXPUNGE-LOGOUT or EXPUNGE-SELECT because 3510 no untagged EXPUNGE responses (which the client would probably 3511 ignore) are sent. 3513 Example: C: A341 CLOSE 3514 S: A341 OK CLOSE completed 3516 6.4.2. UNSELECT Command 3518 Arguments: none 3520 Responses: no specific responses for this command 3522 Result: OK - unselect completed, now in authenticated state 3523 BAD - no mailbox selected, or argument supplied but none 3524 permitted 3526 The UNSELECT command frees session's resources associated with the 3527 selected mailbox and returns the server to the authenticated state. 3529 This command performs the same actions as CLOSE, except that no 3530 messages are permanently removed from the currently selected mailbox. 3532 Example: C: A342 UNSELECT 3533 S: A342 OK Unselect completed 3535 6.4.3. EXPUNGE Command 3537 Arguments: none 3539 Responses: untagged responses: EXPUNGE 3541 Result: OK - expunge completed 3542 NO - expunge failure: can't expunge (e.g., permission 3543 denied) 3544 BAD - command unknown or arguments invalid 3546 The EXPUNGE command permanently removes all messages that have the 3547 \Deleted flag set from the currently selected mailbox. Before 3548 returning an OK to the client, an untagged EXPUNGE response is sent 3549 for each message that is removed. 3551 Example: C: A202 EXPUNGE 3552 S: * 3 EXPUNGE 3553 S: * 3 EXPUNGE 3554 S: * 5 EXPUNGE 3555 S: * 8 EXPUNGE 3556 S: A202 OK EXPUNGE completed 3558 Note: In this example, messages 3, 4, 7, and 11 had the \Deleted flag 3559 set. See the description of the EXPUNGE response (Section 7.5.1) for 3560 further explanation. 3562 6.4.4. SEARCH Command 3564 Arguments: OPTIONAL result specifier 3565 OPTIONAL [CHARSET] specification 3566 searching criteria (one or more) 3568 Responses: OPTIONAL untagged response: ESEARCH 3570 Result: OK - search completed 3571 NO - search error: can't search that [CHARSET] or 3572 criteria 3573 BAD - command unknown or arguments invalid 3575 The SEARCH command searches the mailbox for messages that match the 3576 given searching criteria. 3578 The SEARCH command may contain result options. Result options 3579 control what kind of information is returned about messages matching 3580 the search criteria in an untagged ESEARCH response. If no result 3581 option is specified or empty list of options is specified "()", ALL 3582 is assumed (see below). The order of individual options is 3583 arbitrary. Individual options may contain parameters enclosed in 3584 parentheses. (However, if an option has a mandatory parameter, which 3585 can always be represented as a number or a sequence-set, the option 3586 parameter does not need the enclosing parentheses. See the Formal 3587 Syntax (Section 9) for more details). If an option has parameters, 3588 they consist of atoms and/or strings and/or lists in a specific 3589 order. Any options not defined by extensions that the server 3590 supports MUST be rejected with a BAD response. 3592 Note that IMAP4rev1 used SEARCH responses [RFC3501] instead of 3593 ESEARCH responses. IMAP4rev2-only clients MUST ignore SEARCH 3594 responses. 3596 This document specifies the following result options: 3598 MIN 3600 Return the lowest message number/UID that satisfies the SEARCH 3601 criteria. 3603 If the SEARCH results in no matches, the server MUST NOT 3604 include the MIN result option in the ESEARCH response; however, 3605 it still MUST send the ESEARCH response. 3607 MAX 3609 Return the highest message number/UID that satisfies the SEARCH 3610 criteria. 3612 If the SEARCH results in no matches, the server MUST NOT 3613 include the MAX result option in the ESEARCH response; however, 3614 it still MUST send the ESEARCH response. 3616 ALL 3618 Return all message numbers/UIDs that satisfy the SEARCH 3619 criteria using the sequence-set syntax. Note, the client MUST 3620 NOT assume that messages/UIDs will be listed in any particular 3621 order. 3623 If the SEARCH results in no matches, the server MUST NOT 3624 include the ALL result option in the ESEARCH response; however, 3625 it still MUST send the ESEARCH response. 3627 COUNT Return the number of messages that satisfy the SEARCH 3628 criteria. This result option MUST always be included in the 3629 ESEARCH response. 3631 SAVE 3633 This option tells the server to remember the result of the 3634 SEARCH or UID SEARCH command (as well as any command based on 3635 SEARCH, e.g., SORT and THREAD [RFC5256]>) and store it in an 3636 internal variable that we will reference as the "search result 3637 variable". The client can use the "$" marker to reference the 3638 content of this internal variable. The "$" marker can be used 3639 instead of message sequence or UID sequence in order to 3640 indicate that the server should substitute it with the list of 3641 messages from the search result variable. Thus, the client can 3642 use the result of the latest remembered SEARCH command as a 3643 parameter to another command. See Section 6.4.4.1 for details 3644 on how the value of the search result variable is determined, 3645 how it is affected by other commands executed, and how SAVE 3646 return option interacts with other return options. 3648 In absence of any other SEARCH result option, the SAVE result 3649 option also suppresses any ESEARCH response that would have 3650 been otherwise returned by the SEARCH command. 3652 Note: future extensions to this document can allow servers to return 3653 multiple ESEARCH responses for a single extended SEARCH command. 3654 However all options specified above MUST result in a single ESEARCH 3655 response if used by themselves or in combination. This guarantee 3656 simplifies processing in IMAP4rev2 clients. Future SEARCH extensions 3657 that relax this restriction will have to describe how results from 3658 multiple ESEARCH responses are to be combined. 3660 Searching criteria consist of one or more search keys. 3662 When multiple keys are specified, the result is the intersection (AND 3663 function) of all the messages that match those keys. For example, 3664 the criteria DELETED FROM "SMITH" SINCE 1-Feb-1994 refers to all 3665 deleted messages from Smith with INTERNALDATE greater than February 3666 1, 1994. A search key can also be a parenthesized list of one or 3667 more search keys (e.g., for use with the OR and NOT keys). 3669 Server implementations MAY exclude [MIME-IMB] body parts with 3670 terminal content media types other than TEXT and MESSAGE from 3671 consideration in SEARCH matching. 3673 The OPTIONAL [CHARSET] specification consists of the word "CHARSET" 3674 followed by a registered [CHARSET] [CHARSET-REG]. It indicates the 3676 [CHARSET] of the strings that appear in the search criteria. 3677 [MIME-IMB] content transfer encodings, and [MIME-HDRS] strings in 3678 [RFC-5322]/[MIME-IMB] headers, MUST be decoded before comparing text. 3679 Servers MUST support US-ASCII and UTF-8 charsets; other [CHARSET]s 3680 MAY be supported. Clients SHOULD use UTF-8. Note that if "CHARSET" 3681 is not provided IMAP4rev2 servers MUST assume UTF-8, so selecting 3682 CHARSET UTF-8 is redundant. It is permitted for improved 3683 compatibility with existing IMAP4rev1 clients. 3685 If the server does not support the specified [CHARSET], it MUST 3686 return a tagged NO response (not a BAD). This response SHOULD 3687 contain the BADCHARSET response code, which MAY list the [CHARSET]s 3688 supported by the server. 3690 In all search keys that use strings and unless specified otherwise, a 3691 message matches the key if the string is a substring of the 3692 associated text. The matching SHOULD be case-insensitive for 3693 characters within ASCII range. Consider using [IMAP-I18N] for 3694 language-sensitive case-insensitive searching. Note that the empty 3695 string is a substring; this is useful when doing a HEADER search in 3696 order to test for a header field presence in the message. 3698 The defined search keys are as follows. Refer to the Formal Syntax 3699 section for the precise syntactic definitions of the arguments. 3701 Messages with message sequence numbers corresponding 3702 to the specified message sequence number set. 3704 ALL All messages in the mailbox; the default initial key for ANDing. 3706 ANSWERED Messages with the \Answered flag set. 3708 BCC Messages that contain the specified string in the 3709 envelope structure's BCC field. 3711 BEFORE Messages whose internal date (disregarding time and 3712 timezone) is earlier than the specified date. 3714 BODY Messages that contain the specified string in the body 3715 of the message. Unlike TEXT (see below), this doesn't match any 3716 header fields. Servers are allowed to implement flexible matching 3717 for this search key, for example matching "swim" to both "swam" 3718 and "swum" in English language text or only doing full word 3719 matching (where "swim" will not match "swimming"). 3721 CC Messages that contain the specified string in the 3722 envelope structure's CC field. 3724 DELETED Messages with the \Deleted flag set. 3726 DRAFT Messages with the \Draft flag set. 3728 FLAGGED Messages with the \Flagged flag set. 3730 FROM Messages that contain the specified string in the 3731 envelope structure's FROM field. 3733 HEADER Messages that have a header field with 3734 the specified field-name (as defined in [RFC-5322]) and that 3735 contains the specified string in the text of the header field 3736 (what comes after the colon). If the string to search is zero- 3737 length, this matches all messages that have a header field with 3738 the specified field-name regardless of the contents. Servers 3739 should use substring search for this SEARCH item, as clients can 3740 use it for automatic processing not initiated by end users. For 3741 example this can be used for searching for Message-ID or Content- 3742 Type header field values that need to be exact, or for searches in 3743 header fields that the IMAP server might not know anything about. 3745 KEYWORD Messages with the specified keyword flag set. 3747 LARGER Messages with an [RFC-5322] size larger than the 3748 specified number of octets. 3750 NOT Messages that do not match the specified search 3751 key. 3753 ON Messages whose internal date (disregarding time and 3754 timezone) is within the specified date. 3756 OR Messages that match either search 3757 key. 3759 SEEN Messages that have the \Seen flag set. 3761 SENTBEFORE Messages whose [RFC-5322] Date: header field 3762 (disregarding time and timezone) is earlier than the specified 3763 date. 3765 SENTON Messages whose [RFC-5322] Date: header field 3766 (disregarding time and timezone) is within the specified date. 3768 SENTSINCE Messages whose [RFC-5322] Date: header field 3769 (disregarding time and timezone) is within or later than the 3770 specified date. 3772 SINCE Messages whose internal date (disregarding time and 3773 timezone) is within or later than the specified date. 3775 SMALLER Messages with an [RFC-5322] size smaller than the 3776 specified number of octets. 3778 SUBJECT Messages that contain the specified string in the 3779 envelope structure's SUBJECT field. 3781 TEXT Messages that contain the specified string in the 3782 header (including MIME header fields) or body of the message. 3783 Servers are allowed to implement flexible matching for this search 3784 key, for example matching "swim" to both "swam" and "swum" in 3785 English language text or only doing full word matching (where 3786 "swim" will not match "swimming"). 3788 TO Messages that contain the specified string in the 3789 envelope structure's TO field. 3791 UID Messages with unique identifiers corresponding to 3792 the specified unique identifier set. Sequence set ranges are 3793 permitted. 3795 UNANSWERED Messages that do not have the \Answered flag set. 3797 UNDELETED Messages that do not have the \Deleted flag set. 3799 UNDRAFT Messages that do not have the \Draft flag set. 3801 UNFLAGGED Messages that do not have the \Flagged flag set. 3803 UNKEYWORD Messages that do not have the specified keyword 3804 flag set. 3806 UNSEEN Messages that do not have the \Seen flag set. 3808 Example: C: A282 SEARCH RETURN (MIN COUNT) FLAGGED 3809 SINCE 1-Feb-1994 NOT FROM "Smith" 3810 S: * ESEARCH (TAG "A282") MIN 2 COUNT 3 3811 S: A282 OK SEARCH completed 3813 Example: C: A283 SEARCH RETURN () FLAGGED 3814 SINCE 1-Feb-1994 NOT FROM "Smith" 3815 S: * ESEARCH (TAG "A283") ALL 2,10:11 3816 S: A283 OK SEARCH completed 3818 Example: C: A284 SEARCH TEXT "string not in mailbox" 3819 S: * ESEARCH (TAG "A284") 3820 S: A284 OK SEARCH completed 3821 C: A285 SEARCH CHARSET UTF-8 TEXT {6} 3822 S: + Ready for literal text 3823 C: XXXXXX 3824 S: * ESEARCH (TAG "A285") ALL 43 3825 S: A285 OK SEARCH completed 3827 Note: Since this document is restricted to 7-bit ASCII text, it is 3828 not possible to show actual UTF-8 data. The "XXXXXX" is a 3829 placeholder for what would be 6 octets of 8-bit data in an actual 3830 transaction. 3832 The following example demonstrates finding the first unseen message 3833 in the mailbox: 3835 Example: C: A284 SEARCH RETURN (MIN) UNSEEN 3836 S: * ESEARCH (TAG "A284") MIN 4 3837 S: A284 OK SEARCH completed 3839 The following example demonstrates that if the ESEARCH UID indicator 3840 is present, all data in the ESEARCH response is referring to UIDs; 3841 for example, the MIN result specifier will be followed by a UID. 3843 Example: C: A285 UID SEARCH RETURN (MIN MAX) 1:5000 3844 S: * ESEARCH (TAG "A285") UID MIN 7 MAX 3800 3845 S: A285 OK SEARCH completed 3847 The following example demonstrates returning the number of deleted 3848 messages: 3850 Example: C: A286 SEARCH RETURN (COUNT) DELETED 3851 S: * ESEARCH (TAG "A286") COUNT 15 3852 S: A286 OK SEARCH completed 3854 6.4.4.1. SAVE result option and SEARCH result variable 3856 Upon successful completion of a SELECT or an EXAMINE command (after 3857 the tagged OK response), the current search result variable is reset 3858 to the empty sequence. 3860 A successful SEARCH command with the SAVE result option sets the 3861 value of the search result variable to the list of messages found in 3862 the SEARCH command. For example, if no messages were found, the 3863 search result variable will contain the empty sequence. 3865 Any of the following SEARCH commands MUST NOT change the search 3866 result variable: 3868 a SEARCH command that caused the server to return the BAD tagged 3869 response, 3871 a SEARCH command with no SAVE result option that caused the server 3872 to return NO tagged response, 3874 a successful SEARCH command with no SAVE result option. 3876 A SEARCH command with the SAVE result option that caused the server 3877 to return the NO tagged response sets the value of the search result 3878 variable to the empty sequence. 3880 When a message listed in the search result variable is EXPUNGEd, it 3881 is automatically removed from the list. Implementors are reminded 3882 that if the server stores the list as a list of message numbers, it 3883 MUST automatically adjust them when notifying the client about 3884 expunged messages, as described in Section 7.5.1. 3886 If the server decides to send a new UIDVALIDITY value while the 3887 mailbox is opened, this causes resetting of the search variable to 3888 the empty sequence. 3890 Note that even if the "$" marker contains the empty sequence of 3891 messages, it must be treated by all commands accepting message sets 3892 as parameters as a valid, but non-matching list of messages. For 3893 example, the "FETCH $" command would return a tagged OK response and 3894 no FETCH responses. See also the Example 5 in Section 6.4.4.4. 3896 The SAVE result option doesn't change whether the server would return 3897 items corresponding to MIN, MAX, ALL, or COUNT result options. 3899 When the SAVE result option is combined with the MIN or MAX result 3900 option, and both ALL and COUNT result options are absent, the 3901 corresponding MIN/MAX is returned (if the search result is not 3902 empty), but the "$" marker would contain a single message as returned 3903 in the MIN/MAX return item. 3905 If the SAVE result option is combined with both MIN and MAX result 3906 options, and both ALL and COUNT result options are absent, the "$" 3907 marker would contain zero, one or two messages as returned in the 3908 MIN/MAX return items. 3910 If the SAVE result option is combined with the ALL and/or COUNT 3911 result option(s), the "$" marker would always contain all messages 3912 found by the SEARCH or UID SEARCH command. 3914 The following table summarizes the additional requirement on ESEARCH 3915 server implementations described in this section. 3917 +------------------------------+--------------------+ 3918 | Combination of Result option | "$" marker value | 3919 +------------------------------+--------------------+ 3920 | SAVE MIN | MIN | 3921 | SAVE MAX | MAX | 3922 | SAVE MIN MAX | MIN & MAX | 3923 | SAVE * [m] | all found messages | 3924 +------------------------------+--------------------+ 3926 where '*' means "ALL" and/or "COUNT", and '[m]' means optional "MIN" 3927 and/or "MAX" 3929 Implementation note: server implementors should note that "$" can 3930 reference IMAP message sequences or UID sequences, depending on the 3931 context where it is used. For example, the "$" marker can be set as 3932 a result of a SEARCH (SAVE) command and used as a parameter to a UID 3933 FETCH command (which accepts a UID sequence, not a message sequence), 3934 or the "$" marker can be set as a result of a UID SEARCH (SAVE) 3935 command and used as a parameter to a FETCH command (which accepts a 3936 message sequence, not a UID sequence). Server implementations need 3937 to automatically map the "$" marker value to message numbers or UIDs, 3938 depending on context where the "$" marker is used. 3940 6.4.4.2. Multiple Commands in Progress 3942 Use of a SEARCH RETURN (SAVE) command followed by a command using the 3943 "$" marker creates direct dependency between the two commands. As 3944 directed by Section 5.5, a server MUST execute the two commands in 3945 the order they were received. 3947 A client MAY pipeline a SEARCH RETURN (SAVE) command with one or more 3948 command using the "$" marker, as long as this doesn't create an 3949 ambiguity, as described in Section 5.5. Examples 7-9 in 3950 Section 6.4.4.4 explain this in more details. 3952 6.4.4.3. Refusing to Save Search Results 3954 In some cases, the server MAY refuse to save a SEARCH (SAVE) result, 3955 for example, if an internal limit on the number of saved results is 3956 reached. In this case, the server MUST return a tagged NO response 3957 containing the NOTSAVED response code and set the search result 3958 variable to the empty sequence, as described in Section 6.4.4.1. 3960 6.4.4.4. Examples showing use of SAVE result option 3962 Only in this section: explanatory comments in examples that start 3963 with // are not part of the protocol. 3965 1) The following example demonstrates how the client can use the 3966 result of a SEARCH command to FETCH headers of interesting messages: 3968 Example 1: 3969 C: A282 SEARCH RETURN (SAVE) FLAGGED SINCE 1-Feb-1994 3970 NOT FROM "Smith" 3971 S: A282 OK SEARCH completed, result saved 3972 C: A283 FETCH $ (UID INTERNALDATE FLAGS BODY.PEEK[HEADER]) 3973 S: * 2 FETCH (UID 14 ... 3974 S: * 84 FETCH (UID 100 ... 3975 S: * 882 FETCH (UID 1115 ... 3976 S: A283 OK completed 3978 The client can also pipeline the two commands: 3980 Example 2: 3981 C: A282 SEARCH RETURN (SAVE) FLAGGED SINCE 1-Feb-1994 3982 NOT FROM "Smith" 3983 C: A283 FETCH $ (UID INTERNALDATE FLAGS BODY.PEEK[HEADER]) 3984 S: A282 OK SEARCH completed 3985 S: * 2 FETCH (UID 14 ... 3986 S: * 84 FETCH (UID 100 ... 3987 S: * 882 FETCH (UID 1115 ... 3988 S: A283 OK completed 3990 2) The following example demonstrates that the result of one SEARCH 3991 command can be used as input to another SEARCH command: 3993 Example 3: 3994 C: A300 SEARCH RETURN (SAVE) SINCE 1-Jan-2004 3995 NOT FROM "Smith" 3996 S: A300 OK SEARCH completed 3997 C: A301 UID SEARCH UID $ SMALLER 4096 3998 S: * ESEARCH (TAG "A301") UID ALL 17,900,901 3999 S: A301 OK completed 4001 Note that the second command in Example 3 can be replaced with: 4002 C: A301 UID SEARCH $ SMALLER 4096 4003 and the result of the command would be the same. 4005 3) The following example shows that the "$" marker can be combined 4006 with other message numbers using the OR SEARCH criterion. 4008 Example 4: 4009 C: P282 SEARCH RETURN (SAVE) SINCE 1-Feb-1994 4010 NOT FROM "Smith" 4011 S: P282 OK SEARCH completed 4012 C: P283 SEARCH CHARSET UTF-8 (OR $ 1,3000:3021) TEXT {8+} 4013 C: YYYYYYYY 4014 S: * ESEARCH (TAG "P283") ALL 882,1102,3003,3005:3006 4015 S: P283 OK completed 4017 Note: Since this document format is restricted to 7-bit ASCII text, 4018 it is not possible to show actual UTF-8 data. The "YYYYYYYY" is a 4019 placeholder for what would be 8 octets of 8-bit data in an actual 4020 transaction. 4022 4) The following example demonstrates that a failed SEARCH sets the 4023 search result variable to the empty list. The server doesn't 4024 implement the KOI8-R charset. 4026 Example 5: 4027 C: B282 SEARCH RETURN (SAVE) SINCE 1-Feb-1994 4028 NOT FROM "Smith" 4029 S: B282 OK SEARCH completed 4030 C: B283 SEARCH RETURN (SAVE) CHARSET KOI8-R 4031 (OR $ 1,3000:3021) TEXT {4} 4032 C: XXXX 4033 S: B283 NO [BADCHARSET UTF-8] KOI8-R is not supported 4034 //After this command the saved result variable contains 4035 //no messages. A client that wants to reissue the B283 4036 //SEARCH command with another CHARSET would have to reissue 4037 //the B282 command as well. One possible workaround for 4038 //this is to include the desired CHARSET parameter 4039 //in the earliest SEARCH RETURN (SAVE) command in a 4040 //sequence of related SEARCH commands, to cause 4041 //the earliest SEARCH in the sequence to fail. 4042 //A better approach might be to always use CHARSET UTF-8 4043 //instead. 4045 Note: Since this document format is restricted to 7-bit ASCII text, 4046 it is not possible to show actual KOI8-R data. The "XXXX" is a 4047 placeholder for what would be 4 octets of 8-bit data in an actual 4048 transaction. 4050 5) The following example demonstrates that it is not an error to use 4051 the "$" marker when it contains no messages. 4053 Example 6: 4054 C: E282 SEARCH RETURN (SAVE) SINCE 28-Oct-2006 4055 NOT FROM "Eric" 4056 C: E283 COPY $ "Other Messages" 4057 //The "$" contains no messages 4058 S: E282 OK SEARCH completed 4059 S: E283 OK COPY completed, nothing copied 4061 Example 7: 4062 C: F282 SEARCH RETURN (SAVE) KEYWORD $Junk 4063 C: F283 COPY $ "Junk" 4064 C: F284 STORE $ +FLAGS.Silent (\Deleted) 4065 S: F282 OK SEARCH completed 4066 S: F283 OK COPY completed 4067 S: F284 OK STORE completed 4069 Example 8: 4070 C: G282 SEARCH RETURN (SAVE) KEYWORD $Junk 4071 C: G283 SEARCH RETURN (ALL) SINCE 28-Oct-2006 4072 FROM "Eric" 4073 // The server can execute the two SEARCH commands 4074 // in any order, as they don't have any dependency. 4075 // For example, it may return: 4076 S: * ESEARCH (TAG "G283") ALL 3:15,27,29:103 4077 S: G283 OK SEARCH completed 4078 S: G282 OK SEARCH completed 4080 The following example demonstrates that the result of the second 4081 SEARCH RETURN (SAVE) always overrides the result of the first. 4083 Example 9: 4084 C: H282 SEARCH RETURN (SAVE) KEYWORD $Junk 4085 C: H283 SEARCH RETURN (SAVE) SINCE 28-Oct-2006 4086 FROM "Eric" 4087 S: H282 OK SEARCH completed 4088 S: H283 OK SEARCH completed 4089 // At this point "$" would contain results of H283 4091 The following example demonstrates behavioral difference for 4092 different combinations of ESEARCH result options. 4094 Example 10: 4095 C: C282 SEARCH RETURN (ALL) SINCE 12-Feb-2006 4096 NOT FROM "Smith" 4097 S: * ESEARCH (TAG "C283") ALL 2,10:15,21 4098 //$ value hasn't changed 4099 S: C282 OK SEARCH completed 4101 C: C283 SEARCH RETURN (ALL SAVE) SINCE 12-Feb-2006 4102 NOT FROM "Smith" 4103 S: * ESEARCH (TAG "C283") ALL 2,10:15,21 4104 //$ value is 2,10:15,21 4105 S: C283 OK SEARCH completed 4107 C: C284 SEARCH RETURN (SAVE MIN) SINCE 12-Feb-2006 4108 NOT FROM "Smith" 4109 S: * ESEARCH (TAG "C284") MIN 2 4110 //$ value is 2 4111 S: C284 OK SEARCH completed 4113 C: C285 SEARCH RETURN (MAX SAVE MIN) SINCE 4114 12-Feb-2006 NOT FROM "Smith" 4115 S: * ESEARCH (TAG "C285") MIN 2 MAX 21 4116 //$ value is 2,21 4117 S: C285 OK SEARCH completed 4119 C: C286 SEARCH RETURN (MAX SAVE MIN COUNT) 4120 SINCE 12-Feb-2006 NOT FROM "Smith" 4121 S: * ESEARCH (TAG "C286") MIN 2 MAX 21 COUNT 8 4122 //$ value is 2,10:15,21 4123 S: C286 OK SEARCH completed 4125 C: C286 SEARCH RETURN (ALL SAVE MIN) SINCE 4126 12-Feb-2006 NOT FROM "Smith" 4127 S: * ESEARCH (TAG "C286") MIN 2 ALL 2,10:15,21 4128 //$ value is 2,10:15,21 4129 S: C286 OK SEARCH completed 4131 6.4.5. FETCH Command 4133 Arguments: sequence set 4134 message data item names or macro 4136 Responses: untagged responses: FETCH 4138 Result: OK - fetch completed 4139 NO - fetch error: can't fetch that data 4140 BAD - command unknown or arguments invalid 4142 The FETCH command retrieves data associated with a message in the 4143 mailbox. The data items to be fetched can be either a single atom or 4144 a parenthesized list. 4146 Most data items, identified in the formal syntax (Section 9) under 4147 the msg-att-static rule, are static and MUST NOT change for any 4148 particular message. Other data items, identified in the formal 4149 syntax under the msg-att-dynamic rule, MAY change, either as a result 4150 of a STORE command or due to external events. 4152 For example, if a client receives an ENVELOPE for a message when 4153 it already knows the envelope, it can safely ignore the newly 4154 transmitted envelope. 4156 There are three macros which specify commonly-used sets of data 4157 items, and can be used instead of data items. A macro must be used 4158 by itself, and not in conjunction with other macros or data items. 4160 ALL Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE) 4162 FAST Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE) 4164 FULL Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE 4165 BODY) 4167 Several data items reference "section" or "section-binary". See 4168 Section 6.4.5.1 for their detailed definition. 4170 The currently defined data items that can be fetched are: 4172 BINARY[]<> 4174 Requests that the specified section be transmitted after 4175 performing Content-Transfer-Encoding-related decoding. 4177 The argument, if present, requests that a subset of 4178 the data be returned. The semantics of a partial FETCH BINARY 4179 command are the same as for a partial FETCH BODY command, with 4180 the exception that the arguments refer to the DECODED 4181 section data. 4183 Note that this data item can only be requested for leaf (i.e. 4184 non multipart/*, non message/rfc822 and non message/global) 4185 body parts. 4187 BINARY.PEEK[]<> An alternate form of 4188 BINARY[] that does not implicitly set the \Seen 4189 flag. 4191 BINARY.SIZE[] 4193 Requests the decoded size of the section (i.e., the size to 4194 expect in response to the corresponding FETCH BINARY request). 4196 Note: client authors are cautioned that this might be an 4197 expensive operation for some server implementations. 4198 Needlessly issuing this request could result in degraded 4199 performance due to servers having to calculate the value every 4200 time the request is issued. 4202 Note that this data item can only be requested for leaf (i.e. 4203 non multipart/*, non message/rfc822 and non message/global) 4204 body parts. 4206 BODY Non-extensible form of BODYSTRUCTURE. 4208 BODY[
]<> 4210 The text of a particular body section. 4212 It is possible to fetch a substring of the designated text. 4213 This is done by appending an open angle bracket ("<"), the 4214 octet position of the first desired octet, a period, the 4215 maximum number of octets desired, and a close angle bracket 4216 (">") to the part specifier. If the starting octet is beyond 4217 the end of the text, an empty string is returned. 4219 Any partial fetch that attempts to read beyond the end of the 4220 text is truncated as appropriate. A partial fetch that starts 4221 at octet 0 is returned as a partial fetch, even if this 4222 truncation happened. 4224 Note: This means that BODY[]<0.2048> of a 1500-octet message 4225 will return BODY[]<0> with a literal of size 1500, not 4226 BODY[]. 4228 Note: A substring fetch of a HEADER.FIELDS or 4229 HEADER.FIELDS.NOT part specifier is calculated after 4230 subsetting the header. 4232 The \Seen flag is implicitly set; if this causes the flags to 4233 change, they SHOULD be included as part of the FETCH responses. 4235 BODY.PEEK[
]<> An alternate form of BODY[
] 4236 that does not implicitly set the \Seen flag. 4238 BODYSTRUCTURE The [MIME-IMB] body structure of the message. This is 4239 computed by the server by parsing the [MIME-IMB] header fields in 4240 the [RFC-5322] header and [MIME-IMB] headers. See Section 7.5.2 4241 for more details. 4243 ENVELOPE The envelope structure of the message. This is computed by 4244 the server by parsing the [RFC-5322] header into the component 4245 parts, defaulting various fields as necessary. See Section 7.5.2 4246 for more details. 4248 FLAGS The flags that are set for this message. 4250 INTERNALDATE The internal date of the message. 4252 RFC822.SIZE The [RFC-5322] size of the message. 4254 UID The unique identifier for the message. 4256 Example: C: A654 FETCH 2:4 (FLAGS BODY[HEADER.FIELDS (DATE FROM)]) 4257 S: * 2 FETCH .... 4258 S: * 3 FETCH .... 4259 S: * 4 FETCH .... 4260 S: A654 OK FETCH completed 4262 6.4.5.1. FETCH section specification 4264 Several FETCH data items reference "section" or "section-binary". 4265 The section specification is a set of zero or more part specifiers 4266 delimited by periods. A part specifier is either a part number or 4267 one of the following: HEADER, HEADER.FIELDS, HEADER.FIELDS.NOT, MIME, 4268 and TEXT. (Non numeric part specifiers have to be the last specifier 4269 in a section specification.) An empty section specification refers 4270 to the entire message, including the header. 4272 Every message has at least one part number. Non-[MIME-IMB] messages, 4273 and non-multipart [MIME-IMB] messages with no encapsulated message, 4274 only have a part 1. 4276 Multipart messages are assigned consecutive part numbers, as they 4277 occur in the message. If a particular part is of type message or 4278 multipart, its parts MUST be indicated by a period followed by the 4279 part number within that nested multipart part. 4281 A part of type MESSAGE/RFC822 or MESSAGE/GLOBAL also has nested part 4282 numbers, referring to parts of the MESSAGE part's body. 4284 The HEADER, HEADER.FIELDS, HEADER.FIELDS.NOT, and TEXT part 4285 specifiers can be the sole part specifier or can be prefixed by one 4286 or more numeric part specifiers, provided that the numeric part 4287 specifier refers to a part of type MESSAGE/RFC822 or MESSAGE/GLOBAL. 4288 The MIME part specifier MUST be prefixed by one or more numeric part 4289 specifiers. 4291 The HEADER, HEADER.FIELDS, and HEADER.FIELDS.NOT part specifiers 4292 refer to the [RFC-5322] header of the message or of an encapsulated 4293 [MIME-IMT] MESSAGE/RFC822 or MESSAGE/GLOBAL message. HEADER.FIELDS 4294 and HEADER.FIELDS.NOT are followed by a list of field-name (as 4295 defined in [RFC-5322]) names, and return a subset of the header. The 4296 subset returned by HEADER.FIELDS contains only those header fields 4297 with a field-name that matches one of the names in the list; 4298 similarly, the subset returned by HEADER.FIELDS.NOT contains only the 4299 header fields with a non-matching field-name. The field-matching is 4300 ASCII range case-insensitive but otherwise exact. Subsetting does 4301 not exclude the [RFC-5322] delimiting blank line between the header 4302 and the body; the blank line is included in all header fetches, 4303 except in the case of a message which has no body and no blank line. 4305 The MIME part specifier refers to the [MIME-IMB] header for this 4306 part. 4308 The TEXT part specifier refers to the text body of the message, 4309 omitting the [RFC-5322] header. 4311 Here is an example of a complex message with some of its part 4312 specifiers: 4314 HEADER ([RFC-5322] header of the message) 4315 TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 4316 1 TEXT/PLAIN 4317 2 APPLICATION/OCTET-STREAM 4318 3 MESSAGE/RFC822 4319 3.HEADER ([RFC-5322] header of the message) 4320 3.TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 4321 3.1 TEXT/PLAIN 4322 3.2 APPLICATION/OCTET-STREAM 4323 4 MULTIPART/MIXED 4324 4.1 IMAGE/GIF 4325 4.1.MIME ([MIME-IMB] header for the IMAGE/GIF) 4326 4.2 MESSAGE/RFC822 4327 4.2.HEADER ([RFC-5322] header of the message) 4328 4.2.TEXT ([RFC-5322] text body of the message) MULTIPART/MIXED 4329 4.2.1 TEXT/PLAIN 4330 4.2.2 MULTIPART/ALTERNATIVE 4331 4.2.2.1 TEXT/PLAIN 4332 4.2.2.2 TEXT/RICHTEXT 4334 6.4.6. STORE Command 4336 Arguments: sequence set 4337 message data item name 4338 value for message data item 4340 Responses: untagged responses: FETCH 4342 Result: OK - store completed 4343 NO - store error: can't store that data 4344 BAD - command unknown or arguments invalid 4346 The STORE command alters data associated with a message in the 4347 mailbox. Normally, STORE will return the updated value of the data 4348 with an untagged FETCH response. A suffix of ".SILENT" in the data 4349 item name prevents the untagged FETCH, and the server SHOULD assume 4350 that the client has determined the updated value itself or does not 4351 care about the updated value. 4353 Note: Regardless of whether or not the ".SILENT" suffix was used, 4354 the server SHOULD send an untagged FETCH response if a change to a 4355 message's flags from an external source is observed. The intent 4356 is that the status of the flags is determinate without a race 4357 condition. 4359 The currently defined data items that can be stored are: 4361 FLAGS Replace the flags for the message with the 4362 argument. The new value of the flags is returned as if a FETCH of 4363 those flags was done. 4365 FLAGS.SILENT Equivalent to FLAGS, but without returning 4366 a new value. 4368 +FLAGS Add the argument to the flags for the message. 4369 The new value of the flags is returned as if a FETCH of those 4370 flags was done. 4372 +FLAGS.SILENT Equivalent to +FLAGS, but without 4373 returning a new value. 4375 -FLAGS Remove the argument from the flags for the 4376 message. The new value of the flags is returned as if a FETCH of 4377 those flags was done. 4379 -FLAGS.SILENT Equivalent to -FLAGS, but without 4380 returning a new value. 4382 Example: C: A003 STORE 2:4 +FLAGS (\Deleted) 4383 S: * 2 FETCH (FLAGS (\Deleted \Seen)) 4384 S: * 3 FETCH (FLAGS (\Deleted)) 4385 S: * 4 FETCH (FLAGS (\Deleted \Flagged \Seen)) 4386 S: A003 OK STORE completed 4388 6.4.7. COPY Command 4390 Arguments: sequence set 4391 mailbox name 4393 Responses: no specific responses for this command 4395 Result: OK - copy completed 4396 NO - copy error: can't copy those messages or to that 4397 name 4398 BAD - command unknown or arguments invalid 4400 The COPY command copies the specified message(s) to the end of the 4401 specified destination mailbox. The flags and internal date of the 4402 message(s) SHOULD be preserved in the copy. 4404 If the destination mailbox does not exist, a server MUST return an 4405 error. It MUST NOT automatically create the mailbox. Unless it is 4406 certain that the destination mailbox can not be created, the server 4407 MUST send the response code "[TRYCREATE]" as the prefix of the text 4408 of the tagged NO response. This gives a hint to the client that it 4409 can attempt a CREATE command and retry the COPY if the CREATE is 4410 successful. 4412 If the COPY command is unsuccessful for any reason, server 4413 implementations MUST restore the destination mailbox to its state 4414 before the COPY attempt (other than possibly incrementing UIDNEXT), 4415 i.e. partial copy MUST NOT be done. 4417 On successful completion of a COPY, the server returns a COPYUID 4418 response code (see Section 7.1). Two exception to this requirement 4419 are listed below. 4421 In the case of a mailbox that has permissions set so that the client 4422 can COPY to the mailbox, but not SELECT or EXAMINE it, the server 4423 MUST NOT send an COPYUID response code as it would disclose 4424 information about the mailbox. 4426 In the case of a mailbox that has UIDNOTSTICKY status (see 4427 Section 7.1), the server MAY omit the COPYUID response code as it is 4428 not meaningful. 4430 Example: C: A003 COPY 2:4 MEETING 4431 S: A003 OK [COPYUID 38505 304,319:320 3956:3958] COPY completed 4433 6.4.8. MOVE Command 4435 Arguments: sequence set 4436 mailbox name 4438 Responses: no specific responses for this command 4440 Result: OK - move completed 4441 NO - move error: can't move those messages or to that 4442 name 4443 BAD - command unknown or arguments invalid 4445 The MOVE command moves the specified message(s) to the end of the 4446 specified destination mailbox. The flags and internal date of the 4447 message(s) SHOULD be preserved. 4449 This means that a new message is created in the target mailbox with a 4450 new UID, the original message is removed from the source mailbox, and 4451 it appears to the client as a single action. This has the same 4452 effect for each message as this sequence: 4454 1. [UID] COPY 4456 2. [UID] STORE +FLAGS.SILENT \DELETED 4458 3. UID EXPUNGE 4460 Although the effect of the MOVE is the same as the preceding steps, 4461 the semantics are not identical: The intermediate states produced by 4462 those steps do not occur, and the response codes are different. In 4463 particular, though the COPY and EXPUNGE response codes will be 4464 returned, response codes for a STORE MUST NOT be generated and the 4465 \Deleted flag MUST NOT be set for any message. 4467 Unlike the COPY command, MOVE of a set of messages might fail partway 4468 through the set. Regardless of whether the command is successful in 4469 moving the entire set, each individual message MUST either be moved 4470 or unaffected. The server MUST leave each message in a state where 4471 it is in at least one of the source or target mailboxes (no message 4472 can be lost or orphaned). The server SHOULD NOT leave any message in 4473 both mailboxes (it would be bad for a partial failure to result in a 4474 bunch of duplicate messages). This is true even if the server 4475 returns a tagged NO response to the command. 4477 If the destination mailbox does not exist, a server MUST return an 4478 error. It MUST NOT automatically create the mailbox. Unless it is 4479 certain that the destination mailbox can not be created, the server 4480 MUST send the response code "[TRYCREATE]" as the prefix of the text 4481 of the tagged NO response. This gives a hint to the client that it 4482 can attempt a CREATE command and retry the MOVE if the CREATE is 4483 successful. 4485 Because of the similarity of MOVE to COPY, extensions that affect 4486 COPY affect MOVE in the same way. Response codes listed in 4487 Section 7.1, as well as those defined by extensions, are sent as 4488 indicated for COPY. 4490 Servers send COPYUID in response to a MOVE or a UID MOVE (see 4491 Section 6.4.9) command. For additional information about COPYUID see 4492 Section 7.1. Note that there are several exceptions listed in 4493 Section 6.4.7 that allow servers not to return COPYUID. 4495 Servers are also REQUIRED to send the COPYUID response code in an 4496 untagged OK before sending EXPUNGE or similar responses. (Sending 4497 COPYUID in the tagged OK, as described in the UIDPLUS specification, 4498 means that clients first receive an EXPUNGE for a message and 4499 afterwards COPYUID for the same message. It can be unnecessarily 4500 difficult to process that sequence usefully.) 4502 An example: 4503 C: a UID MOVE 42:69 foo 4504 S: * OK [COPYUID 432432 42:69 1202:1229] 4505 S: * 22 EXPUNGE 4506 ...More EXPUNGE responses from the server... 4507 S: a OK Done 4509 Note that the server may send unrelated EXPUNGE responses as well, if 4510 any happen to have been expunged at the same time; this is normal 4511 IMAP operation. 4513 Note that moving a message to the currently selected mailbox (that 4514 is, where the source and target mailboxes are the same) is allowed 4515 when copying the message to the currently selected mailbox is 4516 allowed. 4518 The server may send EXPUNGE responses before the tagged response, so 4519 the client cannot safely send more commands with message sequence 4520 number arguments while the server is processing MOVE. 4522 MOVE and UID MOVE can be pipelined with other commands, but care has 4523 to be taken. Both commands modify sequence numbers and also allow 4524 unrelated EXPUNGE responses. The renumbering of other messages in 4525 the source mailbox following any EXPUNGE response can be surprising 4526 and makes it unsafe to pipeline any command that relies on message 4527 sequence numbers after a MOVE or UID MOVE. Similarly, MOVE cannot be 4528 pipelined with a command that might cause message renumbering. See 4529 Section 5.5, for more information about ambiguities as well as 4530 handling requirements for both clients and servers. 4532 6.4.9. UID Command 4534 Arguments: command name 4535 command arguments 4537 Responses: untagged responses: FETCH, ESEARCH, EXPUNGE 4539 Result: OK - UID command completed 4540 NO - UID command error 4541 BAD - command unknown or arguments invalid 4543 The UID command has three forms. In the first form, it takes as its 4544 arguments a COPY, MOVE, FETCH, or STORE command with arguments 4545 appropriate for the associated command. However, the numbers in the 4546 sequence set argument are unique identifiers instead of message 4547 sequence numbers. Sequence set ranges are permitted, but there is no 4548 guarantee that unique identifiers will be contiguous. 4550 A non-existent unique identifier is ignored without any error message 4551 generated. Thus, it is possible for a UID FETCH command to return an 4552 OK without any data or a UID COPY, UID MOVE or UID STORE to return an 4553 OK without performing any operations. 4555 In the second form, the UID command takes an EXPUNGE command with an 4556 extra parameter the specified a sequence set of UIDs to operate on. 4557 The UID EXPUNGE command permanently removes all messages that both 4558 have the \Deleted flag set and have a UID that is included in the 4559 specified sequence set from the currently selected mailbox. If a 4560 message either does not have the \Deleted flag set or has a UID that 4561 is not included in the specified sequence set, it is not affected. 4563 UID EXPUNGE is particularly useful for disconnected use clients. 4564 By using UID EXPUNGE instead of EXPUNGE when resynchronizing with 4565 the server, the client can ensure that it does not inadvertantly 4566 remove any messages that have been marked as \Deleted by other 4567 clients between the time that the client was last connected and 4568 the time the client resynchronizes. 4570 Example: C: A003 UID EXPUNGE 3000:3002 4571 S: * 3 EXPUNGE 4572 S: * 3 EXPUNGE 4573 S: * 3 EXPUNGE 4574 S: A003 OK UID EXPUNGE completed 4576 In the third form, the UID command takes a SEARCH command with SEARCH 4577 command arguments. The interpretation of the arguments is the same 4578 as with SEARCH; however, the numbers returned in a ESEARCH response 4579 for a UID SEARCH command are unique identifiers instead of message 4580 sequence numbers. Also, the corresponding ESEARCH response MUST 4581 include the UID indicator. For example, the command UID SEARCH 1:100 4582 UID 443:557 returns the unique identifiers corresponding to the 4583 intersection of two sequence sets, the message sequence number range 4584 1:100 and the UID range 443:557. 4586 Note: in the above example, the UID range 443:557 appears. The 4587 same comment about a non-existent unique identifier being ignored 4588 without any error message also applies here. Hence, even if 4589 neither UID 443 or 557 exist, this range is valid and would 4590 include an existing UID 495. 4592 Also note that a UID range of 559:* always includes the UID of the 4593 last message in the mailbox, even if 559 is higher than any 4594 assigned UID value. This is because the contents of a range are 4595 independent of the order of the range endpoints. Thus, any UID 4596 range with * as one of the endpoints indicates at least one 4597 message (the message with the highest numbered UID), unless the 4598 mailbox is empty. 4600 The number after the "*" in an untagged FETCH or EXPUNGE response is 4601 always a message sequence number, not a unique identifier, even for a 4602 UID command response. However, server implementations MUST 4603 implicitly include the UID message data item as part of any FETCH 4604 response caused by a UID command, regardless of whether a UID was 4605 specified as a message data item to the FETCH. 4607 Note: The rule about including the UID message data item as part of a 4608 FETCH response primarily applies to the UID FETCH and UID STORE 4609 commands, including a UID FETCH command that does not include UID as 4610 a message data item. Although it is unlikely that the other UID 4611 commands will cause an untagged FETCH, this rule applies to these 4612 commands as well. 4614 Example: C: A999 UID FETCH 4827313:4828442 FLAGS 4615 S: * 23 FETCH (FLAGS (\Seen) UID 4827313) 4616 S: * 24 FETCH (FLAGS (\Seen) UID 4827943) 4617 S: * 25 FETCH (FLAGS (\Seen) UID 4828442) 4618 S: A999 OK UID FETCH completed 4620 6.5. Client Commands - Experimental/Expansion 4622 Each command which is not part of this specification MUST have at 4623 least one capability name (see Section 6.1.1) associated with it. 4624 (Multiple commands can be associated with the same capability name.) 4626 Server implementations MUST NOT send any added (not specified in this 4627 specification) untagged responses, unless the client requested it by 4628 issuing the associated experimental command (specified in an 4629 extension document) or the ENABLE command (Section 6.3.1). 4631 The following example demonstrates how a client can check for 4632 presence of a fictitious XPIG-LATIN capability that adds the XPIG- 4633 LATIN command and the the XPIG-LATIN untagged response. (Note that 4634 for an extension the command name and the capability name don't have 4635 to be the same.) 4637 Example: C: a441 CAPABILITY 4638 S: * CAPABILITY IMAP4rev2 XPIG-LATIN 4639 S: a441 OK CAPABILITY completed 4640 C: A442 XPIG-LATIN 4641 S: * XPIG-LATIN ow-nay eaking-spay ig-pay atin-lay 4642 S: A442 OK XPIG-LATIN ompleted-cay 4644 7. Server Responses 4646 Server responses are in three forms: status responses, server data, 4647 and command continuation request. The information contained in a 4648 server response, identified by "Contents:" in the response 4649 descriptions below, is described by function, not by syntax. The 4650 precise syntax of server responses is described in the Formal Syntax 4651 (Section 9). 4653 The client MUST be prepared to accept any response at all times. 4655 Status responses can be tagged or untagged. Tagged status responses 4656 indicate the completion result (OK, NO, or BAD status) of a client 4657 command, and have a tag matching the command. 4659 Some status responses, and all server data, are untagged. An 4660 untagged response is indicated by the token "*" instead of a tag. 4661 Untagged status responses indicate server greeting, or server status 4662 that does not indicate the completion of a command (for example, an 4663 impending system shutdown alert). For historical reasons, untagged 4664 server data responses are also called "unsolicited data", although 4665 strictly speaking, only unilateral server data is truly 4666 "unsolicited". 4668 Certain server data MUST be remembered by the client when it is 4669 received; this is noted in the description of that data. Such data 4670 conveys critical information which affects the interpretation of all 4671 subsequent commands and responses (e.g., updates reflecting the 4672 creation or destruction of messages). 4674 Other server data SHOULD be remembered for later reference; if the 4675 client does not need to remember the data, or if remembering the data 4676 has no obvious purpose (e.g., a SEARCH response when no SEARCH 4677 command is in progress), the data can be ignored. 4679 An example of unilateral untagged server data occurs when the IMAP 4680 connection is in the selected state. In the selected state, the 4681 server checks the mailbox for new messages as part of command 4682 execution. Normally, this is part of the execution of every command; 4683 hence, a NOOP command suffices to check for new messages. If new 4684 messages are found, the server sends untagged EXISTS response 4685 reflecting the new size of the mailbox. Server implementations that 4686 offer multiple simultaneous access to the same mailbox SHOULD also 4687 send appropriate unilateral untagged FETCH and EXPUNGE responses if 4688 another agent changes the state of any message flags or expunges any 4689 messages. 4691 Command continuation request responses use the token "+" instead of a 4692 tag. These responses are sent by the server to indicate acceptance 4693 of an incomplete client command and readiness for the remainder of 4694 the command. 4696 7.1. Server Responses - Generic Status Responses 4698 Status responses are OK, NO, BAD, PREAUTH and BYE. OK, NO, and BAD 4699 can be tagged or untagged. PREAUTH and BYE are always untagged. 4701 Status responses MAY include an OPTIONAL "response code". A response 4702 code consists of data inside square brackets in the form of an atom, 4703 possibly followed by a space and arguments. The response code 4704 contains additional information or status codes for client software 4705 beyond the OK/NO/BAD condition, and are defined when there is a 4706 specific action that a client can take based upon the additional 4707 information. 4709 The currently defined response codes are: 4711 ALERT 4713 The human-readable text contains a special alert that are 4714 presented to the user in a fashion that calls the user's 4715 attention to the message. Content of ALERT response codes 4716 received on a connection without TLS or SASL security layer 4717 confidentiality SHOULD be ignored by clients. If displayed, 4718 such alerts MUST be clearly marked as potentially suspicious. 4719 (Note that some existing clients are known to hyperlink 4720 returned text which make them very dangerous.) Alerts received 4721 after successful establishment of a TLS/SASL confidentiality 4722 layer MUST be presented to the user. 4724 ALREADYEXISTS 4726 The operation attempts to create something that already exists, 4727 such as when the CREATE or RENAME directories attempt to create 4728 a mailbox and there is already one of that name. 4730 C: o356 RENAME this that 4731 S: o356 NO [ALREADYEXISTS] Mailbox "that" already exists 4733 APPENDUID 4735 Followed by the UIDVALIDITY of the destination mailbox and the 4736 UID assigned to the appended message in the destination 4737 mailbox, indicates that the message has been appended to the 4738 destination mailbox with that UID. 4740 If the server also supports the [MULTIAPPEND] extension, and if 4741 multiple messages were appended in the APPEND command, then the 4742 second value is a UID set containing the UIDs assigned to the 4743 appended messages, in the order they were transmitted in the 4744 APPEND command. This UID set may not contain extraneous UIDs 4745 or the symbol "*". 4747 Note: the UID set form of the APPENDUID response code MUST 4748 NOT be used if only a single message was appended. In 4749 particular, a server MUST NOT send a range such as 123:123. 4750 This is because a client that does not support [MULTIAPPEND] 4751 expects only a single UID and not a UID set. 4753 UIDs are assigned in strictly ascending order in the mailbox 4754 (refer to Section 2.3.1.1); note that a range of 12:10 is 4755 exactly equivalent to 10:12 and refers to the sequence 4756 10,11,12. 4758 This response code is returned in a tagged OK response to the 4759 APPEND command. 4761 AUTHENTICATIONFAILED 4763 Authentication failed for some reason on which the server is 4764 unwilling to elaborate. Typically, this includes "unknown 4765 user" and "bad password". 4767 This is the same as not sending any response code, except that 4768 when a client sees AUTHENTICATIONFAILED, it knows that the 4769 problem wasn't, e.g., UNAVAILABLE, so there's no point in 4770 trying the same login/password again later. 4772 C: b LOGIN "fred" "foo" 4773 S: b NO [AUTHENTICATIONFAILED] Authentication failed 4775 AUTHORIZATIONFAILED 4777 Authentication succeeded in using the authentication identity, 4778 but the server cannot or will not allow the authentication 4779 identity to act as the requested authorization identity. This 4780 is only applicable when the authentication and authorization 4781 identities are different. 4783 C: c1 AUTHENTICATE PLAIN 4784 [...] 4785 S: c1 NO [AUTHORIZATIONFAILED] No such authorization-ID 4787 C: c2 AUTHENTICATE PLAIN 4788 [...] 4789 S: c2 NO [AUTHORIZATIONFAILED] Authenticator is not an admin 4791 BADCHARSET 4793 Optionally followed by a parenthesized list of charsets. A 4794 SEARCH failed because the given charset is not supported by 4795 this implementation. If the optional list of charsets is 4796 given, this lists the charsets that are supported by this 4797 implementation. 4799 CANNOT 4801 The operation violates some invariant of the server and can 4802 never succeed. 4804 C: l create "///////" 4805 S: l NO [CANNOT] Adjacent slashes are not supported 4807 CAPABILITY 4809 Followed by a list of capabilities. This can appear in the 4810 initial OK or PREAUTH response to transmit an initial 4811 capabilities list. It can also appear in tagged responses to 4812 LOGIN or AUTHENTICATE commands. This makes it unnecessary for 4813 a client to send a separate CAPABILITY command if it recognizes 4814 this response code and there was no change to the TLS and/or 4815 authentication state since it was received. 4817 CLIENTBUG 4819 The server has detected a client bug. This can accompany all 4820 of OK, NO, and BAD, depending on what the client bug is. 4822 C: k1 select "/archive/projects/experiment-iv" 4823 [...] 4824 S: k1 OK [READ-ONLY] Done 4825 C: k2 status "/archive/projects/experiment-iv" (messages) 4826 [...] 4827 S: k2 OK [CLIENTBUG] Done 4829 CLOSED 4831 The CLOSED response code has no parameters. A server return 4832 the CLOSED response code when the currently selected mailbox is 4833 closed implicitly using the SELECT/EXAMINE command on another 4834 mailbox. The CLOSED response code serves as a boundary between 4835 responses for the previously opened mailbox (which was closed) 4836 and the newly selected mailbox; all responses before the CLOSED 4837 response code relate to the mailbox that was closed, and all 4838 subsequent responses relate to the newly opened mailbox. 4840 There is no need to return the CLOSED response code on 4841 completion of the CLOSE or the UNSELECT command (or similar), 4842 whose purpose is to close the currently selected mailbox 4843 without opening a new one. 4845 CONTACTADMIN 4847 The user should contact the system administrator or support 4848 desk. 4850 C: e login "fred" "foo" 4851 S: e NO [CONTACTADMIN] 4853 COPYUID 4855 Followed by the UIDVALIDITY of the destination mailbox, a UID 4856 set containing the UIDs of the message(s) in the source mailbox 4857 that were copied to the destination mailbox, followed by 4858 another UID set containing the UIDs assigned to the copied 4859 message(s) in the destination mailbox, indicates that the 4860 message(s) have been copied to the destination mailbox with the 4861 stated UID(s). 4863 The source UID set is in the order the message(s) were copied; 4864 the destination UID set corresponds to the source UID set and 4865 is in the same order. Neither of the UID sets may contain 4866 extraneous UIDs or the symbol "*". 4868 UIDs are assigned in strictly ascending order in the mailbox 4869 (refer to Section 2.3.1.1); note that a range of 12:10 is 4870 exactly equivalent to 10:12 and refers to the sequence 4871 10,11,12. 4873 This response code is returned in a tagged OK response to the 4874 COPY/UID COPY command or in the untagged OK response to the 4875 MOVE/UID MOVE command. 4877 CORRUPTION 4879 The server discovered that some relevant data (e.g., the 4880 mailbox) are corrupt. This response code does not include any 4881 information about what's corrupt, but the server can write that 4882 to its logfiles. 4884 C: i select "/archive/projects/experiment-iv" 4885 S: i NO [CORRUPTION] Cannot open mailbox 4887 EXPIRED 4889 Either authentication succeeded or the server no longer had the 4890 necessary data; either way, access is no longer permitted using 4891 that passphrase. The client or user should get a new 4892 passphrase. 4894 C: d login "fred" "foo" 4895 S: d NO [EXPIRED] That password isn't valid any more 4897 EXPUNGEISSUED 4898 Someone else has issued an EXPUNGE for the same mailbox. The 4899 client may want to issue NOOP soon. [IMAP-MULTIACCESS] 4900 discusses this subject in depth. 4902 C: h search from maria@example.com 4903 S: * ESEARCH (TAG "h") ALL 1:3,5,8,13,21,42 4904 S: h OK [EXPUNGEISSUED] Search completed 4906 HASCHILDREN 4908 The mailbox delete operation failed because the mailbox has one 4909 or more children and the server doesn't allow deletion of 4910 mailboxes with children. 4912 C: m356 DELETE Notes 4913 S: o356 NO [HASCHILDREN] Mailbox "Notes" has children that need 4914 to be deleted first 4916 INUSE 4918 An operation has not been carried out because it involves 4919 sawing off a branch someone else is sitting on. Someone else 4920 may be holding an exclusive lock needed for this operation, or 4921 the operation may involve deleting a resource someone else is 4922 using, typically a mailbox. 4924 The operation may succeed if the client tries again later. 4926 C: g delete "/archive/projects/experiment-iv" 4927 S: g NO [INUSE] Mailbox in use 4929 LIMIT 4931 The operation ran up against an implementation limit of some 4932 kind, such as the number of flags on a single message or the 4933 number of flags used in a mailbox. 4935 C: m STORE 42 FLAGS f1 f2 f3 f4 f5 ... f250 4936 S: m NO [LIMIT] At most 32 flags in one mailbox supported 4938 NONEXISTENT 4940 The operation attempts to delete something that does not exist. 4941 Similar to ALREADYEXISTS. 4943 C: p RENAME this that 4944 S: p NO [NONEXISTENT] No such mailbox 4946 NOPERM 4948 The access control system (e.g., Access Control List (ACL), see 4949 [RFC4314]) does not permit this user to carry out an operation, 4950 such as selecting or creating a mailbox. 4952 C: f select "/archive/projects/experiment-iv" 4953 S: f NO [NOPERM] Access denied 4955 OVERQUOTA 4957 The user would be over quota after the operation. (The user 4958 may or may not be over quota already.) 4960 Note that if the server sends OVERQUOTA but doesn't support the 4961 IMAP QUOTA extension defined by [RFC2087], then there is a 4962 quota, but the client cannot find out what the quota is. 4964 C: n1 uid copy 1:* oldmail 4965 S: n1 NO [OVERQUOTA] Sorry 4967 C: n2 uid copy 1:* oldmail 4968 S: n2 OK [OVERQUOTA] You are now over your soft quota 4970 PARSE 4972 The human-readable text represents an error in parsing the 4973 [RFC-5322] header or [MIME-IMB] headers of a message in the 4974 mailbox. 4976 PERMANENTFLAGS 4978 Followed by a parenthesized list of flags, indicates which of 4979 the known flags the client can change permanently. Any flags 4980 that are in the FLAGS untagged response, but not the 4981 PERMANENTFLAGS list, can not be set permanently. The 4982 PERMANENTFLAGS list can also include the special flag \*, which 4983 indicates that it is possible to create new keywords by 4984 attempting to store those keywords in the mailbox. If the 4985 client attempts to STORE a flag that is not in the 4986 PERMANENTFLAGS list, the server will either ignore the change 4987 or store the state change for the remainder of the current 4988 session only. 4990 There is no need for a server that included the special flag \* 4991 to return a new PERMANENTFLAGS response code when a new keyword 4992 was successfully set on a message upon client request. However 4993 if the server has a limit on the number of different keywords 4994 that can be stored in a mailbox and that limit is reached, the 4995 server MUST send a new PERMANENTFLAGS response code without the 4996 special flag \*. 4998 PRIVACYREQUIRED 5000 The operation is not permitted due to a lack of data 5001 confidentiality. If Transport Layer Security (TLS) is not in 5002 use, the client could try STARTTLS (see Section 6.2.1) or 5003 alternatively reconnect on Implicit TLS port, and then repeat 5004 the operation. 5006 C: d login "fred" "foo" 5007 S: d NO [PRIVACYREQUIRED] Connection offers no privacy 5009 C: d select inbox 5010 S: d NO [PRIVACYREQUIRED] Connection offers no privacy 5012 READ-ONLY 5014 The mailbox is selected read-only, or its access while selected 5015 has changed from read-write to read-only. 5017 READ-WRITE 5019 The mailbox is selected read-write, or its access while 5020 selected has changed from read-only to read-write. 5022 SERVERBUG 5024 The server encountered a bug in itself or violated one of its 5025 own invariants. 5027 C: j select "/archive/projects/experiment-iv" 5028 S: j NO [SERVERBUG] This should not happen 5030 TRYCREATE 5032 An APPEND, COPY or MOVE attempt is failing because the target 5033 mailbox does not exist (as opposed to some other reason). This 5034 is a hint to the client that the operation can succeed if the 5035 mailbox is first created by the CREATE command. 5037 UIDNEXT 5038 Followed by a decimal number, indicates the next unique 5039 identifier value. Refer to Section 2.3.1.1 for more 5040 information. 5042 UIDNOTSTICKY 5044 The selected mailbox is supported by a mail store that does not 5045 support persistent UIDs; that is, UIDVALIDITY will be different 5046 each time the mailbox is selected. Consequently, APPEND or 5047 COPY to this mailbox will not return an APPENDUID or COPYUID 5048 response code. 5050 This response code is returned in an untagged NO response to 5051 the SELECT command. 5053 Note: servers SHOULD NOT have any UIDNOTSTICKY mail stores. 5054 This facility exists to support legacy mail stores in which 5055 it is technically infeasible to support persistent UIDs. 5056 This should be avoided when designing new mail stores. 5058 UIDVALIDITY 5060 Followed by a decimal number, indicates the unique identifier 5061 validity value. Refer to Section 2.3.1.1 for more information. 5063 UNAVAILABLE 5065 Temporary failure because a subsystem is down. For example, an 5066 IMAP server that uses a Lightweight Directory Access Protocol 5067 (LDAP) or Radius server for authentication might use this 5068 response code when the LDAP/Radius server is down. 5070 C: a LOGIN "fred" "foo" 5071 S: a NO [UNAVAILABLE] User's backend down for maintenance 5073 UNKNOWN-CTE 5075 The server does not know how to decode the section's Content- 5076 Transfer-Encoding. 5078 Client implementations MUST ignore response codes that they do not 5079 recognize. 5081 7.1.1. OK Response 5083 Contents: OPTIONAL response code 5084 human-readable text 5086 The OK response indicates an information message from the server. 5087 When tagged, it indicates successful completion of the associated 5088 command. The human-readable text MAY be presented to the user as an 5089 information message. The untagged form indicates an information-only 5090 message; the nature of the information MAY be indicated by a response 5091 code. 5093 The untagged form is also used as one of three possible greetings at 5094 connection startup. It indicates that the connection is not yet 5095 authenticated and that a LOGIN or an AUTHENTICATE command is needed. 5097 Example: S: * OK IMAP4rev2 server ready 5098 C: A001 LOGIN fred blurdybloop 5099 S: * OK [ALERT] System shutdown in 10 minutes 5100 S: A001 OK LOGIN Completed 5102 7.1.2. NO Response 5104 Contents: OPTIONAL response code 5105 human-readable text 5107 The NO response indicates an operational error message from the 5108 server. When tagged, it indicates unsuccessful completion of the 5109 associated command. The untagged form indicates a warning; the 5110 command can still complete successfully. The human-readable text 5111 describes the condition. 5113 Example: C: A222 COPY 1:2 owatagusiam 5114 S: * NO Disk is 98% full, please delete unnecessary data 5115 S: A222 OK COPY completed 5116 C: A223 COPY 3:200 blurdybloop 5117 S: * NO Disk is 98% full, please delete unnecessary data 5118 S: * NO Disk is 99% full, please delete unnecessary data 5119 S: A223 NO COPY failed: disk is full 5121 7.1.3. BAD Response 5123 Contents: OPTIONAL response code 5124 human-readable text 5126 The BAD response indicates an error message from the server. When 5127 tagged, it reports a protocol-level error in the client's command; 5128 the tag indicates the command that caused the error. The untagged 5129 form indicates a protocol-level error for which the associated 5130 command can not be determined; it can also indicate an internal 5131 server failure. The human-readable text describes the condition. 5133 Example: C: ...very long command line... 5134 S: * BAD Command line too long 5135 C: ...empty line... 5136 S: * BAD Empty command line 5137 C: A443 EXPUNGE 5138 S: * BAD Disk crash, attempting salvage to a new disk! 5139 S: * OK Salvage successful, no data lost 5140 S: A443 OK Expunge completed 5142 7.1.4. PREAUTH Response 5144 Contents: OPTIONAL response code 5145 human-readable text 5147 The PREAUTH response is always untagged, and is one of three possible 5148 greetings at connection startup. It indicates that the connection 5149 has already been authenticated by external means; thus no LOGIN/ 5150 AUTHENTICATE command is needed. 5152 Because PREAUTH moves the connection directly to the authenticated 5153 state, it effectively prevents the client from using the STARTTLS 5154 command Section 6.2.1. For this reason PREAUTH response SHOULD only 5155 be returned by servers on connections that are protected by TLS (such 5156 as on implicit TLS port [RFC8314]) or protected through other means 5157 such as IPSec. Clients that require mandatory TLS MUST close the 5158 connection after receiving PREAUTH response on a non protected port. 5160 Example: S: * PREAUTH IMAP4rev2 server logged in as Smith 5162 7.1.5. BYE Response 5164 Contents: OPTIONAL response code 5165 human-readable text 5167 The BYE response is always untagged, and indicates that the server is 5168 about to close the connection. The human-readable text MAY be 5169 displayed to the user in a status report by the client. The BYE 5170 response is sent under one of four conditions: 5172 1. as part of a normal logout sequence. The server will close the 5173 connection after sending the tagged OK response to the LOGOUT 5174 command. 5176 2. as a panic shutdown announcement. The server closes the 5177 connection immediately. 5179 3. as an announcement of an inactivity autologout. The server 5180 closes the connection immediately. 5182 4. as one of three possible greetings at connection startup, 5183 indicating that the server is not willing to accept a connection 5184 from this client. The server closes the connection immediately. 5186 The difference between a BYE that occurs as part of a normal LOGOUT 5187 sequence (the first case) and a BYE that occurs because of a failure 5188 (the other three cases) is that the connection closes immediately in 5189 the failure case. In all cases the client SHOULD continue to read 5190 response data from the server until the connection is closed; this 5191 will ensure that any pending untagged or completion responses are 5192 read and processed. 5194 Example: S: * BYE Autologout; idle for too long 5196 7.2. Server Responses - Server Status 5198 These responses are always untagged. This is how server status data 5199 are transmitted from the server to the client. 5201 7.2.1. ENABLED Response 5203 Contents: capability listing 5205 The ENABLED response occurs as a result of an ENABLE command. The 5206 capability listing contains a space-separated listing of capability 5207 names that the server supports and that were successfully enabled. 5208 The ENABLED response may contain no capabilities, which means that no 5209 extensions listed by the client were successfully enabled. 5211 Example: S: * ENABLED CONDSTORE QRESYNC 5213 7.2.2. CAPABILITY Response 5215 Contents: capability listing 5217 The CAPABILITY response occurs as a result of a CAPABILITY command. 5218 The capability listing contains a space-separated listing of 5219 capability names that the server supports. The capability listing 5220 MUST include the atom "IMAP4rev2", but note that it doesn't have to 5221 be the first capability listed. The order of capability names has no 5222 significance. 5224 In addition, client and server implementations MUST implement the 5225 "STARTTLS" and "LOGINDISABLED" (only on the cleartext port), and 5226 "AUTH=PLAIN" (described in [PLAIN]) capabilities. See the Security 5227 Considerations (Section 11) for important information related to 5228 these capabilities. 5230 A capability name which begins with "AUTH=" indicates that the server 5231 supports that particular authentication mechanism [SASL]. 5233 The LOGINDISABLED capability indicates that the LOGIN command is 5234 disabled, and that the server will respond with a tagged NO response 5235 to any attempt to use the LOGIN command even if the user name and 5236 password are valid. An IMAP client MUST NOT issue the LOGIN command 5237 if the server advertises the LOGINDISABLED capability. 5239 Other capability names indicate that the server supports an 5240 extension, revision, or amendment to the IMAP4rev2 protocol. If 5241 IMAP4rev1 capability is not advertised, server responses MUST conform 5242 to this document until the client issues a command that uses the 5243 associated capability. If both IMAP4rev1 and IMAP4rev2 capabilities 5244 are advertised, server responses MUST conform to RFC 3501 until the 5245 client issues a command that uses the associated capability. (For 5246 example, the client can issue ENABLE IMAP4rev2 to enable IMAP4rev2 5247 specific behaviour). 5249 Capability names SHOULD be registered with IANA using RFC Required 5250 policy. A server SHOULD NOT offer unregistered capability names. 5252 Client implementations SHOULD NOT require any capability name other 5253 than "IMAP4rev2", and possibly "STARTTLS" and "LOGINDISABLED" (on a 5254 cleartext port). Client implementations MUST ignore any unknown 5255 capability names. 5257 A server MAY send capabilities automatically, by using the CAPABILITY 5258 response code in the initial PREAUTH or OK responses, and by sending 5259 an updated CAPABILITY response code in the tagged OK response as part 5260 of a successful authentication. It is unnecessary for a client to 5261 send a separate CAPABILITY command if it recognizes these automatic 5262 capabilities and there was no change to the TLS and/or authentication 5263 state since they were received. 5265 The list of capabilities returned by a server MAY change during the 5266 connection. In particular, it is quite common for the server to 5267 change list of capabilities after successful TLS negotiation 5268 (STARTTLS command) and/or after successful authentication 5269 (AUTHENTICATE or LOGIN commands). 5271 Example: S: * CAPABILITY STARTTLS AUTH=GSSAPI IMAP4rev2 LOGINDISABLED 5272 XPIG-LATIN 5274 Note that in the above example XPIG-LATIN is a fictitious capability 5275 name. 5277 7.3. Server Responses - Mailbox Status 5279 These responses are always untagged. This is how mailbox status data 5280 are transmitted from the server to the client. Many of these 5281 responses typically result from a command with the same name. 5283 7.3.1. LIST Response 5285 Contents: name attributes 5286 hierarchy delimiter 5287 name 5288 OPTIONAL extension data 5290 The LIST response occurs as a result of a LIST command. It returns a 5291 single name that matches the LIST specification. There can be 5292 multiple LIST responses for a single LIST command. 5294 The following base mailbox name attributes are defined: 5296 \NonExistent The "\NonExistent" attribute indicates that a mailbox 5297 name does not refer to an existing mailbox. Note that this 5298 attribute is not meaningful by itself, as mailbox names that match 5299 the canonical LIST pattern but don't exist must not be returned 5300 unless one of the two conditions listed below is also satisfied: 5302 1. The mailbox name also satisfies the selection criteria (for 5303 example, it is subscribed and the "SUBSCRIBED" selection 5304 option has been specified). 5306 2. "RECURSIVEMATCH" has been specified, and the mailbox name has 5307 at least one descendant mailbox name that does not match the 5308 LIST pattern and does match the selection criteria. 5310 In practice, this means that the "\NonExistent" attribute is 5311 usually returned with one or more of "\Subscribed", "\Remote", 5312 "\HasChildren", or the CHILDINFO extended data item. 5314 The "\NonExistent" attribute implies "\NoSelect". 5316 \Noinferiors It is not possible for any child levels of hierarchy to 5317 exist under this name; no child levels exist now and none can be 5318 created in the future. 5320 \Noselect It is not possible to use this name as a selectable 5321 mailbox. 5323 \HasChildren The presence of this attribute indicates that the 5324 mailbox has child mailboxes. A server SHOULD NOT set this 5325 attribute if there are child mailboxes and the user does not have 5326 permission to access any of them. In this case, \HasNoChildren 5327 SHOULD be used. In many cases, however, a server may not be able 5328 to efficiently compute whether a user has access to any child 5329 mailbox. Note that even though the \HasChildren attribute for a 5330 mailbox must be correct at the time of processing of the mailbox, 5331 a client must be prepared to deal with a situation when a mailbox 5332 is marked with the \HasChildren attribute, but no child mailbox 5333 appears in the response to the LIST command. This might happen, 5334 for example, due to children mailboxes being deleted or made 5335 inaccessible to the user (using access control) by another client 5336 before the server is able to list them. 5338 \HasNoChildren The presence of this attribute indicates that the 5339 mailbox has NO child mailboxes that are accessible to the 5340 currently authenticated user. 5342 \Marked The mailbox has been marked "interesting" by the server; the 5343 mailbox probably contains messages that have been added since the 5344 last time the mailbox was selected. 5346 \Unmarked The mailbox does not contain any additional messages since 5347 the last time the mailbox was selected. 5349 \Subscribed The mailbox name was subscribed to using the SUBSCRIBE 5350 command. 5352 \Remote The mailbox is a remote mailbox. 5354 It is an error for the server to return both a \HasChildren and a 5355 \HasNoChildren attribute in the same LIST response. A client that 5356 encounters a LIST response with both \HasChildren and \HasNoChildren 5357 attributes present should act as if both are absent in the LIST 5358 response. 5360 Note: the \HasNoChildren attribute should not be confused with the 5361 \NoInferiors attribute, which indicates that no child mailboxes 5362 exist now and none can be created in the future. 5364 If it is not feasible for the server to determine whether or not the 5365 mailbox is "interesting", the server SHOULD NOT send either \Marked 5366 or \Unmarked. The server MUST NOT send more than one of \Marked, 5367 \Unmarked, and \Noselect for a single mailbox, and MAY send none of 5368 these. 5370 In addition to the base mailbox name attributes defined above, an 5371 IMAP server MAY also include any or all of the following attributes 5372 that denote "role" (or "special-use") of a mailbox. These attributes 5373 are included along with base attributes defined above. A given 5374 mailbox may have none, one, or more than one of these attributes. In 5375 some cases, a special use is advice to a client about what to put in 5376 that mailbox. In other cases, it's advice to a client about what to 5377 expect to find there. 5379 \All This mailbox presents all messages in the user's message store. 5380 Implementations MAY omit some messages, such as, perhaps, those in 5381 \Trash and \Junk. When this special use is supported, it is 5382 almost certain to represent a virtual mailbox. 5384 \Archive This mailbox is used to archive messages. The meaning of 5385 an "archival" mailbox is server-dependent; typically, it will be 5386 used to get messages out of the inbox, or otherwise keep them out 5387 of the user's way, while still making them accessible. 5389 \Drafts This mailbox is used to hold draft messages -- typically, 5390 messages that are being composed but have not yet been sent. In 5391 some server implementations, this might be a virtual mailbox, 5392 containing messages from other mailboxes that are marked with the 5393 "\Draft" message flag. Alternatively, this might just be advice 5394 that a client put drafts here. 5396 \Flagged This mailbox presents all messages marked in some way as 5397 "important". When this special use is supported, it is likely to 5398 represent a virtual mailbox collecting messages (from other 5399 mailboxes) that are marked with the "\Flagged" message flag. 5401 \Junk This mailbox is where messages deemed to be junk mail are 5402 held. Some server implementations might put messages here 5403 automatically. Alternatively, this might just be advice to a 5404 client-side spam filter. 5406 \Sent This mailbox is used to hold copies of messages that have been 5407 sent. Some server implementations might put messages here 5408 automatically. Alternatively, this might just be advice that a 5409 client save sent messages here. 5411 \Trash This mailbox is used to hold messages that have been deleted 5412 or marked for deletion. In some server implementations, this 5413 might be a virtual mailbox, containing messages from other 5414 mailboxes that are marked with the "\Deleted" message flag. 5416 Alternatively, this might just be advice that a client that 5417 chooses not to use the IMAP "\Deleted" model should use this as 5418 its trash location. In server implementations that strictly 5419 expect the IMAP "\Deleted" model, this special use is likely not 5420 to be supported. 5422 All of special-use attributes are OPTIONAL, and any given server or 5423 message store may support any combination of the attributes, or none 5424 at all. In most cases, there will likely be at most one mailbox with 5425 a given attribute for a given user, but in some server or message 5426 store implementations it might be possible for multiple mailboxes to 5427 have the same special-use attribute. 5429 Special-use attributes are likely to be user-specific. User Adam 5430 might share his \Sent mailbox with user Barb, but that mailbox is 5431 unlikely to also serve as Barb's \Sent mailbox. 5433 Other mailbox name attributes can be found in the "IMAP Mailbox Name 5434 Attributes" registry [IMAP-MAILBOX-NAME-ATTRS-REG]. 5436 The hierarchy delimiter is a character used to delimit levels of 5437 hierarchy in a mailbox name. A client can use it to create child 5438 mailboxes, and to search higher or lower levels of naming hierarchy. 5439 All children of a top-level hierarchy node MUST use the same 5440 separator character. A NIL hierarchy delimiter means that no 5441 hierarchy exists; the name is a "flat" name. 5443 The name represents an unambiguous left-to-right hierarchy, and MUST 5444 be valid for use as a reference in LIST command. Unless \Noselect or 5445 \NonExistent is indicated, the name MUST also be valid as an argument 5446 for commands, such as SELECT, that accept mailbox names. 5448 The name might be followed by an OPTIONAL series of extended fields, 5449 a parenthesized list of tagged data (also referred to as "extended 5450 data item"). The first element of an extended field is a string, 5451 which identifies the type of data. [RFC5258] specified requirements 5452 on string registration (which are called "tags" there; such tags are 5453 not to be confused with IMAP command tags), in particular it said 5454 that "Tags MUST be registered with IANA". This document doesn't 5455 change that. See Section 9.5 of [RFC5258] for the registration 5456 template. The server MAY return data in the extended fields that was 5457 not directly solicited by the client in the corresponding LIST 5458 command. For example, the client can enable extra extended fields by 5459 using another IMAP extension that make use of the extended LIST 5460 responses. The client MUST ignore all extended fields it doesn't 5461 recognize. 5463 Example: S: * LIST (\Noselect) "/" ~/Mail/foo 5465 Example: S: * LIST (\Marked) ":" Tables (tablecloth (("edge" "lacy") 5466 ("color" "red")) Sample "text") 5467 S: * LIST () ":" Tables:new (tablecloth ("edge" "lacy") 5468 Sample ("text" "more text")) 5470 7.3.2. NAMESPACE Response 5472 Contents: the prefix and hierarchy delimiter to the server's 5473 Personal Namespace(s), Other Users' Namespace(s), and 5474 Shared Namespace(s) 5476 The NAMESPACE response occurs as a result of a NAMESPACE command. It 5477 contains the prefix and hierarchy delimiter to the server's Personal 5478 Namespace(s), Other Users' Namespace(s), and Shared Namespace(s) that 5479 the server wishes to expose. The response will contain a NIL for any 5480 namespace class that is not available. Namespace-Response-Extensions 5481 ABNF non terminal is defined for extensibility and MAY be included in 5482 the response. 5484 Example: S: * NAMESPACE (("" "/")) (("~" "/")) NIL 5486 7.3.3. STATUS Response 5488 Contents: name 5489 status parenthesized list 5491 The STATUS response occurs as a result of an STATUS command. It 5492 returns the mailbox name that matches the STATUS specification and 5493 the requested mailbox status information. 5495 Example: S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) 5497 7.3.4. ESEARCH Response 5499 Contents: one or more search-return-data pairs 5501 The ESEARCH response occurs as a result of a SEARCH or UID SEARCH 5502 command. 5504 The ESEARCH response starts with an optional search correlator. If 5505 it is missing, then the response was not caused by a particular IMAP 5506 command, whereas if it is present, it contains the tag of the command 5507 that caused the response to be returned. 5509 The search correlator is followed by an optional UID indicator. If 5510 this indicator is present, all data in the ESEARCH response refers to 5511 UIDs, otherwise all returned data refers to message numbers. 5513 The rest of the ESEARCH response contains one or more search data 5514 pairs. Each pair starts with unique return item name, followed by a 5515 space and the corresponding data. Search data pairs may be returned 5516 in any order. Unless specified otherwise by an extension, any return 5517 item name SHOULD appear only once in an ESEARCH response. 5519 This document specifies the following return item names: 5521 MIN 5523 Returns the lowest message number/UID that satisfies the SEARCH 5524 criteria. 5526 If the SEARCH results in no matches, the server MUST NOT 5527 include the MIN return item in the ESEARCH response; however, 5528 it still MUST send the ESEARCH response. 5530 MAX 5532 Returns the highest message number/UID that satisfies the 5533 SEARCH criteria. 5535 If the SEARCH results in no matches, the server MUST NOT 5536 include the MAX return item in the ESEARCH response; however, 5537 it still MUST send the ESEARCH response. 5539 ALL 5541 Returns all message numbers/UIDs that satisfy the SEARCH 5542 criteria using the sequence-set syntax. Note, the client MUST 5543 NOT assume that messages/UIDs will be listed in any particular 5544 order. 5546 If the SEARCH results in no matches, the server MUST NOT 5547 include the ALL return item in the ESEARCH response; however, 5548 it still MUST send the ESEARCH response. 5550 COUNT Returns the number of messages that satisfy the SEARCH 5551 criteria. This return item MUST always be included in the ESEARCH 5552 response. 5554 Example: S: * ESEARCH UID COUNT 5 ALL 4:19,21,28 5556 Example: S: * ESEARCH (TAG "a567") UID COUNT 5 ALL 4:19,21,28 5558 Example: S: * ESEARCH COUNT 5 ALL 1:17,21 5560 7.3.5. FLAGS Response 5562 Contents: flag parenthesized list 5564 The FLAGS response occurs as a result of a SELECT or EXAMINE command. 5565 The flag parenthesized list identifies the flags (at a minimum, the 5566 system-defined flags) that are applicable for this mailbox. Flags 5567 other than the system flags can also exist, depending on server 5568 implementation. 5570 The update from the FLAGS response MUST be remembered by the client. 5572 Example: S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 5574 7.4. Server Responses - Mailbox Size 5576 These responses are always untagged. This is how changes in the size 5577 of the mailbox are transmitted from the server to the client. 5578 Immediately following the "*" token is a number that represents a 5579 message count. 5581 7.4.1. EXISTS Response 5583 Contents: none 5585 The EXISTS response reports the number of messages in the mailbox. 5586 This response occurs as a result of a SELECT or EXAMINE command, and 5587 if the size of the mailbox changes (e.g., new messages). 5589 The update from the EXISTS response MUST be remembered by the client. 5591 Example: S: * 23 EXISTS 5593 7.5. Server Responses - Message Status 5595 These responses are always untagged. This is how message data are 5596 transmitted from the server to the client, often as a result of a 5597 command with the same name. Immediately following the "*" token is a 5598 number that represents a message sequence number. 5600 7.5.1. EXPUNGE Response 5602 Contents: none 5604 The EXPUNGE response reports that the specified message sequence 5605 number has been permanently removed from the mailbox. The message 5606 sequence number for each successive message in the mailbox is 5607 immediately decremented by 1, and this decrement is reflected in 5608 message sequence numbers in subsequent responses (including other 5609 untagged EXPUNGE responses). 5611 The EXPUNGE response also decrements the number of messages in the 5612 mailbox; it is not necessary to send an EXISTS response with the new 5613 value. 5615 As a result of the immediate decrement rule, message sequence numbers 5616 that appear in a set of successive EXPUNGE responses depend upon 5617 whether the messages are removed starting from lower numbers to 5618 higher numbers, or from higher numbers to lower numbers. For 5619 example, if the last 5 messages in a 9-message mailbox are expunged, 5620 a "lower to higher" server will send five untagged EXPUNGE responses 5621 for message sequence number 5, whereas a "higher to lower server" 5622 will send successive untagged EXPUNGE responses for message sequence 5623 numbers 9, 8, 7, 6, and 5. 5625 An EXPUNGE response MUST NOT be sent when no command is in progress, 5626 nor while responding to a FETCH, STORE, or SEARCH command. This rule 5627 is necessary to prevent a loss of synchronization of message sequence 5628 numbers between client and server. A command is not "in progress" 5629 until the complete command has been received; in particular, a 5630 command is not "in progress" during the negotiation of command 5631 continuation. 5633 Note: UID FETCH, UID STORE, and UID SEARCH are different commands 5634 from FETCH, STORE, and SEARCH. An EXPUNGE response MAY be sent 5635 during a UID command. 5637 The update from the EXPUNGE response MUST be remembered by the 5638 client. 5640 Example: S: * 44 EXPUNGE 5642 7.5.2. FETCH Response 5644 Contents: message data 5646 The FETCH response returns data about a message to the client. The 5647 data are pairs of data item names and their values in parentheses. 5648 This response occurs as the result of a FETCH or STORE command, as 5649 well as by unilateral server decision (e.g., flag updates). 5651 The current data items are: 5653 BINARY[]<> 5654 An or expressing the content of the 5655 specified section after removing any Content-Transfer-Encoding- 5656 related encoding. If is present it refers to the 5657 offset within the DECODED section data. 5659 If the domain of the decoded data is "8bit" and the data does 5660 not contain the NUL octet, the server SHOULD return the data in 5661 a instead of a ; this allows the client to 5662 determine if the "8bit" data contains the NUL octet without 5663 having to explicitly scan the data stream for for NULs. 5665 Messaging clients and servers have been notoriously lax in 5666 their adherence to the Internet CRLF convention for terminating 5667 lines of textual data (text/* media types) in Internet 5668 protocols. When sending data in BINARY[...] FETCH data item, 5669 servers MUST ensure that textual line-oriented sections are 5670 always transmitted using the IMAP4 CRLF line termination 5671 syntax, regardless of the underlying storage representation of 5672 the data on the server. 5674 If the server does not know how to decode the section's 5675 Content-Transfer-Encoding, it MUST fail the request and issue a 5676 "NO" response that contains the "UNKNOWN-CTE" response code. 5678 BINARY.SIZE[] 5680 The size of the section after removing any Content-Transfer- 5681 Encoding-related encoding. The value returned MUST match the 5682 size of the or that will be returned by 5683 the corresponding FETCH BINARY request. 5685 If the server does not know how to decode the section's 5686 Content-Transfer-Encoding, it MUST fail the request and issue a 5687 "NO" response that contains the "UNKNOWN-CTE" response code. 5689 BODY A form of BODYSTRUCTURE without extension data. 5691 BODY[
]<> 5693 A string expressing the body contents of the specified section. 5694 The string SHOULD be interpreted by the client according to the 5695 content transfer encoding, body type, and subtype. 5697 If the origin octet is specified, this string is a substring of 5698 the entire body contents, starting at that origin octet. This 5699 means that BODY[]<0> MAY be truncated, but BODY[] is NEVER 5700 truncated. 5702 Note: The origin octet facility MUST NOT be used by a server 5703 in a FETCH response unless the client specifically requested 5704 it by means of a FETCH of a BODY[
]<> data 5705 item. 5707 8-bit textual data is permitted if a [CHARSET] identifier is 5708 part of the body parameter parenthesized list for this section. 5709 Note that headers (part specifiers HEADER or MIME, or the 5710 header portion of a MESSAGE/RFC822 or MESSAGE/GLOBAL part), MAY 5711 be in UTF-8. Note also that the [RFC-5322] delimiting blank 5712 line between the header and the body is not affected by header 5713 line subsetting; the blank line is always included as part of 5714 header data, except in the case of a message which has no body 5715 and no blank line. 5717 Non-textual data such as binary data MUST be transfer encoded 5718 into a textual form, such as BASE64, prior to being sent to the 5719 client. To derive the original binary data, the client MUST 5720 decode the transfer encoded string. 5722 BODYSTRUCTURE 5724 A parenthesized list that describes the [MIME-IMB] body 5725 structure of a message. This is computed by the server by 5726 parsing the [MIME-IMB] header fields, defaulting various fields 5727 as necessary. 5729 For example, a simple text message of 48 lines and 2279 octets 5730 can have a body structure of: ("TEXT" "PLAIN" ("CHARSET" "US- 5731 ASCII") NIL NIL "7BIT" 2279 48) 5733 Multiple parts are indicated by parenthesis nesting. Instead 5734 of a body type as the first element of the parenthesized list, 5735 there is a sequence of one or more nested body structures. The 5736 second element of the parenthesized list is the multipart 5737 subtype (mixed, digest, parallel, alternative, etc.). 5739 For example, a two part message consisting of a text and a 5740 BASE64-encoded text attachment can have a body structure of: 5741 (("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 1152 5742 23)("TEXT" "PLAIN" ("CHARSET" "US-ASCII" "NAME" "cc.diff") 5743 "<960723163407.20117h@cac.washington.edu>" "Compiler diff" 5744 "BASE64" 4554 73) "MIXED") 5746 Extension data follows the multipart subtype. Extension data 5747 is never returned with the BODY fetch, but can be returned with 5748 a BODYSTRUCTURE fetch. Extension data, if present, MUST be in 5749 the defined order. The extension data of a multipart body part 5750 are in the following order: 5752 body parameter parenthesized list A parenthesized list of 5753 attribute/value pairs [e.g., ("foo" "bar" "baz" "rag") where 5754 "bar" is the value of "foo", and "rag" is the value of 5755 "baz"] as defined in [MIME-IMB]. Servers SHOULD decode 5756 parameter value continuations and parameter value character 5757 sets as described in [RFC2231], for example, if the message 5758 contains parameters "baz*0", "baz*1" and "baz*2", the server 5759 should RFC2231-decode them, concatenate and return the 5760 resulting value as a parameter "baz". Similarly, if the 5761 message contains parameters "foo*0*" and "foo*1*", the 5762 server should RFC2231-decode them, convert to UTF-8, 5763 concatenate and return the resulting value as a parameter 5764 "foo*". 5766 body disposition A parenthesized list, consisting of a 5767 disposition type string, followed by a parenthesized list of 5768 disposition attribute/value pairs as defined in 5769 [DISPOSITION]. Servers SHOULD decode parameter value 5770 continuations as described in [RFC2231]. 5772 body language A string or parenthesized list giving the body 5773 language value as defined in [LANGUAGE-TAGS]. 5775 body location A string giving the body content URI as defined 5776 in [LOCATION]. 5778 Any following extension data are not yet defined in this 5779 version of the protocol. Such extension data can consist of 5780 zero or more NILs, strings, numbers, or potentially nested 5781 parenthesized lists of such data. Client implementations that 5782 do a BODYSTRUCTURE fetch MUST be prepared to accept such 5783 extension data. Server implementations MUST NOT send such 5784 extension data until it has been defined by a revision of this 5785 protocol. 5787 The basic fields of a non-multipart body part are in the 5788 following order: 5790 body type A string giving the content media type name as 5791 defined in [MIME-IMB]. 5793 body subtype A string giving the content subtype name as 5794 defined in [MIME-IMB]. 5796 body parameter parenthesized list A parenthesized list of 5797 attribute/value pairs [e.g., ("foo" "bar" "baz" "rag") where 5798 "bar" is the value of "foo" and "rag" is the value of "baz"] 5799 as defined in [MIME-IMB]. 5801 body id A string giving the Content-ID header field value as 5802 defined in Section 7 of [MIME-IMB]. 5804 body description A string giving the Content-Description 5805 header field value as defined in Section 8 of [MIME-IMB]. 5807 body encoding A string giving the content transfer encoding as 5808 defined in Section 6 of [MIME-IMB]. 5810 body size A number giving the size of the body in octets. 5811 Note that this size is the size in its transfer encoding and 5812 not the resulting size after any decoding. 5814 A body type of type MESSAGE and subtype RFC822 contains, 5815 immediately after the basic fields, the envelope structure, 5816 body structure, and size in text lines of the encapsulated 5817 message. 5819 A body type of type TEXT contains, immediately after the basic 5820 fields, the size of the body in text lines. Note that this 5821 size is the size in its content transfer encoding and not the 5822 resulting size after any decoding. 5824 Extension data follows the basic fields and the type-specific 5825 fields listed above. Extension data is never returned with the 5826 BODY fetch, but can be returned with a BODYSTRUCTURE fetch. 5827 Extension data, if present, MUST be in the defined order. 5829 The extension data of a non-multipart body part are in the 5830 following order: 5832 body MD5 A string giving the body MD5 value as defined in 5833 [MD5]. 5835 body disposition A parenthesized list with the same content 5836 and function as the body disposition for a multipart body 5837 part. 5839 body language A string or parenthesized list giving the body 5840 language value as defined in [LANGUAGE-TAGS]. 5842 body location A string giving the body content URI as defined 5843 in [LOCATION]. 5845 Any following extension data are not yet defined in this 5846 version of the protocol, and would be as described above under 5847 multipart extension data. 5849 ENVELOPE 5851 A parenthesized list that describes the envelope structure of a 5852 message. This is computed by the server by parsing the 5853 [RFC-5322] header into the component parts, defaulting various 5854 fields as necessary. 5856 The fields of the envelope structure are in the following 5857 order: date, subject, from, sender, reply-to, to, cc, bcc, in- 5858 reply-to, and message-id. The date, subject, in-reply-to, and 5859 message-id fields are strings. The from, sender, reply-to, to, 5860 cc, and bcc fields are parenthesized lists of address 5861 structures. 5863 An address structure is a parenthesized list that describes an 5864 electronic mail address. The fields of an address structure 5865 are in the following order: display name, [SMTP] at-domain-list 5866 (source route, obs-route ABNF production from [RFC-5322]), 5867 mailbox name (local-part ABNF production from [RFC-5322]), and 5868 host name. 5870 [RFC-5322] group syntax is indicated by a special form of 5871 address structure in which the host name field is NIL. If the 5872 mailbox name field is also NIL, this is an end of group marker 5873 (semi-colon in RFC 822 syntax). If the mailbox name field is 5874 non-NIL, this is a start of group marker, and the mailbox name 5875 field holds the group name phrase. 5877 If the Date, Subject, In-Reply-To, and Message-ID header fields 5878 are absent in the [RFC-5322] header, the corresponding member 5879 of the envelope is NIL; if these header fields are present but 5880 empty the corresponding member of the envelope is the empty 5881 string. 5883 Note: some servers may return a NIL envelope member in the 5884 "present but empty" case. Clients SHOULD treat NIL and 5885 empty string as identical. 5887 Note: [RFC-5322] requires that all messages have a valid 5888 Date header field. Therefore, for a well-formed message the 5889 date member in the envelope can not be NIL or the empty 5890 string. However it can be NIL for a malformed or a draft 5891 message. 5893 Note: [RFC-5322] requires that the In-Reply-To and Message- 5894 ID header fields, if present, have non-empty content. 5895 Therefore, for a well-formed message the in-reply-to and 5896 message-id members in the envelope can not be the empty 5897 string. However they can still be the empty string for a 5898 malformed message. 5900 If the From, To, Cc, and Bcc header fields are absent in the 5901 [RFC-5322] header, or are present but empty, the corresponding 5902 member of the envelope is NIL. 5904 If the Sender or Reply-To header fields are absent in the 5905 [RFC-5322] header, or are present but empty, the server sets 5906 the corresponding member of the envelope to be the same value 5907 as the from member (the client is not expected to know to do 5908 this). 5910 Note: [RFC-5322] requires that all messages have a valid 5911 From header field. Therefore, for a well-formed message the 5912 from, sender, and reply-to members in the envelope can not 5913 be NIL. However they can be NIL for a malformed or a draft 5914 message. 5916 FLAGS A parenthesized list of flags that are set for this message. 5918 INTERNALDATE A string representing the internal date of the message. 5920 RFC822.SIZE A number expressing the [RFC-5322] size of the message. 5922 UID A number expressing the unique identifier of the message. 5924 If the server chooses to send unsolicited FETCH responses, they MUST 5925 include UID FETCH item. Note that this is a new requirement when 5926 compared to RFC 3501. 5928 Example: S: * 23 FETCH (FLAGS (\Seen) RFC822.SIZE 44827 UID 447) 5930 7.6. Server Responses - Command Continuation Request 5932 The command continuation request response is indicated by a "+" token 5933 instead of a tag. This form of response indicates that the server is 5934 ready to accept the continuation of a command from the client. The 5935 remainder of this response is a line of text. 5937 This response is used in the AUTHENTICATE command to transmit server 5938 data to the client, and request additional client data. This 5939 response is also used if an argument to any command is a 5940 synchronizing literal. 5942 The client is not permitted to send the octets of the synchronizing 5943 literal unless the server indicates that it is expected. This 5944 permits the server to process commands and reject errors on a line- 5945 by-line basis. The remainder of the command, including the CRLF that 5946 terminates a command, follows the octets of the literal. If there 5947 are any additional command arguments, the literal octets are followed 5948 by a space and those arguments. 5950 Example: C: A001 LOGIN {11} 5951 S: + Ready for additional command text 5952 C: FRED FOOBAR {7} 5953 S: + Ready for additional command text 5954 C: fat man 5955 S: A001 OK LOGIN completed 5956 C: A044 BLURDYBLOOP {102856} 5957 S: A044 BAD No such command as "BLURDYBLOOP" 5959 8. Sample IMAP4rev2 connection 5961 The following is a transcript of an IMAP4rev2 connection on a non TLS 5962 port. A long line in this sample is broken for editorial clarity. 5964 S: * OK [CAPABILITY STARTTLS AUTH=SCRAM-SHA-256 LOGINDISABLED 5965 IMAP4rev2] IMAP4rev2 Service Ready 5966 C: a000 starttls 5967 S: a000 OK Proceed with TLS negotiation 5968 5969 C: A001 AUTHENTICATE SCRAM-SHA-256 5970 biwsbj11c2VyLHI9ck9wck5HZndFYmVSV2diTkVrcU8= 5971 S: + cj1yT3ByTkdmd0ViZVJXZ2JORWtxTyVodllEcFdVYTJSYVRDQWZ1eEZJbGopaE5s 5972 RiRrMCxzPVcyMlphSjBTTlk3c29Fc1VFamI2Z1E9PSxpPTQwOTY= 5973 C: Yz1iaXdzLHI9ck9wck5HZndFYmVSV2diTkVrcU8laHZZRHBXVWEyUmFUQ0FmdXhG 5974 SWxqKWhObEYkazAscD1kSHpiWmFwV0lrNGpVaE4rVXRlOXl0YWc5empmTUhnc3Ft 5975 bWl6N0FuZFZRPQ== 5976 S: + dj02cnJpVFJCaTIzV3BSUi93dHVwK21NaFVaVW4vZEI1bkxUSlJzamw5NUc0PQ== 5977 C: 5978 S: A001 OK SCRAM-SHA-256 authentication successful 5979 C: babc ENABLE IMAP4rev2 5980 S: * ENABLED IMAP4rev2 5981 S: babc OK Some capabilities enabled 5982 C: a002 select inbox 5983 S: * 18 EXISTS 5984 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 5985 S: * OK [UIDVALIDITY 3857529045] UIDs valid 5986 S: * LIST () "/" INBOX ("OLDNAME" ("inbox")) 5987 S: a002 OK [READ-WRITE] SELECT completed 5988 C: a003 fetch 12 full 5989 S: * 12 FETCH (FLAGS (\Seen) INTERNALDATE "17-Jul-1996 02:44:25 -0700" 5990 RFC822.SIZE 4286 ENVELOPE ("Wed, 17 Jul 1996 02:23:25 -0700 (PDT)" 5991 "IMAP4rev2 WG mtg summary and minutes" 5992 (("Terry Gray" NIL "gray" "cac.washington.edu")) 5993 (("Terry Gray" NIL "gray" "cac.washington.edu")) 5994 (("Terry Gray" NIL "gray" "cac.washington.edu")) 5995 ((NIL NIL "imap" "cac.washington.edu")) 5996 ((NIL NIL "minutes" "CNRI.Reston.VA.US") 5997 ("John Klensin" NIL "KLENSIN" "MIT.EDU")) NIL NIL 5998 "") 5999 BODY ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 3028 6000 92)) 6001 S: a003 OK FETCH completed 6002 C: a004 fetch 12 body[header] 6003 S: * 12 FETCH (BODY[HEADER] {342} 6004 S: Date: Wed, 17 Jul 1996 02:23:25 -0700 (PDT) 6005 S: From: Terry Gray 6006 S: Subject: IMAP4rev2 WG mtg summary and minutes 6007 S: To: imap@cac.washington.edu 6008 S: cc: minutes@CNRI.Reston.VA.US, John Klensin 6009 S: Message-Id: 6010 S: MIME-Version: 1.0 6011 S: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 6012 S: 6013 S: ) 6014 S: a004 OK FETCH completed 6015 C: a005 store 12 +flags \deleted 6016 S: * 12 FETCH (FLAGS (\Seen \Deleted)) 6017 S: a005 OK +FLAGS completed 6018 C: a006 logout 6019 S: * BYE IMAP4rev2 server terminating connection 6020 S: a006 OK LOGOUT completed 6022 9. Formal Syntax 6024 The following syntax specification uses the Augmented Backus-Naur 6025 Form (ABNF) notation as specified in [ABNF]. 6027 In the case of alternative or optional rules in which a later rule 6028 overlaps an earlier rule, the rule which is listed earlier MUST take 6029 priority. For example, "\Seen" when parsed as a flag is the \Seen 6030 flag name and not a flag-extension, even though "\Seen" can be parsed 6031 as a flag-extension. Some, but not all, instances of this rule are 6032 noted below. 6034 Note: [ABNF] rules MUST be followed strictly; in particular: 6036 (1) Except as noted otherwise, all alphabetic characters are case- 6037 insensitive. The use of upper or lower case characters to define 6038 token strings is for editorial clarity only. Implementations MUST 6039 accept these strings in a case-insensitive fashion. 6041 (2) In all cases, SP refers to exactly one space. It is NOT 6042 permitted to substitute TAB, insert additional spaces, or 6043 otherwise treat SP as being equivalent to LWSP. 6045 (3) The ASCII NUL character, %x00, MUST NOT be used anywhere, with 6046 the exception of the OCTET production. 6048 SP = 6049 CTL = 6050 CRLF = 6051 ALPHA = 6052 DIGIT = 6053 DQUOTE = 6054 OCTET = 6056 address = "(" addr-name SP addr-adl SP addr-mailbox SP 6057 addr-host ")" 6059 addr-adl = nstring 6060 ; Holds route from [RFC-5322] obs-route if 6061 ; non-NIL 6063 addr-host = nstring 6064 ; NIL indicates [RFC-5322] group syntax. 6065 ; Otherwise, holds [RFC-5322] domain name 6067 addr-mailbox = nstring 6068 ; NIL indicates end of [RFC-5322] group; if 6069 ; non-NIL and addr-host is NIL, holds 6070 ; [RFC-5322] group name. 6071 ; Otherwise, holds [RFC-5322] local-part 6072 ; after removing [RFC-5322] quoting 6074 addr-name = nstring 6075 ; If non-NIL, holds phrase from [RFC-5322] 6076 ; mailbox after removing [RFC-5322] quoting 6078 append = "APPEND" SP mailbox [SP flag-list] [SP date-time] SP 6079 literal 6081 append-uid = uniqueid 6083 astring = 1*ASTRING-CHAR / string 6085 ASTRING-CHAR = ATOM-CHAR / resp-specials 6086 atom = 1*ATOM-CHAR 6088 ATOM-CHAR = 6090 atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards / 6091 quoted-specials / resp-specials 6093 authenticate = "AUTHENTICATE" SP auth-type [SP initial-resp] 6094 *(CRLF base64) 6096 auth-type = atom 6097 ; Defined by [SASL] 6099 base64 = *(4base64-char) [base64-terminal] 6101 base64-char = ALPHA / DIGIT / "+" / "/" 6102 ; Case-sensitive 6104 base64-terminal = (2base64-char "==") / (3base64-char "=") 6106 body = "(" (body-type-1part / body-type-mpart) ")" 6108 body-extension = nstring / number / number64 / 6109 "(" body-extension *(SP body-extension) ")" 6110 ; Future expansion. Client implementations 6111 ; MUST accept body-extension fields. Server 6112 ; implementations MUST NOT generate 6113 ; body-extension fields except as defined by 6114 ; future standard or standards-track 6115 ; revisions of this specification. 6117 body-ext-1part = body-fld-md5 [SP body-fld-dsp [SP body-fld-lang 6118 [SP body-fld-loc *(SP body-extension)]]] 6119 ; MUST NOT be returned on non-extensible 6120 ; "BODY" fetch 6122 body-ext-mpart = body-fld-param [SP body-fld-dsp [SP body-fld-lang 6123 [SP body-fld-loc *(SP body-extension)]]] 6124 ; MUST NOT be returned on non-extensible 6125 ; "BODY" fetch 6127 body-fields = body-fld-param SP body-fld-id SP body-fld-desc SP 6128 body-fld-enc SP body-fld-octets 6130 body-fld-desc = nstring 6132 body-fld-dsp = "(" string SP body-fld-param ")" / nil 6133 body-fld-enc = (DQUOTE ("7BIT" / "8BIT" / "BINARY" / "BASE64"/ 6134 "QUOTED-PRINTABLE") DQUOTE) / string 6135 ; Content-Transfer-Encoding header field value. 6136 ; Defaults to "7BIT" (as per RFC 2045) 6137 ; if not present in the body part. 6139 body-fld-id = nstring 6141 body-fld-lang = nstring / "(" string *(SP string) ")" 6143 body-fld-loc = nstring 6145 body-fld-lines = number64 6147 body-fld-md5 = nstring 6149 body-fld-octets = number 6151 body-fld-param = "(" string SP string *(SP string SP string) ")" / nil 6153 body-type-1part = (body-type-basic / body-type-msg / body-type-text) 6154 [SP body-ext-1part] 6156 body-type-basic = media-basic SP body-fields 6157 ; MESSAGE subtype MUST NOT be "RFC822" or "GLOBAL" 6159 body-type-mpart = 1*body SP media-subtype 6160 [SP body-ext-mpart] 6161 ; MULTIPART body part 6163 body-type-msg = media-message SP body-fields SP envelope 6164 SP body SP body-fld-lines 6166 body-type-text = media-text SP body-fields SP body-fld-lines 6168 capability = ("AUTH=" auth-type) / atom 6169 ; New capabilities SHOULD be 6170 ; registered with IANA using 6171 ; RFC Required policy, i.e. in 6172 ; a standards-track, an experimental 6173 ; or an informational RFC. 6175 capability-data = "CAPABILITY" *(SP capability) SP "IMAP4rev2" 6176 *(SP capability) 6177 ; Servers MUST implement the STARTTLS and LOGINDISABLED 6178 ; (on cleartext port), AUTH=PLAIN capabilities. 6179 ; Servers which offer RFC 1730 compatibility MUST 6180 ; list "IMAP4" as the first capability. 6182 ; Servers which offer RFC 3501 compatibility MUST 6183 ; list "IMAP4rev1" as one of capabilities. 6185 CHAR = 6187 CHAR8 = %x01-ff 6188 ; any OCTET except NUL, %x00 6190 charset = atom / quoted 6192 childinfo-extended-item = "CHILDINFO" SP "(" 6193 list-select-base-opt-quoted 6194 *(SP list-select-base-opt-quoted) ")" 6195 ; Extended data item (mbox-list-extended-item) 6196 ; returned when the RECURSIVEMATCH 6197 ; selection option is specified. 6198 ; Note 1: the CHILDINFO extended data item tag can be 6199 ; returned with and without surrounding quotes, as per 6200 ; mbox-list-extended-item-tag production. 6201 ; Note 2: The selection options are always returned 6202 ; quoted, unlike their specification in 6203 ; the extended LIST command. 6205 child-mbox-flag = "\HasChildren" / "\HasNoChildren" 6206 ; attributes for CHILDREN return option, at most one 6207 ; possible per LIST response 6209 command = tag SP (command-any / command-auth / command-nonauth / 6210 command-select) CRLF 6211 ; Modal based on state 6213 command-any = "CAPABILITY" / "LOGOUT" / "NOOP" 6214 ; Valid in all states 6216 command-auth = append / create / delete / enable / examine / list / 6217 Namespace-Command / 6218 rename / select / status / subscribe / unsubscribe / 6219 idle 6220 ; Valid only in Authenticated or Selected state 6222 command-nonauth = login / authenticate / "STARTTLS" 6223 ; Valid only when in Not Authenticated state 6225 command-select = "CLOSE" / "UNSELECT" / "EXPUNGE" / copy / 6226 move / fetch / store / search / uid 6227 ; Valid only when in Selected state 6229 continue-req = "+" SP (resp-text / base64) CRLF 6230 copy = "COPY" SP sequence-set SP mailbox 6232 create = "CREATE" SP mailbox 6233 ; Use of INBOX gives a NO error 6235 date = date-text / DQUOTE date-text DQUOTE 6237 date-day = 1*2DIGIT 6238 ; Day of month 6240 date-day-fixed = (SP DIGIT) / 2DIGIT 6241 ; Fixed-format version of date-day 6243 date-month = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / 6244 "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec" 6246 date-text = date-day "-" date-month "-" date-year 6248 date-year = 4DIGIT 6250 date-time = DQUOTE date-day-fixed "-" date-month "-" date-year 6251 SP time SP zone DQUOTE 6253 delete = "DELETE" SP mailbox 6254 ; Use of INBOX gives a NO error 6256 digit-nz = %x31-39 6257 ; 1-9 6259 eitem-standard-tag = atom 6260 ; a tag for LIST extended data item defined in a Standard 6261 ; Track or Experimental RFC. 6263 eitem-vendor-tag = vendor-token "-" atom 6264 ; a vendor-specific tag for LIST extended data item 6266 enable = "ENABLE" 1*(SP capability) 6268 enable-data = "ENABLED" *(SP capability) 6270 envelope = "(" env-date SP env-subject SP env-from SP 6271 env-sender SP env-reply-to SP env-to SP env-cc SP 6272 env-bcc SP env-in-reply-to SP env-message-id ")" 6274 env-bcc = "(" 1*address ")" / nil 6276 env-cc = "(" 1*address ")" / nil 6277 env-date = nstring 6279 env-from = "(" 1*address ")" / nil 6281 env-in-reply-to = nstring 6283 env-message-id = nstring 6285 env-reply-to = "(" 1*address ")" / nil 6287 env-sender = "(" 1*address ")" / nil 6289 env-subject = nstring 6291 env-to = "(" 1*address ")" / nil 6293 esearch-response = "ESEARCH" [search-correlator] [SP "UID"] 6294 *(SP search-return-data) 6295 ; ESEARCH response replaces SEARCH response 6296 ; from IMAP4rev1. 6298 examine = "EXAMINE" SP mailbox 6300 fetch = "FETCH" SP sequence-set SP ("ALL" / "FULL" / "FAST" / 6301 fetch-att / "(" fetch-att *(SP fetch-att) ")") 6303 fetch-att = "ENVELOPE" / "FLAGS" / "INTERNALDATE" / 6304 "RFC822.SIZE" / 6305 "BODY" ["STRUCTURE"] / "UID" / 6306 "BODY" section [partial] / 6307 "BODY.PEEK" section [partial] / 6308 "BINARY" [".PEEK"] section-binary [partial] / 6309 "BINARY.SIZE" section-binary 6311 flag = "\Answered" / "\Flagged" / "\Deleted" / 6312 "\Seen" / "\Draft" / flag-keyword / flag-extension 6313 ; Does not include "\Recent" 6315 flag-extension = "\" atom 6316 ; Future expansion. Client implementations 6317 ; MUST accept flag-extension flags. Server 6318 ; implementations MUST NOT generate 6319 ; flag-extension flags except as defined by 6320 ; future standard or standards-track 6321 ; revisions of this specification. 6322 ; "\Recent" was defined in RFC 3501 6323 ; and is now deprecated. 6325 flag-fetch = flag 6327 flag-keyword = "$MDNSent" / "$Forwarded" / "$Junk" / 6328 "$NotJunk" / "$Phishing" / atom 6330 flag-list = "(" [flag *(SP flag)] ")" 6332 flag-perm = flag / "\*" 6334 greeting = "*" SP (resp-cond-auth / resp-cond-bye) CRLF 6336 header-fld-name = astring 6338 header-list = "(" header-fld-name *(SP header-fld-name) ")" 6340 idle = "IDLE" CRLF "DONE" 6342 initial-resp = (base64 / "=") 6343 ; "initial response" defined in 6344 ; Section 5.1 of [RFC4422] 6346 list = "LIST" [SP list-select-opts] SP mailbox SP mbox-or-pat 6347 [SP list-return-opts] 6349 list-mailbox = 1*list-char / string 6351 list-char = ATOM-CHAR / list-wildcards / resp-specials 6353 list-return-opt = return-option 6354 ; Note that return-option is the ABNF 6355 ; non terminal used by RFC 5258 6357 list-return-opts = "RETURN" SP 6358 "(" [list-return-opt *(SP list-return-opt)] ")" 6359 ; list return options, e.g., CHILDREN 6361 list-select-base-opt = "SUBSCRIBED" / option-extension 6362 ; options that can be used by themselves 6364 list-select-base-opt-quoted = DQUOTE list-select-base-opt DQUOTE 6366 list-select-independent-opt = "REMOTE" / option-extension 6367 ; options that do not syntactically interact with 6368 ; other options 6370 list-select-mod-opt = "RECURSIVEMATCH" / option-extension 6371 ; options that require a list-select-base-opt 6372 ; to also be present 6374 list-select-opt = list-select-base-opt / list-select-independent-opt 6375 / list-select-mod-opt 6376 ; An option registration template is described in 6377 ; Section 9.3 of this document. 6379 list-select-opts = "(" [ 6380 (*(list-select-opt SP) list-select-base-opt 6381 *(SP list-select-opt)) 6382 / (list-select-independent-opt 6383 *(SP list-select-independent-opt)) 6384 ] ")" 6385 ; Any number of options may be in any order. 6386 ; If a list-select-mod-opt appears, then a 6387 ; list-select-base-opt must also appear. 6388 ; This allows these: 6389 ; () 6390 ; (REMOTE) 6391 ; (SUBSCRIBED) 6392 ; (SUBSCRIBED REMOTE) 6393 ; (SUBSCRIBED RECURSIVEMATCH) 6394 ; (SUBSCRIBED REMOTE RECURSIVEMATCH) 6395 ; But does NOT allow these: 6396 ; (RECURSIVEMATCH) 6397 ; (REMOTE RECURSIVEMATCH) 6399 list-wildcards = "%" / "*" 6401 literal = "{" number64 ["+"] "}" CRLF *CHAR8 6402 ; represents the number of CHAR8s. 6403 ; A non-synchronizing literal is distinguished from 6404 ; a synchronizing literal by presence of the "+" 6405 ; before the closing "}". 6406 ; Non synchronizing literals are not allowed when 6407 ; sent from server to the client. 6409 literal8 = "~{" number64 "}" CRLF *OCTET 6410 ; represents the number of OCTETs 6411 ; in the response string. 6413 login = "LOGIN" SP userid SP password 6415 mailbox = "INBOX" / astring 6416 ; INBOX is case-insensitive. All case variants of 6417 ; INBOX (e.g., "iNbOx") MUST be interpreted as INBOX 6418 ; not as an astring. An astring which consists of 6419 ; the case-insensitive sequence "I" "N" "B" "O" "X" 6420 ; is considered to be INBOX and not an astring. 6421 ; Refer to section 5.1 for further 6422 ; semantic details of mailbox names. 6424 mailbox-data = "FLAGS" SP flag-list / "LIST" SP mailbox-list / 6425 esearch-response / 6426 "STATUS" SP mailbox SP "(" [status-att-list] ")" / 6427 number SP "EXISTS" / Namespace-Response 6429 mailbox-list = "(" [mbx-list-flags] ")" SP 6430 (DQUOTE QUOTED-CHAR DQUOTE / nil) SP mailbox 6431 [SP mbox-list-extended] 6432 ; This is the list information pointed to by the ABNF 6433 ; item "mailbox-data", which is defined in [IMAP4] 6435 mbox-list-extended = "(" [mbox-list-extended-item 6436 *(SP mbox-list-extended-item)] ")" 6438 mbox-list-extended-item = mbox-list-extended-item-tag SP 6439 tagged-ext-val 6441 mbox-list-extended-item-tag = astring 6442 ; The content MUST conform to either "eitem-vendor-tag" 6443 ; or "eitem-standard-tag" ABNF productions. 6445 mbox-or-pat = list-mailbox / patterns 6447 mbx-list-flags = *(mbx-list-oflag SP) mbx-list-sflag 6448 *(SP mbx-list-oflag) / 6449 mbx-list-oflag *(SP mbx-list-oflag) 6451 mbx-list-oflag = "\Noinferiors" / child-mbox-flag / 6452 "\Subscribed" / "\Remote" / flag-extension 6453 ; Other flags; multiple possible per LIST response 6455 mbx-list-sflag = "\NonExistent" / "\Noselect" / "\Marked" / "\Unmarked" 6456 ; Selectability flags; only one per LIST response 6458 media-basic = ((DQUOTE ("APPLICATION" / "AUDIO" / "IMAGE" / 6459 "FONT" / "MESSAGE" / "MODEL" / "VIDEO" ) DQUOTE) 6460 / string) 6461 SP media-subtype 6462 ; FONT defined in RFC 8081. 6463 ; MODEL defined in RFC 2077. 6464 ; Other top level media types 6465 ; are defined in [MIME-IMT]. 6467 media-message = DQUOTE "MESSAGE" DQUOTE SP 6468 DQUOTE ("RFC822" / "GLOBAL") DQUOTE 6469 ; Defined in [MIME-IMT] 6471 media-subtype = string 6472 ; Defined in [MIME-IMT] 6474 media-text = DQUOTE "TEXT" DQUOTE SP media-subtype 6475 ; Defined in [MIME-IMT] 6477 message-data = nz-number SP ("EXPUNGE" / ("FETCH" SP msg-att)) 6479 move = "MOVE" SP sequence-set SP mailbox 6481 msg-att = "(" (msg-att-dynamic / msg-att-static) 6482 *(SP (msg-att-dynamic / msg-att-static)) ")" 6484 msg-att-dynamic = "FLAGS" SP "(" [flag-fetch *(SP flag-fetch)] ")" 6485 ; MAY change for a message 6487 msg-att-static = "ENVELOPE" SP envelope / "INTERNALDATE" SP date-time / 6488 "RFC822.SIZE" SP number64 / 6489 "BODY" ["STRUCTURE"] SP body / 6490 "BODY" section ["<" number ">"] SP nstring / 6491 "BINARY" section-binary SP (nstring / literal8) / 6492 "BINARY.SIZE" section-binary SP number / 6493 "UID" SP uniqueid 6494 ; MUST NOT change for a message 6496 name-component = 1*UTF8-CHAR 6497 ; MUST NOT contain ".", "/", "%", or "*" 6499 namespace = nil / "(" 1*namespace-descr ")" 6501 namespace-command = "NAMESPACE" 6503 namespace-descr = "(" string SP 6504 (DQUOTE QUOTED-CHAR DQUOTE / nil) 6505 [namespace-response-extensions] ")" 6507 namespace-response-extensions = *namespace-response-extension 6509 namespace-response-extension = SP string SP 6510 "(" string *(SP string) ")" 6512 namespace-response = "NAMESPACE" SP namespace 6513 SP namespace SP namespace 6514 ; The first Namespace is the Personal Namespace(s). 6515 ; The second Namespace is the Other Users' 6516 ; Namespace(s). 6517 ; The third Namespace is the Shared Namespace(s). 6519 nil = "NIL" 6521 nstring = string / nil 6523 number = 1*DIGIT 6524 ; Unsigned 32-bit integer 6525 ; (0 <= n < 4,294,967,296) 6527 number64 = 1*DIGIT 6528 ; Unsigned 63-bit integer 6529 ; (0 <= n <= 9,223,372,036,854,775,807) 6531 nz-number = digit-nz *DIGIT 6532 ; Non-zero unsigned 32-bit integer 6533 ; (0 < n < 4,294,967,296) 6535 nz-number64 = digit-nz *DIGIT 6536 ; Unsigned 63-bit integer 6537 ; (0 < n <= 9,223,372,036,854,775,807) 6539 oldname-extended-item = "OLDNAME" SP "(" mailbox ")" 6540 ; Extended data item (mbox-list-extended-item) 6541 ; returned in a LIST response when a mailbox is 6542 ; renamed or deleted. Also returned when 6543 ; the server canonicalized the provided mailbox 6544 ; name. 6545 ; Note 1: the OLDNAME tag can be returned 6546 ; with or without surrounding quotes, as per 6547 ; mbox-list-extended-item-tag production. 6549 option-extension = (option-standard-tag / option-vendor-tag) 6550 [SP option-value] 6552 option-standard-tag = atom 6553 ; an option defined in a Standards Track or 6554 ; Experimental RFC 6556 option-val-comp = astring / 6557 option-val-comp *(SP option-val-comp) / 6558 "(" option-val-comp ")" 6560 option-value = "(" option-val-comp ")" 6562 option-vendor-tag = vendor-token "-" atom 6563 ; a vendor-specific option, non-standard 6565 partial-range = number64 ["." nz-number64] 6566 ; Copied from RFC 5092 (IMAP URL) 6567 ; and updated to support 64bit sizes. 6569 partial = "<" number64 "." nz-number64 ">" 6570 ; Partial FETCH request. 0-based offset of 6571 ; the first octet, followed by the number of octets 6572 ; in the fragment. 6574 password = astring 6576 patterns = "(" list-mailbox ")" 6577 ; [RFC5258] supports multiple patterns, 6578 ; but this document only requires one 6579 ; to be supported. 6580 ; If the server is also implementing 6581 ; [RFC5258], "patterns" syntax from that 6582 ; document must be followed. 6584 quoted = DQUOTE *QUOTED-CHAR DQUOTE 6586 QUOTED-CHAR = / 6587 "\" quoted-specials / UTF8-2 / UTF8-3 / UTF8-4 6589 quoted-specials = DQUOTE / "\" 6591 rename = "RENAME" SP mailbox SP mailbox 6592 ; Use of INBOX as a destination gives a NO error 6594 response = *(continue-req / response-data) response-done 6596 response-data = "*" SP (resp-cond-state / resp-cond-bye / 6597 mailbox-data / message-data / capability-data / 6598 enable-data) CRLF 6600 response-done = response-tagged / response-fatal 6602 response-fatal = "*" SP resp-cond-bye CRLF 6603 ; Server closes connection immediately 6605 response-tagged = tag SP resp-cond-state CRLF 6607 resp-code-apnd = "APPENDUID" SP nz-number SP append-uid 6609 resp-code-copy = "COPYUID" SP nz-number SP uid-set SP uid-set 6610 resp-cond-auth = ("OK" / "PREAUTH") SP resp-text 6611 ; Authentication condition 6613 resp-cond-bye = "BYE" SP resp-text 6615 resp-cond-state = ("OK" / "NO" / "BAD") SP resp-text 6616 ; Status condition 6618 resp-specials = "]" 6620 resp-text = ["[" resp-text-code "]" SP] [text] 6622 resp-text-code = "ALERT" / 6623 "BADCHARSET" [SP "(" charset *(SP charset) ")" ] / 6624 capability-data / "PARSE" / 6625 "PERMANENTFLAGS" SP 6626 "(" [flag-perm *(SP flag-perm)] ")" / 6627 "READ-ONLY" / "READ-WRITE" / "TRYCREATE" / 6628 "UIDNEXT" SP nz-number / "UIDVALIDITY" SP nz-number / 6629 resp-code-apnd / resp-code-copy / "UIDNOTSTICKY" / 6630 "UNAVAILABLE" / "AUTHENTICATIONFAILED" / 6631 "AUTHORIZATIONFAILED" / "EXPIRED" / 6632 "PRIVACYREQUIRED" / "CONTACTADMIN" / "NOPERM" / 6633 "INUSE" / "EXPUNGEISSUED" / "CORRUPTION" / 6634 "SERVERBUG" / "CLIENTBUG" / "CANNOT" / 6635 "LIMIT" / "OVERQUOTA" / "ALREADYEXISTS" / 6636 "NONEXISTENT" / "NOTSAVED" / "HASCHILDREN" / 6637 "CLOSED" / 6638 "UNKNOWN-CTE" / 6639 atom [SP 1*] 6641 return-option = "SUBSCRIBED" / "CHILDREN" / status-option / 6642 option-extension 6644 search = "SEARCH" [search-return-opts] 6645 SP search-program 6647 search-correlator = SP "(" "TAG" SP tag-string ")" 6649 search-key = "ALL" / "ANSWERED" / "BCC" SP astring / 6650 "BEFORE" SP date / "BODY" SP astring / 6651 "CC" SP astring / "DELETED" / "FLAGGED" / 6652 "FROM" SP astring / "KEYWORD" SP flag-keyword / 6653 "ON" SP date / "SEEN" / 6654 "SINCE" SP date / "SUBJECT" SP astring / 6655 "TEXT" SP astring / "TO" SP astring / 6656 "UNANSWERED" / "UNDELETED" / "UNFLAGGED" / 6657 "UNKEYWORD" SP flag-keyword / "UNSEEN" / 6658 ; Above this line were in [IMAP2] 6659 "DRAFT" / "HEADER" SP header-fld-name SP astring / 6660 "LARGER" SP number64 / "NOT" SP search-key / 6661 "OR" SP search-key SP search-key / 6662 "SENTBEFORE" SP date / "SENTON" SP date / 6663 "SENTSINCE" SP date / "SMALLER" SP number64 / 6664 "UID" SP sequence-set / "UNDRAFT" / sequence-set / 6665 "(" search-key *(SP search-key) ")" 6667 search-modifier-name = tagged-ext-label 6669 search-mod-params = tagged-ext-val 6670 ; This non-terminal shows recommended syntax 6671 ; for future extensions. 6673 search-program = ["CHARSET" SP charset SP] 6674 search-key *(SP search-key) 6675 ; CHARSET argument to SEARCH MUST be 6676 ; registered with IANA. 6678 search-ret-data-ext = search-modifier-name SP search-return-value 6679 ; Note that not every SEARCH return option 6680 ; is required to have the corresponding 6681 ; ESEARCH return data. 6683 search-return-data = "MIN" SP nz-number / 6684 "MAX" SP nz-number / 6685 "ALL" SP sequence-set / 6686 "COUNT" SP number / 6687 search-ret-data-ext 6688 ; All return data items conform to 6689 ; search-ret-data-ext syntax. 6690 ; Note that "$" marker is not allowed 6691 ; after the ALL return data item. 6693 search-return-opts = SP "RETURN" SP "(" [search-return-opt 6694 *(SP search-return-opt)] ")" 6696 search-return-opt = "MIN" / "MAX" / "ALL" / "COUNT" / 6697 "SAVE" / 6698 search-ret-opt-ext 6699 ; conforms to generic search-ret-opt-ext 6700 ; syntax 6702 search-ret-opt-ext = search-modifier-name [SP search-mod-params] 6704 search-return-value = tagged-ext-val 6705 ; Data for the returned search option. 6707 ; A single "nz-number"/"number"/"number64" value 6708 ; can be returned as an atom (i.e., without 6709 ; quoting). A sequence-set can be returned 6710 ; as an atom as well. 6712 section = "[" [section-spec] "]" 6714 section-binary = "[" [section-part] "]" 6716 section-msgtext = "HEADER" / "HEADER.FIELDS" [".NOT"] SP header-list / 6717 "TEXT" 6718 ; top-level or MESSAGE/RFC822 or MESSAGE/GLOBAL part 6720 section-part = nz-number *("." nz-number) 6721 ; body part reference. 6722 ; Allows for accessing nested body parts. 6724 section-spec = section-msgtext / (section-part ["." section-text]) 6726 section-text = section-msgtext / "MIME" 6727 ; text other than actual body part (headers, etc.) 6729 select = "SELECT" SP mailbox 6731 seq-number = nz-number / "*" 6732 ; message sequence number (COPY, FETCH, STORE 6733 ; commands) or unique identifier (UID COPY, 6734 ; UID FETCH, UID STORE commands). 6735 ; * represents the largest number in use. In 6736 ; the case of message sequence numbers, it is 6737 ; the number of messages in a non-empty mailbox. 6738 ; In the case of unique identifiers, it is the 6739 ; unique identifier of the last message in the 6740 ; mailbox or, if the mailbox is empty, the 6741 ; mailbox's current UIDNEXT value. 6742 ; The server should respond with a tagged BAD 6743 ; response to a command that uses a message 6744 ; sequence number greater than the number of 6745 ; messages in the selected mailbox. This 6746 ; includes "*" if the selected mailbox is empty. 6748 seq-range = seq-number ":" seq-number 6749 ; two seq-number values and all values between 6750 ; these two regardless of order. 6751 ; Example: 2:4 and 4:2 are equivalent and indicate 6752 ; values 2, 3, and 4. 6753 ; Example: a unique identifier sequence range of 6754 ; 3291:* includes the UID of the last message in 6755 ; the mailbox, even if that value is less than 3291. 6757 sequence-set = (seq-number / seq-range) ["," sequence-set] 6758 ; set of seq-number values, regardless of order. 6759 ; Servers MAY coalesce overlaps and/or execute the 6760 ; sequence in any order. 6761 ; Example: a message sequence number set of 6762 ; 2,4:7,9,12:* for a mailbox with 15 messages is 6763 ; equivalent to 2,4,5,6,7,9,12,13,14,15 6764 ; Example: a message sequence number set of *:4,5:7 6765 ; for a mailbox with 10 messages is equivalent to 6766 ; 10,9,8,7,6,5,4,5,6,7 and MAY be reordered and 6767 ; overlap coalesced to be 4,5,6,7,8,9,10. 6769 sequence-set =/ seq-last-command 6770 ; Allow for "result of the last command" indicator. 6772 seq-last-command = "$" 6774 status = "STATUS" SP mailbox SP 6775 "(" status-att *(SP status-att) ")" 6777 status-att = "MESSAGES" / "UIDNEXT" / "UIDVALIDITY" / 6778 "UNSEEN" / "DELETED" / "SIZE" 6780 status-att-val = ("MESSAGES" SP number) / 6781 ("UIDNEXT" SP nz-number) / 6782 ("UIDVALIDITY" SP nz-number) / 6783 ("UNSEEN" SP number) / 6784 ("DELETED" SP number) / 6785 ("SIZE" SP number64) 6786 ; Extensions to the STATUS responses 6787 ; should extend this production. 6788 ; Extensions should use the generic 6789 ; syntax defined by tagged-ext. 6791 status-att-list = status-att-val *(SP status-att-val) 6793 status-option = "STATUS" SP "(" status-att *(SP status-att) ")" 6794 ; This ABNF production complies with 6795 ; syntax. 6797 store = "STORE" SP sequence-set SP store-att-flags 6799 store-att-flags = (["+" / "-"] "FLAGS" [".SILENT"]) SP 6800 (flag-list / (flag *(SP flag))) 6802 string = quoted / literal 6803 subscribe = "SUBSCRIBE" SP mailbox 6805 tag = 1* 6807 tag-string = astring 6808 ; represented as 6810 tagged-ext-label = tagged-label-fchar *tagged-label-char 6811 ; Is a valid RFC 3501 "atom". 6813 tagged-label-fchar = ALPHA / "-" / "_" / "." 6815 tagged-label-char = tagged-label-fchar / DIGIT / ":" 6817 tagged-ext-comp = astring / 6818 tagged-ext-comp *(SP tagged-ext-comp) / 6819 "(" tagged-ext-comp ")" 6820 ; Extensions that follow this general 6821 ; syntax should use nstring instead of 6822 ; astring when appropriate in the context 6823 ; of the extension. 6824 ; Note that a message set or a "number" 6825 ; can always be represented as an "atom". 6826 ; An URL should be represented as 6827 ; a "quoted" string. 6829 tagged-ext-simple = sequence-set / number / number64 6831 tagged-ext-val = tagged-ext-simple / 6832 "(" [tagged-ext-comp] ")" 6834 text = 1*(TEXT-CHAR / UTF8-2 / UTF8-3 / UTF8-4) 6835 ; Non ASCII text can only be returned 6836 ; after ENABLE IMAP4rev2 command 6838 TEXT-CHAR = 6840 time = 2DIGIT ":" 2DIGIT ":" 2DIGIT 6841 ; Hours minutes seconds 6843 uid = "UID" SP 6844 (copy / move / fetch / search / store / uid-expunge) 6845 ; Unique identifiers used instead of message 6846 ; sequence numbers 6848 uid-expunge = "EXPUNGE" SP sequence-set 6849 ; Unique identifiers used instead of message 6850 ; sequence numbers 6852 uid-set = (uniqueid / uid-range) *("," uid-set) 6854 uid-range = (uniqueid ":" uniqueid) 6855 ; two uniqueid values and all values 6856 ; between these two regards of order. 6857 ; Example: 2:4 and 4:2 are equivalent. 6859 uniqueid = nz-number 6860 ; Strictly ascending 6862 unsubscribe = "UNSUBSCRIBE" SP mailbox 6864 userid = astring 6866 UTF8-CHAR = 6868 UTF8-2 = 6870 UTF8-3 = 6872 UTF8-4 = 6874 vendor-token = "vendor." name-component 6875 ; Definition copied from RFC 2244. 6876 ; MUST be registered with IANA 6878 zone = ("+" / "-") 4DIGIT 6879 ; Signed four-digit value of hhmm representing 6880 ; hours and minutes east of Greenwich (that is, 6881 ; the amount that the given time differs from 6882 ; Universal Time). Subtracting the timezone 6883 ; from the given time will give the UT form. 6884 ; The Universal Time zone is "+0000". 6886 10. Author's Note 6888 This document is a revision or rewrite of earlier documents, and 6889 supercedes the protocol specification in those documents: RFC 3501, 6890 RFC 2060, RFC 1730, unpublished IMAP2bis.TXT document, RFC 1176, and 6891 RFC 1064. 6893 11. Security Considerations 6895 IMAP4rev2 protocol transactions, including electronic mail data, are 6896 sent in the clear over the network exposing them to possible 6897 eavesdropping and manipulation unless protection is negotiated. This 6898 can be accomplished either by the use of Implicit TLS port, STARTTLS 6899 command, negotiated confidentiality protection in the AUTHENTICATE 6900 command, or some other protection mechanism. 6902 11.1. TLS related Security Considerations 6904 This section applies to both use of STARTTLS command and Implicit TLS 6905 port. 6907 IMAP client and server implementations MUST comply with relevant TLS 6908 recommendations from [RFC8314]. 6910 Clients and servers MUST implement TLS 1.2 [TLS-1.2] or newer. Use 6911 of TLS 1.3 [TLS-1.3] is RECOMMENDED. TLS 1.2 may be used only in 6912 cases where the other party has not yet implemented TLS 1.3. 6913 Additionally, when using TLS 1.2, IMAP implementations MUST implement 6914 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 cipher suite. This is 6915 important as it assures that any two compliant implementations can be 6916 configured to interoperate. Other TLS cipher suites recommended in 6917 RFC 7525 [RFC7525] are RECOMMENDED: 6918 TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, 6919 TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 and 6920 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384. All other cipher suites are 6921 OPTIONAL. Note that this is a change from section 2.1 of [IMAP-TLS]. 6923 The list of mandatory-to-implement TLS 1.3 cipher suites is described 6924 in Section 9.1 of [TLS-1.3]. 6926 During the TLS negotiation [TLS-1.3][TLS-1.2], the client MUST check 6927 its understanding of the server hostname against the server's 6928 identity as presented in the server Certificate message, in order to 6929 prevent on-path attackers attempting to masquerade as the server. 6930 This procedure is described in [RFC7817]. 6932 Both the client and server MUST check the result of the STARTTLS 6933 command and subsequent TLS ([TLS-1.3][TLS-1.2]) negotiation to see 6934 whether acceptable authentication and/or privacy was achieved. 6936 11.2. STARTTLS command versa use of Implicit TLS port 6938 For maximum backward compatibility the client MUST implement both TLS 6939 negotiation on implicit TLS port and TLS negotiation using STARTTLS 6940 command on cleartext port. 6942 The server MUST implement TLS negotiation on implicit TLS port. The 6943 server SHOULD also implement IMAP on cleartext port. If the server 6944 listens on a cleartext port, it MUST allow STARTTLS command on it. 6946 Some site/firewall maintainers insist on TLS site-wide and prefer not 6947 to rely on a configuration option in each higher-level protocol. For 6948 this reason, IMAP4rev2 clients SHOULD try both ports 993 and 143 (and 6949 both IPv4 and IPv6) concurrently by default, unless overridden by 6950 either user configuration or DNS SRV records [RFC6186]. A good 6951 algorithm for implementing such concurrent connect is described in 6952 [RFC8305]. 6954 11.3. Client handling of unsolicited responses not suitable for the 6955 current connection state 6957 Cleartext mail transmission (whether caused by firewall configuration 6958 errors that result in TLS stripping or weak security policies in 6959 email clients that choose not to negotiate TLS in the first place) 6960 can enable injection of responses that can confuse or even cause 6961 crashes in email clients. The following measures are recommended to 6962 minimize damage from them. 6964 See Section 7.1.4 for special security considerations related to 6965 PREAUTH response. 6967 Many server responses and response codes are only meaningful in 6968 authenticated or even selected state. However, nothing prevents a 6969 server (or an on-path attacker) from sending such invalid 6970 responses in cleartext before STARTTLS/AUTHENTICATE commands are 6971 issued. Before authentication clients SHOULD ignore any responses 6972 other than CAPABILITY and server status responses (Section 7.1), 6973 as well as any response codes other than CAPABILITY. (In 6974 particular, some email clients are known to incorrectly process 6975 LIST responses received before authentication.) Clients SHOULD 6976 ignore the ALERT response code until after TLS (whether using 6977 STARTTLS or TLS negotiation on implicit TLS port) or SASL security 6978 layer with confidentiality protection has been successfully 6979 negotiated. Unless explicitly allowed by an IMAP extension, when 6980 not in selected state clients MUST ignore responses/response codes 6981 related to message and mailbox status such as FLAGS, EXIST, 6982 EXPUNGE and FETCH. 6984 11.4. COPYUID and APPENDUID response codes 6986 The COPYUID and APPENDUID response codes return information about the 6987 mailbox, which may be considered sensitive if the mailbox has 6988 permissions set that permit the client to COPY or APPEND to the 6989 mailbox, but not SELECT or EXAMINE it. 6991 Consequently, these response codes SHOULD NOT be issued if the client 6992 does not have access to SELECT or EXAMINE the mailbox. 6994 11.5. LIST command and Other Users' namespace 6996 In response to a LIST command containing an argument of the Other 6997 Users' Namespace prefix, a server SHOULD NOT list users that have not 6998 granted list access to their personal mailboxes to the currently 6999 authenticated user. Providing such a list, could compromise security 7000 by potentially disclosing confidential information of who is located 7001 on the server, or providing a starting point of a list of user 7002 accounts to attack. 7004 11.6. Use of MD5 7006 The BODYSTRUCTURE FETCH Data item can contain a the MD5 digest of the 7007 message body in the "body MD5" field (body-fld-md5 ABNF production). 7008 While MD5 is no longer considered a secure cryptographic hash 7009 [RFC6151], this field is used solely to expose the value of the 7010 Content-MD5 header field (if present in the original message), which 7011 is just a message integrity check and is not used for cryptographic 7012 purposes. Also note that other mechanisms that provide message 7013 integrity checks were defined since RFC 1864 was published and are 7014 now more commonly used than Content-MD5. Two such mechanisms are 7015 DKIM-Signature [RFC6376] header field and S/MIME signing 7016 [RFC8550][RFC8550]. 7018 11.7. Other Security Considerations 7020 A server error message for an AUTHENTICATE command which fails due to 7021 invalid credentials SHOULD NOT detail why the credentials are 7022 invalid. 7024 Use of the LOGIN command sends passwords in the clear. This can be 7025 avoided by using the AUTHENTICATE command with a [SASL] mechanism 7026 that does not use plaintext passwords, by first negotiating 7027 encryption via STARTTLS or some other protection mechanism. 7029 A server implementation MUST implement a configuration that, at the 7030 time of authentication, requires: 7031 (1) The STARTTLS command has been negotiated or TLS negotiated on 7032 implicit TLS port. 7033 OR 7034 (2) Some other mechanism that protects the session from password 7035 snooping has been provided. 7036 OR 7037 (3) The following measures are in place: 7038 (a) The LOGINDISABLED capability is advertised, and [SASL] mechanisms 7039 (such as PLAIN) using plaintext passwords are NOT advertised in the 7040 CAPABILITY list. 7041 AND 7042 (b) The LOGIN command returns an error even if the password is 7043 correct. 7044 AND 7045 (c) The AUTHENTICATE command returns an error with all [SASL] 7046 mechanisms that use plaintext passwords, even if the password is 7047 correct. 7049 A server error message for a failing LOGIN command SHOULD NOT specify 7050 that the user name, as opposed to the password, is invalid. 7052 A server SHOULD have mechanisms in place to limit or delay failed 7053 AUTHENTICATE/LOGIN attempts. 7055 A server SHOULD report any authentication failure and analyze such 7056 authentication failure attempt with regard to a password brute force 7057 attack as well as a password spraying attack. Accounts with 7058 passwords that match well known passwords from spraying attacks MUST 7059 be blocked and users associated with such accounts must be requested 7060 to change their passwords. Only password with significant strength 7061 SHOULD be accepted. 7063 Additional security considerations are discussed in the section 7064 discussing the AUTHENTICATE (see Section 6.2.2) and LOGIN (see 7065 Section 6.2.3) commands. 7067 12. IANA Considerations 7069 IANA is requested to update "Service Names and Transport Protocol 7070 Port Numbers" registry as follows: 7072 1. Registration for TCP port 143 and the corresponding "imap" 7073 service name should be updated to point to this document and RFC 7074 3501. 7076 2. Registration for TCP port 993 and the corresponding "imaps" 7077 service name should be updated to point to this document, RFC 7078 8314 and RFC 3501. 7080 3. Both UDP port 143 and UDP port 993 should be marked as "Reserved" 7081 in the registry. 7083 Additional IANA actions are specified in subsection of this section. 7085 12.1. Updates to IMAP4 Capabilities registry 7087 IMAP4 capabilities are registered by publishing a standards track or 7088 IESG approved informational or experimental RFC. The registry is 7089 currently located at: https://www.iana.org/assignments/ 7090 imap4-capabilities 7092 As this specification revises the AUTH= prefix, STARTTLS and 7093 LOGINDISABLED extensions, IANA is requested to update registry 7094 entries for these 3 extensions to point to this document and RFC 7095 3501. 7097 12.2. GSSAPI/SASL service name 7099 GSSAPI/Kerberos/SASL service names are registered by publishing a 7100 standards track or IESG approved experimental RFC. The registry is 7101 currently located at: https://www.iana.org/assignments/gssapi- 7102 service-names 7104 IANA is requested to update the "imap" service name previously 7105 registered in RFC 3501, to point to both this document and RFC 3501. 7107 12.3. LIST Selection Options, LIST Return Options, LIST extended data 7108 items 7110 [RFC5258] specifies IANA registration procedures for LIST Selection 7111 Options, LIST Return Options, LIST extended data items. This 7112 document doesn't change these registration procedures. In particular 7113 LIST selection options (Section 6.3.9.1) and LIST return options 7114 (Section 6.3.9.2) are registered using the procedure specified in 7115 Section 9 of [RFC5258] (and using the registration template from 7116 Section 9.3 of [RFC5258]). LIST Extended Data Items are registered 7117 using the registration template from Section 9.6 of [RFC5258]). 7119 IANA is requested to add a reference to [RFCXXXX] for the "OLDNAME" 7120 LIST-EXTENDED extended data item entry. This is in addition to the 7121 existing reference to [RFC5465]. 7123 12.4. IMAP Mailbox Name Attributes and IMAP Response Codes 7125 IANA is requested to update the "IMAP Mailbox Name Attributes" 7126 registry to point to this document in addition to RFC 3501. 7128 IANA is requested to update the "IMAP Response Codes" registry to 7129 point to this document in addition to RFC 3501. 7131 13. References 7132 13.1. Normative References 7134 [RFC4752] Melnikov, A., Ed., "The Kerberos V5 ("GSSAPI") Simple 7135 Authentication and Security Layer (SASL) Mechanism", 7136 RFC 4752, DOI 10.17487/RFC4752, November 2006, 7137 . 7139 [RFC5258] Leiba, B. and A. Melnikov, "Internet Message Access 7140 Protocol version 4 - LIST Command Extensions", RFC 5258, 7141 DOI 10.17487/RFC5258, June 2008, 7142 . 7144 [RFC5788] Melnikov, A. and D. Cridland, "IMAP4 Keyword Registry", 7145 RFC 5788, DOI 10.17487/RFC5788, March 2010, 7146 . 7148 [ABNF] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 7149 Specifications: ABNF", STD 68, RFC 5234, January 2008, 7150 . 7152 [CHARSET] Freed, N. and J. Postel, "IANA Charset Registration 7153 Procedures", BCP 19, RFC 2978, October 2000, 7154 . 7156 [SCRAM-SHA-256] 7157 Hansen, T., "SCRAM-SHA-256 and SCRAM-SHA-256-PLUS Simple 7158 Authentication and Security Layer (SASL) Mechanisms", 7159 RFC 7677, DOI 10.17487/RFC7677, November 2015, 7160 . 7162 [DISPOSITION] 7163 Troost, R., Dorner, S., and K. Moore, Ed., "Communicating 7164 Presentation Information in Internet Messages: The 7165 Content-Disposition Header Field", RFC 2183, August 1997, 7166 . 7168 [PLAIN] Zeilenga, K., Ed., "The PLAIN Simple Authentication and 7169 Security Layer (SASL) Mechanism", RFC 4616, August 2006, 7170 . 7172 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 7173 Requirement Levels", BCP 14, RFC 2119, 7174 DOI 10.17487/RFC2119, March 1997, 7175 . 7177 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 7178 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 7179 May 2017, . 7181 [LANGUAGE-TAGS] 7182 Alvestrand, H., "Content Language Headers", RFC 3282, May 7183 2002, . 7185 [LOCATION] 7186 Palme, J., Hopmann, A., and N. Shelness, "MIME 7187 Encapsulation of Aggregate Documents, such as HTML 7188 (MHTML)", RFC 2557, March 1999, 7189 . 7191 [MD5] Myers, J. and M. Rose, "The Content-MD5 Header Field", 7192 RFC 1864, October 1995, 7193 . 7195 [MIME-HDRS] 7196 Moore, K., "MIME (Multipurpose Internet Mail Extensions) 7197 Part Three: Message Header Extensions for Non-ASCII Text", 7198 RFC 2047, November 1996, 7199 . 7201 [MIME-IMB] 7202 Freed, N. and N. Borenstein, "Multipurpose Internet Mail 7203 Extensions (MIME) Part One: Format of Internet Message 7204 Bodies", RFC 2045, November 1996, 7205 . 7207 [MIME-IMT] 7208 Freed, N. and N. Borenstein, "Multipurpose Internet Mail 7209 Extensions (MIME) Part Two: Media Types", RFC 2046, 7210 November 1996, . 7212 [RFC2231] Freed, N. and K. Moore, "MIME Parameter Value and Encoded 7213 Word Extensions: Character Sets, Languages, and 7214 Continuations", RFC 2231, DOI 10.17487/RFC2231, November 7215 1997, . 7217 [RFC-5322] 7218 Resnick, P., Ed., "Internet Message Format", RFC 5322, 7219 October 2008, . 7221 [SASL] Melnikov, A., Ed. and K. Zeilenga, Ed., "Simple 7222 Authentication and Security Layer (SASL)", RFC 4422, June 7223 2006, . 7225 [TLS-1.2] Dierks, T. and E. Rescorla, "The Transport Layer Security 7226 (TLS) Protocol Version 1.2", RFC 5246, August 2008, 7227 . 7229 [TLS-1.3] Rescorla, E., "The Transport Layer Security (TLS) Protocol 7230 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 7231 . 7233 [UTF-7] Goldsmith, D. and M. Davis, "UTF-7 A Mail-Safe 7234 Transformation Format of Unicode", RFC 2152, May 1997, 7235 . 7237 [UTF-8] Yergeau, F., "UTF-8, a transformation format of ISO 7238 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 7239 2003, . 7241 [MULTIAPPEND] 7242 Crispin, M., "Internet Message Access Protocol (IMAP) - 7243 MULTIAPPEND Extension", RFC 3502, March 2003, 7244 . 7246 [NET-UNICODE] 7247 Klensin, J. and M. Padlipsky, "Unicode Format for Network 7248 Interchange", RFC 5198, DOI 10.17487/RFC5198, March 2008, 7249 . 7251 [I18N-HDRS] 7252 Yang, A., Steele, S., and N. Freed, "Internationalized 7253 Email Headers", RFC 6532, DOI 10.17487/RFC6532, February 7254 2012, . 7256 [RFC3503] Melnikov, A., "Message Disposition Notification (MDN) 7257 profile for Internet Message Access Protocol (IMAP)", 7258 RFC 3503, DOI 10.17487/RFC3503, March 2003, 7259 . 7261 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 7262 Encodings", RFC 4648, DOI 10.17487/RFC4648, October 2006, 7263 . 7265 [RFC7525] Sheffer, Y., Holz, R., and P. Saint-Andre, 7266 "Recommendations for Secure Use of Transport Layer 7267 Security (TLS) and Datagram Transport Layer Security 7268 (DTLS)", BCP 195, RFC 7525, DOI 10.17487/RFC7525, May 7269 2015, . 7271 [RFC7817] Melnikov, A., "Updated Transport Layer Security (TLS) 7272 Server Identity Check Procedure for Email-Related 7273 Protocols", RFC 7817, DOI 10.17487/RFC7817, March 2016, 7274 . 7276 [RFC8098] Hansen, T., Ed. and A. Melnikov, Ed., "Message Disposition 7277 Notification", STD 85, RFC 8098, DOI 10.17487/RFC8098, 7278 February 2017, . 7280 [RFC8314] Moore, K. and C. Newman, "Cleartext Considered Obsolete: 7281 Use of Transport Layer Security (TLS) for Email Submission 7282 and Access", RFC 8314, DOI 10.17487/RFC8314, January 2018, 7283 . 7285 [IMAP-IMPLEMENTATION] 7286 Leiba, B., "IMAP4 Implementation Recommendations", 7287 RFC 2683, September 1999, 7288 . 7290 [IMAP-MULTIACCESS] 7291 Gahrns, M., "IMAP4 Multi-Accessed Mailbox Practice", 7292 RFC 2180, July 1997, 7293 . 7295 13.2. Informative References (related protocols) 7297 [CERT-555316] 7298 CERT, "Vulnerability Note VU#555316: STARTTLS plaintext 7299 command injection vulnerability", September 2011, 7300 . 7302 [RFC6151] Turner, S. and L. Chen, "Updated Security Considerations 7303 for the MD5 Message-Digest and the HMAC-MD5 Algorithms", 7304 RFC 6151, DOI 10.17487/RFC6151, March 2011, 7305 . 7307 [RFC2193] Gahrns, M., "IMAP4 Mailbox Referrals", RFC 2193, 7308 DOI 10.17487/RFC2193, September 1997, 7309 . 7311 [RFC3348] Gahrns, M. and R. Cheng, "The Internet Message Action 7312 Protocol (IMAP4) Child Mailbox Extension", RFC 3348, 7313 DOI 10.17487/RFC3348, July 2002, 7314 . 7316 [RFC5256] Crispin, M. and K. Murchison, "Internet Message Access 7317 Protocol - SORT and THREAD Extensions", RFC 5256, 7318 DOI 10.17487/RFC5256, June 2008, 7319 . 7321 [RFC5465] Gulbrandsen, A., King, C., and A. Melnikov, "The IMAP 7322 NOTIFY Extension", RFC 5465, DOI 10.17487/RFC5465, 7323 February 2009, . 7325 [RFC6186] Daboo, C., "Use of SRV Records for Locating Email 7326 Submission/Access Services", RFC 6186, 7327 DOI 10.17487/RFC6186, March 2011, 7328 . 7330 [RFC7162] Melnikov, A. and D. Cridland, "IMAP Extensions: Quick Flag 7331 Changes Resynchronization (CONDSTORE) and Quick Mailbox 7332 Resynchronization (QRESYNC)", RFC 7162, 7333 DOI 10.17487/RFC7162, May 2014, 7334 . 7336 [RFC7888] Melnikov, A., Ed., "IMAP4 Non-synchronizing Literals", 7337 RFC 7888, DOI 10.17487/RFC7888, May 2016, 7338 . 7340 [RFC8474] Gondwana, B., Ed., "IMAP Extension for Object 7341 Identifiers", RFC 8474, DOI 10.17487/RFC8474, September 7342 2018, . 7344 [IMAP-DISC] 7345 Melnikov, A., Ed., "Synchronization Operations for 7346 Disconnected IMAP4 Clients", RFC 4549, June 2006, 7347 . 7349 [IMAP-I18N] 7350 Newman, C., Gulbrandsen, A., and A. Melnikov, "Internet 7351 Message Access Protocol Internationalization", RFC 5255, 7352 DOI 10.17487/RFC5255, June 2008, 7353 . 7355 [IMAP-MODEL] 7356 Crispin, M., "Distributed Electronic Mail Models in 7357 IMAP4", RFC 1733, December 1994, 7358 . 7360 [IMAP-UTF-8] 7361 Resnick, P., Ed., Newman, C., Ed., and S. Shen, Ed., "IMAP 7362 Support for UTF-8", RFC 6855, DOI 10.17487/RFC6855, March 7363 2013, . 7365 [ANONYMOUS] 7366 Zeilenga, K., "Anonymous Simple Authentication and 7367 Security Layer (SASL) Mechanism", RFC 4505, June 2006, 7368 . 7370 [SMTP] Klensin, J., "Simple Mail Transfer Protocol", RFC 5321, 7371 October 2008, . 7373 [RFC3516] Nerenberg, L., "IMAP4 Binary Content Extension", RFC 3516, 7374 DOI 10.17487/RFC3516, April 2003, 7375 . 7377 [RFC4314] Melnikov, A., "IMAP4 Access Control List (ACL) Extension", 7378 RFC 4314, December 2005, 7379 . 7381 [RFC2087] Myers, J., "IMAP4 QUOTA extension", RFC 2087, January 7382 1997, . 7384 [IMAP-URL] 7385 Melnikov, A., Ed. and C. Newman, "IMAP URL Scheme", 7386 RFC 5092, DOI 10.17487/RFC5092, November 2007, 7387 . 7389 [RFC8305] Schinazi, D. and T. Pauly, "Happy Eyeballs Version 2: 7390 Better Connectivity Using Concurrency", RFC 8305, 7391 DOI 10.17487/RFC8305, December 2017, 7392 . 7394 [RFC6376] Crocker, D., Ed., Hansen, T., Ed., and M. Kucherawy, Ed., 7395 "DomainKeys Identified Mail (DKIM) Signatures", STD 76, 7396 RFC 6376, DOI 10.17487/RFC6376, September 2011, 7397 . 7399 [RFC8550] Schaad, J., Ramsdell, B., and S. Turner, "Secure/ 7400 Multipurpose Internet Mail Extensions (S/MIME) Version 4.0 7401 Certificate Handling", RFC 8550, DOI 10.17487/RFC8550, 7402 April 2019, . 7404 [RFC8551] Schaad, J., Ramsdell, B., and S. Turner, "Secure/ 7405 Multipurpose Internet Mail Extensions (S/MIME) Version 4.0 7406 Message Specification", RFC 8551, DOI 10.17487/RFC8551, 7407 April 2019, . 7409 [IMAP-KEYWORDS-REG] 7410 IANA, "IMAP and JMAP Keywords", December 2009, 7411 . 7414 [IMAP-MAILBOX-NAME-ATTRS-REG] 7415 IANA, "IMAP Mailbox Name Attributes", June 2018, 7416 . 7419 [CHARSET-REG] 7420 IANA, "Character Set Registrations", May 2015, 7421 . 7424 13.3. Informative References (historical aspects of IMAP and related 7425 protocols) 7427 [RFC3501] Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - VERSION 7428 4rev1", RFC 3501, DOI 10.17487/RFC3501, March 2003, 7429 . 7431 [IMAP-COMPAT] 7432 Crispin, M., "IMAP4 Compatibility with IMAP2bis", 7433 RFC 2061, December 1996, 7434 . 7436 [IMAP-HISTORICAL] 7437 Crispin, M., "IMAP4 Compatibility with IMAP2 and 7438 IMAP2bis", RFC 1732, December 1994, 7439 . 7441 [IMAP2BIS] 7442 Crispin, M., "INTERACTIVE MAIL ACCESS PROTOCOL - VERSION 7443 2bis", draft-ietf-imap-imap2bis-02 (work in progress), 7444 October 1993, . 7447 [IMAP-OBSOLETE] 7448 Crispin, M., "Internet Message Access Protocol - Obsolete 7449 Syntax", RFC 2062, December 1996, 7450 . 7452 [IMAP2] Crispin, M., "Interactive Mail Access Protocol: Version 7453 2", RFC 1176, August 1990, 7454 . 7456 [RFC-822] Crocker, D., "STANDARD FOR THE FORMAT OF ARPA INTERNET 7457 TEXT MESSAGES", STD 11, RFC 822, August 1982, 7458 . 7460 [IMAP-TLS] 7461 Newman, C., "Using TLS with IMAP, POP3 and ACAP", 7462 RFC 2595, June 1999, 7463 . 7465 Appendix A. Backward compatibility with IMAP4rev1 7467 An implementation that wants to remain compatible with IMAP4rev1 can 7468 advertise both IMAP4rev1 and IMAP4rev2 in its CAPABILITY response/ 7469 response code. (Such server implementation is likely to also want to 7470 advertise other IMAP4rev1 extensions that were folded into IMAP4rev2. 7471 See Appendix E.) While some IMAP4rev1 responses were removed in 7472 IMAP4rev2, their presence will not break IMAP4rev2-only clients. 7474 If both IMAP4rev1 and IMAP4rev2 are advertised, an IMAP client that 7475 wants to use IMAP4rev2 MUST issue an "ENABLE IMAP4rev2" command. 7477 Servers advertising both IMAP4rev1 and IMAP4rev2 MUST NOT generate 7478 UTF-8 quoted strings unless the client has issued "ENABLE IMAP4rev2". 7479 Consider implementation of mechanisms described or referenced in 7480 [IMAP-UTF-8] to achieve this goal. 7482 Servers advertising both IMAP4rev1 and IMAP4rev2, and clients 7483 intending to be compatible with IMAP4rev1 servers MUST be compatible 7484 with the international mailbox naming convention described in 7485 Appendix A.1. 7487 Also see Appendix D for special considerations for servers that 7488 support 63 bit body part/message sizes and want to advertise support 7489 for both IMAP4rev1 and IMAP4rev2. 7491 A.1. Mailbox International Naming Convention for compatibility with 7492 IMAP4rev1 7494 Support for the Mailbox International Naming Convention described in 7495 this section is not required for IMAP4rev2-only clients and servers. 7496 It is only used for backward compatibility with IMAP4rev1 7497 implementations. 7499 By convention, international mailbox names in IMAP4rev1 are specified 7500 using a modified version of the UTF-7 encoding described in [UTF-7]. 7501 Modified UTF-7 may also be usable in servers that implement an 7502 earlier version of this protocol. 7504 In modified UTF-7, printable US-ASCII characters, except for "&", 7505 represent themselves; that is, characters with octet values 0x20-0x25 7506 and 0x27-0x7e. The character "&" (0x26) is represented by the two- 7507 octet sequence "&-". 7509 All other characters (octet values 0x00-0x1f and 0x7f-0xff) are 7510 represented in modified BASE64, with a further modification from 7511 [UTF-7] that "," is used instead of "/". Modified BASE64 MUST NOT be 7512 used to represent any printing US-ASCII character which can represent 7513 itself. Only characters inside the modified BASE64 alphabet are 7514 permitted in modified BASE64 text. 7516 "&" is used to shift to modified BASE64 and "-" to shift back to US- 7517 ASCII. There is no implicit shift from BASE64 to US-ASCII, and null 7518 shifts ("-&" while in BASE64; note that "&-" while in US-ASCII means 7519 "&") are not permitted. However, all names start in US-ASCII, and 7520 MUST end in US-ASCII; that is, a name that ends with a non-ASCII 7521 ISO-10646 character MUST end with a "-"). 7523 The purpose of these modifications is to correct the following 7524 problems with UTF-7: 7526 1. UTF-7 uses the "+" character for shifting; this conflicts with 7527 the common use of "+" in mailbox names, in particular USENET 7528 newsgroup names. 7530 2. UTF-7's encoding is BASE64 which uses the "/" character; this 7531 conflicts with the use of "/" as a popular hierarchy delimiter. 7533 3. UTF-7 prohibits the unencoded usage of "\"; this conflicts with 7534 the use of "\" as a popular hierarchy delimiter. 7536 4. UTF-7 prohibits the unencoded usage of "~"; this conflicts with 7537 the use of "~" in some servers as a home directory indicator. 7539 5. UTF-7 permits multiple alternate forms to represent the same 7540 string; in particular, printable US-ASCII characters can be 7541 represented in encoded form. 7543 Although modified UTF-7 is a convention, it establishes certain 7544 requirements on server handling of any mailbox name with an embedded 7545 "&" character. In particular, server implementations MUST preserve 7546 the exact form of the modified BASE64 portion of a modified UTF-7 7547 name and treat that text as case-sensitive, even if names are 7548 otherwise case-insensitive or case-folded. 7550 Server implementations SHOULD verify that any mailbox name with an 7551 embedded "&" character, used as an argument to CREATE, is: in the 7552 correctly modified UTF-7 syntax, has no superfluous shifts, and has 7553 no encoding in modified BASE64 of any printing US-ASCII character 7554 which can represent itself. However, client implementations MUST NOT 7555 depend upon the server doing this, and SHOULD NOT attempt to create a 7556 mailbox name with an embedded "&" character unless it complies with 7557 the modified UTF-7 syntax. 7559 Server implementations which export a mail store that does not follow 7560 the modified UTF-7 convention MUST convert to modified UTF-7 any 7561 mailbox name that contains either non-ASCII characters or the "&" 7562 character. 7564 For example, here is a mailbox name which mixes English, Chinese, 7565 and Japanese text: ~peter/mail/&U,BTFw-/&ZeVnLIqe- 7567 For example, the string "&Jjo!" is not a valid mailbox name 7568 because it does not contain a shift to US-ASCII before the "!". 7569 The correct form is "&Jjo-!". The string "&U,BTFw-&ZeVnLIqe-" is 7570 not permitted because it contains a superfluous shift. The 7571 correct form is "&U,BTF2XlZyyKng-". 7573 Appendix B. Backward compatibility with BINARY extension 7575 IMAP4rev2 incorporates subset of functionality provided by the BINARY 7576 extension [RFC3516], in particular it includes additional FETCH items 7577 (BINARY, BINARY.PEEK and BINARY.SIZE), but not extensions to the 7578 APPEND command. IMAP4rev2 implementations that supports full RFC 7579 3516 functionality need to also advertise the BINARY capability in 7580 the CAPABILITY response/response code. 7582 Appendix C. Backward compatibility with LIST-EXTENDED extension 7584 IMAP4rev2 incorporates most of functionality provided by the LIST- 7585 EXTENDED extension [RFC5258]. In particular, multiple mailbox 7586 patterns syntax is not supported in IMAP4rev2, unless LIST-EXTENDED 7587 capability is also advertised in the CAPABILITY response/response 7588 code. 7590 Appendix D. 63 bit body part and message sizes 7592 IMAP4rev2 increases allowed body part and message sizes that servers 7593 can support from 32 to 63 bits. Server implementations don't have to 7594 support 63 bit long body parts/message sizes, however client 7595 implementations have to expect them. 7597 As IMAP4rev1 didn't support 63 bit long body part/message sizes, 7598 there is an interoperability issue exposed by 63 bit capable servers 7599 that are accessible by both IMAP4rev1 and IMAP4rev2 email clients. 7600 As IMAP4rev1 would be unable to retrieve full content of messages 7601 bigger than 4Gb, such servers either need to replace messages bigger 7602 that 4Gb with messages under 4Gb or hide them from IMAP4rev1 clients. 7603 This document doesn't prescribe any implementation strategy to 7604 address this issue. 7606 Appendix E. Changes from RFC 3501 / IMAP4rev1 7608 Below is the summary of changes since RFC 3501: 7610 1. Support for 64bit message and body part sizes. 7612 2. Folded in IMAP NAMESPACE (RFC 2342), UNSELECT (RFC 3691), 7613 UIDPLUS (RFC 4315), ESEARCH (RFC 4731), SEARCHRES (RFC 5182), 7614 ENABLE (RFC 5161), IDLE (RFC 2177), SASL-IR (RFC 4959), LIST- 7615 EXTENDED (RFC 5258), LIST-STATUS (RFC 5819), MOVE (RFC 6851) and 7616 LITERAL- (RFC 7888) extensions. Also folded RFC 4466 (IMAP ABNF 7617 extensions), RFC 5530 (response codes), the FETCH side of the 7618 BINARY extension (RFC 3516) and the list of new mailbox 7619 attributes from SPECIAL-USE (RFC 6154). 7621 3. Added STATUS SIZE (RFC 8438) and STATUS DELETED. 7623 4. SEARCH command now requires to return ESEARCH response (SEARCH 7624 response is now deprecated). 7626 5. Clarified which SEARCH keys have to use substring match and 7627 which don't. 7629 6. Clarified that server should decode parameter value 7630 continuations as described in [RFC2231]. This requirement was 7631 hidden in RFC 2231 itself. 7633 7. Clarified that COPYUID response code is returned for both MOVE 7634 and UID MOVE. 7636 8. Tighen requirements about COPY/MOVE commands not creating target 7637 mailbox. Also require them to return TRYCREATE response code, 7638 if the target mailbox doesn't exist and can be created. 7640 9. Added CLOSED response code from RFC 7162. SELECT/EXAMINE when a 7641 mailbox is already selected now requires a CLOSED response code 7642 to be returned. 7644 10. SELECT/EXAMINE are now required to return untagged LIST 7645 response. 7647 11. UNSEEN response code on SELECT/EXAMINE is now deprecated. 7649 12. RECENT response on SELECT/EXAMINE, \Recent flag, RECENT STATUS, 7650 SEARCH NEW items are now deprecated. 7652 13. Clarified that the server doesn't need to send a new 7653 PERMANENTFLAGS response code when a new keyword was successfully 7654 added and the server advertised \* earlier for the same mailbox. 7656 14. For future extensibility extended ABNF for tagged-ext-simple to 7657 allow for bare number64. 7659 15. Added SHOULD level requirement on IMAP servers to support 7660 $MDNSent, $Forwarded, $Junk, $NonJunk and $Phishing keywords. 7662 16. Mailbox names and message headers now allow for UTF-8. Support 7663 for Modified UTF-7 in mailbox names is not required, unless 7664 compatibility with IMAP4rev1 is desired. 7666 17. Removed the CHECK command. Clients should use NOOP instead. 7668 18. RFC822, RFC822.HEADER and RFC822.TEXT FETCH data items were 7669 deprecated. Clients should use the corresponding BODY[] 7670 variants instead. 7672 19. LSUB command was deprecated. Clients should use LIST 7673 (SUBSCRIBED) instead. 7675 20. IDLE command can now return updates not related to the currently 7676 selected mailbox state. 7678 21. All unsolicited FETCH updates are required to include UID. 7680 22. Clarified that client implementations MUST ignore response codes 7681 that they do not recognize. (Change from a SHOULD to a MUST.) 7683 23. resp-text ABNF non terminal was updated to allow for empty text. 7685 24. After ENABLE IMAP4rev2 human readable response text can include 7686 non ASCII encoded in UTF-8. 7688 25. Updated to use modern TLS-related recommendations as per RFC 7689 8314, RFC 7817, RFC 7525. 7691 26. Added warnings about use of ALERT response codes and PREAUTH 7692 response. 7694 27. Replaced DIGEST-MD5 SASL mechanism with SCRAM-SHA-256. DIGEST- 7695 MD5 was deprecated. 7697 28. Clarified that any command received from the client resets 7698 server autologout timer. 7700 29. Revised IANA registration procedure for IMAP extensions and 7701 removed "X" convention in accordance with BCP 178. 7703 30. Loosened requirements on servers when closing connections to be 7704 more aligned with existing practices. 7706 Appendix F. Other Recommended IMAP Extensions 7708 Support for the following extensions is recommended for all IMAP 7709 client and servers. While they significantly reduce bandwidth and/or 7710 number of round trips used by IMAP in certain situations, the EXTRA 7711 WG decided that requiring them as a part of IMAP4rev2 would push the 7712 bar to implement too high for new implementations. Also note that 7713 absence of any IMAP extension from this list doesn't make it somehow 7714 deficient or not recommended for use with IMAP4rev2. 7716 1. QRESYNC and CONDSTORE extensions [RFC7162]. They make 7717 discovering changes to IMAP mailboxes more efficient, at the 7718 expense of storing a bit more state. 7720 2. OBJECTID extension [RFC8474] helps with preserving IMAP client 7721 cache when messages moved/copied or mailboxes are renamed. 7723 Appendix G. Acknowledgement 7725 Earlier versions of this document were edited by Mark Crispin. 7726 Sadly, he is no longer available to help with this work. Editors of 7727 this revisions are hoping that Mark would have approved. 7729 Chris Newman has contributed text on I18N and use of UTF-8 in 7730 messages and mailbox names. 7732 Thank you to Tony Hansen for helping with the index generation. 7733 Thank you to Murray Kucherawy, Timo Sirainen, Bron Gondwana, Stephan 7734 Bosch, Robert Sparks, Arnt Gulbrandsen, Benjamin Kaduk, Daniel 7735 Migault, Roman Danyliw and Eric Vyncke for extensive feedback. 7737 This document incorporates text from RFC 4315 (by Mark Crispin), RFC 7738 4466 (by Cyrus Daboo), RFC 4731 (by Dave Cridland), RFC 5161 (by Arnt 7739 Gulbrandsen), RFC 5465 (by Arnt Gulbrandsen and Curtis King), RFC 7740 5530 (by Arnt Gulbrandsen), RFC 5819 (by Timo Sirainen), RFC 6154 (by 7741 Jamie Nicolson), RFC 8438 (by Stephan Bosch) so work done by authors/ 7742 editors of these documents is appreciated. Note that editors of this 7743 document were redacted from the above list. 7745 The CHILDREN return option was originally proposed by Mike Gahrns and 7746 Raymond Cheng in [RFC3348]. Most of the information in 7747 Section 6.3.9.5 is taken directly from their original specification 7748 [RFC3348]. 7750 Thank you to Damian Poddebniak, Fabian Ising, Hanno Boeck and 7751 Sebastian Schinzel for pointing out that the ENABLE command should be 7752 a member of "command-auth" and not "command-any" ABNF production, as 7753 well as pointing out security issues associated with ALERT, PREAUTH 7754 and other responses received before authentication. 7756 Index 7758 $ 7759 $Forwarded (predefined flag) 13 7760 $Junk (predefined flag) 13 7761 $MDNSent (predefined flag) 13 7762 $NotJunk (predefined flag) 13 7763 $Phishing (predefined flag) 13 7765 + 7766 +FLAGS 97 7767 +FLAGS.SILENT 97 7769 - 7770 -FLAGS 97 7771 -FLAGS.SILENT 97 7773 A 7774 ALERT (response code) 105 7775 ALL (fetch item) 93 7776 ALL (search key) 82 7777 ALL (search result option) 80 7778 ALL (search return item name) 122 7779 ALREADYEXISTS (response code) 105 7780 ANSWERED (search key) 82 7781 APPEND (command) 73 7782 APPENDUID (response code) 105 7783 AUTHENTICATE (command) 31 7784 AUTHENTICATIONFAILED (response code) 106 7785 AUTHORIZATIONFAILED (response code) 106 7787 B 7788 BAD (response) 113 7789 BADCHARSET (response code) 106 7790 BCC (search key) 82 7791 BEFORE (search key) 82 7792 BINARY.PEEK[]<> (fetch item) 93 7793 BINARY.SIZE[] (fetch item) 94 7794 BINARY.SIZE[] (fetch result) 125 7795 BINARY[]<> (fetch result) 124 7796 BINARY[]<> (fetch item) 93 7797 BODY (fetch item) 94 7798 BODY (fetch result) 125 7799 BODY (search key) 82 7800 BODY.PEEK[
]<> (fetch item) 94 7801 BODYSTRUCTURE (fetch item) 95 7802 BODYSTRUCTURE (fetch result) 126 7803 BODY[
]<> (fetch result) 125 7804 BODY[
]<> (fetch item) 94 7805 BYE (response) 114 7806 Body Structure (message attribute) 14 7808 C 7809 CANNOT (response code) 106 7810 CAPABILITY (command) 27 7811 CAPABILITY (response code) 107 7812 CAPABILITY (response) 115 7813 CC (search key) 82 7814 CLIENTBUG (response code) 107 7815 CLOSE (command) 78 7816 CLOSED (response code) 107 7817 CONTACTADMIN (response code) 107 7818 COPY (command) 98 7819 COPYUID (response code) 108 7820 CORRUPTION (response code) 108 7821 COUNT (search result option) 81 7822 COUNT (search return item name) 122 7823 CREATE (command) 41 7825 D 7826 DELETE (command) 42 7827 DELETED (search key) 83 7828 DELETED (status item) 73 7829 DRAFT (search key) 83 7831 E 7832 ENABLE (command) 36 7833 ENVELOPE (fetch item) 95 7834 ENVELOPE (fetch result) 129 7835 ESEARCH (response) 121 7836 EXAMINE (command) 40 7837 EXPIRED (response code) 108 7838 EXPUNGE (command) 79 7839 EXPUNGE (response) 123 7840 EXPUNGEISSUED (response code) 108 7841 Envelope Structure (message attribute) 14 7843 F 7844 FAST (fetch item) 93 7845 FETCH (command) 92 7846 FETCH (response) 124 7847 FLAGGED (search key) 83 7848 FLAGS (fetch item) 95 7849 FLAGS (fetch result) 130 7850 FLAGS (response) 123 7851 FLAGS (store command data item) 97 7852 FLAGS.SILENT (store command data item) 97 7853 FROM (search key) 83 7854 FULL (fetch item) 93 7855 Flags (message attribute) 12 7857 H 7858 HASCHILDREN (response code) 109 7859 HEADER (part specifier) 95 7860 HEADER (search key) 83 7861 HEADER.FIELDS (part specifier) 95 7862 HEADER.FIELDS.NOT (part specifier) 95 7864 I 7865 IDLE (command) 76 7866 INTERNALDATE (fetch item) 95 7867 INTERNALDATE (fetch result) 130 7868 INUSE (response code) 109 7869 Internal Date (message attribute) 14 7871 K 7872 KEYWORD (search key) 83 7873 Keyword (type of flag) 12 7875 L 7876 LARGER (search key) 83 7877 LIMIT (response code) 109 7878 LIST (command) 48 7879 LIST (response) 117 7880 LOGOUT (command) 28 7882 M 7883 MAX (search result option) 80 7884 MAX (search return item name) 122 7885 MAY (specification requirement term) 5 7886 MESSAGES (status item) 72 7887 MIME (part specifier) 96 7888 MIN (search result option) 80 7889 MIN (search return item name) 122 7890 MOVE (command) 99 7891 MUST (specification requirement term) 5 7892 MUST NOT (specification requirement term) 5 7893 Message Sequence Number (message attribute) 11 7895 N 7896 NAMESPACE (command) 66 7897 NAMESPACE (response) 121 7898 NO (response) 113 7899 NONEXISTENT (response code) 109 7900 NOOP (command) 28 7901 NOPERM (response code) 110 7902 NOT (search key) 83 7903 NOT RECOMMENDED (specification requirement term) 5 7905 O 7906 OK (response) 113 7907 ON (search key) 83 7908 OPTIONAL (specification requirement term) 5 7909 OR (search key) 83 7910 OVERQUOTA (response code) 110 7912 P 7913 PARSE (response code) 110 7914 PERMANENTFLAGS (response code) 110 7915 PREAUTH (response) 114 7916 PRIVACYREQUIRED (response code) 111 7917 Permanent Flag (class of flag) 14 7918 Predefined keywords 13 7920 R 7921 READ-ONLY (response code) 111 7922 READ-WRITE (response code) 111 7923 RECOMMENDED (specification requirement term) 5 7924 RENAME (command) 44 7925 REQUIRED (specification requirement term) 5 7926 RFC822.SIZE (fetch item) 95 7927 RFC822.SIZE (fetch result) 130 7929 S 7930 SAVE (search result option) 81 7931 SEARCH (command) 79 7932 SEEN (search key) 83 7933 SELECT (command) 38 7934 SENTBEFORE (search key) 83 7935 SENTON (search key) 83 7936 SENTSINCE (search key) 83 7937 SERVERBUG (response code) 111 7938 SHOULD (specification requirement term) 5 7939 SHOULD NOT (specification requirement term) 5 7940 SINCE (search key) 84 7941 SIZE (status item) 73 7942 SMALLER (search key) 84 7943 STARTTLS (command) 29 7944 STATUS (command) 71 7945 STATUS (response) 121 7946 STORE (command) 97 7947 SUBJECT (search key) 84 7948 SUBSCRIBE (command) 47 7949 Session Flag (class of flag) 14 7950 System Flag (type of flag) 12 7952 T 7953 TEXT (part specifier) 95 7954 TEXT (search key) 84 7955 TO (search key) 84 7956 TRYCREATE (response code) 111 7958 U 7959 UID (command) 101 7960 UID (fetch item) 95 7961 UID (fetch result) 130 7962 UID (search key) 84 7963 UIDNEXT (response code) 111 7964 UIDNEXT (status item) 72 7965 UIDNOTSTICKY (response code) 112 7966 UIDVALIDITY (response code) 112 7967 UIDVALIDITY (status item) 72 7968 UNANSWERED (search key) 84 7969 UNAVAILABLE (response code) 112 7970 UNDELETED (search key) 84 7971 UNDRAFT (search key) 84 7972 UNFLAGGED (search key) 84 7973 UNKEYWORD (search key) 84 7974 UNKNOWN-CTE (response code) 112 7975 UNSEEN (search key) 84 7976 UNSEEN (status item) 73 7977 UNSELECT (command) 78 7978 UNSUBSCRIBE (command) 47 7979 Unique Identifier (UID) (message attribute) 10 7981 [ 7982 [RFC-5322] Size (message attribute) 14 7984 \ 7985 \All (mailbox name attribute) 119 7986 \Answered (system flag) 12 7987 \Archive (mailbox name attribute) 119 7988 \Deleted (system flag) 12 7989 \Draft (system flag) 12 7990 \Drafts (mailbox name attribute) 119 7991 \Flagged (mailbox name attribute) 119 7992 \Flagged (system flag) 12 7993 \HasChildren (mailbox name attribute) 118 7994 \HasNoChildren (mailbox name attribute) 118 7995 \Junk (mailbox name attribute) 119 7996 \Marked (mailbox name attribute) 118 7997 \Noinferiors (mailbox name attribute) 117 7998 \NonExistent (mailbox name attribute) 117 7999 \Noselect (mailbox name attribute) 118 8000 \Recent (system flag) 12 8001 \Remote (mailbox name attribute) 118 8002 \Seen (system flag) 12 8003 \Sent (mailbox name attribute) 119 8004 \Subscribed (mailbox name attribute) 118 8005 \Trash (mailbox name attribute) 119 8006 \Unmarked (mailbox name attribute) 118 8008 Authors' Addresses 8010 Alexey Melnikov (editor) 8011 Isode Ltd 8012 14 Castle Mews 8013 Hampton, Middlesex TW12 2NP 8014 UK 8016 Email: Alexey.Melnikov@isode.com 8018 Barry Leiba (editor) 8019 Futurewei Technologies 8021 Phone: +1 646 827 0648 8022 Email: barryleiba@computer.org 8023 URI: http://internetmessagingtechnology.org/