rfc2060.txt (182481B)
1 2 3 4 5 6 7 Network Working Group M. Crispin 8 Request for Comments: 2060 University of Washington 9 Obsoletes: 1730 December 1996 10 Category: Standards Track 11 12 13 INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1 14 15 Status of this Memo 16 17 This document specifies an Internet standards track protocol for the 18 Internet community, and requests discussion and suggestions for 19 improvements. Please refer to the current edition of the "Internet 20 Official Protocol Standards" (STD 1) for the standardization state 21 and status of this protocol. Distribution of this memo is unlimited. 22 23 Abstract 24 25 The Internet Message Access Protocol, Version 4rev1 (IMAP4rev1) 26 allows a client to access and manipulate electronic mail messages on 27 a server. IMAP4rev1 permits manipulation of remote message folders, 28 called "mailboxes", in a way that is functionally equivalent to local 29 mailboxes. IMAP4rev1 also provides the capability for an offline 30 client to resynchronize with the server (see also [IMAP-DISC]). 31 32 IMAP4rev1 includes operations for creating, deleting, and renaming 33 mailboxes; checking for new messages; permanently removing messages; 34 setting and clearing flags; [RFC-822] and [MIME-IMB] parsing; 35 searching; and selective fetching of message attributes, texts, and 36 portions thereof. Messages in IMAP4rev1 are accessed by the use of 37 numbers. These numbers are either message sequence numbers or unique 38 identifiers. 39 40 IMAP4rev1 supports a single server. A mechanism for accessing 41 configuration information to support multiple IMAP4rev1 servers is 42 discussed in [ACAP]. 43 44 IMAP4rev1 does not specify a means of posting mail; this function is 45 handled by a mail transfer protocol such as [SMTP]. 46 47 IMAP4rev1 is designed to be upwards compatible from the [IMAP2] and 48 unpublished IMAP2bis protocols. In the course of the evolution of 49 IMAP4rev1, some aspects in the earlier protocol have become obsolete. 50 Obsolete commands, responses, and data formats which an IMAP4rev1 51 implementation may encounter when used with an earlier implementation 52 are described in [IMAP-OBSOLETE]. 53 54 55 56 57 58 Crispin Standards Track [Page 1] 59 60 RFC 2060 IMAP4rev1 December 1996 61 62 63 Other compatibility issues with IMAP2bis, the most common variant of 64 the earlier protocol, are discussed in [IMAP-COMPAT]. A full 65 discussion of compatibility issues with rare (and presumed extinct) 66 variants of [IMAP2] is in [IMAP-HISTORICAL]; this document is 67 primarily of historical interest. 68 69 Table of Contents 70 71 IMAP4rev1 Protocol Specification .................................. 4 72 1. How to Read This Document ................................. 4 73 1.1. Organization of This Document ............................. 4 74 1.2. Conventions Used in This Document ......................... 4 75 2. Protocol Overview ......................................... 5 76 2.1. Link Level ................................................ 5 77 2.2. Commands and Responses .................................... 6 78 2.2.1. Client Protocol Sender and Server Protocol Receiver ....... 6 79 2.2.2. Server Protocol Sender and Client Protocol Receiver ....... 7 80 2.3. Message Attributes ........................................ 7 81 2.3.1. Message Numbers ........................................... 7 82 2.3.1.1. Unique Identifier (UID) Message Attribute ......... 7 83 2.3.1.2. Message Sequence Number Message Attribute ......... 9 84 2.3.2. Flags Message Attribute .................................... 9 85 2.3.3. Internal Date Message Attribute ........................... 10 86 2.3.4. [RFC-822] Size Message Attribute .......................... 11 87 2.3.5. Envelope Structure Message Attribute ...................... 11 88 2.3.6. Body Structure Message Attribute .......................... 11 89 2.4. Message Texts ............................................. 11 90 3. State and Flow Diagram .................................... 11 91 3.1. Non-Authenticated State ................................... 11 92 3.2. Authenticated State ....................................... 11 93 3.3. Selected State ............................................ 12 94 3.4. Logout State .............................................. 12 95 4. Data Formats .............................................. 12 96 4.1. Atom ...................................................... 13 97 4.2. Number .................................................... 13 98 4.3. String ..................................................... 13 99 4.3.1. 8-bit and Binary Strings .................................. 13 100 4.4. Parenthesized List ........................................ 14 101 4.5. NIL ....................................................... 14 102 5. Operational Considerations ................................ 14 103 5.1. Mailbox Naming ............................................ 14 104 5.1.1. Mailbox Hierarchy Naming .................................. 14 105 5.1.2. Mailbox Namespace Naming Convention ....................... 14 106 5.1.3. Mailbox International Naming Convention ................... 15 107 5.2. Mailbox Size and Message Status Updates ................... 16 108 5.3. Response when no Command in Progress ...................... 16 109 5.4. Autologout Timer .......................................... 16 110 5.5. Multiple Commands in Progress ............................. 17 111 112 113 114 Crispin Standards Track [Page 2] 115 116 RFC 2060 IMAP4rev1 December 1996 117 118 119 6. Client Commands ........................................... 17 120 6.1. Client Commands - Any State ............................... 18 121 6.1.1. CAPABILITY Command ........................................ 18 122 6.1.2. NOOP Command .............................................. 19 123 6.1.3. LOGOUT Command ............................................ 20 124 6.2. Client Commands - Non-Authenticated State ................. 20 125 6.2.1. AUTHENTICATE Command ...................................... 21 126 6.2.2. LOGIN Command ............................................. 22 127 6.3. Client Commands - Authenticated State ..................... 22 128 6.3.1. SELECT Command ............................................ 23 129 6.3.2. EXAMINE Command ........................................... 24 130 6.3.3. CREATE Command ............................................ 25 131 6.3.4. DELETE Command ............................................ 26 132 6.3.5. RENAME Command ............................................ 27 133 6.3.6. SUBSCRIBE Command ......................................... 29 134 6.3.7. UNSUBSCRIBE Command ....................................... 30 135 6.3.8. LIST Command .............................................. 30 136 6.3.9. LSUB Command .............................................. 32 137 6.3.10. STATUS Command ............................................ 33 138 6.3.11. APPEND Command ............................................ 34 139 6.4. Client Commands - Selected State .......................... 35 140 6.4.1. CHECK Command ............................................. 36 141 6.4.2. CLOSE Command ............................................. 36 142 6.4.3. EXPUNGE Command ........................................... 37 143 6.4.4. SEARCH Command ............................................ 37 144 6.4.5. FETCH Command ............................................. 41 145 6.4.6. STORE Command ............................................. 45 146 6.4.7. COPY Command .............................................. 46 147 6.4.8. UID Command ............................................... 47 148 6.5. Client Commands - Experimental/Expansion .................. 48 149 6.5.1. X<atom> Command ........................................... 48 150 7. Server Responses .......................................... 48 151 7.1. Server Responses - Status Responses ....................... 49 152 7.1.1. OK Response ............................................... 51 153 7.1.2. NO Response ............................................... 51 154 7.1.3. BAD Response .............................................. 52 155 7.1.4. PREAUTH Response .......................................... 52 156 7.1.5. BYE Response .............................................. 52 157 7.2. Server Responses - Server and Mailbox Status .............. 53 158 7.2.1. CAPABILITY Response ....................................... 53 159 7.2.2. LIST Response .............................................. 54 160 7.2.3. LSUB Response ............................................. 55 161 7.2.4 STATUS Response ........................................... 55 162 7.2.5. SEARCH Response ........................................... 55 163 7.2.6. FLAGS Response ............................................ 56 164 7.3. Server Responses - Mailbox Size ........................... 56 165 7.3.1. EXISTS Response ........................................... 56 166 7.3.2. RECENT Response ........................................... 57 167 168 169 170 Crispin Standards Track [Page 3] 171 172 RFC 2060 IMAP4rev1 December 1996 173 174 175 7.4. Server Responses - Message Status ......................... 57 176 7.4.1. EXPUNGE Response .......................................... 57 177 7.4.2. FETCH Response ............................................ 58 178 7.5. Server Responses - Command Continuation Request ........... 63 179 8. Sample IMAP4rev1 connection ............................... 63 180 9. Formal Syntax ............................................. 64 181 10. Author's Note ............................................. 74 182 11. Security Considerations ................................... 74 183 12. Author's Address .......................................... 75 184 Appendices ........................................................ 76 185 A. References ................................................ 76 186 B. Changes from RFC 1730 ..................................... 77 187 C. Key Word Index ............................................ 79 188 189 190 IMAP4rev1 Protocol Specification 191 192 1. How to Read This Document 193 194 1.1. Organization of This Document 195 196 This document is written from the point of view of the implementor of 197 an IMAP4rev1 client or server. Beyond the protocol overview in 198 section 2, it is not optimized for someone trying to understand the 199 operation of the protocol. The material in sections 3 through 5 200 provides the general context and definitions with which IMAP4rev1 201 operates. 202 203 Sections 6, 7, and 9 describe the IMAP commands, responses, and 204 syntax, respectively. The relationships among these are such that it 205 is almost impossible to understand any of them separately. In 206 particular, do not attempt to deduce command syntax from the command 207 section alone; instead refer to the Formal Syntax section. 208 209 1.2. Conventions Used in This Document 210 211 In examples, "C:" and "S:" indicate lines sent by the client and 212 server respectively. 213 214 The following terms are used in this document to signify the 215 requirements of this specification. 216 217 1) MUST, or the adjective REQUIRED, means that the definition is 218 an absolute requirement of the specification. 219 220 2) MUST NOT that the definition is an absolute prohibition of the 221 specification. 222 223 224 225 226 Crispin Standards Track [Page 4] 227 228 RFC 2060 IMAP4rev1 December 1996 229 230 231 3) SHOULD means that there may exist valid reasons in particular 232 circumstances to ignore a particular item, but the full 233 implications MUST be understood and carefully weighed before 234 choosing a different course. 235 236 4) SHOULD NOT means that there may exist valid reasons in 237 particular circumstances when the particular behavior is 238 acceptable or even useful, but the full implications SHOULD be 239 understood and the case carefully weighed before implementing 240 any behavior described with this label. 241 242 5) MAY, or the adjective OPTIONAL, means that an item is truly 243 optional. One vendor may choose to include the item because a 244 particular marketplace requires it or because the vendor feels 245 that it enhances the product while another vendor may omit the 246 same item. An implementation which does not include a 247 particular option MUST be prepared to interoperate with another 248 implementation which does include the option. 249 250 "Can" is used instead of "may" when referring to a possible 251 circumstance or situation, as opposed to an optional facility of 252 the protocol. 253 254 "User" is used to refer to a human user, whereas "client" refers 255 to the software being run by the user. 256 257 "Connection" refers to the entire sequence of client/server 258 interaction from the initial establishment of the network 259 connection until its termination. "Session" refers to the 260 sequence of client/server interaction from the time that a mailbox 261 is selected (SELECT or EXAMINE command) until the time that 262 selection ends (SELECT or EXAMINE of another mailbox, CLOSE 263 command, or connection termination). 264 265 Characters are 7-bit US-ASCII unless otherwise specified. Other 266 character sets are indicated using a "CHARSET", as described in 267 [MIME-IMT] and defined in [CHARSET]. CHARSETs have important 268 additional semantics in addition to defining character set; refer 269 to these documents for more detail. 270 271 2. Protocol Overview 272 273 2.1. Link Level 274 275 The IMAP4rev1 protocol assumes a reliable data stream such as 276 provided by TCP. When TCP is used, an IMAP4rev1 server listens on 277 port 143. 278 279 280 281 282 Crispin Standards Track [Page 5] 283 284 RFC 2060 IMAP4rev1 December 1996 285 286 287 2.2. Commands and Responses 288 289 An IMAP4rev1 connection consists of the establishment of a 290 client/server network connection, an initial greeting from the 291 server, and client/server interactions. These client/server 292 interactions consist of a client command, server data, and a server 293 completion result response. 294 295 All interactions transmitted by client and server are in the form of 296 lines; that is, strings that end with a CRLF. The protocol receiver 297 of an IMAP4rev1 client or server is either reading a line, or is 298 reading a sequence of octets with a known count followed by a line. 299 300 2.2.1. Client Protocol Sender and Server Protocol Receiver 301 302 The client command begins an operation. Each client command is 303 prefixed with an identifier (typically a short alphanumeric string, 304 e.g. A0001, A0002, etc.) called a "tag". A different tag is 305 generated by the client for each command. 306 307 There are two cases in which a line from the client does not 308 represent a complete command. In one case, a command argument is 309 quoted with an octet count (see the description of literal in String 310 under Data Formats); in the other case, the command arguments require 311 server feedback (see the AUTHENTICATE command). In either case, the 312 server sends a command continuation request response if it is ready 313 for the octets (if appropriate) and the remainder of the command. 314 This response is prefixed with the token "+". 315 316 Note: If, instead, the server detected an error in the command, it 317 sends a BAD completion response with tag matching the command (as 318 described below) to reject the command and prevent the client from 319 sending any more of the command. 320 321 It is also possible for the server to send a completion response 322 for some other command (if multiple commands are in progress), or 323 untagged data. In either case, the command continuation request 324 is still pending; the client takes the appropriate action for the 325 response, and reads another response from the server. In all 326 cases, the client MUST send a complete command (including 327 receiving all command continuation request responses and command 328 continuations for the command) before initiating a new command. 329 330 The protocol receiver of an IMAP4rev1 server reads a command line 331 from the client, parses the command and its arguments, and transmits 332 server data and a server command completion result response. 333 334 335 336 337 338 Crispin Standards Track [Page 6] 339 340 RFC 2060 IMAP4rev1 December 1996 341 342 343 2.2.2. Server Protocol Sender and Client Protocol Receiver 344 345 Data transmitted by the server to the client and status responses 346 that do not indicate command completion are prefixed with the token 347 "*", and are called untagged responses. 348 349 Server data MAY be sent as a result of a client command, or MAY be 350 sent unilaterally by the server. There is no syntactic difference 351 between server data that resulted from a specific command and server 352 data that were sent unilaterally. 353 354 The server completion result response indicates the success or 355 failure of the operation. It is tagged with the same tag as the 356 client command which began the operation. Thus, if more than one 357 command is in progress, the tag in a server completion response 358 identifies the command to which the response applies. There are 359 three possible server completion responses: OK (indicating success), 360 NO (indicating failure), or BAD (indicating protocol error such as 361 unrecognized command or command syntax error). 362 363 The protocol receiver of an IMAP4rev1 client reads a response line 364 from the server. It then takes action on the response based upon the 365 first token of the response, which can be a tag, a "*", or a "+". 366 367 A client MUST be prepared to accept any server response at all times. 368 This includes server data that was not requested. Server data SHOULD 369 be recorded, so that the client can reference its recorded copy 370 rather than sending a command to the server to request the data. In 371 the case of certain server data, the data MUST be recorded. 372 373 This topic is discussed in greater detail in the Server Responses 374 section. 375 376 2.3. Message Attributes 377 378 In addition to message text, each message has several attributes 379 associated with it. These attributes may be retrieved individually 380 or in conjunction with other attributes or message texts. 381 382 2.3.1. Message Numbers 383 384 Messages in IMAP4rev1 are accessed by one of two numbers; the unique 385 identifier and the message sequence number. 386 387 2.3.1.1. Unique Identifier (UID) Message Attribute 388 389 A 32-bit value assigned to each message, which when used with the 390 unique identifier validity value (see below) forms a 64-bit value 391 392 393 394 Crispin Standards Track [Page 7] 395 396 RFC 2060 IMAP4rev1 December 1996 397 398 399 that is permanently guaranteed not to refer to any other message in 400 the mailbox. Unique identifiers are assigned in a strictly ascending 401 fashion in the mailbox; as each message is added to the mailbox it is 402 assigned a higher UID than the message(s) which were added 403 previously. 404 405 Unlike message sequence numbers, unique identifiers are not 406 necessarily contiguous. Unique identifiers also persist across 407 sessions. This permits a client to resynchronize its state from a 408 previous session with the server (e.g. disconnected or offline access 409 clients); this is discussed further in [IMAP-DISC]. 410 411 Associated with every mailbox is a unique identifier validity value, 412 which is sent in an UIDVALIDITY response code in an OK untagged 413 response at mailbox selection time. If unique identifiers from an 414 earlier session fail to persist to this session, the unique 415 identifier validity value MUST be greater than the one used in the 416 earlier session. 417 418 Note: Unique identifiers MUST be strictly ascending in the mailbox 419 at all times. If the physical message store is re-ordered by a 420 non-IMAP agent, this requires that the unique identifiers in the 421 mailbox be regenerated, since the former unique identifers are no 422 longer strictly ascending as a result of the re-ordering. Another 423 instance in which unique identifiers are regenerated is if the 424 message store has no mechanism to store unique identifiers. 425 Although this specification recognizes that this may be 426 unavoidable in certain server environments, it STRONGLY ENCOURAGES 427 message store implementation techniques that avoid this problem. 428 429 Another cause of non-persistance is if the mailbox is deleted and 430 a new mailbox with the same name is created at a later date, Since 431 the name is the same, a client may not know that this is a new 432 mailbox unless the unique identifier validity is different. A 433 good value to use for the unique identifier validity value is a 434 32-bit representation of the creation date/time of the mailbox. 435 It is alright to use a constant such as 1, but only if it 436 guaranteed that unique identifiers will never be reused, even in 437 the case of a mailbox being deleted (or renamed) and a new mailbox 438 by the same name created at some future time. 439 440 The unique identifier of a message MUST NOT change during the 441 session, and SHOULD NOT change between sessions. However, if it is 442 not possible to preserve the unique identifier of a message in a 443 subsequent session, each subsequent session MUST have a new unique 444 identifier validity value that is larger than any that was used 445 previously. 446 447 448 449 450 Crispin Standards Track [Page 8] 451 452 RFC 2060 IMAP4rev1 December 1996 453 454 455 2.3.1.2. Message Sequence Number Message Attribute 456 457 A relative position from 1 to the number of messages in the mailbox. 458 This position MUST be ordered by ascending unique identifier. As 459 each new message is added, it is assigned a message sequence number 460 that is 1 higher than the number of messages in the mailbox before 461 that new message was added. 462 463 Message sequence numbers can be reassigned during the session. For 464 example, when a message is permanently removed (expunged) from the 465 mailbox, the message sequence number for all subsequent messages is 466 decremented. Similarly, a new message can be assigned a message 467 sequence number that was once held by some other message prior to an 468 expunge. 469 470 In addition to accessing messages by relative position in the 471 mailbox, message sequence numbers can be used in mathematical 472 calculations. For example, if an untagged "EXISTS 11" is received, 473 and previously an untagged "8 EXISTS" was received, three new 474 messages have arrived with message sequence numbers of 9, 10, and 11. 475 Another example; if message 287 in a 523 message mailbox has UID 476 12345, there are exactly 286 messages which have lesser UIDs and 236 477 messages which have greater UIDs. 478 479 2.3.2. Flags Message Attribute 480 481 A list of zero or more named tokens associated with the message. A 482 flag is set by its addition to this list, and is cleared by its 483 removal. There are two types of flags in IMAP4rev1. A flag of 484 either type may be permanent or session-only. 485 486 A system flag is a flag name that is pre-defined in this 487 specification. All system flags begin with "\". Certain system 488 flags (\Deleted and \Seen) have special semantics described 489 elsewhere. The currently-defined system flags are: 490 491 \Seen Message has been read 492 493 \Answered Message has been answered 494 495 \Flagged Message is "flagged" for urgent/special attention 496 497 \Deleted Message is "deleted" for removal by later EXPUNGE 498 499 \Draft Message has not completed composition (marked as a 500 draft). 501 502 503 504 505 506 Crispin Standards Track [Page 9] 507 508 RFC 2060 IMAP4rev1 December 1996 509 510 511 \Recent Message is "recently" arrived in this mailbox. This 512 session is the first session to have been notified 513 about this message; subsequent sessions will not see 514 \Recent set for this message. This flag can not be 515 altered by the client. 516 517 If it is not possible to determine whether or not 518 this session is the first session to be notified 519 about a message, then that message SHOULD be 520 considered recent. 521 522 If multiple connections have the same mailbox 523 selected simultaneously, it is undefined which of 524 these connections will see newly-arrives messages 525 with \Recent set and which will see it without 526 \Recent set. 527 528 A keyword is defined by the server implementation. Keywords do 529 not begin with "\". Servers MAY permit the client to define new 530 keywords in the mailbox (see the description of the 531 PERMANENTFLAGS response code for more information). 532 533 A flag may be permanent or session-only on a per-flag basis. 534 Permanent flags are those which the client can add or remove 535 from the message flags permanently; that is, subsequent sessions 536 will see any change in permanent flags. Changes to session 537 flags are valid only in that session. 538 539 Note: The \Recent system flag is a special case of a 540 session flag. \Recent can not be used as an argument in a 541 STORE command, and thus can not be changed at all. 542 543 2.3.3. Internal Date Message Attribute 544 545 The internal date and time of the message on the server. This is not 546 the date and time in the [RFC-822] header, but rather a date and time 547 which reflects when the message was received. In the case of 548 messages delivered via [SMTP], this SHOULD be the date and time of 549 final delivery of the message as defined by [SMTP]. In the case of 550 messages delivered by the IMAP4rev1 COPY command, this SHOULD be the 551 internal date and time of the source message. In the case of 552 messages delivered by the IMAP4rev1 APPEND command, this SHOULD be 553 the date and time as specified in the APPEND command description. 554 All other cases are implementation defined. 555 556 557 558 559 560 561 562 Crispin Standards Track [Page 10] 563 564 RFC 2060 IMAP4rev1 December 1996 565 566 567 2.3.4. [RFC-822] Size Message Attribute 568 569 The number of octets in the message, as expressed in [RFC-822] 570 format. 571 572 2.3.5. Envelope Structure Message Attribute 573 574 A parsed representation of the [RFC-822] envelope information (not to 575 be confused with an [SMTP] envelope) of the message. 576 577 2.3.6. Body Structure Message Attribute 578 579 A parsed representation of the [MIME-IMB] body structure information 580 of the message. 581 582 2.4. Message Texts 583 584 In addition to being able to fetch the full [RFC-822] text of a 585 message, IMAP4rev1 permits the fetching of portions of the full 586 message text. Specifically, it is possible to fetch the [RFC-822] 587 message header, [RFC-822] message body, a [MIME-IMB] body part, or a 588 [MIME-IMB] header. 589 590 3. State and Flow Diagram 591 592 An IMAP4rev1 server is in one of four states. Most commands are 593 valid in only certain states. It is a protocol error for the client 594 to attempt a command while the command is in an inappropriate state. 595 In this case, a server will respond with a BAD or NO (depending upon 596 server implementation) command completion result. 597 598 3.1. Non-Authenticated State 599 600 In non-authenticated state, the client MUST supply authentication 601 credentials before most commands will be permitted. This state is 602 entered when a connection starts unless the connection has been pre- 603 authenticated. 604 605 3.2. Authenticated State 606 607 In authenticated state, the client is authenticated and MUST select a 608 mailbox to access before commands that affect messages will be 609 permitted. This state is entered when a pre-authenticated connection 610 starts, when acceptable authentication credentials have been 611 provided, or after an error in selecting a mailbox. 612 613 614 615 616 617 618 Crispin Standards Track [Page 11] 619 620 RFC 2060 IMAP4rev1 December 1996 621 622 623 3.3. Selected State 624 625 In selected state, a mailbox has been selected to access. This state 626 is entered when a mailbox has been successfully selected. 627 628 3.4. Logout State 629 630 In logout state, the connection is being terminated, and the server 631 will close the connection. This state can be entered as a result of 632 a client request or by unilateral server decision. 633 634 +--------------------------------------+ 635 |initial connection and server greeting| 636 +--------------------------------------+ 637 || (1) || (2) || (3) 638 VV || || 639 +-----------------+ || || 640 |non-authenticated| || || 641 +-----------------+ || || 642 || (7) || (4) || || 643 || VV VV || 644 || +----------------+ || 645 || | authenticated |<=++ || 646 || +----------------+ || || 647 || || (7) || (5) || (6) || 648 || || VV || || 649 || || +--------+ || || 650 || || |selected|==++ || 651 || || +--------+ || 652 || || || (7) || 653 VV VV VV VV 654 +--------------------------------------+ 655 | logout and close connection | 656 +--------------------------------------+ 657 658 (1) connection without pre-authentication (OK greeting) 659 (2) pre-authenticated connection (PREAUTH greeting) 660 (3) rejected connection (BYE greeting) 661 (4) successful LOGIN or AUTHENTICATE command 662 (5) successful SELECT or EXAMINE command 663 (6) CLOSE command, or failed SELECT or EXAMINE command 664 (7) LOGOUT command, server shutdown, or connection closed 665 666 4. Data Formats 667 668 IMAP4rev1 uses textual commands and responses. Data in IMAP4rev1 can 669 be in one of several forms: atom, number, string, parenthesized list, 670 or NIL. 671 672 673 674 Crispin Standards Track [Page 12] 675 676 RFC 2060 IMAP4rev1 December 1996 677 678 679 4.1. Atom 680 681 An atom consists of one or more non-special characters. 682 683 4.2. Number 684 685 A number consists of one or more digit characters, and represents a 686 numeric value. 687 688 4.3. String 689 690 A string is in one of two forms: literal and quoted string. The 691 literal form is the general form of string. The quoted string form 692 is an alternative that avoids the overhead of processing a literal at 693 the cost of limitations of characters that can be used in a quoted 694 string. 695 696 A literal is a sequence of zero or more octets (including CR and LF), 697 prefix-quoted with an octet count in the form of an open brace ("{"), 698 the number of octets, close brace ("}"), and CRLF. In the case of 699 literals transmitted from server to client, the CRLF is immediately 700 followed by the octet data. In the case of literals transmitted from 701 client to server, the client MUST wait to receive a command 702 continuation request (described later in this document) before 703 sending the octet data (and the remainder of the command). 704 705 A quoted string is a sequence of zero or more 7-bit characters, 706 excluding CR and LF, with double quote (<">) characters at each end. 707 708 The empty string is represented as either "" (a quoted string with 709 zero characters between double quotes) or as {0} followed by CRLF (a 710 literal with an octet count of 0). 711 712 Note: Even if the octet count is 0, a client transmitting a 713 literal MUST wait to receive a command continuation request. 714 715 4.3.1. 8-bit and Binary Strings 716 717 8-bit textual and binary mail is supported through the use of a 718 [MIME-IMB] content transfer encoding. IMAP4rev1 implementations MAY 719 transmit 8-bit or multi-octet characters in literals, but SHOULD do 720 so only when the [CHARSET] is identified. 721 722 723 724 725 726 727 728 729 730 Crispin Standards Track [Page 13] 731 732 RFC 2060 IMAP4rev1 December 1996 733 734 735 Although a BINARY body encoding is defined, unencoded binary strings 736 are not permitted. A "binary string" is any string with NUL 737 characters. Implementations MUST encode binary data into a textual 738 form such as BASE64 before transmitting the data. A string with an 739 excessive amount of CTL characters MAY also be considered to be 740 binary. 741 742 4.4. Parenthesized List 743 744 Data structures are represented as a "parenthesized list"; a sequence 745 of data items, delimited by space, and bounded at each end by 746 parentheses. A parenthesized list can contain other parenthesized 747 lists, using multiple levels of parentheses to indicate nesting. 748 749 The empty list is represented as () -- a parenthesized list with no 750 members. 751 752 4.5. NIL 753 754 The special atom "NIL" represents the non-existence of a particular 755 data item that is represented as a string or parenthesized list, as 756 distinct from the empty string "" or the empty parenthesized list (). 757 758 5. Operational Considerations 759 760 5.1. Mailbox Naming 761 762 The interpretation of mailbox names is implementation-dependent. 763 However, the case-insensitive mailbox name INBOX is a special name 764 reserved to mean "the primary mailbox for this user on this server". 765 766 5.1.1. Mailbox Hierarchy Naming 767 768 If it is desired to export hierarchical mailbox names, mailbox names 769 MUST be left-to-right hierarchical using a single character to 770 separate levels of hierarchy. The same hierarchy separator character 771 is used for all levels of hierarchy within a single name. 772 773 5.1.2. Mailbox Namespace Naming Convention 774 775 By convention, the first hierarchical element of any mailbox name 776 which begins with "#" identifies the "namespace" of the remainder of 777 the name. This makes it possible to disambiguate between different 778 types of mailbox stores, each of which have their own namespaces. 779 780 781 782 783 784 785 786 Crispin Standards Track [Page 14] 787 788 RFC 2060 IMAP4rev1 December 1996 789 790 791 For example, implementations which offer access to USENET 792 newsgroups MAY use the "#news" namespace to partition the USENET 793 newsgroup namespace from that of other mailboxes. Thus, the 794 comp.mail.misc newsgroup would have an mailbox name of 795 "#news.comp.mail.misc", and the name "comp.mail.misc" could refer 796 to a different object (e.g. a user's private mailbox). 797 798 5.1.3. Mailbox International Naming Convention 799 800 By convention, international mailbox names are specified using a 801 modified version of the UTF-7 encoding described in [UTF-7]. The 802 purpose of these modifications is to correct the following problems 803 with UTF-7: 804 805 1) UTF-7 uses the "+" character for shifting; this conflicts with 806 the common use of "+" in mailbox names, in particular USENET 807 newsgroup names. 808 809 2) UTF-7's encoding is BASE64 which uses the "/" character; this 810 conflicts with the use of "/" as a popular hierarchy delimiter. 811 812 3) UTF-7 prohibits the unencoded usage of "\"; this conflicts with 813 the use of "\" as a popular hierarchy delimiter. 814 815 4) UTF-7 prohibits the unencoded usage of "~"; this conflicts with 816 the use of "~" in some servers as a home directory indicator. 817 818 5) UTF-7 permits multiple alternate forms to represent the same 819 string; in particular, printable US-ASCII chararacters can be 820 represented in encoded form. 821 822 In modified UTF-7, printable US-ASCII characters except for "&" 823 represent themselves; that is, characters with octet values 0x20-0x25 824 and 0x27-0x7e. The character "&" (0x26) is represented by the two- 825 octet sequence "&-". 826 827 All other characters (octet values 0x00-0x1f, 0x7f-0xff, and all 828 Unicode 16-bit octets) are represented in modified BASE64, with a 829 further modification from [UTF-7] that "," is used instead of "/". 830 Modified BASE64 MUST NOT be used to represent any printing US-ASCII 831 character which can represent itself. 832 833 "&" is used to shift to modified BASE64 and "-" to shift back to US- 834 ASCII. All names start in US-ASCII, and MUST end in US-ASCII (that 835 is, a name that ends with a Unicode 16-bit octet MUST end with a "- 836 "). 837 838 839 840 841 842 Crispin Standards Track [Page 15] 843 844 RFC 2060 IMAP4rev1 December 1996 845 846 847 For example, here is a mailbox name which mixes English, Japanese, 848 and Chinese text: ~peter/mail/&ZeVnLIqe-/&U,BTFw- 849 850 5.2. Mailbox Size and Message Status Updates 851 852 At any time, a server can send data that the client did not request. 853 Sometimes, such behavior is REQUIRED. For example, agents other than 854 the server MAY add messages to the mailbox (e.g. new mail delivery), 855 change the flags of message in the mailbox (e.g. simultaneous access 856 to the same mailbox by multiple agents), or even remove messages from 857 the mailbox. A server MUST send mailbox size updates automatically 858 if a mailbox size change is observed during the processing of a 859 command. A server SHOULD send message flag updates automatically, 860 without requiring the client to request such updates explicitly. 861 Special rules exist for server notification of a client about the 862 removal of messages to prevent synchronization errors; see the 863 description of the EXPUNGE response for more detail. 864 865 Regardless of what implementation decisions a client makes on 866 remembering data from the server, a client implementation MUST record 867 mailbox size updates. It MUST NOT assume that any command after 868 initial mailbox selection will return the size of the mailbox. 869 870 5.3. Response when no Command in Progress 871 872 Server implementations are permitted to send an untagged response 873 (except for EXPUNGE) while there is no command in progress. Server 874 implementations that send such responses MUST deal with flow control 875 considerations. Specifically, they MUST either (1) verify that the 876 size of the data does not exceed the underlying transport's available 877 window size, or (2) use non-blocking writes. 878 879 5.4. Autologout Timer 880 881 If a server has an inactivity autologout timer, that timer MUST be of 882 at least 30 minutes' duration. The receipt of ANY command from the 883 client during that interval SHOULD suffice to reset the autologout 884 timer. 885 886 887 888 889 890 891 892 893 894 895 896 897 898 Crispin Standards Track [Page 16] 899 900 RFC 2060 IMAP4rev1 December 1996 901 902 903 5.5. Multiple Commands in Progress 904 905 The client MAY send another command without waiting for the 906 completion result response of a command, subject to ambiguity rules 907 (see below) and flow control constraints on the underlying data 908 stream. Similarly, a server MAY begin processing another command 909 before processing the current command to completion, subject to 910 ambiguity rules. However, any command continuation request responses 911 and command continuations MUST be negotiated before any subsequent 912 command is initiated. 913 914 The exception is if an ambiguity would result because of a command 915 that would affect the results of other commands. Clients MUST NOT 916 send multiple commands without waiting if an ambiguity would result. 917 If the server detects a possible ambiguity, it MUST execute commands 918 to completion in the order given by the client. 919 920 The most obvious example of ambiguity is when a command would affect 921 the results of another command; for example, a FETCH of a message's 922 flags and a STORE of that same message's flags. 923 924 A non-obvious ambiguity occurs with commands that permit an untagged 925 EXPUNGE response (commands other than FETCH, STORE, and SEARCH), 926 since an untagged EXPUNGE response can invalidate sequence numbers in 927 a subsequent command. This is not a problem for FETCH, STORE, or 928 SEARCH commands because servers are prohibited from sending EXPUNGE 929 responses while any of those commands are in progress. Therefore, if 930 the client sends any command other than FETCH, STORE, or SEARCH, it 931 MUST wait for a response before sending a command with message 932 sequence numbers. 933 934 For example, the following non-waiting command sequences are invalid: 935 936 FETCH + NOOP + STORE 937 STORE + COPY + FETCH 938 COPY + COPY 939 CHECK + FETCH 940 941 The following are examples of valid non-waiting command sequences: 942 943 FETCH + STORE + SEARCH + CHECK 944 STORE + COPY + EXPUNGE 945 946 6. Client Commands 947 948 IMAP4rev1 commands are described in this section. Commands are 949 organized by the state in which the command is permitted. Commands 950 which are permitted in multiple states are listed in the minimum 951 952 953 954 Crispin Standards Track [Page 17] 955 956 RFC 2060 IMAP4rev1 December 1996 957 958 959 permitted state (for example, commands valid in authenticated and 960 selected state are listed in the authenticated state commands). 961 962 Command arguments, identified by "Arguments:" in the command 963 descriptions below, are described by function, not by syntax. The 964 precise syntax of command arguments is described in the Formal Syntax 965 section. 966 967 Some commands cause specific server responses to be returned; these 968 are identified by "Responses:" in the command descriptions below. 969 See the response descriptions in the Responses section for 970 information on these responses, and the Formal Syntax section for the 971 precise syntax of these responses. It is possible for server data to 972 be transmitted as a result of any command; thus, commands that do not 973 specifically require server data specify "no specific responses for 974 this command" instead of "none". 975 976 The "Result:" in the command description refers to the possible 977 tagged status responses to a command, and any special interpretation 978 of these status responses. 979 980 6.1. Client Commands - Any State 981 982 The following commands are valid in any state: CAPABILITY, NOOP, and 983 LOGOUT. 984 985 6.1.1. CAPABILITY Command 986 987 Arguments: none 988 989 Responses: REQUIRED untagged response: CAPABILITY 990 991 Result: OK - capability completed 992 BAD - command unknown or arguments invalid 993 994 The CAPABILITY command requests a listing of capabilities that the 995 server supports. The server MUST send a single untagged 996 CAPABILITY response with "IMAP4rev1" as one of the listed 997 capabilities before the (tagged) OK response. This listing of 998 capabilities is not dependent upon connection state or user. It 999 is therefore not necessary to issue a CAPABILITY command more than 1000 once in a connection. 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 Crispin Standards Track [Page 18] 1011 1012 RFC 2060 IMAP4rev1 December 1996 1013 1014 1015 A capability name which begins with "AUTH=" indicates that the 1016 server supports that particular authentication mechanism. All 1017 such names are, by definition, part of this specification. For 1018 example, the authorization capability for an experimental 1019 "blurdybloop" authenticator would be "AUTH=XBLURDYBLOOP" and not 1020 "XAUTH=BLURDYBLOOP" or "XAUTH=XBLURDYBLOOP". 1021 1022 Other capability names refer to extensions, revisions, or 1023 amendments to this specification. See the documentation of the 1024 CAPABILITY response for additional information. No capabilities, 1025 beyond the base IMAP4rev1 set defined in this specification, are 1026 enabled without explicit client action to invoke the capability. 1027 1028 See the section entitled "Client Commands - 1029 Experimental/Expansion" for information about the form of site or 1030 implementation-specific capabilities. 1031 1032 Example: C: abcd CAPABILITY 1033 S: * CAPABILITY IMAP4rev1 AUTH=KERBEROS_V4 1034 S: abcd OK CAPABILITY completed 1035 1036 6.1.2. NOOP Command 1037 1038 Arguments: none 1039 1040 Responses: no specific responses for this command (but see below) 1041 1042 Result: OK - noop completed 1043 BAD - command unknown or arguments invalid 1044 1045 The NOOP command always succeeds. It does nothing. 1046 1047 Since any command can return a status update as untagged data, the 1048 NOOP command can be used as a periodic poll for new messages or 1049 message status updates during a period of inactivity. The NOOP 1050 command can also be used to reset any inactivity autologout timer 1051 on the server. 1052 1053 Example: C: a002 NOOP 1054 S: a002 OK NOOP completed 1055 . . . 1056 C: a047 NOOP 1057 S: * 22 EXPUNGE 1058 S: * 23 EXISTS 1059 S: * 3 RECENT 1060 S: * 14 FETCH (FLAGS (\Seen \Deleted)) 1061 S: a047 OK NOOP completed 1062 1063 1064 1065 1066 Crispin Standards Track [Page 19] 1067 1068 RFC 2060 IMAP4rev1 December 1996 1069 1070 1071 6.1.3. LOGOUT Command 1072 1073 Arguments: none 1074 1075 Responses: REQUIRED untagged response: BYE 1076 1077 Result: OK - logout completed 1078 BAD - command unknown or arguments invalid 1079 1080 The LOGOUT command informs the server that the client is done with 1081 the connection. The server MUST send a BYE untagged response 1082 before the (tagged) OK response, and then close the network 1083 connection. 1084 1085 Example: C: A023 LOGOUT 1086 S: * BYE IMAP4rev1 Server logging out 1087 S: A023 OK LOGOUT completed 1088 (Server and client then close the connection) 1089 1090 6.2. Client Commands - Non-Authenticated State 1091 1092 In non-authenticated state, the AUTHENTICATE or LOGIN command 1093 establishes authentication and enter authenticated state. The 1094 AUTHENTICATE command provides a general mechanism for a variety of 1095 authentication techniques, whereas the LOGIN command uses the 1096 traditional user name and plaintext password pair. 1097 1098 Server implementations MAY allow non-authenticated access to certain 1099 mailboxes. The convention is to use a LOGIN command with the userid 1100 "anonymous". A password is REQUIRED. It is implementation-dependent 1101 what requirements, if any, are placed on the password and what access 1102 restrictions are placed on anonymous users. 1103 1104 Once authenticated (including as anonymous), it is not possible to 1105 re-enter non-authenticated state. 1106 1107 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 1108 the following commands are valid in non-authenticated state: 1109 AUTHENTICATE and LOGIN. 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 Crispin Standards Track [Page 20] 1123 1124 RFC 2060 IMAP4rev1 December 1996 1125 1126 1127 6.2.1. AUTHENTICATE Command 1128 1129 Arguments: authentication mechanism name 1130 1131 Responses: continuation data can be requested 1132 1133 Result: OK - authenticate completed, now in authenticated state 1134 NO - authenticate failure: unsupported authentication 1135 mechanism, credentials rejected 1136 BAD - command unknown or arguments invalid, 1137 authentication exchange cancelled 1138 1139 The AUTHENTICATE command indicates an authentication mechanism, 1140 such as described in [IMAP-AUTH], to the server. If the server 1141 supports the requested authentication mechanism, it performs an 1142 authentication protocol exchange to authenticate and identify the 1143 client. It MAY also negotiate an OPTIONAL protection mechanism 1144 for subsequent protocol interactions. If the requested 1145 authentication mechanism is not supported, the server SHOULD 1146 reject the AUTHENTICATE command by sending a tagged NO response. 1147 1148 The authentication protocol exchange consists of a series of 1149 server challenges and client answers that are specific to the 1150 authentication mechanism. A server challenge consists of a 1151 command continuation request response with the "+" token followed 1152 by a BASE64 encoded string. The client answer consists of a line 1153 consisting of a BASE64 encoded string. If the client wishes to 1154 cancel an authentication exchange, it issues a line with a single 1155 "*". If the server receives such an answer, it MUST reject the 1156 AUTHENTICATE command by sending a tagged BAD response. 1157 1158 A protection mechanism provides integrity and privacy protection 1159 to the connection. If a protection mechanism is negotiated, it is 1160 applied to all subsequent data sent over the connection. The 1161 protection mechanism takes effect immediately following the CRLF 1162 that concludes the authentication exchange for the client, and the 1163 CRLF of the tagged OK response for the server. Once the 1164 protection mechanism is in effect, the stream of command and 1165 response octets is processed into buffers of ciphertext. Each 1166 buffer is transferred over the connection as a stream of octets 1167 prepended with a four octet field in network byte order that 1168 represents the length of the following data. The maximum 1169 ciphertext buffer length is defined by the protection mechanism. 1170 1171 Authentication mechanisms are OPTIONAL. Protection mechanisms are 1172 also OPTIONAL; an authentication mechanism MAY be implemented 1173 without any protection mechanism. If an AUTHENTICATE command 1174 fails with a NO response, the client MAY try another 1175 1176 1177 1178 Crispin Standards Track [Page 21] 1179 1180 RFC 2060 IMAP4rev1 December 1996 1181 1182 1183 authentication mechanism by issuing another AUTHENTICATE command, 1184 or MAY attempt to authenticate by using the LOGIN command. In 1185 other words, the client MAY request authentication types in 1186 decreasing order of preference, with the LOGIN command as a last 1187 resort. 1188 1189 Example: S: * OK KerberosV4 IMAP4rev1 Server 1190 C: A001 AUTHENTICATE KERBEROS_V4 1191 S: + AmFYig== 1192 C: BAcAQU5EUkVXLkNNVS5FRFUAOCAsho84kLN3/IJmrMG+25a4DT 1193 +nZImJjnTNHJUtxAA+o0KPKfHEcAFs9a3CL5Oebe/ydHJUwYFd 1194 WwuQ1MWiy6IesKvjL5rL9WjXUb9MwT9bpObYLGOKi1Qh 1195 S: + or//EoAADZI= 1196 C: DiAF5A4gA+oOIALuBkAAmw== 1197 S: A001 OK Kerberos V4 authentication successful 1198 1199 Note: the line breaks in the first client answer are for editorial 1200 clarity and are not in real authenticators. 1201 1202 6.2.2. LOGIN Command 1203 1204 Arguments: user name 1205 password 1206 1207 Responses: no specific responses for this command 1208 1209 Result: OK - login completed, now in authenticated state 1210 NO - login failure: user name or password rejected 1211 BAD - command unknown or arguments invalid 1212 1213 The LOGIN command identifies the client to the server and carries 1214 the plaintext password authenticating this user. 1215 1216 Example: C: a001 LOGIN SMITH SESAME 1217 S: a001 OK LOGIN completed 1218 1219 6.3. Client Commands - Authenticated State 1220 1221 In authenticated state, commands that manipulate mailboxes as atomic 1222 entities are permitted. Of these commands, the SELECT and EXAMINE 1223 commands will select a mailbox for access and enter selected state. 1224 1225 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 1226 the following commands are valid in authenticated state: SELECT, 1227 EXAMINE, CREATE, DELETE, RENAME, SUBSCRIBE, UNSUBSCRIBE, LIST, LSUB, 1228 STATUS, and APPEND. 1229 1230 1231 1232 1233 1234 Crispin Standards Track [Page 22] 1235 1236 RFC 2060 IMAP4rev1 December 1996 1237 1238 1239 6.3.1. SELECT Command 1240 1241 Arguments: mailbox name 1242 1243 Responses: REQUIRED untagged responses: FLAGS, EXISTS, RECENT 1244 OPTIONAL OK untagged responses: UNSEEN, PERMANENTFLAGS 1245 1246 Result: OK - select completed, now in selected state 1247 NO - select failure, now in authenticated state: no 1248 such mailbox, can't access mailbox 1249 BAD - command unknown or arguments invalid 1250 1251 The SELECT command selects a mailbox so that messages in the 1252 mailbox can be accessed. Before returning an OK to the client, 1253 the server MUST send the following untagged data to the client: 1254 1255 FLAGS Defined flags in the mailbox. See the description 1256 of the FLAGS response for more detail. 1257 1258 <n> EXISTS The number of messages in the mailbox. See the 1259 description of the EXISTS response for more detail. 1260 1261 <n> RECENT The number of messages with the \Recent flag set. 1262 See the description of the RECENT response for more 1263 detail. 1264 1265 OK [UIDVALIDITY <n>] 1266 The unique identifier validity value. See the 1267 description of the UID command for more detail. 1268 1269 to define the initial state of the mailbox at the client. 1270 1271 The server SHOULD also send an UNSEEN response code in an OK 1272 untagged response, indicating the message sequence number of the 1273 first unseen message in the mailbox. 1274 1275 If the client can not change the permanent state of one or more of 1276 the flags listed in the FLAGS untagged response, the server SHOULD 1277 send a PERMANENTFLAGS response code in an OK untagged response, 1278 listing the flags that the client can change permanently. 1279 1280 Only one mailbox can be selected at a time in a connection; 1281 simultaneous access to multiple mailboxes requires multiple 1282 connections. The SELECT command automatically deselects any 1283 currently selected mailbox before attempting the new selection. 1284 Consequently, if a mailbox is selected and a SELECT command that 1285 fails is attempted, no mailbox is selected. 1286 1287 1288 1289 1290 Crispin Standards Track [Page 23] 1291 1292 RFC 2060 IMAP4rev1 December 1996 1293 1294 1295 If the client is permitted to modify the mailbox, the server 1296 SHOULD prefix the text of the tagged OK response with the 1297 "[READ-WRITE]" response code. 1298 1299 If the client is not permitted to modify the mailbox but is 1300 permitted read access, the mailbox is selected as read-only, and 1301 the server MUST prefix the text of the tagged OK response to 1302 SELECT with the "[READ-ONLY]" response code. Read-only access 1303 through SELECT differs from the EXAMINE command in that certain 1304 read-only mailboxes MAY permit the change of permanent state on a 1305 per-user (as opposed to global) basis. Netnews messages marked in 1306 a server-based .newsrc file are an example of such per-user 1307 permanent state that can be modified with read-only mailboxes. 1308 1309 Example: C: A142 SELECT INBOX 1310 S: * 172 EXISTS 1311 S: * 1 RECENT 1312 S: * OK [UNSEEN 12] Message 12 is first unseen 1313 S: * OK [UIDVALIDITY 3857529045] UIDs valid 1314 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1315 S: * OK [PERMANENTFLAGS (\Deleted \Seen \*)] Limited 1316 S: A142 OK [READ-WRITE] SELECT completed 1317 1318 6.3.2. EXAMINE Command 1319 1320 Arguments: mailbox name 1321 1322 Responses: REQUIRED untagged responses: FLAGS, EXISTS, RECENT 1323 OPTIONAL OK untagged responses: UNSEEN, PERMANENTFLAGS 1324 1325 Result: OK - examine completed, now in selected state 1326 NO - examine failure, now in authenticated state: no 1327 such mailbox, can't access mailbox 1328 BAD - command unknown or arguments invalid 1329 1330 The EXAMINE command is identical to SELECT and returns the same 1331 output; however, the selected mailbox is identified as read-only. 1332 No changes to the permanent state of the mailbox, including 1333 per-user state, are permitted. 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 Crispin Standards Track [Page 24] 1347 1348 RFC 2060 IMAP4rev1 December 1996 1349 1350 1351 The text of the tagged OK response to the EXAMINE command MUST 1352 begin with the "[READ-ONLY]" response code. 1353 1354 Example: C: A932 EXAMINE blurdybloop 1355 S: * 17 EXISTS 1356 S: * 2 RECENT 1357 S: * OK [UNSEEN 8] Message 8 is first unseen 1358 S: * OK [UIDVALIDITY 3857529045] UIDs valid 1359 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 1360 S: * OK [PERMANENTFLAGS ()] No permanent flags permitted 1361 S: A932 OK [READ-ONLY] EXAMINE completed 1362 1363 6.3.3. CREATE Command 1364 1365 Arguments: mailbox name 1366 1367 Responses: no specific responses for this command 1368 1369 Result: OK - create completed 1370 NO - create failure: can't create mailbox with that name 1371 BAD - command unknown or arguments invalid 1372 1373 The CREATE command creates a mailbox with the given name. An OK 1374 response is returned only if a new mailbox with that name has been 1375 created. It is an error to attempt to create INBOX or a mailbox 1376 with a name that refers to an extant mailbox. Any error in 1377 creation will return a tagged NO response. 1378 1379 If the mailbox name is suffixed with the server's hierarchy 1380 separator character (as returned from the server by a LIST 1381 command), this is a declaration that the client intends to create 1382 mailbox names under this name in the hierarchy. Server 1383 implementations that do not require this declaration MUST ignore 1384 it. 1385 1386 If the server's hierarchy separator character appears elsewhere in 1387 the name, the server SHOULD create any superior hierarchical names 1388 that are needed for the CREATE command to complete successfully. 1389 In other words, an attempt to create "foo/bar/zap" on a server in 1390 which "/" is the hierarchy separator character SHOULD create foo/ 1391 and foo/bar/ if they do not already exist. 1392 1393 If a new mailbox is created with the same name as a mailbox which 1394 was deleted, its unique identifiers MUST be greater than any 1395 unique identifiers used in the previous incarnation of the mailbox 1396 UNLESS the new incarnation has a different unique identifier 1397 validity value. See the description of the UID command for more 1398 detail. 1399 1400 1401 1402 Crispin Standards Track [Page 25] 1403 1404 RFC 2060 IMAP4rev1 December 1996 1405 1406 1407 Example: C: A003 CREATE owatagusiam/ 1408 S: A003 OK CREATE completed 1409 C: A004 CREATE owatagusiam/blurdybloop 1410 S: A004 OK CREATE completed 1411 1412 Note: the interpretation of this example depends on whether "/" 1413 was returned as the hierarchy separator from LIST. If "/" is the 1414 hierarchy separator, a new level of hierarchy named "owatagusiam" 1415 with a member called "blurdybloop" is created. Otherwise, two 1416 mailboxes at the same hierarchy level are created. 1417 1418 6.3.4. DELETE Command 1419 1420 Arguments: mailbox name 1421 1422 Responses: no specific responses for this command 1423 1424 Result: OK - delete completed 1425 NO - delete failure: can't delete mailbox with that name 1426 BAD - command unknown or arguments invalid 1427 1428 The DELETE command permanently removes the mailbox with the given 1429 name. A tagged OK response is returned only if the mailbox has 1430 been deleted. It is an error to attempt to delete INBOX or a 1431 mailbox name that does not exist. 1432 1433 The DELETE command MUST NOT remove inferior hierarchical names. 1434 For example, if a mailbox "foo" has an inferior "foo.bar" 1435 (assuming "." is the hierarchy delimiter character), removing 1436 "foo" MUST NOT remove "foo.bar". It is an error to attempt to 1437 delete a name that has inferior hierarchical names and also has 1438 the \Noselect mailbox name attribute (see the description of the 1439 LIST response for more details). 1440 1441 It is permitted to delete a name that has inferior hierarchical 1442 names and does not have the \Noselect mailbox name attribute. In 1443 this case, all messages in that mailbox are removed, and the name 1444 will acquire the \Noselect mailbox name attribute. 1445 1446 The value of the highest-used unique identifier of the deleted 1447 mailbox MUST be preserved so that a new mailbox created with the 1448 same name will not reuse the identifiers of the former 1449 incarnation, UNLESS the new incarnation has a different unique 1450 identifier validity value. See the description of the UID command 1451 for more detail. 1452 1453 1454 1455 1456 1457 1458 Crispin Standards Track [Page 26] 1459 1460 RFC 2060 IMAP4rev1 December 1996 1461 1462 1463 Examples: C: A682 LIST "" * 1464 S: * LIST () "/" blurdybloop 1465 S: * LIST (\Noselect) "/" foo 1466 S: * LIST () "/" foo/bar 1467 S: A682 OK LIST completed 1468 C: A683 DELETE blurdybloop 1469 S: A683 OK DELETE completed 1470 C: A684 DELETE foo 1471 S: A684 NO Name "foo" has inferior hierarchical names 1472 C: A685 DELETE foo/bar 1473 S: A685 OK DELETE Completed 1474 C: A686 LIST "" * 1475 S: * LIST (\Noselect) "/" foo 1476 S: A686 OK LIST completed 1477 C: A687 DELETE foo 1478 S: A687 OK DELETE Completed 1479 1480 1481 C: A82 LIST "" * 1482 S: * LIST () "." blurdybloop 1483 S: * LIST () "." foo 1484 S: * LIST () "." foo.bar 1485 S: A82 OK LIST completed 1486 C: A83 DELETE blurdybloop 1487 S: A83 OK DELETE completed 1488 C: A84 DELETE foo 1489 S: A84 OK DELETE Completed 1490 C: A85 LIST "" * 1491 S: * LIST () "." foo.bar 1492 S: A85 OK LIST completed 1493 C: A86 LIST "" % 1494 S: * LIST (\Noselect) "." foo 1495 S: A86 OK LIST completed 1496 1497 6.3.5. RENAME Command 1498 1499 Arguments: existing mailbox name 1500 new mailbox name 1501 1502 Responses: no specific responses for this command 1503 1504 Result: OK - rename completed 1505 NO - rename failure: can't rename mailbox with that name, 1506 can't rename to mailbox with that name 1507 BAD - command unknown or arguments invalid 1508 1509 The RENAME command changes the name of a mailbox. A tagged OK 1510 response is returned only if the mailbox has been renamed. It is 1511 1512 1513 1514 Crispin Standards Track [Page 27] 1515 1516 RFC 2060 IMAP4rev1 December 1996 1517 1518 1519 an error to attempt to rename from a mailbox name that does not 1520 exist or to a mailbox name that already exists. Any error in 1521 renaming will return a tagged NO response. 1522 1523 If the name has inferior hierarchical names, then the inferior 1524 hierarchical names MUST also be renamed. For example, a rename of 1525 "foo" to "zap" will rename "foo/bar" (assuming "/" is the 1526 hierarchy delimiter character) to "zap/bar". 1527 1528 The value of the highest-used unique identifier of the old mailbox 1529 name MUST be preserved so that a new mailbox created with the same 1530 name will not reuse the identifiers of the former incarnation, 1531 UNLESS the new incarnation has a different unique identifier 1532 validity value. See the description of the UID command for more 1533 detail. 1534 1535 Renaming INBOX is permitted, and has special behavior. It moves 1536 all messages in INBOX to a new mailbox with the given name, 1537 leaving INBOX empty. If the server implementation supports 1538 inferior hierarchical names of INBOX, these are unaffected by a 1539 rename of INBOX. 1540 1541 Examples: C: A682 LIST "" * 1542 S: * LIST () "/" blurdybloop 1543 S: * LIST (\Noselect) "/" foo 1544 S: * LIST () "/" foo/bar 1545 S: A682 OK LIST completed 1546 C: A683 RENAME blurdybloop sarasoop 1547 S: A683 OK RENAME completed 1548 C: A684 RENAME foo zowie 1549 S: A684 OK RENAME Completed 1550 C: A685 LIST "" * 1551 S: * LIST () "/" sarasoop 1552 S: * LIST (\Noselect) "/" zowie 1553 S: * LIST () "/" zowie/bar 1554 S: A685 OK LIST completed 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 Crispin Standards Track [Page 28] 1571 1572 RFC 2060 IMAP4rev1 December 1996 1573 1574 1575 C: Z432 LIST "" * 1576 S: * LIST () "." INBOX 1577 S: * LIST () "." INBOX.bar 1578 S: Z432 OK LIST completed 1579 C: Z433 RENAME INBOX old-mail 1580 S: Z433 OK RENAME completed 1581 C: Z434 LIST "" * 1582 S: * LIST () "." INBOX 1583 S: * LIST () "." INBOX.bar 1584 S: * LIST () "." old-mail 1585 S: Z434 OK LIST completed 1586 1587 6.3.6. SUBSCRIBE Command 1588 1589 Arguments: mailbox 1590 1591 Responses: no specific responses for this command 1592 1593 Result: OK - subscribe completed 1594 NO - subscribe failure: can't subscribe to that name 1595 BAD - command unknown or arguments invalid 1596 1597 The SUBSCRIBE command adds the specified mailbox name to the 1598 server's set of "active" or "subscribed" mailboxes as returned by 1599 the LSUB command. This command returns a tagged OK response only 1600 if the subscription is successful. 1601 1602 A server MAY validate the mailbox argument to SUBSCRIBE to verify 1603 that it exists. However, it MUST NOT unilaterally remove an 1604 existing mailbox name from the subscription list even if a mailbox 1605 by that name no longer exists. 1606 1607 Note: this requirement is because some server sites may routinely 1608 remove a mailbox with a well-known name (e.g. "system-alerts") 1609 after its contents expire, with the intention of recreating it 1610 when new contents are appropriate. 1611 1612 Example: C: A002 SUBSCRIBE #news.comp.mail.mime 1613 S: A002 OK SUBSCRIBE completed 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 Crispin Standards Track [Page 29] 1627 1628 RFC 2060 IMAP4rev1 December 1996 1629 1630 1631 6.3.7. UNSUBSCRIBE Command 1632 1633 Arguments: mailbox name 1634 1635 Responses: no specific responses for this command 1636 1637 Result: OK - unsubscribe completed 1638 NO - unsubscribe failure: can't unsubscribe that name 1639 BAD - command unknown or arguments invalid 1640 1641 The UNSUBSCRIBE command removes the specified mailbox name from 1642 the server's set of "active" or "subscribed" mailboxes as returned 1643 by the LSUB command. This command returns a tagged OK response 1644 only if the unsubscription is successful. 1645 1646 Example: C: A002 UNSUBSCRIBE #news.comp.mail.mime 1647 S: A002 OK UNSUBSCRIBE completed 1648 1649 6.3..8. LIST Command 1650 1651 Arguments: reference name 1652 mailbox name with possible wildcards 1653 1654 Responses: untagged responses: LIST 1655 1656 Result: OK - list completed 1657 NO - list failure: can't list that reference or name 1658 BAD - command unknown or arguments invalid 1659 1660 The LIST command returns a subset of names from the complete set 1661 of all names available to the client. Zero or more untagged LIST 1662 replies are returned, containing the name attributes, hierarchy 1663 delimiter, and name; see the description of the LIST reply for 1664 more detail. 1665 1666 The LIST command SHOULD return its data quickly, without undue 1667 delay. For example, it SHOULD NOT go to excess trouble to 1668 calculate \Marked or \Unmarked status or perform other processing; 1669 if each name requires 1 second of processing, then a list of 1200 1670 names would take 20 minutes! 1671 1672 An empty ("" string) reference name argument indicates that the 1673 mailbox name is interpreted as by SELECT. The returned mailbox 1674 names MUST match the supplied mailbox name pattern. A non-empty 1675 reference name argument is the name of a mailbox or a level of 1676 mailbox hierarchy, and indicates a context in which the mailbox 1677 name is interpreted in an implementation-defined manner. 1678 1679 1680 1681 1682 Crispin Standards Track [Page 30] 1683 1684 RFC 2060 IMAP4rev1 December 1996 1685 1686 1687 An empty ("" string) mailbox name argument is a special request to 1688 return the hierarchy delimiter and the root name of the name given 1689 in the reference. The value returned as the root MAY be null if 1690 the reference is non-rooted or is null. In all cases, the 1691 hierarchy delimiter is returned. This permits a client to get the 1692 hierarchy delimiter even when no mailboxes by that name currently 1693 exist. 1694 1695 The reference and mailbox name arguments are interpreted, in an 1696 implementation-dependent fashion, into a canonical form that 1697 represents an unambiguous left-to-right hierarchy. The returned 1698 mailbox names will be in the interpreted form. 1699 1700 Any part of the reference argument that is included in the 1701 interpreted form SHOULD prefix the interpreted form. It SHOULD 1702 also be in the same form as the reference name argument. This 1703 rule permits the client to determine if the returned mailbox name 1704 is in the context of the reference argument, or if something about 1705 the mailbox argument overrode the reference argument. Without 1706 this rule, the client would have to have knowledge of the server's 1707 naming semantics including what characters are "breakouts" that 1708 override a naming context. 1709 1710 For example, here are some examples of how references and mailbox 1711 names might be interpreted on a UNIX-based server: 1712 1713 Reference Mailbox Name Interpretation 1714 ------------ ------------ -------------- 1715 ~smith/Mail/ foo.* ~smith/Mail/foo.* 1716 archive/ % archive/% 1717 #news. comp.mail.* #news.comp.mail.* 1718 ~smith/Mail/ /usr/doc/foo /usr/doc/foo 1719 archive/ ~fred/Mail/* ~fred/Mail/* 1720 1721 The first three examples demonstrate interpretations in the 1722 context of the reference argument. Note that "~smith/Mail" SHOULD 1723 NOT be transformed into something like "/u2/users/smith/Mail", or 1724 it would be impossible for the client to determine that the 1725 interpretation was in the context of the reference. 1726 1727 The character "*" is a wildcard, and matches zero or more 1728 characters at this position. The character "%" is similar to "*", 1729 but it does not match a hierarchy delimiter. If the "%" wildcard 1730 is the last character of a mailbox name argument, matching levels 1731 of hierarchy are also returned. If these levels of hierarchy are 1732 not also selectable mailboxes, they are returned with the 1733 \Noselect mailbox name attribute (see the description of the LIST 1734 response for more details). 1735 1736 1737 1738 Crispin Standards Track [Page 31] 1739 1740 RFC 2060 IMAP4rev1 December 1996 1741 1742 1743 Server implementations are permitted to "hide" otherwise 1744 accessible mailboxes from the wildcard characters, by preventing 1745 certain characters or names from matching a wildcard in certain 1746 situations. For example, a UNIX-based server might restrict the 1747 interpretation of "*" so that an initial "/" character does not 1748 match. 1749 1750 The special name INBOX is included in the output from LIST, if 1751 INBOX is supported by this server for this user and if the 1752 uppercase string "INBOX" matches the interpreted reference and 1753 mailbox name arguments with wildcards as described above. The 1754 criteria for omitting INBOX is whether SELECT INBOX will return 1755 failure; it is not relevant whether the user's real INBOX resides 1756 on this or some other server. 1757 1758 Example: C: A101 LIST "" "" 1759 S: * LIST (\Noselect) "/" "" 1760 S: A101 OK LIST Completed 1761 C: A102 LIST #news.comp.mail.misc "" 1762 S: * LIST (\Noselect) "." #news. 1763 S: A102 OK LIST Completed 1764 C: A103 LIST /usr/staff/jones "" 1765 S: * LIST (\Noselect) "/" / 1766 S: A103 OK LIST Completed 1767 C: A202 LIST ~/Mail/ % 1768 S: * LIST (\Noselect) "/" ~/Mail/foo 1769 S: * LIST () "/" ~/Mail/meetings 1770 S: A202 OK LIST completed 1771 1772 6.3.9. LSUB Command 1773 1774 Arguments: reference name 1775 mailbox name with possible wildcards 1776 1777 Responses: untagged responses: LSUB 1778 1779 Result: OK - lsub completed 1780 NO - lsub failure: can't list that reference or name 1781 BAD - command unknown or arguments invalid 1782 1783 The LSUB command returns a subset of names from the set of names 1784 that the user has declared as being "active" or "subscribed". 1785 Zero or more untagged LSUB replies are returned. The arguments to 1786 LSUB are in the same form as those for LIST. 1787 1788 A server MAY validate the subscribed names to see if they still 1789 exist. If a name does not exist, it SHOULD be flagged with the 1790 \Noselect attribute in the LSUB response. The server MUST NOT 1791 1792 1793 1794 Crispin Standards Track [Page 32] 1795 1796 RFC 2060 IMAP4rev1 December 1996 1797 1798 1799 unilaterally remove an existing mailbox name from the subscription 1800 list even if a mailbox by that name no longer exists. 1801 1802 Example: C: A002 LSUB "#news." "comp.mail.*" 1803 S: * LSUB () "." #news.comp.mail.mime 1804 S: * LSUB () "." #news.comp.mail.misc 1805 S: A002 OK LSUB completed 1806 1807 6.3.10. STATUS Command 1808 1809 Arguments: mailbox name 1810 status data item names 1811 1812 Responses: untagged responses: STATUS 1813 1814 Result: OK - status completed 1815 NO - status failure: no status for that name 1816 BAD - command unknown or arguments invalid 1817 1818 The STATUS command requests the status of the indicated mailbox. 1819 It does not change the currently selected mailbox, nor does it 1820 affect the state of any messages in the queried mailbox (in 1821 particular, STATUS MUST NOT cause messages to lose the \Recent 1822 flag). 1823 1824 The STATUS command provides an alternative to opening a second 1825 IMAP4rev1 connection and doing an EXAMINE command on a mailbox to 1826 query that mailbox's status without deselecting the current 1827 mailbox in the first IMAP4rev1 connection. 1828 1829 Unlike the LIST command, the STATUS command is not guaranteed to 1830 be fast in its response. In some implementations, the server is 1831 obliged to open the mailbox read-only internally to obtain certain 1832 status information. Also unlike the LIST command, the STATUS 1833 command does not accept wildcards. 1834 1835 The currently defined status data items that can be requested are: 1836 1837 MESSAGES The number of messages in the mailbox. 1838 1839 RECENT The number of messages with the \Recent flag set. 1840 1841 UIDNEXT The next UID value that will be assigned to a new 1842 message in the mailbox. It is guaranteed that this 1843 value will not change unless new messages are added 1844 to the mailbox; and that it will change when new 1845 messages are added even if those new messages are 1846 subsequently expunged. 1847 1848 1849 1850 Crispin Standards Track [Page 33] 1851 1852 RFC 2060 IMAP4rev1 December 1996 1853 1854 1855 UIDVALIDITY The unique identifier validity value of the 1856 mailbox. 1857 1858 UNSEEN The number of messages which do not have the \Seen 1859 flag set. 1860 1861 1862 Example: C: A042 STATUS blurdybloop (UIDNEXT MESSAGES) 1863 S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) 1864 S: A042 OK STATUS completed 1865 1866 6.3.11. APPEND Command 1867 1868 Arguments: mailbox name 1869 OPTIONAL flag parenthesized list 1870 OPTIONAL date/time string 1871 message literal 1872 1873 Responses: no specific responses for this command 1874 1875 Result: OK - append completed 1876 NO - append error: can't append to that mailbox, error 1877 in flags or date/time or message text 1878 BAD - command unknown or arguments invalid 1879 1880 The APPEND command appends the literal argument as a new message 1881 to the end of the specified destination mailbox. This argument 1882 SHOULD be in the format of an [RFC-822] message. 8-bit characters 1883 are permitted in the message. A server implementation that is 1884 unable to preserve 8-bit data properly MUST be able to reversibly 1885 convert 8-bit APPEND data to 7-bit using a [MIME-IMB] content 1886 transfer encoding. 1887 1888 Note: There MAY be exceptions, e.g. draft messages, in which 1889 required [RFC-822] header lines are omitted in the message literal 1890 argument to APPEND. The full implications of doing so MUST be 1891 understood and carefully weighed. 1892 1893 If a flag parenthesized list is specified, the flags SHOULD be set in 1894 the resulting message; otherwise, the flag list of the resulting 1895 message is set empty by default. 1896 1897 If a date_time is specified, the internal date SHOULD be set in the 1898 resulting message; otherwise, the internal date of the resulting 1899 message is set to the current date and time by default. 1900 1901 1902 1903 1904 1905 1906 Crispin Standards Track [Page 34] 1907 1908 RFC 2060 IMAP4rev1 December 1996 1909 1910 1911 If the append is unsuccessful for any reason, the mailbox MUST be 1912 restored to its state before the APPEND attempt; no partial appending 1913 is permitted. 1914 1915 If the destination mailbox does not exist, a server MUST return an 1916 error, and MUST NOT automatically create the mailbox. Unless it is 1917 certain that the destination mailbox can not be created, the server 1918 MUST send the response code "[TRYCREATE]" as the prefix of the text 1919 of the tagged NO response. This gives a hint to the client that it 1920 can attempt a CREATE command and retry the APPEND if the CREATE is 1921 successful. 1922 1923 If the mailbox is currently selected, the normal new mail actions 1924 SHOULD occur. Specifically, the server SHOULD notify the client 1925 immediately via an untagged EXISTS response. If the server does not 1926 do so, the client MAY issue a NOOP command (or failing that, a CHECK 1927 command) after one or more APPEND commands. 1928 1929 Example: C: A003 APPEND saved-messages (\Seen) {310} 1930 C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST) 1931 C: From: Fred Foobar <foobar@Blurdybloop.COM> 1932 C: Subject: afternoon meeting 1933 C: To: mooch@owatagu.siam.edu 1934 C: Message-Id: <B27397-0100000@Blurdybloop.COM> 1935 C: MIME-Version: 1.0 1936 C: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 1937 C: 1938 C: Hello Joe, do you think we can meet at 3:30 tomorrow? 1939 C: 1940 S: A003 OK APPEND completed 1941 1942 Note: the APPEND command is not used for message delivery, because 1943 it does not provide a mechanism to transfer [SMTP] envelope 1944 information. 1945 1946 6.4. Client Commands - Selected State 1947 1948 In selected state, commands that manipulate messages in a mailbox are 1949 permitted. 1950 1951 In addition to the universal commands (CAPABILITY, NOOP, and LOGOUT), 1952 and the authenticated state commands (SELECT, EXAMINE, CREATE, 1953 DELETE, RENAME, SUBSCRIBE, UNSUBSCRIBE, LIST, LSUB, STATUS, and 1954 APPEND), the following commands are valid in the selected state: 1955 CHECK, CLOSE, EXPUNGE, SEARCH, FETCH, STORE, COPY, and UID. 1956 1957 1958 1959 1960 1961 1962 Crispin Standards Track [Page 35] 1963 1964 RFC 2060 IMAP4rev1 December 1996 1965 1966 1967 6.4.1. CHECK Command 1968 1969 Arguments: none 1970 1971 Responses: no specific responses for this command 1972 1973 Result: OK - check completed 1974 BAD - command unknown or arguments invalid 1975 1976 The CHECK command requests a checkpoint of the currently selected 1977 mailbox. A checkpoint refers to any implementation-dependent 1978 housekeeping associated with the mailbox (e.g. resolving the 1979 server's in-memory state of the mailbox with the state on its 1980 disk) that is not normally executed as part of each command. A 1981 checkpoint MAY take a non-instantaneous amount of real time to 1982 complete. If a server implementation has no such housekeeping 1983 considerations, CHECK is equivalent to NOOP. 1984 1985 There is no guarantee that an EXISTS untagged response will happen 1986 as a result of CHECK. NOOP, not CHECK, SHOULD be used for new 1987 mail polling. 1988 1989 Example: C: FXXZ CHECK 1990 S: FXXZ OK CHECK Completed 1991 1992 6.4.2. CLOSE Command 1993 1994 Arguments: none 1995 1996 Responses: no specific responses for this command 1997 1998 Result: OK - close completed, now in authenticated state 1999 NO - close failure: no mailbox selected 2000 BAD - command unknown or arguments invalid 2001 2002 The CLOSE command permanently removes from the currently selected 2003 mailbox all messages that have the \Deleted flag set, and returns 2004 to authenticated state from selected state. No untagged EXPUNGE 2005 responses are sent. 2006 2007 No messages are removed, and no error is given, if the mailbox is 2008 selected by an EXAMINE command or is otherwise selected read-only. 2009 2010 Even if a mailbox is selected, a SELECT, EXAMINE, or LOGOUT 2011 command MAY be issued without previously issuing a CLOSE command. 2012 The SELECT, EXAMINE, and LOGOUT commands implicitly close the 2013 currently selected mailbox without doing an expunge. However, 2014 when many messages are deleted, a CLOSE-LOGOUT or CLOSE-SELECT 2015 2016 2017 2018 Crispin Standards Track [Page 36] 2019 2020 RFC 2060 IMAP4rev1 December 1996 2021 2022 2023 sequence is considerably faster than an EXPUNGE-LOGOUT or 2024 EXPUNGE-SELECT because no untagged EXPUNGE responses (which the 2025 client would probably ignore) are sent. 2026 2027 Example: C: A341 CLOSE 2028 S: A341 OK CLOSE completed 2029 2030 6.4.3. EXPUNGE Command 2031 2032 Arguments: none 2033 2034 Responses: untagged responses: EXPUNGE 2035 2036 Result: OK - expunge completed 2037 NO - expunge failure: can't expunge (e.g. permission 2038 denied) 2039 BAD - command unknown or arguments invalid 2040 2041 The EXPUNGE command permanently removes from the currently 2042 selected mailbox all messages that have the \Deleted flag set. 2043 Before returning an OK to the client, an untagged EXPUNGE response 2044 is sent for each message that is removed. 2045 2046 Example: C: A202 EXPUNGE 2047 S: * 3 EXPUNGE 2048 S: * 3 EXPUNGE 2049 S: * 5 EXPUNGE 2050 S: * 8 EXPUNGE 2051 S: A202 OK EXPUNGE completed 2052 2053 Note: in this example, messages 3, 4, 7, and 11 had the 2054 \Deleted flag set. See the description of the EXPUNGE 2055 response for further explanation. 2056 2057 6.4.4. SEARCH Command 2058 2059 Arguments: OPTIONAL [CHARSET] specification 2060 searching criteria (one or more) 2061 2062 Responses: REQUIRED untagged response: SEARCH 2063 2064 Result: OK - search completed 2065 NO - search error: can't search that [CHARSET] or 2066 criteria 2067 BAD - command unknown or arguments invalid 2068 2069 2070 2071 2072 2073 2074 Crispin Standards Track [Page 37] 2075 2076 RFC 2060 IMAP4rev1 December 1996 2077 2078 2079 The SEARCH command searches the mailbox for messages that match 2080 the given searching criteria. Searching criteria consist of one 2081 or more search keys. The untagged SEARCH response from the server 2082 contains a listing of message sequence numbers corresponding to 2083 those messages that match the searching criteria. 2084 2085 When multiple keys are specified, the result is the intersection 2086 (AND function) of all the messages that match those keys. For 2087 example, the criteria DELETED FROM "SMITH" SINCE 1-Feb-1994 refers 2088 to all deleted messages from Smith that were placed in the mailbox 2089 since February 1, 1994. A search key can also be a parenthesized 2090 list of one or more search keys (e.g. for use with the OR and NOT 2091 keys). 2092 2093 Server implementations MAY exclude [MIME-IMB] body parts with 2094 terminal content media types other than TEXT and MESSAGE from 2095 consideration in SEARCH matching. 2096 2097 The OPTIONAL [CHARSET] specification consists of the word 2098 "CHARSET" followed by a registered [CHARSET]. It indicates the 2099 [CHARSET] of the strings that appear in the search criteria. 2100 [MIME-IMB] content transfer encodings, and [MIME-HDRS] strings in 2101 [RFC-822]/[MIME-IMB] headers, MUST be decoded before comparing 2102 text in a [CHARSET] other than US-ASCII. US-ASCII MUST be 2103 supported; other [CHARSET]s MAY be supported. If the server does 2104 not support the specified [CHARSET], it MUST return a tagged NO 2105 response (not a BAD). 2106 2107 In all search keys that use strings, a message matches the key if 2108 the string is a substring of the field. The matching is case- 2109 insensitive. 2110 2111 The defined search keys are as follows. Refer to the Formal 2112 Syntax section for the precise syntactic definitions of the 2113 arguments. 2114 2115 <message set> Messages with message sequence numbers 2116 corresponding to the specified message sequence 2117 number set 2118 2119 ALL All messages in the mailbox; the default initial 2120 key for ANDing. 2121 2122 ANSWERED Messages with the \Answered flag set. 2123 2124 BCC <string> Messages that contain the specified string in the 2125 envelope structure's BCC field. 2126 2127 2128 2129 2130 Crispin Standards Track [Page 38] 2131 2132 RFC 2060 IMAP4rev1 December 1996 2133 2134 2135 BEFORE <date> Messages whose internal date is earlier than the 2136 specified date. 2137 2138 BODY <string> Messages that contain the specified string in the 2139 body of the message. 2140 2141 CC <string> Messages that contain the specified string in the 2142 envelope structure's CC field. 2143 2144 DELETED Messages with the \Deleted flag set. 2145 2146 DRAFT Messages with the \Draft flag set. 2147 2148 FLAGGED Messages with the \Flagged flag set. 2149 2150 FROM <string> Messages that contain the specified string in the 2151 envelope structure's FROM field. 2152 2153 HEADER <field-name> <string> 2154 Messages that have a header with the specified 2155 field-name (as defined in [RFC-822]) and that 2156 contains the specified string in the [RFC-822] 2157 field-body. 2158 2159 KEYWORD <flag> Messages with the specified keyword set. 2160 2161 LARGER <n> Messages with an [RFC-822] size larger than the 2162 specified number of octets. 2163 2164 NEW Messages that have the \Recent flag set but not the 2165 \Seen flag. This is functionally equivalent to 2166 "(RECENT UNSEEN)". 2167 2168 NOT <search-key> 2169 Messages that do not match the specified search 2170 key. 2171 2172 OLD Messages that do not have the \Recent flag set. 2173 This is functionally equivalent to "NOT RECENT" (as 2174 opposed to "NOT NEW"). 2175 2176 ON <date> Messages whose internal date is within the 2177 specified date. 2178 2179 OR <search-key1> <search-key2> 2180 Messages that match either search key. 2181 2182 RECENT Messages that have the \Recent flag set. 2183 2184 2185 2186 Crispin Standards Track [Page 39] 2187 2188 RFC 2060 IMAP4rev1 December 1996 2189 2190 2191 SEEN Messages that have the \Seen flag set. 2192 2193 SENTBEFORE <date> 2194 Messages whose [RFC-822] Date: header is earlier 2195 than the specified date. 2196 2197 SENTON <date> Messages whose [RFC-822] Date: header is within the 2198 specified date. 2199 2200 SENTSINCE <date> 2201 Messages whose [RFC-822] Date: header is within or 2202 later than the specified date. 2203 2204 SINCE <date> Messages whose internal date is within or later 2205 than the specified date. 2206 2207 SMALLER <n> Messages with an [RFC-822] size smaller than the 2208 specified number of octets. 2209 2210 SUBJECT <string> 2211 Messages that contain the specified string in the 2212 envelope structure's SUBJECT field. 2213 2214 TEXT <string> Messages that contain the specified string in the 2215 header or body of the message. 2216 2217 TO <string> Messages that contain the specified string in the 2218 envelope structure's TO field. 2219 2220 UID <message set> 2221 Messages with unique identifiers corresponding to 2222 the specified unique identifier set. 2223 2224 UNANSWERED Messages that do not have the \Answered flag set. 2225 2226 UNDELETED Messages that do not have the \Deleted flag set. 2227 2228 UNDRAFT Messages that do not have the \Draft flag set. 2229 2230 UNFLAGGED Messages that do not have the \Flagged flag set. 2231 2232 UNKEYWORD <flag> 2233 Messages that do not have the specified keyword 2234 set. 2235 2236 UNSEEN Messages that do not have the \Seen flag set. 2237 2238 2239 2240 2241 2242 Crispin Standards Track [Page 40] 2243 2244 RFC 2060 IMAP4rev1 December 1996 2245 2246 2247 Example: C: A282 SEARCH FLAGGED SINCE 1-Feb-1994 NOT FROM "Smith" 2248 S: * SEARCH 2 84 882 2249 S: A282 OK SEARCH completed 2250 2251 6.4.5. FETCH Command 2252 2253 Arguments: message set 2254 message data item names 2255 2256 Responses: untagged responses: FETCH 2257 2258 Result: OK - fetch completed 2259 NO - fetch error: can't fetch that data 2260 BAD - command unknown or arguments invalid 2261 2262 The FETCH command retrieves data associated with a message in the 2263 mailbox. The data items to be fetched can be either a single atom 2264 or a parenthesized list. 2265 2266 The currently defined data items that can be fetched are: 2267 2268 ALL Macro equivalent to: (FLAGS INTERNALDATE 2269 RFC822.SIZE ENVELOPE) 2270 2271 BODY Non-extensible form of BODYSTRUCTURE. 2272 2273 BODY[<section>]<<partial>> 2274 The text of a particular body section. The section 2275 specification is a set of zero or more part 2276 specifiers delimited by periods. A part specifier 2277 is either a part number or one of the following: 2278 HEADER, HEADER.FIELDS, HEADER.FIELDS.NOT, MIME, and 2279 TEXT. An empty section specification refers to the 2280 entire message, including the header. 2281 2282 Every message has at least one part number. 2283 Non-[MIME-IMB] messages, and non-multipart 2284 [MIME-IMB] messages with no encapsulated message, 2285 only have a part 1. 2286 2287 Multipart messages are assigned consecutive part 2288 numbers, as they occur in the message. If a 2289 particular part is of type message or multipart, 2290 its parts MUST be indicated by a period followed by 2291 the part number within that nested multipart part. 2292 2293 2294 2295 2296 2297 2298 Crispin Standards Track [Page 41] 2299 2300 RFC 2060 IMAP4rev1 December 1996 2301 2302 2303 A part of type MESSAGE/RFC822 also has nested part 2304 numbers, referring to parts of the MESSAGE part's 2305 body. 2306 2307 The HEADER, HEADER.FIELDS, HEADER.FIELDS.NOT, and 2308 TEXT part specifiers can be the sole part specifier 2309 or can be prefixed by one or more numeric part 2310 specifiers, provided that the numeric part 2311 specifier refers to a part of type MESSAGE/RFC822. 2312 The MIME part specifier MUST be prefixed by one or 2313 more numeric part specifiers. 2314 2315 The HEADER, HEADER.FIELDS, and HEADER.FIELDS.NOT 2316 part specifiers refer to the [RFC-822] header of 2317 the message or of an encapsulated [MIME-IMT] 2318 MESSAGE/RFC822 message. HEADER.FIELDS and 2319 HEADER.FIELDS.NOT are followed by a list of 2320 field-name (as defined in [RFC-822]) names, and 2321 return a subset of the header. The subset returned 2322 by HEADER.FIELDS contains only those header fields 2323 with a field-name that matches one of the names in 2324 the list; similarly, the subset returned by 2325 HEADER.FIELDS.NOT contains only the header fields 2326 with a non-matching field-name. The field-matching 2327 is case-insensitive but otherwise exact. In all 2328 cases, the delimiting blank line between the header 2329 and the body is always included. 2330 2331 The MIME part specifier refers to the [MIME-IMB] 2332 header for this part. 2333 2334 The TEXT part specifier refers to the text body of 2335 the message, omitting the [RFC-822] header. 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 Crispin Standards Track [Page 42] 2355 2356 RFC 2060 IMAP4rev1 December 1996 2357 2358 2359 Here is an example of a complex message 2360 with some of its part specifiers: 2361 2362 HEADER ([RFC-822] header of the message) 2363 TEXT MULTIPART/MIXED 2364 1 TEXT/PLAIN 2365 2 APPLICATION/OCTET-STREAM 2366 3 MESSAGE/RFC822 2367 3.HEADER ([RFC-822] header of the message) 2368 3.TEXT ([RFC-822] text body of the message) 2369 3.1 TEXT/PLAIN 2370 3.2 APPLICATION/OCTET-STREAM 2371 4 MULTIPART/MIXED 2372 4.1 IMAGE/GIF 2373 4.1.MIME ([MIME-IMB] header for the IMAGE/GIF) 2374 4.2 MESSAGE/RFC822 2375 4.2.HEADER ([RFC-822] header of the message) 2376 4.2.TEXT ([RFC-822] text body of the message) 2377 4.2.1 TEXT/PLAIN 2378 4.2.2 MULTIPART/ALTERNATIVE 2379 4.2.2.1 TEXT/PLAIN 2380 4.2.2.2 TEXT/RICHTEXT 2381 2382 2383 It is possible to fetch a substring of the 2384 designated text. This is done by appending an open 2385 angle bracket ("<"), the octet position of the 2386 first desired octet, a period, the maximum number 2387 of octets desired, and a close angle bracket (">") 2388 to the part specifier. If the starting octet is 2389 beyond the end of the text, an empty string is 2390 returned. 2391 2392 Any partial fetch that attempts to read beyond the 2393 end of the text is truncated as appropriate. A 2394 partial fetch that starts at octet 0 is returned as 2395 a partial fetch, even if this truncation happened. 2396 2397 Note: this means that BODY[]<0.2048> of a 2398 1500-octet message will return BODY[]<0> 2399 with a literal of size 1500, not BODY[]. 2400 2401 Note: a substring fetch of a 2402 HEADER.FIELDS or HEADER.FIELDS.NOT part 2403 specifier is calculated after subsetting 2404 the header. 2405 2406 2407 2408 2409 2410 Crispin Standards Track [Page 43] 2411 2412 RFC 2060 IMAP4rev1 December 1996 2413 2414 2415 The \Seen flag is implicitly set; if this causes 2416 the flags to change they SHOULD be included as part 2417 of the FETCH responses. 2418 2419 BODY.PEEK[<section>]<<partial>> 2420 An alternate form of BODY[<section>] that does not 2421 implicitly set the \Seen flag. 2422 2423 BODYSTRUCTURE The [MIME-IMB] body structure of the message. This 2424 is computed by the server by parsing the [MIME-IMB] 2425 header fields in the [RFC-822] header and 2426 [MIME-IMB] headers. 2427 2428 ENVELOPE The envelope structure of the message. This is 2429 computed by the server by parsing the [RFC-822] 2430 header into the component parts, defaulting various 2431 fields as necessary. 2432 2433 FAST Macro equivalent to: (FLAGS INTERNALDATE 2434 RFC822.SIZE) 2435 2436 FLAGS The flags that are set for this message. 2437 2438 FULL Macro equivalent to: (FLAGS INTERNALDATE 2439 RFC822.SIZE ENVELOPE BODY) 2440 2441 INTERNALDATE The internal date of the message. 2442 2443 RFC822 Functionally equivalent to BODY[], differing in the 2444 syntax of the resulting untagged FETCH data (RFC822 2445 is returned). 2446 2447 RFC822.HEADER Functionally equivalent to BODY.PEEK[HEADER], 2448 differing in the syntax of the resulting untagged 2449 FETCH data (RFC822.HEADER is returned). 2450 2451 RFC822.SIZE The [RFC-822] size of the message. 2452 2453 RFC822.TEXT Functionally equivalent to BODY[TEXT], differing in 2454 the syntax of the resulting untagged FETCH data 2455 (RFC822.TEXT is returned). 2456 2457 UID The unique identifier for the message. 2458 2459 2460 2461 2462 2463 2464 2465 2466 Crispin Standards Track [Page 44] 2467 2468 RFC 2060 IMAP4rev1 December 1996 2469 2470 2471 Example: C: A654 FETCH 2:4 (FLAGS BODY[HEADER.FIELDS (DATE FROM)]) 2472 S: * 2 FETCH .... 2473 S: * 3 FETCH .... 2474 S: * 4 FETCH .... 2475 S: A654 OK FETCH completed 2476 2477 6.4.6. STORE Command 2478 2479 Arguments: message set 2480 message data item name 2481 value for message data item 2482 2483 Responses: untagged responses: FETCH 2484 2485 Result: OK - store completed 2486 NO - store error: can't store that data 2487 BAD - command unknown or arguments invalid 2488 2489 The STORE command alters data associated with a message in the 2490 mailbox. Normally, STORE will return the updated value of the 2491 data with an untagged FETCH response. A suffix of ".SILENT" in 2492 the data item name prevents the untagged FETCH, and the server 2493 SHOULD assume that the client has determined the updated value 2494 itself or does not care about the updated value. 2495 2496 Note: regardless of whether or not the ".SILENT" suffix was 2497 used, the server SHOULD send an untagged FETCH response if a 2498 change to a message's flags from an external source is 2499 observed. The intent is that the status of the flags is 2500 determinate without a race condition. 2501 2502 The currently defined data items that can be stored are: 2503 2504 FLAGS <flag list> 2505 Replace the flags for the message with the 2506 argument. The new value of the flags are returned 2507 as if a FETCH of those flags was done. 2508 2509 FLAGS.SILENT <flag list> 2510 Equivalent to FLAGS, but without returning a new 2511 value. 2512 2513 +FLAGS <flag list> 2514 Add the argument to the flags for the message. The 2515 new value of the flags are returned as if a FETCH 2516 of those flags was done. 2517 2518 2519 2520 2521 2522 Crispin Standards Track [Page 45] 2523 2524 RFC 2060 IMAP4rev1 December 1996 2525 2526 2527 +FLAGS.SILENT <flag list> 2528 Equivalent to +FLAGS, but without returning a new 2529 value. 2530 2531 -FLAGS <flag list> 2532 Remove the argument from the flags for the message. 2533 The new value of the flags are returned as if a 2534 FETCH of those flags was done. 2535 2536 -FLAGS.SILENT <flag list> 2537 Equivalent to -FLAGS, but without returning a new 2538 value. 2539 2540 Example: C: A003 STORE 2:4 +FLAGS (\Deleted) 2541 S: * 2 FETCH FLAGS (\Deleted \Seen) 2542 S: * 3 FETCH FLAGS (\Deleted) 2543 S: * 4 FETCH FLAGS (\Deleted \Flagged \Seen) 2544 S: A003 OK STORE completed 2545 2546 6.4.7. COPY Command 2547 2548 Arguments: message set 2549 mailbox name 2550 2551 Responses: no specific responses for this command 2552 2553 Result: OK - copy completed 2554 NO - copy error: can't copy those messages or to that 2555 name 2556 BAD - command unknown or arguments invalid 2557 2558 The COPY command copies the specified message(s) to the end of the 2559 specified destination mailbox. The flags and internal date of the 2560 message(s) SHOULD be preserved in the copy. 2561 2562 If the destination mailbox does not exist, a server SHOULD return 2563 an error. It SHOULD NOT automatically create the mailbox. Unless 2564 it is certain that the destination mailbox can not be created, the 2565 server MUST send the response code "[TRYCREATE]" as the prefix of 2566 the text of the tagged NO response. This gives a hint to the 2567 client that it can attempt a CREATE command and retry the COPY if 2568 the CREATE is successful. 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 Crispin Standards Track [Page 46] 2579 2580 RFC 2060 IMAP4rev1 December 1996 2581 2582 2583 If the COPY command is unsuccessful for any reason, server 2584 implementations MUST restore the destination mailbox to its state 2585 before the COPY attempt. 2586 2587 Example: C: A003 COPY 2:4 MEETING 2588 S: A003 OK COPY completed 2589 2590 6.4.8. UID Command 2591 2592 Arguments: command name 2593 command arguments 2594 2595 Responses: untagged responses: FETCH, SEARCH 2596 2597 Result: OK - UID command completed 2598 NO - UID command error 2599 BAD - command unknown or arguments invalid 2600 2601 The UID command has two forms. In the first form, it takes as its 2602 arguments a COPY, FETCH, or STORE command with arguments 2603 appropriate for the associated command. However, the numbers in 2604 the message set argument are unique identifiers instead of message 2605 sequence numbers. 2606 2607 In the second form, the UID command takes a SEARCH command with 2608 SEARCH command arguments. The interpretation of the arguments is 2609 the same as with SEARCH; however, the numbers returned in a SEARCH 2610 response for a UID SEARCH command are unique identifiers instead 2611 of message sequence numbers. For example, the command UID SEARCH 2612 1:100 UID 443:557 returns the unique identifiers corresponding to 2613 the intersection of the message sequence number set 1:100 and the 2614 UID set 443:557. 2615 2616 Message set ranges are permitted; however, there is no guarantee 2617 that unique identifiers be contiguous. A non-existent unique 2618 identifier within a message set range is ignored without any error 2619 message generated. 2620 2621 The number after the "*" in an untagged FETCH response is always a 2622 message sequence number, not a unique identifier, even for a UID 2623 command response. However, server implementations MUST implicitly 2624 include the UID message data item as part of any FETCH response 2625 caused by a UID command, regardless of whether a UID was specified 2626 as a message data item to the FETCH. 2627 2628 2629 2630 2631 2632 2633 2634 Crispin Standards Track [Page 47] 2635 2636 RFC 2060 IMAP4rev1 December 1996 2637 2638 2639 Example: C: A999 UID FETCH 4827313:4828442 FLAGS 2640 S: * 23 FETCH (FLAGS (\Seen) UID 4827313) 2641 S: * 24 FETCH (FLAGS (\Seen) UID 4827943) 2642 S: * 25 FETCH (FLAGS (\Seen) UID 4828442) 2643 S: A999 UID FETCH completed 2644 2645 6.5. Client Commands - Experimental/Expansion 2646 2647 6.5.1. X<atom> Command 2648 2649 Arguments: implementation defined 2650 2651 Responses: implementation defined 2652 2653 Result: OK - command completed 2654 NO - failure 2655 BAD - command unknown or arguments invalid 2656 2657 Any command prefixed with an X is an experimental command. 2658 Commands which are not part of this specification, a standard or 2659 standards-track revision of this specification, or an IESG- 2660 approved experimental protocol, MUST use the X prefix. 2661 2662 Any added untagged responses issued by an experimental command 2663 MUST also be prefixed with an X. Server implementations MUST NOT 2664 send any such untagged responses, unless the client requested it 2665 by issuing the associated experimental command. 2666 2667 Example: C: a441 CAPABILITY 2668 S: * CAPABILITY IMAP4rev1 AUTH=KERBEROS_V4 XPIG-LATIN 2669 S: a441 OK CAPABILITY completed 2670 C: A442 XPIG-LATIN 2671 S: * XPIG-LATIN ow-nay eaking-spay ig-pay atin-lay 2672 S: A442 OK XPIG-LATIN ompleted-cay 2673 2674 7. Server Responses 2675 2676 Server responses are in three forms: status responses, server data, 2677 and command continuation request. The information contained in a 2678 server response, identified by "Contents:" in the response 2679 descriptions below, is described by function, not by syntax. The 2680 precise syntax of server responses is described in the Formal Syntax 2681 section. 2682 2683 The client MUST be prepared to accept any response at all times. 2684 2685 2686 2687 2688 2689 2690 Crispin Standards Track [Page 48] 2691 2692 RFC 2060 IMAP4rev1 December 1996 2693 2694 2695 Status responses can be tagged or untagged. Tagged status responses 2696 indicate the completion result (OK, NO, or BAD status) of a client 2697 command, and have a tag matching the command. 2698 2699 Some status responses, and all server data, are untagged. An 2700 untagged response is indicated by the token "*" instead of a tag. 2701 Untagged status responses indicate server greeting, or server status 2702 that does not indicate the completion of a command (for example, an 2703 impending system shutdown alert). For historical reasons, untagged 2704 server data responses are also called "unsolicited data", although 2705 strictly speaking only unilateral server data is truly "unsolicited". 2706 2707 Certain server data MUST be recorded by the client when it is 2708 received; this is noted in the description of that data. Such data 2709 conveys critical information which affects the interpretation of all 2710 subsequent commands and responses (e.g. updates reflecting the 2711 creation or destruction of messages). 2712 2713 Other server data SHOULD be recorded for later reference; if the 2714 client does not need to record the data, or if recording the data has 2715 no obvious purpose (e.g. a SEARCH response when no SEARCH command is 2716 in progress), the data SHOULD be ignored. 2717 2718 An example of unilateral untagged server data occurs when the IMAP 2719 connection is in selected state. In selected state, the server 2720 checks the mailbox for new messages as part of command execution. 2721 Normally, this is part of the execution of every command; hence, a 2722 NOOP command suffices to check for new messages. If new messages are 2723 found, the server sends untagged EXISTS and RECENT responses 2724 reflecting the new size of the mailbox. Server implementations that 2725 offer multiple simultaneous access to the same mailbox SHOULD also 2726 send appropriate unilateral untagged FETCH and EXPUNGE responses if 2727 another agent changes the state of any message flags or expunges any 2728 messages. 2729 2730 Command continuation request responses use the token "+" instead of a 2731 tag. These responses are sent by the server to indicate acceptance 2732 of an incomplete client command and readiness for the remainder of 2733 the command. 2734 2735 7.1. Server Responses - Status Responses 2736 2737 Status responses are OK, NO, BAD, PREAUTH and BYE. OK, NO, and BAD 2738 may be tagged or untagged. PREAUTH and BYE are always untagged. 2739 2740 Status responses MAY include an OPTIONAL "response code". A response 2741 code consists of data inside square brackets in the form of an atom, 2742 possibly followed by a space and arguments. The response code 2743 2744 2745 2746 Crispin Standards Track [Page 49] 2747 2748 RFC 2060 IMAP4rev1 December 1996 2749 2750 2751 contains additional information or status codes for client software 2752 beyond the OK/NO/BAD condition, and are defined when there is a 2753 specific action that a client can take based upon the additional 2754 information. 2755 2756 The currently defined response codes are: 2757 2758 ALERT The human-readable text contains a special alert 2759 that MUST be presented to the user in a fashion 2760 that calls the user's attention to the message. 2761 2762 NEWNAME Followed by a mailbox name and a new mailbox name. 2763 A SELECT or EXAMINE is failing because the target 2764 mailbox name no longer exists because it was 2765 renamed to the new mailbox name. This is a hint to 2766 the client that the operation can succeed if the 2767 SELECT or EXAMINE is reissued with the new mailbox 2768 name. 2769 2770 PARSE The human-readable text represents an error in 2771 parsing the [RFC-822] header or [MIME-IMB] headers 2772 of a message in the mailbox. 2773 2774 PERMANENTFLAGS Followed by a parenthesized list of flags, 2775 indicates which of the known flags that the client 2776 can change permanently. Any flags that are in the 2777 FLAGS untagged response, but not the PERMANENTFLAGS 2778 list, can not be set permanently. If the client 2779 attempts to STORE a flag that is not in the 2780 PERMANENTFLAGS list, the server will either reject 2781 it with a NO reply or store the state for the 2782 remainder of the current session only. The 2783 PERMANENTFLAGS list can also include the special 2784 flag \*, which indicates that it is possible to 2785 create new keywords by attempting to store those 2786 flags in the mailbox. 2787 2788 READ-ONLY The mailbox is selected read-only, or its access 2789 while selected has changed from read-write to 2790 read-only. 2791 2792 READ-WRITE The mailbox is selected read-write, or its access 2793 while selected has changed from read-only to 2794 read-write. 2795 2796 2797 2798 2799 2800 2801 2802 Crispin Standards Track [Page 50] 2803 2804 RFC 2060 IMAP4rev1 December 1996 2805 2806 2807 TRYCREATE An APPEND or COPY attempt is failing because the 2808 target mailbox does not exist (as opposed to some 2809 other reason). This is a hint to the client that 2810 the operation can succeed if the mailbox is first 2811 created by the CREATE command. 2812 2813 UIDVALIDITY Followed by a decimal number, indicates the unique 2814 identifier validity value. 2815 2816 UNSEEN Followed by a decimal number, indicates the number 2817 of the first message without the \Seen flag set. 2818 2819 Additional response codes defined by particular client or server 2820 implementations SHOULD be prefixed with an "X" until they are 2821 added to a revision of this protocol. Client implementations 2822 SHOULD ignore response codes that they do not recognize. 2823 2824 7.1.1. OK Response 2825 2826 Contents: OPTIONAL response code 2827 human-readable text 2828 2829 The OK response indicates an information message from the server. 2830 When tagged, it indicates successful completion of the associated 2831 command. The human-readable text MAY be presented to the user as 2832 an information message. The untagged form indicates an 2833 information-only message; the nature of the information MAY be 2834 indicated by a response code. 2835 2836 The untagged form is also used as one of three possible greetings 2837 at connection startup. It indicates that the connection is not 2838 yet authenticated and that a LOGIN command is needed. 2839 2840 Example: S: * OK IMAP4rev1 server ready 2841 C: A001 LOGIN fred blurdybloop 2842 S: * OK [ALERT] System shutdown in 10 minutes 2843 S: A001 OK LOGIN Completed 2844 2845 7.1.2. NO Response 2846 2847 Contents: OPTIONAL response code 2848 human-readable text 2849 2850 The NO response indicates an operational error message from the 2851 server. When tagged, it indicates unsuccessful completion of the 2852 associated command. The untagged form indicates a warning; the 2853 command can still complete successfully. The human-readable text 2854 describes the condition. 2855 2856 2857 2858 Crispin Standards Track [Page 51] 2859 2860 RFC 2060 IMAP4rev1 December 1996 2861 2862 2863 Example: C: A222 COPY 1:2 owatagusiam 2864 S: * NO Disk is 98% full, please delete unnecessary data 2865 S: A222 OK COPY completed 2866 C: A223 COPY 3:200 blurdybloop 2867 S: * NO Disk is 98% full, please delete unnecessary data 2868 S: * NO Disk is 99% full, please delete unnecessary data 2869 S: A223 NO COPY failed: disk is full 2870 2871 7.1.3. BAD Response 2872 2873 Contents: OPTIONAL response code 2874 human-readable text 2875 2876 The BAD response indicates an error message from the server. When 2877 tagged, it reports a protocol-level error in the client's command; 2878 the tag indicates the command that caused the error. The untagged 2879 form indicates a protocol-level error for which the associated 2880 command can not be determined; it can also indicate an internal 2881 server failure. The human-readable text describes the condition. 2882 2883 Example: C: ...very long command line... 2884 S: * BAD Command line too long 2885 C: ...empty line... 2886 S: * BAD Empty command line 2887 C: A443 EXPUNGE 2888 S: * BAD Disk crash, attempting salvage to a new disk! 2889 S: * OK Salvage successful, no data lost 2890 S: A443 OK Expunge completed 2891 2892 7.1.4. PREAUTH Response 2893 2894 Contents: OPTIONAL response code 2895 human-readable text 2896 2897 The PREAUTH response is always untagged, and is one of three 2898 possible greetings at connection startup. It indicates that the 2899 connection has already been authenticated by external means and 2900 thus no LOGIN command is needed. 2901 2902 Example: S: * PREAUTH IMAP4rev1 server logged in as Smith 2903 2904 7.1.5. BYE Response 2905 2906 Contents: OPTIONAL response code 2907 human-readable text 2908 2909 2910 2911 2912 2913 2914 Crispin Standards Track [Page 52] 2915 2916 RFC 2060 IMAP4rev1 December 1996 2917 2918 2919 The BYE response is always untagged, and indicates that the server 2920 is about to close the connection. The human-readable text MAY be 2921 displayed to the user in a status report by the client. The BYE 2922 response is sent under one of four conditions: 2923 2924 1) as part of a normal logout sequence. The server will close 2925 the connection after sending the tagged OK response to the 2926 LOGOUT command. 2927 2928 2) as a panic shutdown announcement. The server closes the 2929 connection immediately. 2930 2931 3) as an announcement of an inactivity autologout. The server 2932 closes the connection immediately. 2933 2934 4) as one of three possible greetings at connection startup, 2935 indicating that the server is not willing to accept a 2936 connection from this client. The server closes the 2937 connection immediately. 2938 2939 The difference between a BYE that occurs as part of a normal 2940 LOGOUT sequence (the first case) and a BYE that occurs because of 2941 a failure (the other three cases) is that the connection closes 2942 immediately in the failure case. 2943 2944 Example: S: * BYE Autologout; idle for too long 2945 2946 7.2. Server Responses - Server and Mailbox Status 2947 2948 These responses are always untagged. This is how server and mailbox 2949 status data are transmitted from the server to the client. Many of 2950 these responses typically result from a command with the same name. 2951 2952 7.2.1. CAPABILITY Response 2953 2954 Contents: capability listing 2955 2956 The CAPABILITY response occurs as a result of a CAPABILITY 2957 command. The capability listing contains a space-separated 2958 listing of capability names that the server supports. The 2959 capability listing MUST include the atom "IMAP4rev1". 2960 2961 A capability name which begins with "AUTH=" indicates that the 2962 server supports that particular authentication mechanism. 2963 2964 2965 2966 2967 2968 2969 2970 Crispin Standards Track [Page 53] 2971 2972 RFC 2060 IMAP4rev1 December 1996 2973 2974 2975 Other capability names indicate that the server supports an 2976 extension, revision, or amendment to the IMAP4rev1 protocol. 2977 Server responses MUST conform to this document until the client 2978 issues a command that uses the associated capability. 2979 2980 Capability names MUST either begin with "X" or be standard or 2981 standards-track IMAP4rev1 extensions, revisions, or amendments 2982 registered with IANA. A server MUST NOT offer unregistered or 2983 non-standard capability names, unless such names are prefixed with 2984 an "X". 2985 2986 Client implementations SHOULD NOT require any capability name 2987 other than "IMAP4rev1", and MUST ignore any unknown capability 2988 names. 2989 2990 Example: S: * CAPABILITY IMAP4rev1 AUTH=KERBEROS_V4 XPIG-LATIN 2991 2992 7.2.2. LIST Response 2993 2994 Contents: name attributes 2995 hierarchy delimiter 2996 name 2997 2998 The LIST response occurs as a result of a LIST command. It 2999 returns a single name that matches the LIST specification. There 3000 can be multiple LIST responses for a single LIST command. 3001 3002 Four name attributes are defined: 3003 3004 \Noinferiors It is not possible for any child levels of 3005 hierarchy to exist under this name; no child levels 3006 exist now and none can be created in the future. 3007 3008 \Noselect It is not possible to use this name as a selectable 3009 mailbox. 3010 3011 \Marked The mailbox has been marked "interesting" by the 3012 server; the mailbox probably contains messages that 3013 have been added since the last time the mailbox was 3014 selected. 3015 3016 \Unmarked The mailbox does not contain any additional 3017 messages since the last time the mailbox was 3018 selected. 3019 3020 If it is not feasible for the server to determine whether the 3021 mailbox is "interesting" or not, or if the name is a \Noselect 3022 name, the server SHOULD NOT send either \Marked or \Unmarked. 3023 3024 3025 3026 Crispin Standards Track [Page 54] 3027 3028 RFC 2060 IMAP4rev1 December 1996 3029 3030 3031 The hierarchy delimiter is a character used to delimit levels of 3032 hierarchy in a mailbox name. A client can use it to create child 3033 mailboxes, and to search higher or lower levels of naming 3034 hierarchy. All children of a top-level hierarchy node MUST use 3035 the same separator character. A NIL hierarchy delimiter means 3036 that no hierarchy exists; the name is a "flat" name. 3037 3038 The name represents an unambiguous left-to-right hierarchy, and 3039 MUST be valid for use as a reference in LIST and LSUB commands. 3040 Unless \Noselect is indicated, the name MUST also be valid as an 3041 argument for commands, such as SELECT, that accept mailbox 3042 names. 3043 3044 Example: S: * LIST (\Noselect) "/" ~/Mail/foo 3045 3046 7.2.3. LSUB Response 3047 3048 Contents: name attributes 3049 hierarchy delimiter 3050 name 3051 3052 The LSUB response occurs as a result of an LSUB command. It 3053 returns a single name that matches the LSUB specification. There 3054 can be multiple LSUB responses for a single LSUB command. The 3055 data is identical in format to the LIST response. 3056 3057 Example: S: * LSUB () "." #news.comp.mail.misc 3058 3059 7.2.4 STATUS Response 3060 3061 Contents: name 3062 status parenthesized list 3063 3064 The STATUS response occurs as a result of an STATUS command. It 3065 returns the mailbox name that matches the STATUS specification and 3066 the requested mailbox status information. 3067 3068 Example: S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) 3069 3070 7.2.5. SEARCH Response 3071 3072 Contents: zero or more numbers 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 Crispin Standards Track [Page 55] 3083 3084 RFC 2060 IMAP4rev1 December 1996 3085 3086 3087 The SEARCH response occurs as a result of a SEARCH or UID SEARCH 3088 command. The number(s) refer to those messages that match the 3089 search criteria. For SEARCH, these are message sequence numbers; 3090 for UID SEARCH, these are unique identifiers. Each number is 3091 delimited by a space. 3092 3093 Example: S: * SEARCH 2 3 6 3094 3095 7.2.6. FLAGS Response 3096 3097 Contents: flag parenthesized list 3098 3099 The FLAGS response occurs as a result of a SELECT or EXAMINE 3100 command. The flag parenthesized list identifies the flags (at a 3101 minimum, the system-defined flags) that are applicable for this 3102 mailbox. Flags other than the system flags can also exist, 3103 depending on server implementation. 3104 3105 The update from the FLAGS response MUST be recorded by the client. 3106 3107 Example: S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 3108 3109 7.3. Server Responses - Mailbox Size 3110 3111 These responses are always untagged. This is how changes in the size 3112 of the mailbox are trasnmitted from the server to the client. 3113 Immediately following the "*" token is a number that represents a 3114 message count. 3115 3116 7.3.1. EXISTS Response 3117 3118 Contents: none 3119 3120 The EXISTS response reports the number of messages in the mailbox. 3121 This response occurs as a result of a SELECT or EXAMINE command, 3122 and if the size of the mailbox changes (e.g. new mail). 3123 3124 The update from the EXISTS response MUST be recorded by the 3125 client. 3126 3127 Example: S: * 23 EXISTS 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 Crispin Standards Track [Page 56] 3139 3140 RFC 2060 IMAP4rev1 December 1996 3141 3142 3143 7.3.2. RECENT Response 3144 3145 Contents: none 3146 3147 The RECENT response reports the number of messages with the 3148 \Recent flag set. This response occurs as a result of a SELECT or 3149 EXAMINE command, and if the size of the mailbox changes (e.g. new 3150 mail). 3151 3152 Note: It is not guaranteed that the message sequence numbers of 3153 recent messages will be a contiguous range of the highest n 3154 messages in the mailbox (where n is the value reported by the 3155 RECENT response). Examples of situations in which this is not 3156 the case are: multiple clients having the same mailbox open 3157 (the first session to be notified will see it as recent, others 3158 will probably see it as non-recent), and when the mailbox is 3159 re-ordered by a non-IMAP agent. 3160 3161 The only reliable way to identify recent messages is to look at 3162 message flags to see which have the \Recent flag set, or to do 3163 a SEARCH RECENT. 3164 3165 The update from the RECENT response MUST be recorded by the 3166 client. 3167 3168 Example: S: * 5 RECENT 3169 3170 7.4. Server Responses - Message Status 3171 3172 These responses are always untagged. This is how message data are 3173 transmitted from the server to the client, often as a result of a 3174 command with the same name. Immediately following the "*" token is a 3175 number that represents a message sequence number. 3176 3177 7.4.1. EXPUNGE Response 3178 3179 Contents: none 3180 3181 The EXPUNGE response reports that the specified message sequence 3182 number has been permanently removed from the mailbox. The message 3183 sequence number for each successive message in the mailbox is 3184 immediately decremented by 1, and this decrement is reflected in 3185 message sequence numbers in subsequent responses (including other 3186 untagged EXPUNGE responses). 3187 3188 As a result of the immediate decrement rule, message sequence 3189 numbers that appear in a set of successive EXPUNGE responses 3190 depend upon whether the messages are removed starting from lower 3191 3192 3193 3194 Crispin Standards Track [Page 57] 3195 3196 RFC 2060 IMAP4rev1 December 1996 3197 3198 3199 numbers to higher numbers, or from higher numbers to lower 3200 numbers. For example, if the last 5 messages in a 9-message 3201 mailbox are expunged; a "lower to higher" server will send five 3202 untagged EXPUNGE responses for message sequence number 5, whereas 3203 a "higher to lower server" will send successive untagged EXPUNGE 3204 responses for message sequence numbers 9, 8, 7, 6, and 5. 3205 3206 An EXPUNGE response MUST NOT be sent when no command is in 3207 progress; nor while responding to a FETCH, STORE, or SEARCH 3208 command. This rule is necessary to prevent a loss of 3209 synchronization of message sequence numbers between client and 3210 server. 3211 3212 The update from the EXPUNGE response MUST be recorded by the 3213 client. 3214 3215 Example: S: * 44 EXPUNGE 3216 3217 7.4.2. FETCH Response 3218 3219 Contents: message data 3220 3221 The FETCH response returns data about a message to the client. 3222 The data are pairs of data item names and their values in 3223 parentheses. This response occurs as the result of a FETCH or 3224 STORE command, as well as by unilateral server decision (e.g. flag 3225 updates). 3226 3227 The current data items are: 3228 3229 BODY A form of BODYSTRUCTURE without extension data. 3230 3231 BODY[<section>]<<origin_octet>> 3232 A string expressing the body contents of the 3233 specified section. The string SHOULD be 3234 interpreted by the client according to the content 3235 transfer encoding, body type, and subtype. 3236 3237 If the origin octet is specified, this string is a 3238 substring of the entire body contents, starting at 3239 that origin octet. This means that BODY[]<0> MAY 3240 be truncated, but BODY[] is NEVER truncated. 3241 3242 8-bit textual data is permitted if a [CHARSET] 3243 identifier is part of the body parameter 3244 parenthesized list for this section. Note that 3245 headers (part specifiers HEADER or MIME, or the 3246 header portion of a MESSAGE/RFC822 part), MUST be 3247 3248 3249 3250 Crispin Standards Track [Page 58] 3251 3252 RFC 2060 IMAP4rev1 December 1996 3253 3254 3255 7-bit; 8-bit characters are not permitted in 3256 headers. Note also that the blank line at the end 3257 of the header is always included in header data. 3258 3259 Non-textual data such as binary data MUST be 3260 transfer encoded into a textual form such as BASE64 3261 prior to being sent to the client. To derive the 3262 original binary data, the client MUST decode the 3263 transfer encoded string. 3264 3265 BODYSTRUCTURE A parenthesized list that describes the [MIME-IMB] 3266 body structure of a message. This is computed by 3267 the server by parsing the [MIME-IMB] header fields, 3268 defaulting various fields as necessary. 3269 3270 For example, a simple text message of 48 lines and 3271 2279 octets can have a body structure of: ("TEXT" 3272 "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 2279 3273 48) 3274 3275 Multiple parts are indicated by parenthesis 3276 nesting. Instead of a body type as the first 3277 element of the parenthesized list there is a nested 3278 body. The second element of the parenthesized list 3279 is the multipart subtype (mixed, digest, parallel, 3280 alternative, etc.). 3281 3282 For example, a two part message consisting of a 3283 text and a BASE645-encoded text attachment can have 3284 a body structure of: (("TEXT" "PLAIN" ("CHARSET" 3285 "US-ASCII") NIL NIL "7BIT" 1152 23)("TEXT" "PLAIN" 3286 ("CHARSET" "US-ASCII" "NAME" "cc.diff") 3287 "<960723163407.20117h@cac.washington.edu>" 3288 "Compiler diff" "BASE64" 4554 73) "MIXED")) 3289 3290 Extension data follows the multipart subtype. 3291 Extension data is never returned with the BODY 3292 fetch, but can be returned with a BODYSTRUCTURE 3293 fetch. Extension data, if present, MUST be in the 3294 defined order. 3295 3296 The extension data of a multipart body part are in 3297 the following order: 3298 3299 body parameter parenthesized list 3300 A parenthesized list of attribute/value pairs 3301 [e.g. ("foo" "bar" "baz" "rag") where "bar" is 3302 the value of "foo" and "rag" is the value of 3303 3304 3305 3306 Crispin Standards Track [Page 59] 3307 3308 RFC 2060 IMAP4rev1 December 1996 3309 3310 3311 "baz"] as defined in [MIME-IMB]. 3312 3313 body disposition 3314 A parenthesized list, consisting of a 3315 disposition type string followed by a 3316 parenthesized list of disposition 3317 attribute/value pairs. The disposition type and 3318 attribute names will be defined in a future 3319 standards-track revision to [DISPOSITION]. 3320 3321 body language 3322 A string or parenthesized list giving the body 3323 language value as defined in [LANGUAGE-TAGS]. 3324 3325 Any following extension data are not yet defined in 3326 this version of the protocol. Such extension data 3327 can consist of zero or more NILs, strings, numbers, 3328 or potentially nested parenthesized lists of such 3329 data. Client implementations that do a 3330 BODYSTRUCTURE fetch MUST be prepared to accept such 3331 extension data. Server implementations MUST NOT 3332 send such extension data until it has been defined 3333 by a revision of this protocol. 3334 3335 The basic fields of a non-multipart body part are 3336 in the following order: 3337 3338 body type 3339 A string giving the content media type name as 3340 defined in [MIME-IMB]. 3341 3342 body subtype 3343 A string giving the content subtype name as 3344 defined in [MIME-IMB]. 3345 3346 body parameter parenthesized list 3347 A parenthesized list of attribute/value pairs 3348 [e.g. ("foo" "bar" "baz" "rag") where "bar" is 3349 the value of "foo" and "rag" is the value of 3350 "baz"] as defined in [MIME-IMB]. 3351 3352 body id 3353 A string giving the content id as defined in 3354 [MIME-IMB]. 3355 3356 body description 3357 A string giving the content description as 3358 defined in [MIME-IMB]. 3359 3360 3361 3362 Crispin Standards Track [Page 60] 3363 3364 RFC 2060 IMAP4rev1 December 1996 3365 3366 3367 body encoding 3368 A string giving the content transfer encoding as 3369 defined in [MIME-IMB]. 3370 3371 body size 3372 A number giving the size of the body in octets. 3373 Note that this size is the size in its transfer 3374 encoding and not the resulting size after any 3375 decoding. 3376 3377 A body type of type MESSAGE and subtype RFC822 3378 contains, immediately after the basic fields, the 3379 envelope structure, body structure, and size in 3380 text lines of the encapsulated message. 3381 3382 A body type of type TEXT contains, immediately 3383 after the basic fields, the size of the body in 3384 text lines. Note that this size is the size in its 3385 content transfer encoding and not the resulting 3386 size after any decoding. 3387 3388 Extension data follows the basic fields and the 3389 type-specific fields listed above. Extension data 3390 is never returned with the BODY fetch, but can be 3391 returned with a BODYSTRUCTURE fetch. Extension 3392 data, if present, MUST be in the defined order. 3393 3394 The extension data of a non-multipart body part are 3395 in the following order: 3396 3397 body MD5 3398 A string giving the body MD5 value as defined in 3399 [MD5]. 3400 3401 body disposition 3402 A parenthesized list with the same content and 3403 function as the body disposition for a multipart 3404 body part. 3405 3406 body language 3407 A string or parenthesized list giving the body 3408 language value as defined in [LANGUAGE-TAGS]. 3409 3410 Any following extension data are not yet defined in 3411 this version of the protocol, and would be as 3412 described above under multipart extension data. 3413 3414 3415 3416 3417 3418 Crispin Standards Track [Page 61] 3419 3420 RFC 2060 IMAP4rev1 December 1996 3421 3422 3423 ENVELOPE A parenthesized list that describes the envelope 3424 structure of a message. This is computed by the 3425 server by parsing the [RFC-822] header into the 3426 component parts, defaulting various fields as 3427 necessary. 3428 3429 The fields of the envelope structure are in the 3430 following order: date, subject, from, sender, 3431 reply-to, to, cc, bcc, in-reply-to, and message-id. 3432 The date, subject, in-reply-to, and message-id 3433 fields are strings. The from, sender, reply-to, 3434 to, cc, and bcc fields are parenthesized lists of 3435 address structures. 3436 3437 An address structure is a parenthesized list that 3438 describes an electronic mail address. The fields 3439 of an address structure are in the following order: 3440 personal name, [SMTP] at-domain-list (source 3441 route), mailbox name, and host name. 3442 3443 [RFC-822] group syntax is indicated by a special 3444 form of address structure in which the host name 3445 field is NIL. If the mailbox name field is also 3446 NIL, this is an end of group marker (semi-colon in 3447 RFC 822 syntax). If the mailbox name field is 3448 non-NIL, this is a start of group marker, and the 3449 mailbox name field holds the group name phrase. 3450 3451 Any field of an envelope or address structure that 3452 is not applicable is presented as NIL. Note that 3453 the server MUST default the reply-to and sender 3454 fields from the from field; a client is not 3455 expected to know to do this. 3456 3457 FLAGS A parenthesized list of flags that are set for this 3458 message. 3459 3460 INTERNALDATE A string representing the internal date of the 3461 message. 3462 3463 RFC822 Equivalent to BODY[]. 3464 3465 RFC822.HEADER Equivalent to BODY.PEEK[HEADER]. 3466 3467 RFC822.SIZE A number expressing the [RFC-822] size of the 3468 message. 3469 3470 RFC822.TEXT Equivalent to BODY[TEXT]. 3471 3472 3473 3474 Crispin Standards Track [Page 62] 3475 3476 RFC 2060 IMAP4rev1 December 1996 3477 3478 3479 UID A number expressing the unique identifier of the 3480 message. 3481 3482 3483 Example: S: * 23 FETCH (FLAGS (\Seen) RFC822.SIZE 44827) 3484 3485 7.5. Server Responses - Command Continuation Request 3486 3487 The command continuation request response is indicated by a "+" token 3488 instead of a tag. This form of response indicates that the server is 3489 ready to accept the continuation of a command from the client. The 3490 remainder of this response is a line of text. 3491 3492 This response is used in the AUTHORIZATION command to transmit server 3493 data to the client, and request additional client data. This 3494 response is also used if an argument to any command is a literal. 3495 3496 The client is not permitted to send the octets of the literal unless 3497 the server indicates that it expects it. This permits the server to 3498 process commands and reject errors on a line-by-line basis. The 3499 remainder of the command, including the CRLF that terminates a 3500 command, follows the octets of the literal. If there are any 3501 additional command arguments the literal octets are followed by a 3502 space and those arguments. 3503 3504 Example: C: A001 LOGIN {11} 3505 S: + Ready for additional command text 3506 C: FRED FOOBAR {7} 3507 S: + Ready for additional command text 3508 C: fat man 3509 S: A001 OK LOGIN completed 3510 C: A044 BLURDYBLOOP {102856} 3511 S: A044 BAD No such command as "BLURDYBLOOP" 3512 3513 8. Sample IMAP4rev1 connection 3514 3515 The following is a transcript of an IMAP4rev1 connection. A long 3516 line in this sample is broken for editorial clarity. 3517 3518 S: * OK IMAP4rev1 Service Ready 3519 C: a001 login mrc secret 3520 S: a001 OK LOGIN completed 3521 C: a002 select inbox 3522 S: * 18 EXISTS 3523 S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) 3524 S: * 2 RECENT 3525 S: * OK [UNSEEN 17] Message 17 is the first unseen message 3526 S: * OK [UIDVALIDITY 3857529045] UIDs valid 3527 3528 3529 3530 Crispin Standards Track [Page 63] 3531 3532 RFC 2060 IMAP4rev1 December 1996 3533 3534 3535 S: a002 OK [READ-WRITE] SELECT completed 3536 C: a003 fetch 12 full 3537 S: * 12 FETCH (FLAGS (\Seen) INTERNALDATE "17-Jul-1996 02:44:25 -0700" 3538 RFC822.SIZE 4286 ENVELOPE ("Wed, 17 Jul 1996 02:23:25 -0700 (PDT)" 3539 "IMAP4rev1 WG mtg summary and minutes" 3540 (("Terry Gray" NIL "gray" "cac.washington.edu")) 3541 (("Terry Gray" NIL "gray" "cac.washington.edu")) 3542 (("Terry Gray" NIL "gray" "cac.washington.edu")) 3543 ((NIL NIL "imap" "cac.washington.edu")) 3544 ((NIL NIL "minutes" "CNRI.Reston.VA.US") 3545 ("John Klensin" NIL "KLENSIN" "INFOODS.MIT.EDU")) NIL NIL 3546 "<B27397-0100000@cac.washington.edu>") 3547 BODY ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 3028 92)) 3548 S: a003 OK FETCH completed 3549 C: a004 fetch 12 body[header] 3550 S: * 12 FETCH (BODY[HEADER] {350} 3551 S: Date: Wed, 17 Jul 1996 02:23:25 -0700 (PDT) 3552 S: From: Terry Gray <gray@cac.washington.edu> 3553 S: Subject: IMAP4rev1 WG mtg summary and minutes 3554 S: To: imap@cac.washington.edu 3555 S: cc: minutes@CNRI.Reston.VA.US, John Klensin <KLENSIN@INFOODS.MIT.EDU> 3556 S: Message-Id: <B27397-0100000@cac.washington.edu> 3557 S: MIME-Version: 1.0 3558 S: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII 3559 S: 3560 S: ) 3561 S: a004 OK FETCH completed 3562 C: a005 store 12 +flags \deleted 3563 S: * 12 FETCH (FLAGS (\Seen \Deleted)) 3564 S: a005 OK +FLAGS completed 3565 C: a006 logout 3566 S: * BYE IMAP4rev1 server terminating connection 3567 S: a006 OK LOGOUT completed 3568 3569 9. Formal Syntax 3570 3571 The following syntax specification uses the augmented Backus-Naur 3572 Form (BNF) notation as specified in [RFC-822] with one exception; the 3573 delimiter used with the "#" construct is a single space (SPACE) and 3574 not one or more commas. 3575 3576 In the case of alternative or optional rules in which a later rule 3577 overlaps an earlier rule, the rule which is listed earlier MUST take 3578 priority. For example, "\Seen" when parsed as a flag is the \Seen 3579 flag name and not a flag_extension, even though "\Seen" could be 3580 parsed as a flag_extension. Some, but not all, instances of this 3581 rule are noted below. 3582 3583 3584 3585 3586 Crispin Standards Track [Page 64] 3587 3588 RFC 2060 IMAP4rev1 December 1996 3589 3590 3591 Except as noted otherwise, all alphabetic characters are case- 3592 insensitive. The use of upper or lower case characters to define 3593 token strings is for editorial clarity only. Implementations MUST 3594 accept these strings in a case-insensitive fashion. 3595 3596 address ::= "(" addr_name SPACE addr_adl SPACE addr_mailbox 3597 SPACE addr_host ")" 3598 3599 addr_adl ::= nstring 3600 ;; Holds route from [RFC-822] route-addr if 3601 ;; non-NIL 3602 3603 addr_host ::= nstring 3604 ;; NIL indicates [RFC-822] group syntax. 3605 ;; Otherwise, holds [RFC-822] domain name 3606 3607 addr_mailbox ::= nstring 3608 ;; NIL indicates end of [RFC-822] group; if 3609 ;; non-NIL and addr_host is NIL, holds 3610 ;; [RFC-822] group name. 3611 ;; Otherwise, holds [RFC-822] local-part 3612 3613 addr_name ::= nstring 3614 ;; Holds phrase from [RFC-822] mailbox if 3615 ;; non-NIL 3616 3617 alpha ::= "A" / "B" / "C" / "D" / "E" / "F" / "G" / "H" / 3618 "I" / "J" / "K" / "L" / "M" / "N" / "O" / "P" / 3619 "Q" / "R" / "S" / "T" / "U" / "V" / "W" / "X" / 3620 "Y" / "Z" / 3621 "a" / "b" / "c" / "d" / "e" / "f" / "g" / "h" / 3622 "i" / "j" / "k" / "l" / "m" / "n" / "o" / "p" / 3623 "q" / "r" / "s" / "t" / "u" / "v" / "w" / "x" / 3624 "y" / "z" 3625 ;; Case-sensitive 3626 3627 append ::= "APPEND" SPACE mailbox [SPACE flag_list] 3628 [SPACE date_time] SPACE literal 3629 3630 astring ::= atom / string 3631 3632 atom ::= 1*ATOM_CHAR 3633 3634 ATOM_CHAR ::= <any CHAR except atom_specials> 3635 3636 atom_specials ::= "(" / ")" / "{" / SPACE / CTL / list_wildcards / 3637 quoted_specials 3638 3639 3640 3641 3642 Crispin Standards Track [Page 65] 3643 3644 RFC 2060 IMAP4rev1 December 1996 3645 3646 3647 authenticate ::= "AUTHENTICATE" SPACE auth_type *(CRLF base64) 3648 3649 auth_type ::= atom 3650 ;; Defined by [IMAP-AUTH] 3651 3652 base64 ::= *(4base64_char) [base64_terminal] 3653 3654 base64_char ::= alpha / digit / "+" / "/" 3655 3656 base64_terminal ::= (2base64_char "==") / (3base64_char "=") 3657 3658 body ::= "(" body_type_1part / body_type_mpart ")" 3659 3660 body_extension ::= nstring / number / "(" 1#body_extension ")" 3661 ;; Future expansion. Client implementations 3662 ;; MUST accept body_extension fields. Server 3663 ;; implementations MUST NOT generate 3664 ;; body_extension fields except as defined by 3665 ;; future standard or standards-track 3666 ;; revisions of this specification. 3667 3668 body_ext_1part ::= body_fld_md5 [SPACE body_fld_dsp 3669 [SPACE body_fld_lang 3670 [SPACE 1#body_extension]]] 3671 ;; MUST NOT be returned on non-extensible 3672 ;; "BODY" fetch 3673 3674 body_ext_mpart ::= body_fld_param 3675 [SPACE body_fld_dsp SPACE body_fld_lang 3676 [SPACE 1#body_extension]] 3677 ;; MUST NOT be returned on non-extensible 3678 ;; "BODY" fetch 3679 3680 body_fields ::= body_fld_param SPACE body_fld_id SPACE 3681 body_fld_desc SPACE body_fld_enc SPACE 3682 body_fld_octets 3683 3684 body_fld_desc ::= nstring 3685 3686 body_fld_dsp ::= "(" string SPACE body_fld_param ")" / nil 3687 3688 body_fld_enc ::= (<"> ("7BIT" / "8BIT" / "BINARY" / "BASE64"/ 3689 "QUOTED-PRINTABLE") <">) / string 3690 3691 body_fld_id ::= nstring 3692 3693 body_fld_lang ::= nstring / "(" 1#string ")" 3694 3695 3696 3697 3698 Crispin Standards Track [Page 66] 3699 3700 RFC 2060 IMAP4rev1 December 1996 3701 3702 3703 body_fld_lines ::= number 3704 3705 body_fld_md5 ::= nstring 3706 3707 body_fld_octets ::= number 3708 3709 body_fld_param ::= "(" 1#(string SPACE string) ")" / nil 3710 3711 body_type_1part ::= (body_type_basic / body_type_msg / body_type_text) 3712 [SPACE body_ext_1part] 3713 3714 body_type_basic ::= media_basic SPACE body_fields 3715 ;; MESSAGE subtype MUST NOT be "RFC822" 3716 3717 body_type_mpart ::= 1*body SPACE media_subtype 3718 [SPACE body_ext_mpart] 3719 3720 body_type_msg ::= media_message SPACE body_fields SPACE envelope 3721 SPACE body SPACE body_fld_lines 3722 3723 body_type_text ::= media_text SPACE body_fields SPACE body_fld_lines 3724 3725 capability ::= "AUTH=" auth_type / atom 3726 ;; New capabilities MUST begin with "X" or be 3727 ;; registered with IANA as standard or 3728 ;; standards-track 3729 3730 capability_data ::= "CAPABILITY" SPACE [1#capability SPACE] "IMAP4rev1" 3731 [SPACE 1#capability] 3732 ;; IMAP4rev1 servers which offer RFC 1730 3733 ;; compatibility MUST list "IMAP4" as the first 3734 ;; capability. 3735 3736 CHAR ::= <any 7-bit US-ASCII character except NUL, 3737 0x01 - 0x7f> 3738 3739 CHAR8 ::= <any 8-bit octet except NUL, 0x01 - 0xff> 3740 3741 command ::= tag SPACE (command_any / command_auth / 3742 command_nonauth / command_select) CRLF 3743 ;; Modal based on state 3744 3745 command_any ::= "CAPABILITY" / "LOGOUT" / "NOOP" / x_command 3746 ;; Valid in all states 3747 3748 command_auth ::= append / create / delete / examine / list / lsub / 3749 rename / select / status / subscribe / unsubscribe 3750 ;; Valid only in Authenticated or Selected state 3751 3752 3753 3754 Crispin Standards Track [Page 67] 3755 3756 RFC 2060 IMAP4rev1 December 1996 3757 3758 3759 command_nonauth ::= login / authenticate 3760 ;; Valid only when in Non-Authenticated state 3761 3762 command_select ::= "CHECK" / "CLOSE" / "EXPUNGE" / 3763 copy / fetch / store / uid / search 3764 ;; Valid only when in Selected state 3765 3766 continue_req ::= "+" SPACE (resp_text / base64) 3767 3768 copy ::= "COPY" SPACE set SPACE mailbox 3769 3770 CR ::= <ASCII CR, carriage return, 0x0D> 3771 3772 create ::= "CREATE" SPACE mailbox 3773 ;; Use of INBOX gives a NO error 3774 3775 CRLF ::= CR LF 3776 3777 CTL ::= <any ASCII control character and DEL, 3778 0x00 - 0x1f, 0x7f> 3779 3780 date ::= date_text / <"> date_text <"> 3781 3782 date_day ::= 1*2digit 3783 ;; Day of month 3784 3785 date_day_fixed ::= (SPACE digit) / 2digit 3786 ;; Fixed-format version of date_day 3787 3788 date_month ::= "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / 3789 "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec" 3790 3791 date_text ::= date_day "-" date_month "-" date_year 3792 3793 date_year ::= 4digit 3794 3795 date_time ::= <"> date_day_fixed "-" date_month "-" date_year 3796 SPACE time SPACE zone <"> 3797 3798 delete ::= "DELETE" SPACE mailbox 3799 ;; Use of INBOX gives a NO error 3800 3801 digit ::= "0" / digit_nz 3802 3803 digit_nz ::= "1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / 3804 "9" 3805 3806 3807 3808 3809 3810 Crispin Standards Track [Page 68] 3811 3812 RFC 2060 IMAP4rev1 December 1996 3813 3814 3815 envelope ::= "(" env_date SPACE env_subject SPACE env_from 3816 SPACE env_sender SPACE env_reply_to SPACE env_to 3817 SPACE env_cc SPACE env_bcc SPACE env_in_reply_to 3818 SPACE env_message_id ")" 3819 3820 env_bcc ::= "(" 1*address ")" / nil 3821 3822 env_cc ::= "(" 1*address ")" / nil 3823 3824 env_date ::= nstring 3825 3826 env_from ::= "(" 1*address ")" / nil 3827 3828 env_in_reply_to ::= nstring 3829 3830 env_message_id ::= nstring 3831 3832 env_reply_to ::= "(" 1*address ")" / nil 3833 3834 env_sender ::= "(" 1*address ")" / nil 3835 3836 env_subject ::= nstring 3837 3838 env_to ::= "(" 1*address ")" / nil 3839 3840 examine ::= "EXAMINE" SPACE mailbox 3841 3842 fetch ::= "FETCH" SPACE set SPACE ("ALL" / "FULL" / 3843 "FAST" / fetch_att / "(" 1#fetch_att ")") 3844 3845 fetch_att ::= "ENVELOPE" / "FLAGS" / "INTERNALDATE" / 3846 "RFC822" [".HEADER" / ".SIZE" / ".TEXT"] / 3847 "BODY" ["STRUCTURE"] / "UID" / 3848 "BODY" [".PEEK"] section 3849 ["<" number "." nz_number ">"] 3850 3851 flag ::= "\Answered" / "\Flagged" / "\Deleted" / 3852 "\Seen" / "\Draft" / flag_keyword / flag_extension 3853 3854 flag_extension ::= "\" atom 3855 ;; Future expansion. Client implementations 3856 ;; MUST accept flag_extension flags. Server 3857 ;; implementations MUST NOT generate 3858 ;; flag_extension flags except as defined by 3859 ;; future standard or standards-track 3860 ;; revisions of this specification. 3861 3862 flag_keyword ::= atom 3863 3864 3865 3866 Crispin Standards Track [Page 69] 3867 3868 RFC 2060 IMAP4rev1 December 1996 3869 3870 3871 flag_list ::= "(" #flag ")" 3872 3873 greeting ::= "*" SPACE (resp_cond_auth / resp_cond_bye) CRLF 3874 3875 header_fld_name ::= astring 3876 3877 header_list ::= "(" 1#header_fld_name ")" 3878 3879 LF ::= <ASCII LF, line feed, 0x0A> 3880 3881 list ::= "LIST" SPACE mailbox SPACE list_mailbox 3882 3883 list_mailbox ::= 1*(ATOM_CHAR / list_wildcards) / string 3884 3885 list_wildcards ::= "%" / "*" 3886 3887 literal ::= "{" number "}" CRLF *CHAR8 3888 ;; Number represents the number of CHAR8 octets 3889 3890 login ::= "LOGIN" SPACE userid SPACE password 3891 3892 lsub ::= "LSUB" SPACE mailbox SPACE list_mailbox 3893 3894 mailbox ::= "INBOX" / astring 3895 ;; INBOX is case-insensitive. All case variants of 3896 ;; INBOX (e.g. "iNbOx") MUST be interpreted as INBOX 3897 ;; not as an astring. Refer to section 5.1 for 3898 ;; further semantic details of mailbox names. 3899 3900 mailbox_data ::= "FLAGS" SPACE flag_list / 3901 "LIST" SPACE mailbox_list / 3902 "LSUB" SPACE mailbox_list / 3903 "MAILBOX" SPACE text / 3904 "SEARCH" [SPACE 1#nz_number] / 3905 "STATUS" SPACE mailbox SPACE 3906 "(" #<status_att number ")" / 3907 number SPACE "EXISTS" / number SPACE "RECENT" 3908 3909 mailbox_list ::= "(" #("\Marked" / "\Noinferiors" / 3910 "\Noselect" / "\Unmarked" / flag_extension) ")" 3911 SPACE (<"> QUOTED_CHAR <"> / nil) SPACE mailbox 3912 3913 media_basic ::= (<"> ("APPLICATION" / "AUDIO" / "IMAGE" / 3914 "MESSAGE" / "VIDEO") <">) / string) 3915 SPACE media_subtype 3916 ;; Defined in [MIME-IMT] 3917 3918 media_message ::= <"> "MESSAGE" <"> SPACE <"> "RFC822" <"> 3919 3920 3921 3922 Crispin Standards Track [Page 70] 3923 3924 RFC 2060 IMAP4rev1 December 1996 3925 3926 3927 ;; Defined in [MIME-IMT] 3928 3929 media_subtype ::= string 3930 ;; Defined in [MIME-IMT] 3931 3932 media_text ::= <"> "TEXT" <"> SPACE media_subtype 3933 ;; Defined in [MIME-IMT] 3934 3935 message_data ::= nz_number SPACE ("EXPUNGE" / 3936 ("FETCH" SPACE msg_att)) 3937 3938 msg_att ::= "(" 1#("ENVELOPE" SPACE envelope / 3939 "FLAGS" SPACE "(" #(flag / "\Recent") ")" / 3940 "INTERNALDATE" SPACE date_time / 3941 "RFC822" [".HEADER" / ".TEXT"] SPACE nstring / 3942 "RFC822.SIZE" SPACE number / 3943 "BODY" ["STRUCTURE"] SPACE body / 3944 "BODY" section ["<" number ">"] SPACE nstring / 3945 "UID" SPACE uniqueid) ")" 3946 3947 nil ::= "NIL" 3948 3949 nstring ::= string / nil 3950 3951 number ::= 1*digit 3952 ;; Unsigned 32-bit integer 3953 ;; (0 <= n < 4,294,967,296) 3954 3955 nz_number ::= digit_nz *digit 3956 ;; Non-zero unsigned 32-bit integer 3957 ;; (0 < n < 4,294,967,296) 3958 3959 password ::= astring 3960 3961 quoted ::= <"> *QUOTED_CHAR <"> 3962 3963 QUOTED_CHAR ::= <any TEXT_CHAR except quoted_specials> / 3964 "\" quoted_specials 3965 3966 quoted_specials ::= <"> / "\" 3967 3968 rename ::= "RENAME" SPACE mailbox SPACE mailbox 3969 ;; Use of INBOX as a destination gives a NO error 3970 3971 response ::= *(continue_req / response_data) response_done 3972 3973 response_data ::= "*" SPACE (resp_cond_state / resp_cond_bye / 3974 mailbox_data / message_data / capability_data) 3975 3976 3977 3978 Crispin Standards Track [Page 71] 3979 3980 RFC 2060 IMAP4rev1 December 1996 3981 3982 3983 CRLF 3984 3985 response_done ::= response_tagged / response_fatal 3986 3987 response_fatal ::= "*" SPACE resp_cond_bye CRLF 3988 ;; Server closes connection immediately 3989 3990 response_tagged ::= tag SPACE resp_cond_state CRLF 3991 3992 resp_cond_auth ::= ("OK" / "PREAUTH") SPACE resp_text 3993 ;; Authentication condition 3994 3995 resp_cond_bye ::= "BYE" SPACE resp_text 3996 3997 resp_cond_state ::= ("OK" / "NO" / "BAD") SPACE resp_text 3998 ;; Status condition 3999 4000 resp_text ::= ["[" resp_text_code "]" SPACE] (text_mime2 / text) 4001 ;; text SHOULD NOT begin with "[" or "=" 4002 4003 resp_text_code ::= "ALERT" / "PARSE" / 4004 "PERMANENTFLAGS" SPACE "(" #(flag / "\*") ")" / 4005 "READ-ONLY" / "READ-WRITE" / "TRYCREATE" / 4006 "UIDVALIDITY" SPACE nz_number / 4007 "UNSEEN" SPACE nz_number / 4008 atom [SPACE 1*<any TEXT_CHAR except "]">] 4009 4010 search ::= "SEARCH" SPACE ["CHARSET" SPACE astring SPACE] 4011 1#search_key 4012 ;; [CHARSET] MUST be registered with IANA 4013 4014 search_key ::= "ALL" / "ANSWERED" / "BCC" SPACE astring / 4015 "BEFORE" SPACE date / "BODY" SPACE astring / 4016 "CC" SPACE astring / "DELETED" / "FLAGGED" / 4017 "FROM" SPACE astring / 4018 "KEYWORD" SPACE flag_keyword / "NEW" / "OLD" / 4019 "ON" SPACE date / "RECENT" / "SEEN" / 4020 "SINCE" SPACE date / "SUBJECT" SPACE astring / 4021 "TEXT" SPACE astring / "TO" SPACE astring / 4022 "UNANSWERED" / "UNDELETED" / "UNFLAGGED" / 4023 "UNKEYWORD" SPACE flag_keyword / "UNSEEN" / 4024 ;; Above this line were in [IMAP2] 4025 "DRAFT" / 4026 "HEADER" SPACE header_fld_name SPACE astring / 4027 "LARGER" SPACE number / "NOT" SPACE search_key / 4028 "OR" SPACE search_key SPACE search_key / 4029 "SENTBEFORE" SPACE date / "SENTON" SPACE date / 4030 "SENTSINCE" SPACE date / "SMALLER" SPACE number / 4031 4032 4033 4034 Crispin Standards Track [Page 72] 4035 4036 RFC 2060 IMAP4rev1 December 1996 4037 4038 4039 "UID" SPACE set / "UNDRAFT" / set / 4040 "(" 1#search_key ")" 4041 4042 section ::= "[" [section_text / (nz_number *["." nz_number] 4043 ["." (section_text / "MIME")])] "]" 4044 4045 section_text ::= "HEADER" / "HEADER.FIELDS" [".NOT"] 4046 SPACE header_list / "TEXT" 4047 4048 select ::= "SELECT" SPACE mailbox 4049 4050 sequence_num ::= nz_number / "*" 4051 ;; * is the largest number in use. For message 4052 ;; sequence numbers, it is the number of messages 4053 ;; in the mailbox. For unique identifiers, it is 4054 ;; the unique identifier of the last message in 4055 ;; the mailbox. 4056 4057 set ::= sequence_num / (sequence_num ":" sequence_num) / 4058 (set "," set) 4059 ;; Identifies a set of messages. For message 4060 ;; sequence numbers, these are consecutive 4061 ;; numbers from 1 to the number of messages in 4062 ;; the mailbox 4063 ;; Comma delimits individual numbers, colon 4064 ;; delimits between two numbers inclusive. 4065 ;; Example: 2,4:7,9,12:* is 2,4,5,6,7,9,12,13, 4066 ;; 14,15 for a mailbox with 15 messages. 4067 4068 SPACE ::= <ASCII SP, space, 0x20> 4069 4070 status ::= "STATUS" SPACE mailbox SPACE "(" 1#status_att ")" 4071 4072 status_att ::= "MESSAGES" / "RECENT" / "UIDNEXT" / "UIDVALIDITY" / 4073 "UNSEEN" 4074 4075 store ::= "STORE" SPACE set SPACE store_att_flags 4076 4077 store_att_flags ::= (["+" / "-"] "FLAGS" [".SILENT"]) SPACE 4078 (flag_list / #flag) 4079 4080 string ::= quoted / literal 4081 4082 subscribe ::= "SUBSCRIBE" SPACE mailbox 4083 4084 tag ::= 1*<any ATOM_CHAR except "+"> 4085 4086 text ::= 1*TEXT_CHAR 4087 4088 4089 4090 Crispin Standards Track [Page 73] 4091 4092 RFC 2060 IMAP4rev1 December 1996 4093 4094 4095 text_mime2 ::= "=?" <charset> "?" <encoding> "?" 4096 <encoded-text> "?=" 4097 ;; Syntax defined in [MIME-HDRS] 4098 4099 TEXT_CHAR ::= <any CHAR except CR and LF> 4100 4101 time ::= 2digit ":" 2digit ":" 2digit 4102 ;; Hours minutes seconds 4103 4104 uid ::= "UID" SPACE (copy / fetch / search / store) 4105 ;; Unique identifiers used instead of message 4106 ;; sequence numbers 4107 4108 uniqueid ::= nz_number 4109 ;; Strictly ascending 4110 4111 unsubscribe ::= "UNSUBSCRIBE" SPACE mailbox 4112 4113 userid ::= astring 4114 4115 x_command ::= "X" atom <experimental command arguments> 4116 4117 zone ::= ("+" / "-") 4digit 4118 ;; Signed four-digit value of hhmm representing 4119 ;; hours and minutes west of Greenwich (that is, 4120 ;; (the amount that the given time differs from 4121 ;; Universal Time). Subtracting the timezone 4122 ;; from the given time will give the UT form. 4123 ;; The Universal Time zone is "+0000". 4124 4125 10. Author's Note 4126 4127 This document is a revision or rewrite of earlier documents, and 4128 supercedes the protocol specification in those documents: RFC 1730, 4129 unpublished IMAP2bis.TXT document, RFC 1176, and RFC 1064. 4130 4131 11. Security Considerations 4132 4133 IMAP4rev1 protocol transactions, including electronic mail data, are 4134 sent in the clear over the network unless privacy protection is 4135 negotiated in the AUTHENTICATE command. 4136 4137 A server error message for an AUTHENTICATE command which fails due to 4138 invalid credentials SHOULD NOT detail why the credentials are 4139 invalid. 4140 4141 Use of the LOGIN command sends passwords in the clear. This can be 4142 avoided by using the AUTHENTICATE command instead. 4143 4144 4145 4146 Crispin Standards Track [Page 74] 4147 4148 RFC 2060 IMAP4rev1 December 1996 4149 4150 4151 A server error message for a failing LOGIN command SHOULD NOT specify 4152 that the user name, as opposed to the password, is invalid. 4153 4154 Additional security considerations are discussed in the section 4155 discussing the AUTHENTICATE and LOGIN commands. 4156 4157 12. Author's Address 4158 4159 Mark R. Crispin 4160 Networks and Distributed Computing 4161 University of Washington 4162 4545 15th Aveneue NE 4163 Seattle, WA 98105-4527 4164 4165 Phone: (206) 543-5762 4166 4167 EMail: MRC@CAC.Washington.EDU 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 Crispin Standards Track [Page 75] 4203 4204 RFC 2060 IMAP4rev1 December 1996 4205 4206 4207 Appendices 4208 4209 A. References 4210 4211 [ACAP] Myers, J. "ACAP -- Application Configuration Access Protocol", 4212 Work in Progress. 4213 4214 [CHARSET] Reynolds, J., and J. Postel, "Assigned Numbers", STD 2, 4215 RFC 1700, USC/Information Sciences Institute, October 1994. 4216 4217 [DISPOSITION] Troost, R., and Dorner, S., "Communicating Presentation 4218 Information in Internet Messages: The Content-Disposition Header", 4219 RFC 1806, June 1995. 4220 4221 [IMAP-AUTH] Myers, J., "IMAP4 Authentication Mechanism", RFC 1731. 4222 Carnegie-Mellon University, December 1994. 4223 4224 [IMAP-COMPAT] Crispin, M., "IMAP4 Compatibility with IMAP2bis", RFC 4225 2061, University of Washington, November 1996. 4226 4227 [IMAP-DISC] Austein, R., "Synchronization Operations for Disconnected 4228 IMAP4 Clients", Work in Progress. 4229 4230 [IMAP-HISTORICAL] Crispin, M. "IMAP4 Compatibility with IMAP2 and 4231 IMAP2bis", RFC 1732, University of Washington, December 1994. 4232 4233 [IMAP-MODEL] Crispin, M., "Distributed Electronic Mail Models in 4234 IMAP4", RFC 1733, University of Washington, December 1994. 4235 4236 [IMAP-OBSOLETE] Crispin, M., "Internet Message Access Protocol - 4237 Obsolete Syntax", RFC 2062, University of Washington, November 1996. 4238 4239 [IMAP2] Crispin, M., "Interactive Mail Access Protocol - Version 2", 4240 RFC 1176, University of Washington, August 1990. 4241 4242 [LANGUAGE-TAGS] Alvestrand, H., "Tags for the Identification of 4243 Languages", RFC 1766, March 1995. 4244 4245 [MD5] Myers, J., and M. Rose, "The Content-MD5 Header Field", RFC 4246 1864, October 1995. 4247 4248 [MIME-IMB] Freed, N., and N. Borenstein, "MIME (Multipurpose Internet 4249 Mail Extensions) Part One: Format of Internet Message Bodies", RFC 4250 2045, November 1996. 4251 4252 [MIME-IMT] Freed, N., and N. Borenstein, "MIME (Multipurpose 4253 Internet Mail Extensions) Part Two: Media Types", RFC 2046, 4254 November 1996. 4255 4256 4257 4258 Crispin Standards Track [Page 76] 4259 4260 RFC 2060 IMAP4rev1 December 1996 4261 4262 4263 [MIME-HDRS] Moore, K., "MIME (Multipurpose Internet Mail Extensions) 4264 Part Three: Message Header Extensions for Non-ASCII Text", RFC 4265 2047, November 1996. 4266 4267 [RFC-822] Crocker, D., "Standard for the Format of ARPA Internet Text 4268 Messages", STD 11, RFC 822, University of Delaware, August 1982. 4269 4270 [SMTP] Postel, J., "Simple Mail Transfer Protocol", STD 10, 4271 RFC 821, USC/Information Sciences Institute, August 1982. 4272 4273 [UTF-7] Goldsmith, D., and Davis, M., "UTF-7: A Mail-Safe 4274 Transformation Format of Unicode", RFC 1642, July 1994. 4275 4276 B. Changes from RFC 1730 4277 4278 1) The STATUS command has been added. 4279 4280 2) Clarify in the formal syntax that the "#" construct can never 4281 refer to multiple spaces. 4282 4283 3) Obsolete syntax has been moved to a separate document. 4284 4285 4) The PARTIAL command has been obsoleted. 4286 4287 5) The RFC822.HEADER.LINES, RFC822.HEADER.LINES.NOT, RFC822.PEEK, and 4288 RFC822.TEXT.PEEK fetch attributes have been obsoleted. 4289 4290 6) The "<" origin "." size ">" suffix for BODY text attributes has 4291 been added. 4292 4293 7) The HEADER, HEADER.FIELDS, HEADER.FIELDS.NOT, MIME, and TEXT part 4294 specifiers have been added. 4295 4296 8) Support for Content-Disposition and Content-Language has been 4297 added. 4298 4299 9) The restriction on fetching nested MULTIPART parts has been 4300 removed. 4301 4302 10) Body part number 0 has been obsoleted. 4303 4304 11) Server-supported authenticators are now identified by 4305 capabilities. 4306 4307 4308 4309 4310 4311 4312 4313 4314 Crispin Standards Track [Page 77] 4315 4316 RFC 2060 IMAP4rev1 December 1996 4317 4318 4319 12) The capability that identifies this protocol is now called 4320 "IMAP4rev1". A server that provides backwards support for RFC 1730 4321 SHOULD emit the "IMAP4" capability in addition to "IMAP4rev1" in its 4322 CAPABILITY response. Because RFC-1730 required "IMAP4" to appear as 4323 the first capability, it MUST listed first in the response. 4324 4325 13) A description of the mailbox name namespace convention has been 4326 added. 4327 4328 14) A description of the international mailbox name convention has 4329 been added. 4330 4331 15) The UID-NEXT and UID-VALIDITY status items are now called UIDNEXT 4332 and UIDVALIDITY. This is a change from the IMAP STATUS 4333 Work in Progress and not from RFC-1730 4334 4335 16) Add a clarification that a null mailbox name argument to the LIST 4336 command returns an untagged LIST response with the hierarchy 4337 delimiter and root of the reference argument. 4338 4339 17) Define terms such as "MUST", "SHOULD", and "MUST NOT". 4340 4341 18) Add a section which defines message attributes and more 4342 thoroughly details the semantics of message sequence numbers, UIDs, 4343 and flags. 4344 4345 19) Add a clarification detailing the circumstances when a client may 4346 send multiple commands without waiting for a response, and the 4347 circumstances in which ambiguities may result. 4348 4349 20) Add a recommendation on server behavior for DELETE and RENAME 4350 when inferior hierarchical names of the given name exist. 4351 4352 21) Add a clarification that a mailbox name may not be unilaterally 4353 unsubscribed by the server, even if that mailbox name no longer 4354 exists. 4355 4356 22) Add a clarification that LIST should return its results quickly 4357 without undue delay. 4358 4359 23) Add a clarification that the date_time argument to APPEND sets 4360 the internal date of the message. 4361 4362 24) Add a clarification on APPEND behavior when the target mailbox is 4363 the currently selected mailbox. 4364 4365 4366 4367 4368 4369 4370 Crispin Standards Track [Page 78] 4371 4372 RFC 2060 IMAP4rev1 December 1996 4373 4374 4375 25) Add a clarification that external changes to flags should be 4376 always announced via an untagged FETCH even if the current command is 4377 a STORE with the ".SILENT" suffix. 4378 4379 26) Add a clarification that COPY appends to the target mailbox. 4380 4381 27) Add the NEWNAME response code. 4382 4383 28) Rewrite the description of the untagged BYE response to clarify 4384 its semantics. 4385 4386 29) Change the reference for the body MD5 to refer to the proper RFC. 4387 4388 30) Clarify that the formal syntax contains rules which may overlap, 4389 and that in the event of such an overlap the rule which occurs first 4390 takes precedence. 4391 4392 31) Correct the definition of body_fld_param. 4393 4394 32) More formal syntax for capability_data. 4395 4396 33) Clarify that any case variant of "INBOX" must be interpreted as 4397 INBOX. 4398 4399 34) Clarify that the human-readable text in resp_text should not 4400 begin with "[" or "=". 4401 4402 35) Change MIME references to Draft Standard documents. 4403 4404 36) Clarify \Recent semantics. 4405 4406 37) Additional examples. 4407 4408 C. Key Word Index 4409 4410 +FLAGS <flag list> (store command data item) ............... 45 4411 +FLAGS.SILENT <flag list> (store command data item) ........ 46 4412 -FLAGS <flag list> (store command data item) ............... 46 4413 -FLAGS.SILENT <flag list> (store command data item) ........ 46 4414 ALERT (response code) ...................................... 50 4415 ALL (fetch item) ........................................... 41 4416 ALL (search key) ........................................... 38 4417 ANSWERED (search key) ...................................... 38 4418 APPEND (command) ........................................... 34 4419 AUTHENTICATE (command) ..................................... 20 4420 BAD (response) ............................................. 52 4421 BCC <string> (search key) .................................. 38 4422 BEFORE <date> (search key) ................................. 39 4423 4424 4425 4426 Crispin Standards Track [Page 79] 4427 4428 RFC 2060 IMAP4rev1 December 1996 4429 4430 4431 BODY (fetch item) .......................................... 41 4432 BODY (fetch result) ........................................ 58 4433 BODY <string> (search key) ................................. 39 4434 BODY.PEEK[<section>]<<partial>> (fetch item) ............... 44 4435 BODYSTRUCTURE (fetch item) ................................. 44 4436 BODYSTRUCTURE (fetch result) ............................... 59 4437 BODY[<section>]<<origin_octet>> (fetch result) ............. 58 4438 BODY[<section>]<<partial>> (fetch item) .................... 41 4439 BYE (response) ............................................. 52 4440 Body Structure (message attribute) ......................... 11 4441 CAPABILITY (command) ....................................... 18 4442 CAPABILITY (response) ...................................... 53 4443 CC <string> (search key) ................................... 39 4444 CHECK (command) ............................................ 36 4445 CLOSE (command) ............................................ 36 4446 COPY (command) ............................................. 46 4447 CREATE (command) ........................................... 25 4448 DELETE (command) ........................................... 26 4449 DELETED (search key) ....................................... 39 4450 DRAFT (search key) ......................................... 39 4451 ENVELOPE (fetch item) ...................................... 44 4452 ENVELOPE (fetch result) .................................... 62 4453 EXAMINE (command) .......................................... 24 4454 EXISTS (response) .......................................... 56 4455 EXPUNGE (command) .......................................... 37 4456 EXPUNGE (response) ......................................... 57 4457 Envelope Structure (message attribute) ..................... 11 4458 FAST (fetch item) .......................................... 44 4459 FETCH (command) ............................................ 41 4460 FETCH (response) ........................................... 58 4461 FLAGGED (search key) ....................................... 39 4462 FLAGS (fetch item) ......................................... 44 4463 FLAGS (fetch result) ....................................... 62 4464 FLAGS (response) ........................................... 56 4465 FLAGS <flag list> (store command data item) ................ 45 4466 FLAGS.SILENT <flag list> (store command data item) ......... 45 4467 FROM <string> (search key) ................................. 39 4468 FULL (fetch item) .......................................... 44 4469 Flags (message attribute) .................................. 9 4470 HEADER (part specifier) .................................... 41 4471 HEADER <field-name> <string> (search key) .................. 39 4472 HEADER.FIELDS <header_list> (part specifier) ............... 41 4473 HEADER.FIELDS.NOT <header_list> (part specifier) ........... 41 4474 INTERNALDATE (fetch item) .................................. 44 4475 INTERNALDATE (fetch result) ................................ 62 4476 Internal Date (message attribute) .......................... 10 4477 KEYWORD <flag> (search key) ................................ 39 4478 Keyword (type of flag) ..................................... 10 4479 4480 4481 4482 Crispin Standards Track [Page 80] 4483 4484 RFC 2060 IMAP4rev1 December 1996 4485 4486 4487 LARGER <n> (search key) .................................... 39 4488 LIST (command) ............................................. 30 4489 LIST (response) ............................................ 54 4490 LOGIN (command) ............................................ 22 4491 LOGOUT (command) ........................................... 20 4492 LSUB (command) ............................................. 32 4493 LSUB (response) ............................................ 55 4494 MAY (specification requirement term) ....................... 5 4495 MESSAGES (status item) ..................................... 33 4496 MIME (part specifier) ...................................... 42 4497 MUST (specification requirement term) ...................... 4 4498 MUST NOT (specification requirement term) .................. 4 4499 Message Sequence Number (message attribute) ................ 9 4500 NEW (search key) ........................................... 39 4501 NEWNAME (response code) .................................... 50 4502 NO (response) .............................................. 51 4503 NOOP (command) ............................................. 19 4504 NOT <search-key> (search key) .............................. 39 4505 OK (response) .............................................. 51 4506 OLD (search key) ........................................... 39 4507 ON <date> (search key) ..................................... 39 4508 OPTIONAL (specification requirement term) .................. 5 4509 OR <search-key1> <search-key2> (search key) ................ 39 4510 PARSE (response code) ...................................... 50 4511 PERMANENTFLAGS (response code) ............................. 50 4512 PREAUTH (response) ......................................... 52 4513 Permanent Flag (class of flag) ............................. 10 4514 READ-ONLY (response code) .................................. 50 4515 READ-WRITE (response code) ................................. 50 4516 RECENT (response) .......................................... 57 4517 RECENT (search key) ........................................ 39 4518 RECENT (status item) ....................................... 33 4519 RENAME (command) ........................................... 27 4520 REQUIRED (specification requirement term) .................. 4 4521 RFC822 (fetch item) ........................................ 44 4522 RFC822 (fetch result) ...................................... 63 4523 RFC822.HEADER (fetch item) ................................. 44 4524 RFC822.HEADER (fetch result) ............................... 62 4525 RFC822.SIZE (fetch item) ................................... 44 4526 RFC822.SIZE (fetch result) ................................. 62 4527 RFC822.TEXT (fetch item) ................................... 44 4528 RFC822.TEXT (fetch result) ................................. 62 4529 SEARCH (command) ........................................... 37 4530 SEARCH (response) .......................................... 55 4531 SEEN (search key) .......................................... 40 4532 SELECT (command) ........................................... 23 4533 SENTBEFORE <date> (search key) ............................. 40 4534 SENTON <date> (search key) ................................. 40 4535 4536 4537 4538 Crispin Standards Track [Page 81] 4539 4540 RFC 2060 IMAP4rev1 December 1996 4541 4542 4543 SENTSINCE <date> (search key) .............................. 40 4544 SHOULD (specification requirement term) .................... 5 4545 SHOULD NOT (specification requirement term) ................ 5 4546 SINCE <date> (search key) .................................. 40 4547 SMALLER <n> (search key) ................................... 40 4548 STATUS (command) ........................................... 33 4549 STATUS (response) .......................................... 55 4550 STORE (command) ............................................ 45 4551 SUBJECT <string> (search key) .............................. 40 4552 SUBSCRIBE (command) ........................................ 29 4553 Session Flag (class of flag) ............................... 10 4554 System Flag (type of flag) ................................. 9 4555 TEXT (part specifier) ...................................... 42 4556 TEXT <string> (search key) ................................. 40 4557 TO <string> (search key) ................................... 40 4558 TRYCREATE (response code) .................................. 51 4559 UID (command) .............................................. 47 4560 UID (fetch item) ........................................... 44 4561 UID (fetch result) ......................................... 63 4562 UID <message set> (search key) ............................. 40 4563 UIDNEXT (status item) ...................................... 33 4564 UIDVALIDITY (response code) ................................ 51 4565 UIDVALIDITY (status item) .................................. 34 4566 UNANSWERED (search key) .................................... 40 4567 UNDELETED (search key) ..................................... 40 4568 UNDRAFT (search key) ....................................... 40 4569 UNFLAGGED (search key) ..................................... 40 4570 UNKEYWORD <flag> (search key) .............................. 40 4571 UNSEEN (response code) ..................................... 51 4572 UNSEEN (search key) ........................................ 40 4573 UNSEEN (status item) ....................................... 34 4574 UNSUBSCRIBE (command) ...................................... 30 4575 Unique Identifier (UID) (message attribute) ................ 7 4576 X<atom> (command) .......................................... 48 4577 [RFC-822] Size (message attribute) ......................... 11 4578 \Answered (system flag) .................................... 9 4579 \Deleted (system flag) ..................................... 9 4580 \Draft (system flag) ....................................... 9 4581 \Flagged (system flag) ..................................... 9 4582 \Marked (mailbox name attribute) ........................... 54 4583 \Noinferiors (mailbox name attribute) ...................... 54 4584 \Noselect (mailbox name attribute) ......................... 54 4585 \Recent (system flag) ...................................... 10 4586 \Seen (system flag) ........................................ 9 4587 \Unmarked (mailbox name attribute) ......................... 54 4588 4589 4590 4591 4592 4593 4594 Crispin Standards Track [Page 82] 4595