rfc5465.IMAP_NOTIFY_extension.txt 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235
  1. Network Working Group A. Gulbrandsen
  2. Request for Comments: 5465 Oryx Mail Systems GmbH
  3. Updates: 5267 C. King
  4. Category: Standards Track A. Melnikov
  5. Isode Ltd.
  6. February 2009
  7. The IMAP NOTIFY Extension
  8. Status of This Memo
  9. This document specifies an Internet standards track protocol for the
  10. Internet community, and requests discussion and suggestions for
  11. improvements. Please refer to the current edition of the "Internet
  12. Official Protocol Standards" (STD 1) for the standardization state
  13. and status of this protocol. Distribution of this memo is unlimited.
  14. Copyright Notice
  15. Copyright (c) 2009 IETF Trust and the persons identified as the
  16. document authors. All rights reserved.
  17. This document is subject to BCP 78 and the IETF Trust's Legal
  18. Provisions Relating to IETF Documents (http://trustee.ietf.org/
  19. license-info) in effect on the date of publication of this document.
  20. Please review these documents carefully, as they describe your rights
  21. and restrictions with respect to this document.
  22. Abstract
  23. This document defines an IMAP extension that allows a client to
  24. request specific kinds of unsolicited notifications for specified
  25. mailboxes, such as messages being added to or deleted from such
  26. mailboxes.
  27. Gulbrandsen, et al. Standards Track [Page 1]
  28. RFC 5465 IMAP NOTIFY Extension February 2009
  29. Table of Contents
  30. 1. Overview and Rationale ..........................................3
  31. 2. Conventions Used in This Document ...............................4
  32. 3. The NOTIFY Extension ............................................4
  33. 3.1. The NOTIFY Command .........................................4
  34. 4. Interaction with the IDLE Command ...............................8
  35. 5. Event Types .....................................................8
  36. 5.1. FlagChange and AnnotationChange ............................9
  37. 5.2. MessageNew .................................................9
  38. 5.3. MessageExpunge ............................................10
  39. 5.4. MailboxName ...............................................11
  40. 5.5. SubscriptionChange ........................................12
  41. 5.6. MailboxMetadataChange .....................................12
  42. 5.7. ServerMetadataChange ......................................13
  43. 5.8. Notification Overflow .....................................13
  44. 5.9. ACL (Access Control List) Changes .........................13
  45. 6. Mailbox Specification ..........................................14
  46. 6.1. Mailbox Specifiers Affecting the Currently
  47. Selected Mailbox ..........................................14
  48. 6.2. Personal ..................................................15
  49. 6.3. Inboxes ...................................................15
  50. 6.4. Subscribed ................................................15
  51. 6.5. Subtree ...................................................15
  52. 6.6. Mailboxes .................................................16
  53. 7. Extension to SEARCH and SORT Commands ..........................16
  54. 8. Formal Syntax ..................................................16
  55. 9. Security Considerations ........................................19
  56. 10. IANA Considerations ...........................................19
  57. 10.1. Initial LIST-EXTENDED Extended Data Item Registrations ...19
  58. 11. Acknowledgements ..............................................20
  59. 12. Normative References ..........................................20
  60. 13. Informative References ........................................21
  61. Gulbrandsen, et al. Standards Track [Page 2]
  62. RFC 5465 IMAP NOTIFY Extension February 2009
  63. 1. Overview and Rationale
  64. The IDLE command (defined in [RFC2177]) provides a way for the client
  65. to go into a mode where the IMAP server pushes it notifications about
  66. IMAP mailstore events for the selected mailbox. However, the IDLE
  67. extension doesn't restrict or control which server events can be
  68. sent, or what information the server sends in response to each event.
  69. Also, IDLE only applies to the selected mailbox, thus requiring an
  70. additional TCP connection per mailbox.
  71. This document defines an IMAP extension that allows clients to
  72. express their preferences about unsolicited events generated by the
  73. server. The extension allows clients to only receive events that
  74. they are interested in, while servers know that they don't need to go
  75. to the effort of generating certain types of untagged responses.
  76. Without the NOTIFY command defined in this document, an IMAP server
  77. will only send information about mailstore changes to the client in
  78. the following cases:
  79. - as the result of a client command (e.g., FETCH responses to a
  80. FETCH or STORE command),
  81. - as unsolicited responses sent just before the end of a command
  82. (e.g., EXISTS or EXPUNGE) as the result of changes in other
  83. sessions, and
  84. - during an IDLE command.
  85. The NOTIFY command extends what information may be returned in those
  86. last two cases, and also permits and requires the server to send
  87. information about updates between commands. The NOTIFY command also
  88. allows for the client to extend what information is sent unsolicited
  89. about the selected mailbox and to request some update information to
  90. be sent regarding other mailboxes.
  91. The interaction between IDLE and NOTIFY commands is described in
  92. Section 4.
  93. For the new messages delivered to or appended to the selected
  94. mailbox, the NOTIFY command can be used to request that a set of
  95. attributes be sent to the client in an unsolicited FETCH response.
  96. This allows a client to be a passive recipient of events and new mail
  97. and to be able to maintain full synchronisation without having to
  98. issue any subsequent commands except to modify the state of the
  99. mailbox on the server.
  100. Gulbrandsen, et al. Standards Track [Page 3]
  101. RFC 5465 IMAP NOTIFY Extension February 2009
  102. Some mobile clients, however, may want mail "pushed" only for mail
  103. that matches a SEARCH pattern. To meet that need, [RFC5267] is
  104. augmented by this document to extend the UPDATE return option to
  105. specify a list of fetch-atts to be returned when a new message is
  106. delivered or appended in another session.
  107. 2. Conventions Used in This Document
  108. The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
  109. "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
  110. document are to be interpreted as described in [RFC2119].
  111. The acronym MSN stands for Message Sequence Numbers (see Section
  112. 2.3.1.2 of [RFC3501]).
  113. Example lines prefaced by "C:" are sent by the client and ones
  114. prefaced by "S:", by the server. "[...]" means elision.
  115. 3. The NOTIFY Extension
  116. IMAP servers that support this extension advertise the NOTIFY
  117. capability. This extension adds the NOTIFY command as defined in
  118. Section 5.1.
  119. A server implementing this extension is not required to implement
  120. LIST-EXTENDED [RFC5258], even though a NOTIFY-compliant server must
  121. be able to return extended LIST responses, defined in [RFC5258].
  122. 3.1. The NOTIFY Command
  123. Arguments: "SET"
  124. Optional STATUS indicator
  125. Mailboxes to be watched
  126. Events about which to notify the client
  127. Or
  128. Arguments: "NONE"
  129. Responses: Possibly untagged STATUS responses (for SET)
  130. Result: OK - The server will notify the client as requested.
  131. NO - Unsupported NOTIFY event, NOTIFY too complex or
  132. expensive, etc.
  133. BAD - Command unknown, invalid, unsupported, or has
  134. unknown arguments.
  135. Gulbrandsen, et al. Standards Track [Page 4]
  136. RFC 5465 IMAP NOTIFY Extension February 2009
  137. The NOTIFY command informs the server that the client listens for
  138. event notifications all the time (even when no command is in
  139. progress), and requests the server to notify it about the specified
  140. set of events. The NOTIFY command has two forms. NOTIFY NONE
  141. specifies that the client is not interested in any kind of event
  142. happening on the server. NOTIFY SET replaces the current list of
  143. interesting events with a new list of events.
  144. Until the NOTIFY command is used for the first time, the server only
  145. sends notifications while a command is being processed, and notifies
  146. the client about these events on the selected mailbox (see Section 5
  147. for definitions): MessageNew, MessageExpunge, or FlagChange. It does
  148. not notify the client about any events on other mailboxes.
  149. The effect of a successful NOTIFY command lasts until the next NOTIFY
  150. command or until the IMAP connection is closed.
  151. A successful NOTIFY SET command MUST cause the server to immediately
  152. return any accumulated changes to the currently selected mailbox (if
  153. any), such as flag changes and new or expunged messages. Thus, a
  154. successful NOTIFY SET command implies an implicit NOOP command.
  155. The NOTIFY SET command can request notifications of message-related
  156. changes to the selected mailbox, whatever that may be at the time the
  157. message notifications are being generated. This is done by
  158. specifying either the SELECTED or the SELECTED-DELAYED mailbox
  159. selector (see Section 6.1) in the NOTIFY SET command. If the
  160. SELECTED/SELECTED-DELAYED mailbox selector is not specified in the
  161. NOTIFY SET command, this means that the client doesn't want to
  162. receive any <message-event>s for the currently selected mailbox.
  163. This is the same as specifying SELECTED NONE.
  164. The client can also request notifications on other mailboxes by name
  165. or by a limited mailbox pattern match. Message-related notifications
  166. returned for the currently selected mailbox will be those specified
  167. by the SELECTED/SELECTED-DELAYED mailbox specifier, even if the
  168. selected mailbox also appears by name (or matches a pattern) in the
  169. command. Non-message-related notifications are controlled by mailbox
  170. specifiers other than SELECTED/SELECTED-DELAYED.
  171. If the NOTIFY command enables MessageNew, MessageExpunge,
  172. AnnotationChange, or FlagChange notifications for a mailbox other
  173. than the currently selected mailbox, and the client has specified the
  174. STATUS indicator parameter, then the server MUST send a STATUS
  175. response for that mailbox before NOTIFY's tagged OK. If MessageNew
  176. is enabled, the STATUS response MUST contain MESSAGES, UIDNEXT, and
  177. UIDVALIDITY. If MessageExpunge is enabled, the STATUS response MUST
  178. contain MESSAGES. If either AnnotationChange or FlagChange are
  179. Gulbrandsen, et al. Standards Track [Page 5]
  180. RFC 5465 IMAP NOTIFY Extension February 2009
  181. included and the server also supports the CONDSTORE [RFC4551] and/or
  182. QRESYNC [RFC5162] extensions, the STATUS response MUST contain
  183. UIDVALIDITY and HIGHESTMODSEQ. Absence of the STATUS indicator
  184. parameter allows the client to avoid the additional STATUS responses.
  185. This might be useful if the client already retrieved this information
  186. before issuing the NOTIFY command.
  187. Clients are advised to limit the number of mailboxes used with
  188. NOTIFY. Particularly, if a client asks for events for all accessible
  189. mailboxes, the server may swamp the client with updates about shared
  190. mailboxes. This may reduce the client's battery life. Also, this
  191. wastes both server and network resources.
  192. For each mailbox specified, the server verifies that the client has
  193. access using the following test:
  194. - If the name does not refer to an existing mailbox, the server MUST
  195. ignore it.
  196. - If the name refers to a mailbox that the client can't LIST, the
  197. server MUST ignore it. For a server that implements [RFC4314],
  198. this means that if the client doesn't have the 'l' (lookup) right
  199. for the name, then the server MUST ignore the mailbox. This
  200. behavior prevents disclosure of potentially confidential
  201. information to clients who don't have rights to know it.
  202. - If the name refers to a mailbox that the client can LIST (e.g., it
  203. has the 'l' right from [RFC4314]), but the client doesn't have
  204. another right required for processing of the specified event(s),
  205. then the server MUST respond with an untagged extended LIST
  206. response containing the \NoAccess name attribute.
  207. The server SHOULD return the tagged OK response if the client has
  208. access to at least one of the mailboxes specified in the current list
  209. of interesting events. The server MAY return the tagged NO response
  210. if the client has no access to any of the specified mailboxes and no
  211. access can ever be granted in the future (e.g., the client specified
  212. an event for 'Subtree Bar/Foo', 'Bar/Foo' doesn't exist, and LIST
  213. returns \Noinferiors for the parent 'Bar').
  214. If the notification would be prohibitively expensive for the server
  215. (e.g., "notify me of all flag changes in all mailboxes"), the server
  216. MAY refuse the command with a tagged NO [NOTIFICATIONOVERFLOW]
  217. response.
  218. Gulbrandsen, et al. Standards Track [Page 6]
  219. RFC 5465 IMAP NOTIFY Extension February 2009
  220. If the client requests information for events of an unsupported type,
  221. the server MUST refuse the command with a tagged NO response (not a
  222. BAD). This response SHOULD contain the BADEVENT response code, which
  223. MUST list names of all events supported by the server.
  224. Here's an example:
  225. S: * OK [CAPABILITY IMAP4REV1 NOTIFY]
  226. C: a login bob alice
  227. S: a OK Password matched
  228. C: b notify set status (selected MessageNew (uid
  229. body.peek[header.fields (from to subject)]) MessageExpunge)
  230. (subtree Lists MessageNew)
  231. S: * STATUS Lists/Lemonade (UIDVALIDITY 4 UIDNEXT 9999 MESSAGES
  232. 500)
  233. S: [...]
  234. S: * STATUS Lists/Im2000 (UIDVALIDITY 901 UIDNEXT 1 MESSAGES 0)
  235. S: b OK done
  236. C: c select inbox
  237. S: [...] (the usual 7-8 responses to SELECT)
  238. S: c OK INBOX selected
  239. (Time passes. A new message is delivered to mailbox
  240. Lists/Lemonade.)
  241. S: * STATUS Lists/Lemonade (UIDVALIDITY 4 UIDNEXT 10000
  242. MESSAGES 501)
  243. (Time passes. A new message is delivered to inbox.)
  244. S: * 127 FETCH (UID 127001 BODY[HEADER.FIELDS (From To
  245. Subject)] {75}
  246. S: Subject: Re: good morning
  247. S: From: alice@example.org
  248. S: To: bob@example.org
  249. S:
  250. S: )
  251. (Time passes. The client decides it wants to know about
  252. one more mailbox. As the client already knows necessary
  253. STATUS information for all mailboxes below the Lists
  254. mailbox, and because "notify set status" would cause
  255. STATUS responses for *all* mailboxes specified in the
  256. NOTIFY command, including the ones for which the client
  257. already knows STATUS information, the client issues an
  258. explicit STATUS request for the mailbox to be added to
  259. the watch list, followed by the NOTIFY SET without the
  260. STATUS parameter.)
  261. C: d STATUS misc (UIDVALIDITY UIDNEXT MESSAGES)
  262. S: * STATUS misc (UIDVALIDITY 1 UIDNEXT 999)
  263. S: d STATUS completed
  264. Gulbrandsen, et al. Standards Track [Page 7]
  265. RFC 5465 IMAP NOTIFY Extension February 2009
  266. C: e notify set (selected MessageNew (uid
  267. body.peek[header.fields (from to subject)]) MessageExpunge)
  268. (subtree Lists MessageNew) (mailboxes misc MessageNew)
  269. S: e OK done
  270. 4. Interaction with the IDLE Command
  271. If IDLE [RFC2177] (as well as this extension) is supported, then
  272. while processing any IDLE command, the server MUST send exactly the
  273. same events as instructed by the client using the NOTIFY command.
  274. NOTIFY makes IDLE unnecessary for some clients. If a client does not
  275. use MSNs and '*' in commands, it can request MessageExpunge and
  276. MessageNew for the selected mailbox by using the NOTIFY command
  277. instead of entering the IDLE mode.
  278. A client that uses MSNs and '*' in commands can still use the NOTIFY
  279. command if it specifies the SELECTED-DELAYED mailbox specifier in the
  280. NOTIFY command.
  281. 5. Event Types
  282. Only some of the events in [RFC5423] can be expressed in IMAP, and
  283. for some of them there are several possible ways to express the
  284. event.
  285. This section specifies the events of which an IMAP server can notify
  286. an IMAP client, and how.
  287. The server SHOULD omit notifying the client if the event is caused by
  288. this client. For example, if the client issues CREATE and has
  289. requested a MailboxName event that would cover the newly created
  290. mailbox, the server SHOULD NOT notify the client of the MailboxName
  291. change.
  292. All event types described in this document require the 'l' and 'r'
  293. rights (see [RFC4314]) on all observed mailboxes. Servers that don't
  294. implement [RFC4314] should map the above rights to their access-
  295. control model.
  296. If the FlagChange and/or AnnotationChange events are specified,
  297. MessageNew and MessageExpunge MUST also be specified by the client.
  298. Otherwise, the server MUST respond with the tagged BAD response.
  299. If one of MessageNew or MessageExpunge is specified, then both events
  300. MUST be specified. Otherwise, the server MUST respond with the
  301. tagged BAD response.
  302. Gulbrandsen, et al. Standards Track [Page 8]
  303. RFC 5465 IMAP NOTIFY Extension February 2009
  304. The client can instruct the server not to send an event by omitting
  305. the necessary event from the list of events specified in NOTIFY SET,
  306. by using the NONE event specifier in the NOTIFY SET, or by using
  307. NOTIFY NONE. In particular, NOTIFY SET ... NONE can be used as a
  308. snapshot facility by clients.
  309. 5.1. FlagChange and AnnotationChange
  310. If the flag and/or message annotation change happens in the selected
  311. mailbox, the server MUST notify the client by sending an unsolicited
  312. FETCH response, which MUST include UID and FLAGS/ANNOTATION FETCH
  313. data items. It MAY also send new FLAGS and/or OK [PERMANENTFLAGS
  314. ...] responses.
  315. If a search context is in effect as specified in [RFC5267], an
  316. ESEARCH ADDTO or ESEARCH REMOVEFROM will also be generated, if
  317. appropriate. In this case, the FETCH response MUST precede the
  318. ESEARCH response.
  319. If the change happens in another mailbox, then the server responds
  320. with a STATUS response. The exact content of the STATUS response
  321. depends on various factors. If CONDSTORE [RFC4551] and/or QRESYNC
  322. [RFC5162] are enabled by the client, then the server sends a STATUS
  323. response that includes at least HIGHESTMODSEQ and UIDVALIDITY status
  324. data items. If the number of messages with the \Seen flag changes,
  325. the server MAY also include the UNSEEN data item in the STATUS
  326. response. If CONDSTORE/QRESYNC is not enabled by the client and the
  327. server chooses not to include the UNSEEN data item, the server does
  328. not notify the client. When this event is requested, the server MUST
  329. notify the client about mailbox UIDVALIDITY changes. This is done by
  330. sending a STATUS response that includes UIDVALIDITY.
  331. FlagChange covers the MessageRead, MessageTrash, FlagsSet, and
  332. FlagsClear events in [RFC5423].
  333. Example in the selected mailbox:
  334. S: * 99 FETCH (UID 9999 FLAGS ($Junk))
  335. And in another mailbox, with CONDSTORE in use:
  336. S: * STATUS Lists/Lemonade (HIGHESTMODSEQ 65666665 UIDVALIDITY
  337. 101)
  338. Gulbrandsen, et al. Standards Track [Page 9]
  339. RFC 5465 IMAP NOTIFY Extension February 2009
  340. 5.2. MessageNew
  341. This covers both MessageNew and MessageAppend in [RFC5423].
  342. If the new/appended message is in the selected mailbox, the server
  343. notifies the client by sending an unsolicited EXISTS response,
  344. followed by an unsolicited FETCH response containing the information
  345. requested by the client. A FETCH response SHOULD NOT be generated
  346. for a new message created by the client on this particular
  347. connection, for instance, as the result of an APPEND or COPY command
  348. to the selected mailbox performed by the client itself. The server
  349. MAY also send a RECENT response, if the server marks the message as
  350. \Recent.
  351. Note that a single EXISTS response can be returned for multiple
  352. MessageAppend/MessageNew events.
  353. If a search context is in effect as specified in [RFC5267], an
  354. ESEARCH ADDTO will also be generated, if appropriate. In this case,
  355. the EXISTS response MUST precede the ESEARCH response. Both the
  356. NOTIFY command and the SEARCH and SORT commands (see Section 7) can
  357. specify attributes to be returned for new messages. These attributes
  358. SHOULD be combined into a single FETCH response. The server SHOULD
  359. avoid sending duplicate data. The FETCH response(s) MUST follow any
  360. ESEARCH ADDTO responses.
  361. If the new/appended message is in another mailbox, the server sends
  362. an unsolicited STATUS (UIDNEXT MESSAGES) response for the relevant
  363. mailbox. If the CONDSTORE extension [RFC4551] and/or the QRESYNC
  364. extension [RFC5162] is enabled, the HIGHESTMODSEQ status data item
  365. MUST be included in the STATUS response.
  366. The client SHOULD NOT use FETCH attributes that implicitly set the
  367. \seen flag, or that presuppose the existence of a given bodypart.
  368. UID, MODSEQ, FLAGS, ENVELOPE, BODY.PEEK[HEADER.FIELDS... and
  369. BODY/BODYSTRUCTURE may be the most useful attributes.
  370. Note that if a client asks to be notified of MessageNew events with
  371. the SELECTED mailbox specifier, the number of messages can increase
  372. at any time, and therefore the client cannot refer to a specific
  373. message using the MSN/UID '*'.
  374. Example in the selected mailbox:
  375. S: * 444 EXISTS
  376. S: * 444 FETCH (UID 9999)
  377. And in another mailbox, without CONDSTORE enabled:
  378. S: * STATUS Lists/Lemonade (UIDNEXT 10002 MESSAGES 503)
  379. Gulbrandsen, et al. Standards Track [Page 10]
  380. RFC 5465 IMAP NOTIFY Extension February 2009
  381. 5.3. MessageExpunge
  382. If the expunged message or messages are in the selected mailbox, the
  383. server notifies the client using EXPUNGE (or VANISHED, if [RFC5162]
  384. is supported by the server and enabled by the client).
  385. If a search context is in effect, as specified in [RFC5267], an
  386. ESEARCH REMOVEFROM will also be generated, if appropriate.
  387. If the expunged message or messages are in another mailbox, the
  388. server sends an unsolicited STATUS (UIDNEXT MESSAGES) response for
  389. the relevant mailbox. If the QRESYNC [RFC5162] extension is enabled,
  390. the HIGHESTMODSEQ data item MUST be included in the STATUS response
  391. as well.
  392. Note that if a client requests MessageExpunge with the SELECTED
  393. mailbox specifier, the meaning of an MSN can change at any time, so
  394. the client cannot use MSNs in commands anymore. For example, such a
  395. client cannot use FETCH, but has to use UID FETCH. The meaning of
  396. '*' can also change when messages are added or expunged. A client
  397. wishing to keep using MSNs can either use the SELECTED-DELAYED
  398. mailbox specifier or can avoid using the MessageExpunge event
  399. entirely.
  400. The MessageExpunge notification covers both MessageExpunge and
  401. MessageExpire events from [RFC5423].
  402. Example in the selected mailbox, without QRESYNC:
  403. S: * 444 EXPUNGE
  404. The same example in the selected mailbox, with QRESYNC:
  405. S: * VANISHED 5444
  406. And in another mailbox, when QRESYNC is not enabled:
  407. S: * STATUS misc (UIDNEXT 999 MESSAGES 554)
  408. 5.4. MailboxName
  409. These notifications are sent if an affected mailbox name was created
  410. (with CREATE), deleted (with DELETE), or renamed (with RENAME). For
  411. a server that implements [RFC4314], granting or revocation of the 'l'
  412. right to the current user on the affected mailbox MUST be considered
  413. mailbox creation or deletion, respectively. If a mailbox is created
  414. or deleted, the mailbox itself and its direct parent (whether it is
  415. an existing mailbox or not) are considered to be affected.
  416. Gulbrandsen, et al. Standards Track [Page 11]
  417. RFC 5465 IMAP NOTIFY Extension February 2009
  418. The server notifies the client by sending an unsolicited LIST
  419. response for each affected mailbox name. If, after the event, the
  420. mailbox name does not refer to a mailbox accessible to the client,
  421. the \Nonexistent flag MUST be included.
  422. For each LISTable mailbox renamed, the server sends an extended LIST
  423. response [RFC5258] for the new mailbox name, containing the OLDNAME
  424. extended data item with the old mailbox name. When a mailbox is
  425. renamed, its children are renamed too. No additional MailboxName
  426. events are sent for children in this case. When INBOX is renamed, a
  427. new INBOX is assumed to be created. No MailboxName event is sent for
  428. INBOX in this case.
  429. If the server automatically subscribes a mailbox when it is created
  430. or renamed, then the unsolicited LIST response for each affected
  431. subscribed mailbox name MUST include the \Subscribed attribute (see
  432. [RFC5258]). The server SHOULD also include \HasChildren or
  433. \HasNoChildren attributes [RFC5258] as appropriate.
  434. Example of a newly created mailbox (or granting of the 'l' right on
  435. the mailbox):
  436. S: * LIST () "/" "NewMailbox"
  437. And a deleted mailbox (or revocation of the 'l' right on the
  438. mailbox):
  439. S: * LIST (\NonExistent) "." "INBOX.DeletedMailbox"
  440. Example of a renamed mailbox:
  441. S: * LIST () "/" "NewMailbox" ("OLDNAME" ("OldMailbox"))
  442. 5.5. SubscriptionChange
  443. The server notifies the client by sending an unsolicited LIST
  444. response for each affected mailbox name. If and only if the mailbox
  445. is subscribed after the event, the \Subscribed attribute (see
  446. [RFC5258]) is included. Note that in the LIST response, all mailbox
  447. attributes MUST be accurately computed (this differs from the
  448. behavior of the LSUB command).
  449. Example:
  450. S: * LIST (\Subscribed) "/" "SubscribedMailbox"
  451. 5.6. MailboxMetadataChange
  452. Support for this event type is OPTIONAL unless the METADATA extension
  453. [RFC5464] is also supported by the server, in which case support for
  454. this event type is REQUIRED.
  455. Gulbrandsen, et al. Standards Track [Page 12]
  456. RFC 5465 IMAP NOTIFY Extension February 2009
  457. A client willing to receive unsolicited METADATA responses as a
  458. result of using the MailboxMetadataChange event in the NOTIFY command
  459. doesn't have to issue ENABLE METADATA.
  460. The server sends an unsolicited METADATA response (as per Section
  461. 4.4.2 of [RFC5464]). If possible, only the changed metadata SHOULD
  462. be included, but if the server can't detect a change to a single
  463. metadata item, it MAY include all metadata items set on the mailbox.
  464. If a metadata item is deleted (set to NIL), it MUST always be
  465. included in the METADATA response.
  466. Example:
  467. S: * METADATA "INBOX" /shared/comment
  468. 5.7. ServerMetadataChange
  469. Support for this event type is OPTIONAL unless the METADATA or the
  470. METADATA-SERVER extension [RFC5464] is also supported by the server,
  471. in which case support for this event type is REQUIRED.
  472. A client willing to receive unsolicited METADATA responses as a
  473. result of using the ServerMetadataChange event in the NOTIFY command
  474. doesn't have to issue ENABLE METADATA or ENABLE METADATA-SERVER.
  475. The server sends an unsolicited METADATA response (as per Section
  476. 4.4.2 of [RFC5464]). Only the names of changed metadata entries
  477. SHOULD be returned in such METADATA responses. If a metadata item is
  478. deleted (set to NIL), it MUST always be included in the METADATA
  479. response.
  480. Example:
  481. S: * METADATA "" /shared/comment
  482. 5.8. Notification Overflow
  483. If the server is unable or unwilling to deliver as many notifications
  484. as it is being asked to, it may disable notifications for some or all
  485. clients. It MUST notify these clients by sending an untagged "OK
  486. [NOTIFICATIONOVERFLOW]" response and behave as if a NOTIFY NONE
  487. command had just been received.
  488. Example:
  489. S: * OK [NOTIFICATIONOVERFLOW] ...A comment can go here...
  490. Gulbrandsen, et al. Standards Track [Page 13]
  491. RFC 5465 IMAP NOTIFY Extension February 2009
  492. 5.9. ACL (Access Control List) Changes
  493. Even if NOTIFY succeeds, it is still possible to lose access to the
  494. mailboxes being monitored at a later time. If this happens, the
  495. server MUST stop monitoring these mailboxes. If access is later
  496. granted, the server MUST restart event monitoring.
  497. The server SHOULD return the LIST response with the \NoAccess name
  498. attribute if and when the mailbox loses the 'l' right. Similarly,
  499. the server SHOULD return the LIST response with no \NoAccess name
  500. attribute if the mailbox was previously reported as having \NoAccess
  501. and the 'l' right is later granted.
  502. 6. Mailbox Specification
  503. Mailboxes to be monitored can be specified in several different ways.
  504. Only 'SELECTED' and 'SELECTED-DELAYED' (Section 6.1) match the
  505. currently selected mailbox. All other mailbox specifications affect
  506. other (non-selected) mailboxes.
  507. Note that multiple <event-group>s can apply to the same mailbox. The
  508. following example demonstrates this. In this example, MessageNew and
  509. MessageExpunge events are reported for INBOX, due to the first
  510. <event-group>. A SubscriptionChange event will also be reported for
  511. INBOX, due to the second <event-group>.
  512. C: a notify set (mailboxes INBOX (Messagenew messageExpunge))
  513. (personal (SubscriptionChange))
  514. A typical client that supports the NOTIFY extension would ask for
  515. events on the selected mailbox and some named mailboxes.
  516. In the next example, the client asks for FlagChange events for all
  517. personal mailboxes except the currently selected mailbox. This is
  518. different from the previous example because SELECTED overrides all
  519. other message event definitions for the currently selected mailbox
  520. (see Section 3.1).
  521. C: a notify set (selected (Messagenew (uid flags) messageExpunge))
  522. (personal (MessageNew FlagChange MessageExpunge))
  523. 6.1. Mailbox Specifiers Affecting the Currently Selected Mailbox
  524. Only one of the mailbox specifiers affecting the currently selected
  525. mailbox can be specified in any NOTIFY command. The two such mailbox
  526. specifiers (SELECTED and SELECTED-DELAYED) are described below.
  527. Gulbrandsen, et al. Standards Track [Page 14]
  528. RFC 5465 IMAP NOTIFY Extension February 2009
  529. Both refer to the mailbox that was selected using either SELECT or
  530. EXAMINE (see [RFC3501], Sections 6.3.1 and 6.3.2). When the IMAP
  531. connection is not in the selected state, such mailbox specifiers
  532. don't refer to any mailbox.
  533. The mailbox specifiers only apply to <message-event>s. It is an
  534. error to specify other types of events with either the SELECTED or
  535. the SELECTED-DELAYED selector.
  536. 6.1.1. Selected
  537. The SELECTED mailbox specifier requires the server to send immediate
  538. notifications for the currently selected mailbox about all specified
  539. <message-event>s.
  540. 6.1.2. Selected-Delayed
  541. The SELECTED-DELAYED mailbox specifier requires the server to delay a
  542. MessageExpunge event until the client issues a command that allows
  543. returning information about expunged messages (see Section 7.4.1 of
  544. [RFC3501] for more details), for example, till a NOOP or an IDLE
  545. command has been issued. When SELECTED-DELAYED is specified, the
  546. server MAY also delay returning other <message-event>s until the
  547. client issues one of the commands specified above, or it MAY return
  548. them immediately.
  549. 6.2. Personal
  550. Personal refers to all selectable mailboxes in the user's personal
  551. namespace(s), as defined in [RFC2342].
  552. 6.3. Inboxes
  553. Inboxes refers to all selectable mailboxes in the user's personal
  554. namespace(s) to which messages may be delivered by a Message Delivery
  555. Agent (MDA) (see [EMAIL-ARCH], particularly Section 4.3.3).
  556. If the IMAP server cannot easily compute this set, it MUST treat
  557. "inboxes" as equivalent to "personal".
  558. 6.4. Subscribed
  559. Subscribed refers to all mailboxes subscribed to by the user.
  560. If the subscription list changes, the server MUST reevaluate the
  561. list.
  562. Gulbrandsen, et al. Standards Track [Page 15]
  563. RFC 5465 IMAP NOTIFY Extension February 2009
  564. 6.5. Subtree
  565. Subtree is followed by a mailbox name or list of mailbox names. A
  566. subtree refers to all selectable mailboxes that are subordinate to
  567. the specified mailbox plus the specified mailbox itself.
  568. 6.6. Mailboxes
  569. Mailboxes is followed by a mailbox name or a list of mailbox names.
  570. The server MUST NOT do a wildcard expansion. This means there is no
  571. special treatment for the LIST wildcard characters ('*' and '%') if
  572. they are present in mailbox names.
  573. 7. Extension to SEARCH and SORT Commands
  574. If the server that supports the NOTIFY extension also supports
  575. CONTEXT=SEARCH and/or CONTEXT=SORT as defined in [RFC5267], the
  576. UPDATE return option is extended so that a client can request that
  577. FETCH attributes be returned when a new message is added to the
  578. context result set.
  579. For example:
  580. C: a00 SEARCH RETURN (COUNT UPDATE (UID BODY[HEADER.FIELDS (TO
  581. FROM SUBJECT)])) FROM "boss"
  582. S: * ESEARCH (TAG "a00") (COUNT 17)
  583. S: a00 OK
  584. [...a new message is delivered...]
  585. S: * EXISTS 93
  586. S: * 93 FETCH (UID 127001 BODY[HEADER.FIELDS (FROM TO SUBJECT)]
  587. {76}
  588. S: Subject: Re: good morning
  589. S: From: myboss@example.org
  590. S: To: bob@example.org
  591. S:
  592. S: )
  593. S: * ESEARCH (TAG "a00") ADDTO (0 93)
  594. Note that the EXISTS response MUST precede any FETCH responses, and
  595. together they MUST precede the ESEARCH response.
  596. No untagged FETCH response SHOULD be returned if a message becomes a
  597. member of UPDATE SEARCH due to flag or annotation changes.
  598. Gulbrandsen, et al. Standards Track [Page 16]
  599. RFC 5465 IMAP NOTIFY Extension February 2009
  600. 8. Formal Syntax
  601. The following syntax specification uses the Augmented Backus-Naur
  602. Form (ABNF) notation as specified in [RFC5234]. [RFC3501] defines
  603. the non-terminals "capability", "command-auth", "mailbox", "mailbox-
  604. data", "resp-text-code", and "search-key". The "modifier-update"
  605. non-terminal is defined in [RFC5267]. "mbx-list-oflag" is defined in
  606. [RFC3501] and updated by [RFC5258].
  607. Except as noted otherwise, all alphabetic characters are case-
  608. insensitive. The use of upper or lower case characters to define
  609. token strings is for editorial clarity only. Implementations MUST
  610. accept these strings in a case-insensitive fashion. For example, the
  611. <filter-mailboxes-selected> non-terminal value "SELECTED" must be
  612. treated in the same way as "Selected" or "selected".
  613. capability =/ "NOTIFY"
  614. command-auth =/ notify
  615. notify = "NOTIFY" SP
  616. (notify-set / notify-none)
  617. notify-set = "SET" [status-indicator] SP event-groups
  618. ; Replace registered notification events
  619. ; with the specified list of events
  620. notify-none = "NONE"
  621. ; Cancel all registered notification
  622. ; events. The client is not interested
  623. ; in receiving any events.
  624. status-indicator = SP "STATUS"
  625. one-or-more-mailbox = mailbox / many-mailboxes
  626. many-mailboxes = "(" mailbox *(SP mailbox) ")"
  627. event-groups = event-group *(SP event-group)
  628. event-group = "(" filter-mailboxes SP events ")"
  629. ;; Only <message-event>s are allowed in <events>
  630. ;; when <filter-mailboxes-selected> is used.
  631. filter-mailboxes = filter-mailboxes-selected /
  632. filter-mailboxes-other
  633. Gulbrandsen, et al. Standards Track [Page 17]
  634. RFC 5465 IMAP NOTIFY Extension February 2009
  635. filter-mailboxes-other = "inboxes" / "personal" / "subscribed" /
  636. ( "subtree" SP one-or-more-mailbox ) /
  637. ( "mailboxes" SP one-or-more-mailbox )
  638. filter-mailboxes-selected = "selected" / "selected-delayed"
  639. ;; Apply to the currently selected mailbox only.
  640. ;; Only one of them can be specified in a NOTIFY
  641. ;; command.
  642. events = ( "(" event *(SP event) ")" ) / "NONE"
  643. ;; As in [MSGEVENT].
  644. ;; "NONE" means that the client does not wish
  645. ;; to receive any events for the specified
  646. ;; mailboxes.
  647. event = message-event /
  648. mailbox-event / user-event / event-ext
  649. message-event = ( "MessageNew" [SP
  650. "(" fetch-att *(SP fetch-att) ")" ] )
  651. / "MessageExpunge"
  652. / "FlagChange"
  653. / "AnnotationChange"
  654. ;; "MessageNew" includes "MessageAppend" from
  655. ;; [MSGEVENT]. "FlagChange" is any of
  656. ;; "MessageRead", "MessageTrash", "FlagsSet",
  657. ;; "FlagsClear" [MSGEVENT]. "MessageExpunge"
  658. ;; includes "MessageExpire" [MSGEVENT].
  659. ;; MessageNew and MessageExpunge MUST always
  660. ;; be specified together. If FlagChange is
  661. ;; specified, then MessageNew and MessageExpunge
  662. ;; MUST be specified as well.
  663. ;; The fett-att list may only be present for the
  664. ;; SELECTED/SELECTED-DELAYED mailbox filter
  665. ;; (<filter-mailboxes>).
  666. mailbox-event = "MailboxName" /
  667. "SubscriptionChange" / "MailboxMetadataChange"
  668. ; "SubscriptionChange" includes
  669. ; MailboxSubscribe and MailboxUnSubscribe.
  670. ; "MailboxName" includes MailboxCreate,
  671. ; "MailboxDelete" and "MailboxRename".
  672. user-event = "ServerMetadataChange"
  673. event-ext = atom
  674. ;; For future extensions
  675. Gulbrandsen, et al. Standards Track [Page 18]
  676. RFC 5465 IMAP NOTIFY Extension February 2009
  677. oldname-extended-item = "OLDNAME" SP "(" mailbox ")"
  678. ;; Extended data item (mbox-list-extended-item)
  679. ;; returned in a LIST response when a mailbox is
  680. ;; renamed.
  681. ;; Note 1: the OLDNAME tag can be returned
  682. ;; with or without surrounding quotes, as per
  683. ;; mbox-list-extended-item-tag production.
  684. resp-text-code =/ "NOTIFICATIONOVERFLOW" /
  685. unsupported-events-code
  686. message-event-name = "MessageNew" /
  687. "MessageExpunge" / "FlagChange" /
  688. "AnnotationChange"
  689. event-name = message-event-name / mailbox-event /
  690. user-event
  691. unsupported-events-code = "BADEVENT"
  692. SP "(" event-name *(SP event-name) ")"
  693. modifier-update = "UPDATE"
  694. [ "(" fetch-att *(SP fetch-att) ")" ]
  695. mbx-list-oflag =/ "\NoAccess"
  696. 9. Security Considerations
  697. It is very easy for a client to deny itself service using NOTIFY.
  698. Asking for all events on all mailboxes may work on a small server,
  699. but with a big server, can swamp the client's network connection or
  700. processing capability. In the worst case, the server's processing
  701. could also degrade the service it offers to other clients.
  702. Server authors should be aware that if a client issues requests and
  703. does not listen to the resulting responses, the TCP window can easily
  704. fill up, and a careless server might block. This problem also exists
  705. in plain IMAP; however, this extension magnifies the problem.
  706. This extension makes it possible to retrieve messages immediately
  707. when they are added to the mailbox. This makes it wholly impractical
  708. to delete sensitive messages using programs like imapfilter. Using
  709. SIEVE [RFC5228] or similar is much better.
  710. Gulbrandsen, et al. Standards Track [Page 19]
  711. RFC 5465 IMAP NOTIFY Extension February 2009
  712. 10. IANA Considerations
  713. The IANA has added NOTIFY to the list of IMAP extensions.
  714. 10.1. Initial LIST-EXTENDED Extended Data Item Registrations
  715. The following entry has been added to the LIST-EXTENDED response
  716. registry [RFC5258]:
  717. To: iana@iana.org
  718. Subject: Registration of OLDNAME LIST-EXTENDED extended data item
  719. LIST-EXTENDED extended data item tag: OLDNAME
  720. LIST-EXTENDED extended data item description: The OLDNAME extended
  721. data item describes the old mailbox name for the mailbox
  722. identified by the LIST response.
  723. Which LIST-EXTENDED option(s) (and their types) causes this extended
  724. data item to be returned (if any): none
  725. Published specification : RFC 5465, Section 5.4.
  726. Security considerations: none
  727. Intended usage: COMMON
  728. Person and email address to contact for further information: Alexey
  729. Melnikov <Alexey.Melnikov@isode.com>
  730. Owner/Change controller: iesg@ietf.org
  731. 11. Acknowledgments
  732. The authors gratefully acknowledge the help of Peter Coates, Dave
  733. Cridland, Mark Crispin, Cyrus Daboo, Abhijit Menon-Sen, Timo
  734. Sirainen, and Eric Burger. In particular, Peter Coates contributed
  735. lots of text and useful suggestions to this document.
  736. Various examples are copied from other RFCs.
  737. This document builds on one published and two unpublished drafts by
  738. the same authors.
  739. Gulbrandsen, et al. Standards Track [Page 20]
  740. RFC 5465 IMAP NOTIFY Extension February 2009
  741. 12. Normative References
  742. [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
  743. Requirement Levels", BCP 14, RFC 2119, March 1997.
  744. [RFC2177] Leiba, B., "IMAP4 IDLE command", RFC 2177, June 1997.
  745. [RFC2342] Gahrns, M. and C. Newman, "IMAP4 Namespace", RFC 2342,
  746. May 1998.
  747. [RFC3501] Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - VERSION
  748. 4rev1", RFC 3501, March 2003.
  749. [RFC4314] Melnikov, A., "IMAP4 Access Control List (ACL)
  750. Extension", RFC 4314, December 2005.
  751. [RFC4466] Melnikov, A. and C. Daboo, "Collected Extensions to
  752. IMAP4 ABNF", RFC 4466, April 2006.
  753. [RFC4551] Melnikov, A. and S. Hole, "IMAP Extension for
  754. Conditional STORE Operation or Quick Flag Changes
  755. Resynchronization", RFC 4551, June 2006.
  756. [RFC5162] Melnikov, A., Cridland, D., and C. Wilson, "IMAP4
  757. Extensions for Quick Mailbox Resynchronization", RFC
  758. 5162, March 2008.
  759. [RFC5234] Crocker, D., Ed., and P. Overell, "Augmented BNF for
  760. Syntax Specifications: ABNF", STD 68, RFC 5234, January
  761. 2008.
  762. [RFC5258] Leiba, B. and A. Melnikov, "Internet Message Access
  763. Protocol version 4 - LIST Command Extensions", RFC 5258,
  764. June 2008.
  765. [RFC5267] Cridland, D. and C. King, "Contexts for IMAP4", RFC
  766. 5267, July 2008.
  767. [RFC5423] Newman, C. and R. Gellens, "Internet Message Store
  768. Events", RFC 5423, Month 2009.
  769. [RFC5464] Daboo, C., "The IMAP METADATA Extension", RFC 5464,
  770. February 2009.
  771. 13. Informative References
  772. [RFC5228] Guenther, P., Ed., and T. Showalter, Ed., "Sieve: An
  773. Email Filtering Language", RFC 5228, January 2008.
  774. Gulbrandsen, et al. Standards Track [Page 21]
  775. RFC 5465 IMAP NOTIFY Extension February 2009
  776. [EMAIL-ARCH] Crocker, D., "Internet Mail Architecture", Work in
  777. Progress, October 2008.
  778. Authors' Addresses
  779. Arnt Gulbrandsen
  780. Oryx Mail Systems GmbH
  781. Schweppermannstr. 8
  782. D-81671 Muenchen
  783. Germany
  784. EMail: arnt@oryx.com
  785. Curtis King
  786. Isode Ltd
  787. 5 Castle Business Village
  788. 36 Station Road
  789. Hampton, Middlesex TW12 2BX
  790. UK
  791. EMail: Curtis.King@isode.com
  792. Alexey Melnikov
  793. Isode Ltd
  794. 5 Castle Business Village
  795. 36 Station Road
  796. Hampton, Middlesex TW12 2BX
  797. UK
  798. EMail: Alexey.Melnikov@isode.com
  799. Gulbrandsen, et al. Standards Track [Page 22]