1
2
3
4
5
6
7Internet Engineering Task Force (IETF) S. Bosch
8Request for Comments: 8579 Open Xchange Oy
9Category: Standards Track May 2019
10ISSN: 2070-1721
11
12
13 Sieve Email Filtering: Delivering to Special-Use Mailboxes
14
15Abstract
16
17 The SPECIAL-USE capability of the IMAP protocol (RFC 6154) allows
18 clients to identify special-use mailboxes, e.g., where draft or sent
19 messages should be put. This simplifies client configuration. In
20 contrast, the Sieve mail filtering language (RFC 5228) currently has
21 no such capability. This memo defines a Sieve extension that fills
22 this gap: it adds a test for checking whether a special-use attribute
23 is assigned for a particular mailbox or any mailbox, and it adds the
24 ability to file messages into a mailbox identified solely by a
25 special-use attribute.
26
27Status of This Memo
28
29 This is an Internet Standards Track document.
30
31 This document is a product of the Internet Engineering Task Force
32 (IETF). It represents the consensus of the IETF community. It has
33 received public review and has been approved for publication by the
34 Internet Engineering Steering Group (IESG). Further information on
35 Internet Standards is available in Section 2 of RFC 7841.
36
37 Information about the current status of this document, any errata,
38 and how to provide feedback on it may be obtained at
39 https://www.rfc-editor.org/info/rfc8579.
40
41Copyright Notice
42
43 Copyright (c) 2019 IETF Trust and the persons identified as the
44 document authors. All rights reserved.
45
46 This document is subject to BCP 78 and the IETF Trust's Legal
47 Provisions Relating to IETF Documents
48 (https://trustee.ietf.org/license-info) in effect on the date of
49 publication of this document. Please review these documents
50 carefully, as they describe your rights and restrictions with respect
51 to this document. Code Components extracted from this document must
52 include Simplified BSD License text as described in Section 4.e of
53 the Trust Legal Provisions and are provided without warranty as
54 described in the Simplified BSD License.
55
56
57
58Bosch Standards Track [Page 1]
59
60RFC 8579 Sieve: Special-Use Mailboxes May 2019
61
62
63Table of Contents
64
65 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2
66 2. Conventions Used in This Document . . . . . . . . . . . . . . 3
67 3. Test "specialuse_exists" . . . . . . . . . . . . . . . . . . 3
68 3.1. Equivalent IMAP Operations . . . . . . . . . . . . . . . 4
69 4. ":specialuse" Argument to "fileinto" Command . . . . . . . . 5
70 4.1. Mailboxes Created Implicitly by the "fileinto" Command . 6
71 4.2. Equivalent IMAP Operations . . . . . . . . . . . . . . . 7
72 5. Sieve Capability Strings . . . . . . . . . . . . . . . . . . 8
73 6. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 8
74 7. Security Considerations . . . . . . . . . . . . . . . . . . . 9
75 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 10
76 9. References . . . . . . . . . . . . . . . . . . . . . . . . . 10
77 9.1. Normative References . . . . . . . . . . . . . . . . . . 10
78 9.2. Informative References . . . . . . . . . . . . . . . . . 11
79 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 11
80 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 12
81
821. Introduction
83
84 Commonly, several mailboxes in an IMAP message store [IMAP] have a
85 special use. For example, there can be a special-use mailbox for
86 storing the user's draft messages, for keeping copies of sent
87 messages, and for collecting spam messages that were classified as
88 such at delivery. The SPECIAL-USE capability [SPECIAL-USE] of the
89 IMAP protocol defines mailbox attributes that identify these special
90 mailboxes explicitly to the client. This way, client configuration
91 is simplified significantly. Using the CREATE-SPECIAL-USE capability
92 [SPECIAL-USE], IMAP clients can also configure these attributes
93 dynamically based on user preference.
94
95 Unlike the IMAP protocol, the Sieve mail filtering language [SIEVE]
96 currently cannot freely access these special-use mailbox attributes.
97 Particularly, the Sieve interpreter has no means to identify a
98 mailbox with a particular special-use attribute. This would be very
99 useful, for example, to find the user's "Spam" mailbox at delivery.
100
101 In Sieve, limited access to the special-use attributes is provided
102 using the "mboxmetadata" extension [SIEVE-MAILBOX], which allows
103 testing for the presence of a special-use attribute in the "/private/
104 specialuse" IMAP METADATA [IMAP-METADATA] entry of a mailbox. Still,
105 not all implementers will be willing to add the complexity of the
106 IMAP METADATA capability just to provide access to special-use
107 attributes to the Sieve interpreter.
108
109
110
111
112
113
114Bosch Standards Track [Page 2]
115
116RFC 8579 Sieve: Special-Use Mailboxes May 2019
117
118
119 This document defines an extension to the Sieve mail filtering
120 language that adds the ability to freely access mailbox special-use
121 attributes. It adds a test called "specialuse_exists" that checks 1)
122 whether a special-use attribute is assigned for a particular mailbox
123 or 2) whether any of the user's personal mailboxes have a special-use
124 attribute assigned. It also adds the ability to file messages into a
125 personal mailbox identified by a particular special-use attribute
126 rather than the mailbox's name. This is achieved using the new
127 ":specialuse" argument for the "fileinto" command [SIEVE].
128
1292. Conventions Used in This Document
130
131 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
132 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
133 "OPTIONAL" in this document are to be interpreted as described in
134 BCP 14 [KEYWORDS] [KEYWORDS-UPD] when, and only when, they appear in
135 all capitals, as shown here.
136
137 Conventions for notations are as described in Section 1.1 of [SIEVE],
138 including use of the "Usage:" label for the definition of the action
139 and the syntax of tagged arguments.
140
141 In [IMAP] examples, "C:" and "S:" indicate lines sent by the client
142 and server, respectively. If such lines are wrapped without a new
143 "C:" or "S:" label, then the wrapping is for editorial clarity and is
144 not part of the command.
145
1463. Test "specialuse_exists"
147
148 Usage: specialuse_exists [<mailbox: string>]
149 <special-use-attrs: string-list>
150
151 If the "mailbox" string argument is omitted, the "specialuse_exists"
152 test yields "true" if all of the following statements are true for
153 each of the special-use attributes listed in the special-use-attrs
154 argument:
155
156 a. At least one mailbox exists in the user's personal namespace
157 [NAMESPACE] that has that particular special-use attribute
158 assigned.
159
160 b. That mailbox allows the user in whose context the Sieve script
161 runs to "deliver" messages into it.
162
163
164
165
166
167
168
169
170Bosch Standards Track [Page 3]
171
172RFC 8579 Sieve: Special-Use Mailboxes May 2019
173
174
175 If the mailbox argument is specified, the "specialuse_exists" test
176 yields "true" if all of the following statements are true:
177
178 a. The indicated mailbox exists.
179
180 b. That mailbox allows the user in whose context the Sieve script
181 runs to "deliver" messages into it.
182
183 c. That mailbox has all of the special-use attributes listed in the
184 special-use-attrs argument assigned to it.
185
186 Refer to the specification of the "mailboxexists" test in Section 3.1
187 of RFC 5490 [SIEVE-MAILBOX] for a definition of when "delivery" of
188 messages into a mailbox is deemed possible.
189
1903.1. Equivalent IMAP Operations
191
192 To clarify, the following IMAP protocol examples show a sequence of
193 [IMAP] commands that a client could send to perform an assessment
194 without Sieve that is equivalent to the "specialuse_exists" test.
195
196 First, the client queries which namespaces are available using the
197 NAMESPACE command [NAMESPACE]:
198
199 C: A01 NAMESPACE
200 S: * NAMESPACE (("INBOX/" "/")("Archive/" "/")) NIL (("Public/" "/"))
201 S: A01 OK NAMESPACE command completed
202
203 Subsequently, when no particular mailbox is of interest (i.e., the
204 "specialuse_exists" test has no mailbox argument), the client lists
205 all mailboxes with special-use attributes in the two returned
206 personal namespaces (this extended LIST command requires the LIST-
207 EXTENDED IMAP capability [LIST-EXTENDED]):
208
209 C: A02 LIST (SPECIAL-USE) "" ("INBOX/*" "Archive/*")
210 RETURN (SPECIAL-USE)
211 S: * LIST (\Drafts) "/" INBOX/Drafts
212 S: * LIST (\Trash) "/" INBOX/Trash
213 S: * LIST (\Sent) "/" INBOX/Sent
214 S: * LIST (\Archive) "/" Archive/Default
215 S: A02 OK LIST command completed
216
217 Finally, using the MYRIGHTS command [IMAP-ACL], the client determines
218 the access rights it has for the mailbox or mailboxes that have all
219 the requested attributes assigned. This way, it can determine
220 whether messages can be saved to any of those. In this example, an
221 "\Archive" special-use mailbox is sought:
222
223
224
225
226Bosch Standards Track [Page 4]
227
228RFC 8579 Sieve: Special-Use Mailboxes May 2019
229
230
231 C: A03 MYRIGHTS Archive/Default
232 S: * MYRIGHTS Archive/Default lrwsip
233 S: A03 OK Myrights completed
234
235 The MYRIGHTS response indicates that the user has "insert" rights
236 [IMAP-ACL] for the "Archive/Default" mailbox, meaning that the client
237 can deliver (APPEND) messages to that mailbox and that the Sieve
238 "specialuse_exists" test would yield "true" in this case.
239
2404. ":specialuse" Argument to "fileinto" Command
241
242 Usage: fileinto [:specialuse <special-use-attr: string>]
243 <mailbox: string>
244
245 Normally, the "fileinto" command delivers the message in the mailbox
246 specified using its positional mailbox argument, which is the name of
247 the mailbox. However, if the optional ":specialuse" argument is also
248 specified, the "fileinto" command first checks whether a mailbox
249 exists in the user's personal namespace [NAMESPACE] with the
250 specified special-use attribute assigned to it. If that is the case,
251 that special-use mailbox is used for delivery instead. If there is
252 no such mailbox or if the specified special-use attribute is unknown
253 to the implementation in general, the "fileinto" action proceeds as
254 it would without the ":specialuse" argument.
255
256 Summarizing, if the ":specialuse" argument is specified, the
257 "fileinto" command deals with two mailboxes that may or may not exist
258 and may, in fact, be equal:
259
260 o A special-use mailbox in the user's personal namespace, which has
261 at least the special-use attribute specified with the
262 ":specialuse" argument assigned to it. The name for this mailbox
263 is not relevant here; it is only identified by the assigned
264 special-use attribute.
265
266 o The default mailbox named by the positional string argument of the
267 "fileinto" command, which is used when the special-use mailbox is
268 not found.
269
270 The special-use attribute specified with the ":specialuse" argument
271 conforms to the "use-attr" syntax described in Section 6 of RFC 6154
272 [SPECIAL-USE]. Implementations SHOULD handle an invalid special-use
273 attribute in the same way as an invalid mailbox name is handled. The
274 string parameter of the ":specialuse" argument is not a constant
275 string, which means that variable substitutions are allowed when the
276 "variables" extension [VARIABLES] is active. In that case, the
277 syntax of the special-use attribute is only verified at runtime.
278
279
280
281
282Bosch Standards Track [Page 5]
283
284RFC 8579 Sieve: Special-Use Mailboxes May 2019
285
286
287 If neither the special-use mailbox nor the default mailbox exists,
288 the "fileinto" action MUST proceed exactly as it does in case the
289 ":specialuse" argument is absent and the mailbox named by its
290 positional argument does not exist. The various options for handling
291 this situation are described in Section 4.1 of RFC 5228 [SIEVE].
292
293 More than one mailbox in the user's personal namespace can have a
294 particular special-use attribute assigned. If one of those mailboxes
295 is, in fact, the default mailbox named by the positional string
296 argument of the "fileinto" command, that mailbox MUST be used for
297 delivery. If the default mailbox is not one of the options, the
298 mailbox that is chosen for delivery is implementation defined.
299 However, while the set of mailboxes to which the involved special-use
300 attribute are assigned remains unchanged, implementations SHOULD
301 ensure that the mailbox choice is made consistently, so that the same
302 mailbox is used every time. Conversely, the chosen mailbox MAY
303 change once the assignments of the special-use attribute that are
304 relevant for the mailbox choice are changed (usually by user
305 interaction).
306
307 If delivery to the special-use mailbox fails for reasons not relating
308 to its existence, the Sieve interpreter MUST NOT subsequently attempt
309 delivery in the indicated default mailbox as a fallback. Instead, it
310 MUST proceed exactly as it does in case the ":specialuse" argument is
311 absent and delivery to the mailbox named by its positional argument
312 fails. This prevents the situation where messages are unexpectedly
313 spread over two mailboxes in case transient or intermittent delivery
314 failures occur.
315
3164.1. Mailboxes Created Implicitly by the "fileinto" Command
317
318 Before attempting to deliver the message into the specified mailbox,
319 the "fileinto" command may implicitly create the mailbox if it does
320 not exist (see Section 4.1 of RFC 5228 [SIEVE]). This optional
321 behavior can be requested explicitly using the "mailbox" extension
322 [SIEVE-MAILBOX], which adds the optional ":create" argument to the
323 "fileinto" command. If the ":create" argument is specified with
324 "fileinto", it instructs the Sieve interpreter to unconditionally
325 create the specified mailbox if needed. Note that the ":create"
326 argument has no effect when the implicit creation of mailboxes for
327 delivery is the default behavior.
328
329 When the ":specialuse" argument is present, this behavior does not
330 change; the Sieve interpreter will implicitly create the specified
331 default mailbox if needed. This need arises when both the special-
332 use mailbox and the default mailbox are not found.
333
334
335
336
337
338Bosch Standards Track [Page 6]
339
340RFC 8579 Sieve: Special-Use Mailboxes May 2019
341
342
343 If the server implementation supports the CREATE-SPECIAL-USE
344 capability [SPECIAL-USE] for IMAP (i.e., it allows assigning special-
345 use attributes to new mailboxes), it SHOULD assign the special-use
346 attribute specified with the ":specialuse" argument to the newly
347 created mailbox.
348
3494.2. Equivalent IMAP Operations
350
351 To clarify, the following IMAP protocol examples show a sequence of
352 [IMAP] commands that a client could send to perform an action without
353 Sieve that is equivalent to the "fileinto" action with the
354 ":specialuse" argument. The following Sieve script is assumed:
355
356 require "fileinto";
357 require "special-use";
358
359 fileinto :specialuse "\\Archive" "INBOX/Archive";
360
361 First, the client proceeds as in Section 3.1 to find out whether the
362 indicated special-use attribute is assigned to any mailbox in the
363 user's personal namespace. If a matching special-use mailbox is
364 found, the message is delivered there using the IMAP APPEND command.
365 If no matching special-use mailbox is found, the client attempts to
366 deliver the message to the indicated default mailbox:
367
368 C: A04 APPEND INBOX/Archive {309}
369 S: A04 NO [TRYCREATE] Mailbox does not exist: INBOX/Archive
370
371 In this example, the default mailbox does not exist either. In that
372 case, the client MAY create the default mailbox and assign the
373 indicated special-use attribute to it:
374
375 C: A05 CREATE INBOX/Archive (USE (\Archive))
376 S: A05 OK Create completed
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394Bosch Standards Track [Page 7]
395
396RFC 8579 Sieve: Special-Use Mailboxes May 2019
397
398
399 Finally, the client completes the delivery:
400
401 C: A06 APPEND INBOX/Archive {309}
402 S: + OK
403 C: Date: Wed, 18 Jul 2018 22:00:09 +0200
404 C: From: mooch@owatagu.siam.example
405 C: To: Fred Foobar <foobar@Blurdybloop.example>
406 C: Subject: afternoon meeting
407 C: Message-Id: <Q234234-01012222@owatagu.siam.example>
408 C: MIME-Version: 1.0
409 C: Content-Type: text/plain; charset=UTF-8
410 C:
411 C: Hi Fred, do you think we can meet again at 3:30 tomorrow?
412 C:
413 S: A06 OK [APPENDUID 1533375901 2312] Append completed.
414
4155. Sieve Capability Strings
416
417 A Sieve implementation that defines the "specialuse_exists" test and
418 the ":specialuse" argument for the "fileinto" command will advertise
419 the capability string "special-use".
420
4216. Examples
422
423 The following example saves the message in the mailbox where messages
424 deemed to be junk mail are held. This mailbox is identified using
425 the "\Junk" special-use attribute. If no mailbox has this attribute
426 assigned, the message is filed into the mailbox named "Spam". If the
427 mailbox named "Spam" does not exist either, the result of this Sieve
428 script is implementation dependent, e.g., it may trigger an error or
429 the mailbox may be created implicitly.
430
431 require "fileinto";
432 require "special-use";
433
434 fileinto :specialuse "\\Junk" "Spam";
435
436 The following very similar example explicitly handles the case in
437 which neither a "\Junk" special-use mailbox nor the "Spam" mailbox
438 exists. In that case, a mailbox called "Spam" is created, and the
439 message is stored there. Additionally, the "\Junk" special-use
440 attribute may be assigned to it.
441
442 require "fileinto";
443 require "special-use";
444 require "mailbox";
445
446 fileinto :specialuse "\\Junk" :create "Spam";
447
448
449
450Bosch Standards Track [Page 8]
451
452RFC 8579 Sieve: Special-Use Mailboxes May 2019
453
454
455 The following example is used in a Sieve script that is triggered
456 from an IMAP event rather than at message delivery [IMAPSIEVE]. This
457 Sieve script redirects messages to an automated recipient that
458 processes junk mail if those messages are copied or moved into a
459 mailbox that has the "\Junk" special-use attribute assigned.
460
461 require "imapsieve";
462 require "special-use";
463 require "environment";
464 require "variables";
465
466 if environment :contains "imap.mailbox" "*" {
467 set "mailbox" "${1}";
468 }
469
470 if allof(
471 environment "imap.cause" "COPY",
472 specialuse_exists "${mailbox}" "\\Junk") {
473 redirect "spam-report@example.org";
474 }
475
4767. Security Considerations
477
478 Security considerations are discussed in [SIEVE], [VARIABLES], and
479 [SPECIAL-USE]. It is believed that this extension does not introduce
480 any additional security concerns.
481
482 Note that this specification explicitly restricts the special-use
483 mailbox to the user's personal namespace. First, this avoids the
484 need to search the entire mail storage for mailboxes that have a
485 particular special-use attribute assigned. This could put undue load
486 on the system, while shared special-use mailboxes are deemed of
487 limited use with the currently defined special-use attributes.
488 Secondly, it prevents security concerns with shared mailboxes that
489 have special-use attributes assigned that apply to all users.
490 Searching the entire mail storage for special-use mailboxes could
491 lead to messages unexpectedly or even maliciously being filed to
492 shared mailboxes.
493
494 This restriction could be lifted for particular future special-use
495 attributes, but such new attributes should have a clear application
496 for shared mailboxes, and the security concerns should be considered
497 carefully.
498
499
500
501
502
503
504
505
506Bosch Standards Track [Page 9]
507
508RFC 8579 Sieve: Special-Use Mailboxes May 2019
509
510
5118. IANA Considerations
512
513 IANA has registered the Sieve extension specified in this document in
514 the "Sieve Extensions" registry at <https://www.iana.org/assignments/
515 sieve-extensions>:
516
517 Capability name: special-use
518 Description: adds a test for checking whether an IMAP
519 special-use attribute is assigned for a
520 particular mailbox or any mailbox; also adds
521 the ability to file messages into a mailbox
522 identified solely by a special-use attribute.
523 RFC number: RFC 8579
524 Contact address: Sieve discussion list <sieve@ietf.org>
525
5269. References
527
5289.1. Normative References
529
530 [IMAP-METADATA]
531 Daboo, C., "The IMAP METADATA Extension", RFC 5464,
532 DOI 10.17487/RFC5464, February 2009,
533 <https://www.rfc-editor.org/info/rfc5464>.
534
535 [KEYWORDS] Bradner, S., "Key words for use in RFCs to Indicate
536 Requirement Levels", BCP 14, RFC 2119,
537 DOI 10.17487/RFC2119, March 1997,
538 <https://www.rfc-editor.org/info/rfc2119>.
539
540 [KEYWORDS-UPD]
541 Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
542 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174,
543 May 2017, <https://www.rfc-editor.org/info/rfc8174>.
544
545 [NAMESPACE]
546 Gahrns, M. and C. Newman, "IMAP4 Namespace", RFC 2342,
547 DOI 10.17487/RFC2342, May 1998,
548 <https://www.rfc-editor.org/info/rfc2342>.
549
550 [SIEVE] Guenther, P., Ed. and T. Showalter, Ed., "Sieve: An Email
551 Filtering Language", RFC 5228, DOI 10.17487/RFC5228,
552 January 2008, <https://www.rfc-editor.org/info/rfc5228>.
553
554 [SIEVE-MAILBOX]
555 Melnikov, A., "The Sieve Mail-Filtering Language --
556 Extensions for Checking Mailbox Status and Accessing
557 Mailbox Metadata", RFC 5490, DOI 10.17487/RFC5490, March
558 2009, <https://www.rfc-editor.org/info/rfc5490>.
559
560
561
562Bosch Standards Track [Page 10]
563
564RFC 8579 Sieve: Special-Use Mailboxes May 2019
565
566
567 [SPECIAL-USE]
568 Leiba, B. and J. Nicolson, "IMAP LIST Extension for
569 Special-Use Mailboxes", RFC 6154, DOI 10.17487/RFC6154,
570 March 2011, <https://www.rfc-editor.org/info/rfc6154>.
571
572 [VARIABLES]
573 Homme, K., "Sieve Email Filtering: Variables Extension",
574 RFC 5229, DOI 10.17487/RFC5229, January 2008,
575 <https://www.rfc-editor.org/info/rfc5229>.
576
5779.2. Informative References
578
579 [IMAP] Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - VERSION
580 4rev1", RFC 3501, DOI 10.17487/RFC3501, March 2003,
581 <https://www.rfc-editor.org/info/rfc3501>.
582
583 [IMAP-ACL] Melnikov, A., "IMAP4 Access Control List (ACL) Extension",
584 RFC 4314, DOI 10.17487/RFC4314, December 2005,
585 <https://www.rfc-editor.org/info/rfc4314>.
586
587 [IMAPSIEVE]
588 Leiba, B., "Support for Internet Message Access Protocol
589 (IMAP) Events in Sieve", RFC 6785, DOI 10.17487/RFC6785,
590 November 2012, <https://www.rfc-editor.org/info/rfc6785>.
591
592 [LIST-EXTENDED]
593 Leiba, B. and A. Melnikov, "Internet Message Access
594 Protocol version 4 - LIST Command Extensions", RFC 5258,
595 DOI 10.17487/RFC5258, June 2008,
596 <https://www.rfc-editor.org/info/rfc5258>.
597
598Acknowledgements
599
600 Thanks to Stan Kalisch, Barry Leiba, Alexey Melnikov, Ken Murchison,
601 and Ned Freed for reviews and suggestions.
602
603 Thanks to the authors of RFC 5490 [SIEVE-MAILBOX], from which some
604 descriptive text in this document is borrowed.
605
606
607
608
609
610
611
612
613
614
615
616
617
618Bosch Standards Track [Page 11]
619
620RFC 8579 Sieve: Special-Use Mailboxes May 2019
621
622
623Author's Address
624
625 Stephan Bosch
626 Open Xchange Oy
627 Lars Sonckin kaari 12
628 Espoo 02600
629 Finland
630
631 Email: stephan.bosch@open-xchange.com
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674Bosch Standards Track [Page 12]
675
676