idnits 2.17.1 draft-leiba-imap-implement-guide-01.txt: ** The Abstract section seems to be numbered Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- ** Cannot find the required boilerplate sections (Copyright, IPR, etc.) in this document. Expected boilerplate is as follows today (2024-04-19) according to https://trustee.ietf.org/license-info : IETF Trust Legal Provisions of 28-dec-2009, Section 6.a: This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79. IETF Trust Legal Provisions of 28-dec-2009, Section 6.b(i), paragraph 2: Copyright (c) 2024 IETF Trust and the persons identified as the document authors. All rights reserved. IETF Trust Legal Provisions of 28-dec-2009, Section 6.b(i), paragraph 3: This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- ** Missing expiration date. The document expiration date should appear on the first and last page. ** The document seems to lack a 1id_guidelines paragraph about Internet-Drafts being working documents. ** The document seems to lack a 1id_guidelines paragraph about 6 months document validity. ** The document seems to lack a 1id_guidelines paragraph about the list of current Internet-Drafts. ** The document seems to lack a 1id_guidelines paragraph about the list of Shadow Directories. == No 'Intended status' indicated for this document; assuming Proposed Standard Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The document seems to lack an Introduction section. ** The document seems to lack an IANA Considerations section. (See Section 2.2 of https://www.ietf.org/id-info/checklist for how to handle the case when there are no actions for IANA.) ** The document seems to lack separate sections for Informative/Normative References. All references will be assumed normative when checking for downward references. ** The abstract seems to contain references ([RFC-2060]), which it shouldn't. Please replace those with straight textual mentions of the documents in question. Miscellaneous warnings: ---------------------------------------------------------------------------- -- The document seems to lack a disclaimer for pre-RFC5378 work, but may have content which was first submitted before 10 November 2008. If you have contacted all the original authors and they are all willing to grant the BCP78 rights to the IETF Trust, then this is fine, and you can ignore this comment. If not, you may need to add the pre-RFC5378 disclaimer. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (February 1998) is 9560 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Missing Reference: 'UIDVALIDITY 824708485' is mentioned on line 232, but not defined == Missing Reference: 'UNSEEN 9921' is mentioned on line 233, but not defined == Missing Reference: 'UNSEEN' is mentioned on line 238, but not defined == Missing Reference: 'TRYCREATE' is mentioned on line 384, but not defined == Missing Reference: 'READ-ONLY' is mentioned on line 386, but not defined == Missing Reference: 'UIDVALIDITY 12345' is mentioned on line 498, but not defined -- Looks like a reference, but probably isn't: '1' on line 539 ** Obsolete normative reference: RFC 2060 (Obsoleted by RFC 3501) ** Downref: Normative reference to an Informational RFC: RFC 2180 -- Possible downref: Non-RFC (?) normative reference: ref. 'NAMESPACE' Summary: 13 errors (**), 0 flaws (~~), 7 warnings (==), 4 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 1 Network Working Group B. Leiba 2 Internet Draft IBM T.J. Watson Research Center 3 Document: draft-leiba-imap-implement-guide-01.txt September 1997 4 Expires February 1998 6 IMAP4 Implementation Recommendations 8 Status of this Document 10 This document provides information for the Internet community. This 11 document does not specify an Internet standard of any kind. 12 Distribution of this document is unlimited. 14 This document is an Internet Draft. Internet Drafts are working 15 documents of the Internet Engineering Task Force (IETF), its Areas, 16 and its Working Groups. Note that other groups may also distribute 17 working documents as Internet Drafts. 19 Internet Drafts are draft documents valid for a maximum of six 20 months. Internet Drafts may be updated, replaced, or obsoleted by 21 other documents at any time. It is not appropriate to use Internet 22 Drafts as reference material or to cite them other than as a "working 23 draft" or "work in progress". 25 To learn the current status of any Internet-Draft, please check the 26 1id-abstracts.txt listing contained in the Internet-Drafts Shadow 27 Directories on ds.internic.net, nic.nordu.net, ftp.isi.edu, or 28 munnari.oz.au. 30 A revised version of this draft document will be submitted to the RFC 31 editor. Discussion and suggestions for improvement are requested. 32 This document will expire by the end of February 1998. 34 1. Abstract 36 The IMAP4 specification [RFC-2060] describes a rich protocol for use 37 in building clients and servers for storage, retrieval, and 38 manipulation of electronic mail. Because the protocol is so rich and 39 has so many implementation choices, there are often trade-offs that 40 must be made and issues that must be considered when designing such 41 clients and servers. This document attempts to outline these issues 42 and to make recommendations in order to make the end products as 43 interoperable as possible. 45 Internet DRAFT Implementation Recommendations September 1997 47 2. Conventions used in this document 49 In examples,"C:" indicates lines sent by a client that is connected 50 to a server. "S:" indicates lines sent by the server to the client. 52 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 53 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 54 document are to be interpreted as described in [RFC-2119]. 56 3. Interoperability Issues and Recommendations 58 3.1. Accessibility 60 This section describes the issues related to access to servers and 61 server resources. Concerns here include data sharing and maintenance 62 of client/server connections. 64 3.1.1. Multiple Accesses of the Same Mailbox 66 One strong point of IMAP4 is that, unlike POP3, it allows for 67 multiple simultaneous access to a single mailbox. A user can, thus, 68 read mail from a client at home while the client in the office is 69 still connected; or the help desk staff can all work out of the same 70 inbox, all seeing the same pool of questions. An important point 71 about this capability, though is that NO SERVER IS GUARANTEED TO 72 SUPPORT THIS. If you are selecting an IMAP server and this facility 73 is important to you, be sure that the server you choose to install, 74 in the configuration you choose to use, supports it. 76 If you are designing a client, you MUST NOT assume that you can 77 access the same mailbox more than once at a time. That means 78 1. you must handle gracefully the failure of a SELECT command if 79 the server refuses the second SELECT, 80 2. you must handle reasonably the severing of your connection (see 81 "Severed Connections", below) if the server chooses to allow the 82 second SELECT by forcing the first off, 83 3. you must avoid making multiple connections to the same mailbox 84 in your own client (for load balancing or other such reasons), 85 and 86 4. you must avoid using the STATUS command on a mailbox that you 87 have selected (with some server implementations the STATUS 88 command has the same problems with multiple access as do the 89 SELECT and EXAMINE commands). 91 A further note about STATUS: The STATUS command is sometimes used to 92 check a non-selected mailbox for new mail. This mechanism MUST NOT 93 be used to check for new mail in the selected mailbox; section 5.2 of 95 Internet DRAFT Implementation Recommendations September 1997 97 [RFC-2060] specifically forbids this in its last paragraph. 99 3.1.2. Severed Connections 101 The client/server connection may be severed for one of three reasons: 102 the client severs the connection, the server severs the connection, 103 or the connection is severed by outside forces beyond the control of 104 the client and the server (a telephone line drops, for example). 105 Clients and servers must both deal with these situations. 107 When the client wants to sever a connection, it's usually because it 108 has finished the work it needed to do on that connection. The client 109 SHOULD send a LOGOUT command, wait for the tagged response, and then 110 close the socket. But note that, while this is what's intended in 111 the protocol design, there isn't universal agreement here. Some 112 contend that sending the LOGOUT and waiting for the two responses 113 (untagged BYE and tagged OK) is wasteful and unnecessary, and that 114 the client can simply close the socket. The server should interpret 115 the closed socket as a log out by the client. The counterargument is 116 that it's useful from the standpoint of cleanup, problem 117 determination, and the like, to have an explicit client log out, 118 because otherwise there is no way for the server to tell the 119 difference between "closed socket because of log out" and "closed 120 socket because communication was disrupted". If there is a 121 client/server interaction problem, a client which routinely 122 terminates a session by breaking the connection without a LOGOUT will 123 make it much more difficult to determine the problem. 125 Because of this disagreement, server designers must be aware that 126 some clients might close the socket without sending a LOGOUT. In any 127 case, whether or not a LOGOUT was sent, the server SHOULD NOT 128 implicitly expunge any messages from the selected mailbox. If a 129 client wants the server to do so, it MUST send a CLOSE or EXPUNGE 130 command explicitly. 132 When the server wants to sever a connection it's usually due to an 133 inactivity timeout or is because a situation has arisen that has 134 changed the state of the mail store in a way that the server can not 135 communicate to the client. The server SHOULD send an untagged BYE 136 response to the client and then close the socket. Sending an 137 untagged BYE response before severing allows the server to send a 138 human-readable explanation of the problem to the client, which the 139 client may then log, display to the user, or both (see section 7.1.5 140 of [RFC-2060]). 142 Internet DRAFT Implementation Recommendations September 1997 144 3.2. Scaling 146 IMAP4 has many features that allow for scalability, as mail stores 147 become larger and more numerous. Large numbers of users, mailboxes, 148 and messages, and very large messages require thought to handle 149 efficiently. This document will not address the administrative 150 issues involved in large numbers of users, but we will look at the 151 other items. 153 3.2.1. Flood Control 155 There are three situations when a client can make a request that will 156 result in a very large response - too large for the client reasonably 157 to deal with: there are a great many mailboxes available, there are a 158 great many messages in the selected mailbox, or there is a very large 159 message part. The danger here is that the end user will be stuck 160 waiting while the server sends (and the client processes) an enormous 161 response. In all of these cases there are things a client can do to 162 reduce that danger. 164 3.2.1.1. Listing Mailboxes 166 Some servers present Usenet newsgroups to IMAP users. Newsgroups, 167 and other such hierarchical mailbox structures, can be very numerous 168 but may have only a few entries at the top level of hierarchy. 169 Clients that will have trouble with this are those that use 170 C: 001 LIST "" * 171 to determine the mailbox list. Because of this, clients SHOULD NOT 172 use an unqualified "*" that way in the LIST command. A safer 173 approach is to list each level of hierarchy individually, allowing 174 the user to traverse the tree one limb at a time, thus: 176 C: 001 LIST "" % 177 S: * LIST () "/" Banana 178 S: * LIST ...etc... 179 S: 001 OK done 180 and then 181 C: 002 LIST "" Banana/% 182 S: * LIST () "/" Banana/Apple 183 S: * LIST ...etc... 184 S: 002 OK done 186 Using this technique the client's user interface can give the user 187 full flexibility without choking on the voluminous reply to "LIST *". 188 Of course, it is still possible that the reply to 189 C: 005 LIST "" alt.fan.celebrity.% 190 may be thousands of entries long, and there is, unfortunately, 192 Internet DRAFT Implementation Recommendations September 1997 194 nothing the client can do to protect itself from that. This has not 195 yet been a notable problem. 197 3.2.1.2. Fetching the List of Messages 199 When a client selects a mailbox, it is given a count, in the untagged 200 EXISTS response, of the messages in the mailbox. This number can be 201 very large. In such a case it might be unwise to use 202 C: 004 FETCH 1:* ALL 203 to populate the user's view of the mailbox. One good method to avoid 204 problems with this is to batch the requests, thus: 206 C: 004 FETCH 1:50 ALL 207 S: * 1 FETCH ...etc... 208 S: 004 OK done 209 C: 005 FETCH 51:100 ALL 210 S: * 51 FETCH ...etc... 211 S: 005 OK done 212 C: 006 FETCH 101:150 ALL 213 ...etc... 215 Using this method, another command, such as "FETCH 6 BODY[1]" can be 216 inserted as necessary, and the client will not have its access to the 217 server blocked by a storm of FETCH replies. (Such a method could be 218 reversed to fetch the LAST 50 messages first, then the 50 prior to 219 that, and so on.) 221 As a smart extension of this, a well designed client, prepared for 222 very large mailboxes, will not fetch all message data AT ALL. 223 Rather, the client will populate the user's view only as the user 224 sees it, possibly pre-fetching selected information, and only 225 fetching other information as the user scrolls to it. For example, 226 to select only those messages beginning with the first unseen one: 228 C: 003 SELECT INBOX 229 S: * 10000 EXISTS 230 S: * 80 RECENT 231 S: * FLAGS (\Answered \Flagged \Deleted \Draft \Seen) 232 S: * OK [UIDVALIDITY 824708485] UID validity status 233 S: * OK [UNSEEN 9921] First unseen message 234 S: 003 OK [READ-WRITE] SELECT completed 235 C: 004 FETCH 9921:* ALL 236 ... etc... 238 If the server does not return an OK [UNSEEN] response, the client may 239 use SEARCH UNSEEN to obtain that value. 241 Internet DRAFT Implementation Recommendations September 1997 243 3.2.1.3. Fetching a Large Body Part 245 The issue here is similar to the one for a list of messages. In the 246 BODYSTRUCTURE response the client knows the size, in bytes, of the 247 body part it plans to fetch. Suppose this is a 70 MB video clip. 248 The client can use partial fetches to retrieve the body part in 249 pieces, avoiding the problem of an uninterruptible 70 MB literal 250 coming back from the server: 252 C: 022 FETCH 3 BODY[1]<0.20000> 253 S: * 3 FETCH (FLAGS(\Seen) BODY[1]<0> {20000} 254 S: ...data...) 255 S: 022 OK done 256 C: 023 FETCH 3 BODY[1]<20001.20000> 257 S: * 3 FETCH (BODY[1]<20001> {20000} 258 S: ...data...) 259 S: 023 OK done 260 C: 024 FETCH 3 BODY[1]<40001.20000> 261 ...etc... 263 3.2.1.4. BODYSTRUCTURE vs. Entire Messages 265 Because FETCH BODYSTRUCTURE is necessary in order to determine the 266 number of body parts, and, thus, whether a message has "attachments", 267 clients often use FETCH FULL as their normal method of populating the 268 user's view of a mailbox. The benefit is that the client can display 269 a paperclip icon or some such indication along with the normal 270 message summary. However, this comes at a significant cost with some 271 server configurations. The parsing needed to generate the FETCH 272 BODYSTRUCTURE response may be time-consuming compared with that 273 needed for FETCH ENVELOPE. The client developer should consider this 274 issue when deciding whether the ability to add a paperclip icon is 275 worth the tradeoff in performance, especially with large mailboxes. 277 Some clients, rather than using FETCH BODYSTRUCTURE, use FETCH BODY[] 278 (or the equivalent FETCH RFC822) to retrieve the entire message. 279 They then do the MIME parsing in the client. This may give the 280 client slightly more flexibility in some areas (access, for instance, 281 to header fields that aren't returned in the BODYSTRUCTURE and 282 ENVELOPE responses), but it can cause severe performance problems by 283 forcing the transfer of all body parts when the user might only want 284 to see some of them - a user logged on by modem and reading a small 285 text message with a large ZIP file attached may prefer to read the 286 text only and save the ZIP file for later. Therefore, a client 287 SHOULD NOT normally retrieve entire messages and SHOULD retrieve 288 message body parts selectively. 290 Internet DRAFT Implementation Recommendations September 1997 292 3.2.2. Subscriptions 294 The client isn't the only entity that can get flooded: the end user, 295 too, may need some flood control. The IMAP4 protocol provides such 296 control in the form of subscriptions. Most servers support the 297 SUBSCRIBE, UNSUBSCRIBE, and LSUB commands, and many users choose to 298 narrow down a large list of available mailboxes by subscribing to the 299 ones that they usually want to see. Clients, with this in mind, 300 SHOULD give the user a way to see only subscribed mailboxes. A 301 client that never uses the LSUB command takes a significant usability 302 feature away from the user. Of course, the client would not want to 303 hide the LIST command completely; the user needs to be able to go 304 both ways. 306 3.2.3. Searching 308 IMAP SEARCH commands can become particularly troublesome (that is, 309 slow) on mailboxes containing a large number of messages. So let's 310 put a few things in perspective in that regard. 312 The flag searches SHOULD be fast. The flag searches (ALL, [UN]SEEN, 313 [UN]ANSWERED, [UN]DELETED, [UN]DRAFT, [UN]FLAGGED, NEW, OLD, RECENT) 314 are known to be used by clients for the client's own use (for 315 instance, some clients use "SEARCH UNSEEN" to find unseen mail and 316 "SEARCH DELETED" to warn the user before expunging messages). 318 Other searches, particularly the text searches (HEADER, TEXT, BODY) 319 are initiated by the user, rather than by the client itself, and 320 somewhat slower performance can be tolerated, since the user is aware 321 that the search is being done (and is probably aware that it might be 322 time-consuming). 324 The client MAY allow other commands to be sent to the server while a 325 SEARCH is in progress, but at the time of this writing there is 326 little or no server support for parallel processing of multiple 327 commands in the same session (and see "Multiple Accesses of the Same 328 Mailbox" above for a description of the dangers of trying to work 329 around this by doing your SEARCH in another session). 331 Another word about text searches: some servers, built on database 332 back-ends with indexed search capabilities, may return search results 333 that do not match the IMAP spec's "case-insensitive substring" 334 requirements. While these servers are in violation of the protocol, 335 there is little harm in the violation as long as the search results 336 are used only to response to a user's request. Still, developers of 337 such servers should be aware that they ARE violating the protocol, 338 should think carefully about that behaviour, and MUST be certain that 339 their servers respond accurately to the flag searches for the reasons 341 Internet DRAFT Implementation Recommendations September 1997 343 outlined above. 345 3.3 Avoiding Invalid Requests 347 IMAP4 provides ways for a server to tell a client in advance what is 348 and isn't permitted in some circumstances. Clients SHOULD use these 349 features to avoid sending requests that a well designed client would 350 know to be invalid. This section explains this in more detail. 352 3.3.1. The CAPABILITY Command 354 All IMAP4 clients SHOULD use the CAPABILITY command to determine what 355 version of IMAP and what optional features a server supports. The 356 client SHOULD NOT send IMAP4rev1 commands and arguments to a server 357 that does not advertize IMAP4rev1 in its CAPABILITY response. 358 Similarly, the client SHOULD NOT send IMAP4 commands that no longer 359 exist in IMAP4rev1 to a server that does not advertize IMAP4 in its 360 CAPABILITY response. An IMAP4rev1 server is NOT required to support 361 obsolete IMAP4 or IMAP2bis commands (though some do; do not let this 362 fact lull you into thinking that it's valid to send such commands to 363 an IMAP4rev1 server). 365 A client SHOULD NOT send commands to probe for the existance of 366 certain extensions. All standard and standards-track extensions 367 include CAPABILITY tokens indicating their presense. All private and 368 experimental extensions SHOULD do the same, and clients that take 369 advantage of them SHOULD use the CAPABILITY response to determine 370 whether they may be used or not. 372 3.3.2. Don't Do What the Server Says You Can't 374 In many cases, the server, in response to a command, will tell the 375 client something about what can and can't be done with a particular 376 mailbox. The client SHOULD pay attention to this information and 377 SHOULD NOT try to do things that it's been told it can't do. 378 Examples: 379 * Do not try to SELECT a mailbox that has the \Noselect flag set. 380 * Do not try to CREATE a sub-mailbox in a mailbox that has the 381 \Noinferiors flag set. 382 * Do not respond to a failing COPY or APPEND command by trying to 383 CREATE the target mailbox if the server does not respond with a 384 [TRYCREATE] response code. 385 * Do not try to expunge a mailbox that has been selected with the 386 [READ-ONLY] response code. 388 Internet DRAFT Implementation Recommendations September 1997 390 3.4. Miscellaneous Protocol Considerations 392 We describe here a number of important protocol-related issues, the 393 misunderstanding of which has caused significant interoperability 394 problems in IMAP4 implementations. One general item is that every 395 implementer should be certain to take note of and to understand 396 section 2.2.2 and the preamble to section 7 of the IMAP4rev1 spec 397 [RFC-2060]. 399 3.4.1. Well Formed Protocol 401 We cannot stress enough the importance of adhering strictly to the 402 protocol grammar. The specification of the protocol is quite rigid; 403 do not assume that you can insert blank space for "readability" if 404 none is called for. Keep in mind that there are parsers out there 405 that will crash if there are protocol errors. There are clients that 406 will report every parser burp to the user. And in any case, 407 information that cannot be parsed is information that is lost. Be 408 careful in your protocol generation. And see "A Word About Testing", 409 below. 411 In particular, note that the string in the INTERNALDATE response is 412 NOT an RFC-822 date string - that is, it is not in the same format as 413 the first string in the ENVELOPE response. Since most clients will, 414 in fact, accept an RFC-822 date string in the INTERNALDATE response, 415 it's easy to miss this in your interoperability testing. But it will 416 cause a problem with some client, so be sure to generate the correct 417 string for this field. 419 3.4.2. Special Characters 421 Certain characters, currently the double-quote and the backslash, may 422 not be sent as they are inside a quoted string. These characters 423 MUST be preceded by the escape character if they are in a quoted 424 string, or else the string must be sent as a literal. Both clients 425 and servers MUST handle this, both on output (they must send these 426 characters properly) and on input (they must be able to receive 428 Internet DRAFT Implementation Recommendations September 1997 430 escaped characters in quoted strings). Example: 432 C: 001 LIST "" % 433 S: * LIST () "" INBOX 434 S: * LIST () "\\" TEST 435 S: * LIST () "\\" {12} 436 S: "My" mailbox 437 S: 001 OK done 438 C: 002 LIST "" "\"My\" mailbox\\%" 439 S: * LIST () "\\" {17} 440 S: "My" mailbox\Junk 441 S: 002 OK done 443 Note that in the example the server sent the hierarchy delimiter as 444 an escaped character in the quoted string and sent the mailbox name 445 containing imbedded double-quotes as a literal. The client used only 446 quoted strings, escaping both the backslash and the double-quote 447 characters. 449 The CR and LF characters may be sent ONLY in literals; they are not 450 allowed, even if escaped, inside quoted strings. 452 3.4.3. UIDs and UIDVALIDITY 454 Servers that support existing back-end mail stores often have no good 455 place to save UIDs for messages. Often the existing mail store will 456 not have the concept of UIDs in the sense that IMAP has: strictly 457 increasing, never re-issued, 32-bit integers. Some servers solve 458 this by storing the UIDs in a place that's accessible to end users, 459 allowing for the possibility that the users will delete them. Others 460 solve it by re-assigning UIDs every time a mailbox is selected. 462 The server SHOULD maintain UIDs permanently for all messages if it 463 can. If that's not possible, the server MUST change the UIDVALIDITY 464 value for the mailbox whenever any of the UIDs may have become 465 invalid. Clients MUST recognize that the UIDVALIDITY has changed and 466 MUST respond to that condition by throwing away any information that 467 they have saved about UIDs in that mailbox. There have been many 468 problems in this area when clients have failed to do this; in the 469 worst case it will result in loss of mail when a client deletes the 470 wrong piece of mail by using a stale UID. 472 It seems to be a common myth that "the UIDVALIDITY and the UID, taken 473 together, form a 64-bit identifier that uniquely identifies a message 474 on a server". This is absolutely NOT TRUE. There is no assurance 475 that the UIDVALIDITY values of two mailboxes be different, so the 476 UIDVALIDITY in no way identifies a mailbox. The ONLY purpose of 477 UIDVALIDITY is, as its name indicates, to give the client a way to 479 Internet DRAFT Implementation Recommendations September 1997 481 check the validity of the UIDs it has cached. While it is a valid 482 implementation choice to put these values together to make a 64-bit 483 identifier for the message, the important concept here is that UIDs 484 are not unique between mailboxes; they are only unique WITHIN a given 485 mailbox. 487 Under extreme circumstances (and this is extreme, indeed), the server 488 may have to invalidate UIDs while a mailbox is in use by a client - 489 that is, the UIDs that the client knows about in its active mailbox 490 are no longer valid. In that case, the server MUST immediately 491 change the UIDVALIDITY and MUST communicate this to the client. The 492 server MAY do this by sending an unsolicited UIDVALIDITY message, in 493 the same form as in response to the SELECT command. Clients MUST be 494 prepared to handle such a message and the possibly coincident failure 495 of the command in process. For example: 497 C: 032 UID STORE 382 +Flags.silent \Deleted 498 S: * OK [UIDVALIDITY 12345] New UIDVALIDITY value! 499 S: 032 NO UID command rejeced because UIDVALIDITY changed! 500 C: ...invalidates local information and re-fetches... 501 C: 033 FETCH 1:* UID 502 ...etc... 504 Alternatively, some servers force the client to re-select the 505 mailbox, at which time it will obtain a new UIDVALIDITY value. To do 506 this, the server closes this client session (see "Severed 507 Connections" above) and the client then reconnects and gets back in 508 synch. Clients MUST be prepared for either of these behaviours. 510 3.4.4. FETCH Responses 512 When a client asks for certain information in a FETCH command, the 513 server MAY return the requested information in any order, not 514 necessarily in the order that it was requested. Further, the server 515 MAY return the information in separate FETCH responses and MAY also 516 return information that was not explicitly requested (to reflect to 517 the client changes in the state of the subject message). Some 518 examples: 520 C: 001 FETCH 1 UID FLAGS INTERNALDATE 521 S: * 5 FETCH (FLAGS (\Deleted)) 522 S: * 1 FETCH (FLAGS (\Seen) INTERNALDATE "..." UID 345) 523 S: 001 OK done 524 (In this case, the responses are in a different order. Also, the 525 server returned a flag update for message 5, which wasn't part of the 526 client's request.) 528 Internet DRAFT Implementation Recommendations September 1997 530 C: 002 FETCH 2 UID FLAGS INTERNALDATE 531 S: * 2 FETCH (INTERNALDATE "...") 532 S: * 2 FETCH (UID 399) 533 S: * 2 FETCH (FLAGS ()) 534 S: 002 OK done 535 (In this case, the responses are in a different order and were 536 returned in separate responses.) 538 C: 003 FETCH 2 BODY[1] 539 S: * 2 FETCH (FLAGS (\Seen) BODY[1] {14} 540 S: Hello world! 541 S: ) 542 S: 003 OK done 543 (In this case, the FLAGS response was added by the server, since 544 fetching the body part caused the server to set the \Seen flag.) 546 Because of this characteristic a client MUST be ready to receive any 547 FETCH response at any time and should use that information to update 548 its local information about the message to which the FETCH response 549 refers. A client MUST NOT assume that any FETCH responses will come 550 in any particular order, or even that any will come at all. If after 551 receiving the tagged response for a FETCH command the client finds 552 that it did not get all of the information requested, the client 553 SHOULD send a NOOP command to the server to ensure that the server 554 has an opportunity to send any pending EXPUNGE responses to the 555 client (see [RFC-2180]). 557 3.4.5. RFC822.SIZE 559 Some back-end mail stores keep the mail in a canonical form, rather 560 than retaining the original MIME format of the messages. This means 561 that the server must reassemble the message to produce a MIME stream 562 when a client does a fetch such as RFC822 or BODY[], requesting the 563 entire message. It also may mean that the server has no convenient 564 way to know the RFC822.SIZE of the message. Often, such a server 565 will actually have to build the MIME stream to compute the size, only 566 to throw the stream away and report the size to the client. 568 When this is the case, some servers have chosen to estimate the size, 569 rather than to compute it precisely. Such an estimate allows the 570 client to display an approximate size to the user and to use the 571 estimate in flood control considerations (q.v.), but requires that 572 the client not use the size for things such as allocation of buffers, 573 because those buffers might then be too small to hold the actual MIME 574 stream. Instead, a client SHOULD use the size that's returned in the 575 literal when you fetch the data. 577 The protocol requires that the RFC822.SIZE value returned by the 579 Internet DRAFT Implementation Recommendations September 1997 581 server be EXACT. Estimating the size is a protocol violation, and 582 server designers must be aware that, despite the performance savings 583 they might realize in using an estimate, this practice will cause 584 some clients to fail in various ways. If possible, the server SHOULD 585 compute the RFC822.SIZE for a particular message once, and then save 586 it for later retrieval. If that's not possible, the server MUST 587 compute the value exactly every time. Incorrect estimates do cause 588 severe interoperability problems with some clients. 590 3.4.6. Expunged Messages 592 If the server allows multiple connections to the same mailbox, it is 593 often possible for messages to be expunged in one client unbeknownst 594 to another client. Since the server is not allowed to tell the 595 client about these expunged messages in response to a FETCH command, 596 the server may have to deal with the issue of how to return 597 information about an expunged message. There was extensive 598 discussion about this issue, and the results of that discussion are 599 summarized in [RFC-2180]. See that reference for a detailed 600 explanation and for recommendations. 602 3.4.7. The Namespace Issue 604 Namespaces are a very muddy area in IMAP4 implementation right now 605 (see [NAMESPACE] for a proposal to clear the water a bit). Until the 606 issue is resolved, the important thing for client developers to 607 understand is that some servers provide access through IMAP to more 608 than just the user's personal mailboxes, and, in fact, the user's 609 personal mailboxes may be "hidden" somewhere in the user's default 610 hierarchy. The client, therefore, SHOULD provide a setting wherein 611 the user can specify a prefix to be used when accessing mailboxes. 612 If the user's mailboxes are all in "~/mail/", for instance, then the 613 user can put that string in the prefix. The client would then put 614 the prefix in front of any name pattern in the LIST and LSUB 615 commands: 616 C: 001 LIST "" ~/mail/% 617 (See also "Reference Names in the LIST Command" below.) 619 3.4.8. Creating Special-Use Mailboxes 621 It may seem at first that this is part of the namespace issue; it is 622 not, and is only indirectly related to it. A number of clients like 623 to create special-use mailboxes with particular names. Most 624 commonly, clients with a "trash folder" model of message deletion 625 want to create a mailbox with the name "Trash" or "Deleted". Some 626 clients want to create a "Drafts" mailbox, an "Outbox" mailbox, or a 628 Internet DRAFT Implementation Recommendations September 1997 630 "Sent Mail" mailbox. And so on. There are two major 631 interoperability problems with this practice: 632 1. different clients may use different names for mailboxes with 633 similar functions (such as "Trash" and "Deleted"), or may manage the 634 same mailboxes in different ways, causing problems if a user switches 635 between clients and 636 2. there is no guarantee that the server will allow the creation of 637 the desired mailbox. 639 The client developer is, therefore, well advised to consider 640 carefully the creation of any special-use mailboxes on the server, 641 and, further, the client MUST NOT require such mailbox creation - 642 that is, if you do decide to do this, you MUST handle gracefully the 643 failure of the CREATE command and behave reasonably when your 644 special-use mailboxes do not exist and can not be created. 646 In addition, the client developer SHOULD provide a convenient way for 647 the user to select the names for any special-use mailboxes, allowing 648 the user to make these names the same in all clients s/he uses and to 649 put them where s/he wants them. 651 3.4.9. Reference Names in the LIST Command 653 Many implementers of both clients and servers are confused by the 654 "reference name" on the LIST command. The reference name is intended 655 to be used in much the way a "cd" (change directory) command is used 656 on Unix, PC DOS, Windows, and OS/2 systems. That is, the mailbox 657 name is interpreted in much the same way as a file of that name would 658 be found if one had done a "cd" command into the directory specified 659 by the reference name. For example, in Unix we have the following: 661 > cd /u/jones/junk 662 > vi banana [file is "/u/jones/junk/banana"] 663 > vi stuff/banana [file is "/u/jones/junk/stuff/banana"] 664 > vi /etc/hosts [file is "/etc/hosts"] 666 The interoperability problems with this, in practice, are several. 667 First, while some IMAP servers are built on Unix or PC file systems, 668 many others are not, and the file system semantics do not make sense 669 in those configurations. Second, while some IMAP servers expose the 670 underlying file system to the clients, others allow access only to 671 the user's personal mailboxes, or to some other limited set of files, 672 making such file-system-like semantics less meaningful. Third, 673 because the IMAP spec leaves the interpretation of the reference name 674 as "implementation-dependent", the various server implementations 675 handle it in vastly differing ways, and fourth, many implementers 676 simply do not understand it and misuse it, do not use it, or ignore 677 it as a result. 679 Internet DRAFT Implementation Recommendations September 1997 681 The following statement gets somewhat into the religious issues that 682 we've tried to avoid scrupulously here; so be it: because of the 683 confusion around the reference name, its use by a client is a 684 dangerous thing, prone to result in interoperability problems. There 685 are servers that interpret it as originally intended; there are 686 servers that ignore it completely; there are servers that simply 687 prepend it to the mailbox name (with or without inserting a hierarchy 688 delimiter in between). Because a client can't know which of these 689 four behaviours to expect, a client SHOULD NOT use a reference name 690 itself, expecting a particular server behavior. However, a client 691 SHOULD permit a USER, by configuration, to use a reference name. 693 There is in no way universal agreement about the use or non-use of 694 the reference name. The last words here are, "Be aware." 696 3.5. A Word About Testing 698 Since the whole point of IMAP is interoperability, and since 699 interoperability can not be tested in a vacuum, the final 700 recommendation of this treatise is, "Test against EVERYTHING." Test 701 your client against every server you can get an account on. Test 702 your server with every client you can get your hands on. Many 703 clients make limited test versions available on the Web for the 704 downloading. Many server owners will give serious client developers 705 guest accounts for testing. Contact them and ask. NEVER assume that 706 because your client works with one or two servers, or because your 707 server does fine with one or two clients, you will interoperate well 708 in general. 710 In particular, in addition to everything else, be sure to test 711 against the reference implementations: the PINE client, the 712 University of Washington server, and the Cyrus server. 714 See the following URLs on the web for more information here: 715 IMAP Products and Sources: http://www.imap.org/products.html 716 IMC MailConnect: http://www.imc.org/imc-mailconnect 718 4. Security Considerations 720 This document describes behaviour of clients and servers that use the 721 IMAP4 protocol, and as such, has the same security considerations as 722 described in [RFC-2060]. 724 Internet DRAFT Implementation Recommendations September 1997 726 5. References 728 [RFC-2060], Crispin, M., "Internet Message Access Protocol - Version 729 4rev1", RFC 2060, University of Washington, December 1996. 731 [RFC-2119], Bradner, S., "Key words for use in RFCs to Indicate 732 Requirement Levels", RFC 2119, Harvard University, March 1997. 734 [RFC-2180], Gahrns, M., "IMAP4 Multi-Accessed Mailbox Practice", RFC 735 2180, Microsoft, July 1997. 737 [NAMESPACE], Gahrns, M. & Newman, C., "IMAP4 Namespace", draft 738 document , June 1997. 740 6. Acknowledgments 742 To be completed... 744 7. Author's Address 746 Barry Leiba 747 IBM T.J. Watson Research Center 748 30 Saw Mill River Road 749 Hawthorne, NY 10532 751 Phone: 1-914-784-7941 752 Email: leiba@watson.ibm.com