1
2
3
4
5Internet Engineering Task Force (IETF) B. Gondwana, Ed.
6Request for Comments: 9042 Fastmail
7Updates: 5228 June 2021
8Category: Standards Track
9ISSN: 2070-1721
10
11
12 Sieve Email Filtering: Delivery by MAILBOXID
13
14Abstract
15
16 The OBJECTID capability of IMAP (RFC 8474) allows clients to identify
17 mailboxes by a unique identifier that survives renaming.
18
19 This document extends the Sieve email filtering language (RFC 5228)
20 to allow using that same unique identifier as a target for fileinto
21 rules and for testing the existence of mailboxes.
22
23Status of This Memo
24
25 This is an Internet Standards Track document.
26
27 This document is a product of the Internet Engineering Task Force
28 (IETF). It represents the consensus of the IETF community. It has
29 received public review and has been approved for publication by the
30 Internet Engineering Steering Group (IESG). Further information on
31 Internet Standards is available in Section 2 of RFC 7841.
32
33 Information about the current status of this document, any errata,
34 and how to provide feedback on it may be obtained at
35 https://www.rfc-editor.org/info/rfc9042.
36
37Copyright Notice
38
39 Copyright (c) 2021 IETF Trust and the persons identified as the
40 document authors. All rights reserved.
41
42 This document is subject to BCP 78 and the IETF Trust's Legal
43 Provisions Relating to IETF Documents
44 (https://trustee.ietf.org/license-info) in effect on the date of
45 publication of this document. Please review these documents
46 carefully, as they describe your rights and restrictions with respect
47 to this document. Code Components extracted from this document must
48 include Simplified BSD License text as described in Section 4.e of
49 the Trust Legal Provisions and are provided without warranty as
50 described in the Simplified BSD License.
51
52Table of Contents
53
54 1. Introduction
55 2. Conventions Used in This Document
56 3. Sieve Capability String
57 4. Argument :mailboxid to Command fileinto
58 4.1. Interaction with Mailbox Extension
59 4.2. Interaction with Special-Use Extension
60 5. Interaction with FCC Extension
61 6. Test mailboxidexists
62 7. Interaction with Variables Extension
63 8. Security Considerations
64 9. IANA Considerations
65 10. References
66 10.1. Normative References
67 10.2. Informative References
68 Acknowledgements
69 Author's Address
70
711. Introduction
72
73 Sieve rules [RFC5228] are sometimes created using graphical
74 interfaces, which allow users to select the mailbox to be used as a
75 target for a rule.
76
77 If that mailbox is renamed, the client may also update its internal
78 representation of the rule and update the Sieve script to match;
79 however, this is a multistep process and subject to partial failures.
80 Also, if the folder is renamed by a different mechanism (e.g.,
81 another IMAP client), the rules will get out of sync.
82
83 By telling fileinto to reference the immutable MAILBOXID specified by
84 [RFC8474], using the extension specified herein, Sieve rules can
85 continue to target the same mailbox, even if it gets renamed.
86
872. Conventions Used in This Document
88
89 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
90 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
91 "OPTIONAL" in this document are to be interpreted as described in
92 BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all
93 capitals, as shown here.
94
953. Sieve Capability String
96
97 Scripts that use the extensions defined in this document MUST
98 explicitly require the capability "mailboxid".
99
100 Example:
101
102 require "mailboxid";
103
1044. Argument :mailboxid to Command fileinto
105
106 Normally, the fileinto command delivers the message in the mailbox
107 specified using its positional mailbox argument. However, if the
108 optional :mailboxid argument is also specified, the fileinto command
109 first checks whether a mailbox exists in the user's personal
110 namespace [RFC2342] with the specified MAILBOXID [RFC8474].
111
112 If a matching mailbox is found, that mailbox is used for delivery.
113
114 If there is no such mailbox, the fileinto action proceeds as it would
115 without the :mailboxid argument.
116
117 The tagged argument :mailboxid to fileinto consumes one additional
118 token, a string containing the OBJECTID of the target mailbox.
119
120 Example:
121
122 require "fileinto";
123 require "mailboxid";
124
125 if header :contains ["from"] "coyote" {
126 fileinto :mailboxid "F6352ae03-b7f5-463c-896f-d8b48ee3"
127 "INBOX.harassment";
128 }
129
1304.1. Interaction with Mailbox Extension
131
132 For servers that also support the mailbox extension defined in
133 [RFC5490], if both the :create and :mailboxid arguments are provided
134 to a fileinto command and no matching mailbox is found, then a new
135 mailbox will be created.
136
137 This new mailbox will have the name specified by the positional
138 mailbox argument ([RFC5228], Section 4.1); however, it will get a
139 different MAILBOXID (chosen by the server) rather than the one
140 specified by the :mailboxid argument to fileinto.
141
142 Example:
143
144 require "fileinto";
145 require "mailboxid";
146 require "mailbox";
147
148 fileinto :mailboxid "Fnosuch"
149 :create
150 "INBOX.no-such-folder";
151 # creates INBOX.no-such-folder, but it doesn't
152 # get the "Fnosuch" mailboxid.
153
1544.2. Interaction with Special-Use Extension
155
156 For servers that also support delivery to special-use mailboxes
157 [RFC8579], it is an error to specify both :mailboxid and :specialuse
158 in the same fileinto command.
159
160 Advanced filtering based on both special-use and MAILBOXID can be
161 built with explicit specialuse_exists and mailboxidexists tests.
162
163 | Note to developers of Sieve generation tools:
164 |
165 | It is advisable to use special-use rather than MAILBOXID when
166 | creating rules that are based on a special-use purpose (e.g.,
167 | delivery directly to the Junk folder based on a header that was
168 | added by a scanning agent earlier in the mail flow).
169
1705. Interaction with FCC Extension
171
172 This document extends the definition of the :fcc argument defined in
173 [RFC8580] so that it can optionally be used with the :mailboxid
174 argument. The syntax for FCC is extended here using ABNF [RFC5234]:
175
176 MAILBOXID-OPT = ":mailboxid" objectid
177
178 FCC-OPTS =/ MAILBOXID-OPT
179
180 If the optional :mailboxid argument is specified with :fcc, it
181 instructs the Sieve interpreter to check whether a mailbox exists
182 with the specific MAILBOXID. If such a mailbox exists, the generated
183 message is filed into that mailbox. Otherwise, the generated message
184 is filed into the :fcc target mailbox.
185
186 As with fileinto, it is an error to specify both :mailboxid and
187 :specialuse for the same fcc rule.
188
189 Example:
190
191 require ["enotify", "fcc", "mailboxid"];
192 notify :fcc "INBOX.Sent"
193 :mailboxid "F6352ae03-b7f5-463c-896f-d8b48ee3"
194 :message "You got mail!"
195 "mailto:ken@example.com";
196
1976. Test mailboxidexists
198
199 Usage: mailboxidexists <mailbox-objectids: string-list>
200
201 The mailboxidexists test is true if every string argument provided is
202 the MAILBOXID of a mailbox that exists in the mailstore and that
203 allows the user in whose context the Sieve script runs to deliver
204 messages into it.
205
206 When the mailstore is an IMAP server that also supports IMAP Access
207 Control List (ACL) [RFC4314], delivery is allowed if the user has the
208 'p' or 'i' rights for the mailbox (see Section 5.2 of [RFC4314]).
209
210 When the mailstore is an IMAP server that does not support IMAP ACL,
211 delivery is allowed if the READ-WRITE response code is present for
212 the mailbox when selected by the user (see Section 7.1 of [RFC3501]).
213
214 Note that a successful mailboxidexists test for a mailbox doesn't
215 necessarily mean that a "fileinto :mailboxid" action on this mailbox
216 would succeed. For example, the fileinto action might put the user
217 over quota. The mailboxidexists test only verifies existence of the
218 mailbox and whether the user in whose context the Sieve script runs
219 has permissions to execute fileinto on it.
220
221 Example:
222
223 require "fileinto";
224 require "mailboxid";
225
226 if header :contains ["from"] "coyote" {
227 if mailboxidexists "F6352ae03-b7f5-463c-896f-d8b48ee3" {
228 fileinto :mailboxid "F6352ae03-b7f5-463c-896f-d8b48ee3"
229 "INBOX.name.will.not.be.used";
230 } else {
231 fileinto "INBOX.harassment";
232 }
233 }
234
235 | Note to implementers:
236 |
237 | This test behaves identically to the mailboxexists test defined
238 | in [RFC5490] but operates on MAILBOXIDs rather than mailbox
239 | names.
240
2417. Interaction with Variables Extension
242
243 There is no special interaction defined; however, as an OBJECTID is a
244 string in this document, OBJECTID values can contain variable
245 expansions if [RFC5229] is enabled.
246
2478. Security Considerations
248
249 Because MAILBOXID is always generated by the server, implementations
250 MUST NOT allow Sieve to make an end run around this protection by
251 creating mailboxes with the specified ID by using :create and
252 :mailboxid in a fileinto rule for a nonexistent mailbox.
253
254 Implementers are referred to the Security Considerations sections of
255 [RFC5228] and [RFC8474].
256
2579. IANA Considerations
258
259 IANA has added the following capability to the "Sieve Extensions"
260 registry at <https://www.iana.org/assignments/sieve-extensions>:
261
262 Capability name: mailboxid
263 Description: adds a test for checking mailbox existence by OBJECTID
264 and new optional arguments to fileinto and :fcc that allow
265 selecting the destination mailbox by OBJECTID.
266 RFC number: RFC 9042
267 Contact address: EXTRA discussion list <extra@ietf.org>
268
26910. References
270
27110.1. Normative References
272
273 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
274 Requirement Levels", BCP 14, RFC 2119,
275 DOI 10.17487/RFC2119, March 1997,
276 <https://www.rfc-editor.org/info/rfc2119>.
277
278 [RFC2342] Gahrns, M. and C. Newman, "IMAP4 Namespace", RFC 2342,
279 DOI 10.17487/RFC2342, May 1998,
280 <https://www.rfc-editor.org/info/rfc2342>.
281
282 [RFC5228] Guenther, P., Ed. and T. Showalter, Ed., "Sieve: An Email
283 Filtering Language", RFC 5228, DOI 10.17487/RFC5228,
284 January 2008, <https://www.rfc-editor.org/info/rfc5228>.
285
286 [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax
287 Specifications: ABNF", STD 68, RFC 5234,
288 DOI 10.17487/RFC5234, January 2008,
289 <https://www.rfc-editor.org/info/rfc5234>.
290
291 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
292 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174,
293 May 2017, <https://www.rfc-editor.org/info/rfc8174>.
294
295 [RFC8474] Gondwana, B., Ed., "IMAP Extension for Object
296 Identifiers", RFC 8474, DOI 10.17487/RFC8474, September
297 2018, <https://www.rfc-editor.org/info/rfc8474>.
298
299 [RFC8580] Murchison, K. and B. Gondwana, "Sieve Extension: File
300 Carbon Copy (FCC)", RFC 8580, DOI 10.17487/RFC8580, May
301 2019, <https://www.rfc-editor.org/info/rfc8580>.
302
30310.2. Informative References
304
305 [RFC3501] Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - VERSION
306 4rev1", RFC 3501, DOI 10.17487/RFC3501, March 2003,
307 <https://www.rfc-editor.org/info/rfc3501>.
308
309 [RFC4314] Melnikov, A., "IMAP4 Access Control List (ACL) Extension",
310 RFC 4314, DOI 10.17487/RFC4314, December 2005,
311 <https://www.rfc-editor.org/info/rfc4314>.
312
313 [RFC5229] Homme, K., "Sieve Email Filtering: Variables Extension",
314 RFC 5229, DOI 10.17487/RFC5229, January 2008,
315 <https://www.rfc-editor.org/info/rfc5229>.
316
317 [RFC5490] Melnikov, A., "The Sieve Mail-Filtering Language --
318 Extensions for Checking Mailbox Status and Accessing
319 Mailbox Metadata", RFC 5490, DOI 10.17487/RFC5490, March
320 2009, <https://www.rfc-editor.org/info/rfc5490>.
321
322 [RFC8579] Bosch, S., "Sieve Email Filtering: Delivering to Special-
323 Use Mailboxes", RFC 8579, DOI 10.17487/RFC8579, May 2019,
324 <https://www.rfc-editor.org/info/rfc8579>.
325
326Acknowledgements
327
328 This document borrows heavily from [RFC5490] for the matching
329 mailboxexists test and from [RFC8579] for an example of modifying the
330 fileinto command.
331
332 Thanks to Ned Freed, Ken Murchison, and Alexey Melnikov for feedback
333 on the EXTRA mailing list.
334
335Author's Address
336
337 Bron Gondwana (editor)
338 Fastmail
339 Level 2
340 114 William St
341 Melbourne VIC 3000
342 Australia
343
344 Email: brong@fastmailteam.com
345 URI: https://www.fastmail.com
346