Debian Codegraph @

rfc5703.html

raw
1 <pre>Network Working Group T. Hansen
2 Request for Comments: 5703 AT&amp;T Laboratories
3 Category: Standards Track C. Daboo
4 Apple Inc.
5 October 2009
6
7
8 <span class="h1">Sieve Email Filtering: MIME Part Tests, Iteration, Extraction,</span>
9 <span class="h1">Replacement, and Enclosure</span>
10
11 Abstract
12
13 This document defines extensions to the Sieve email filtering
14 language to permit analysis and manipulation of the MIME body parts
15 of an email message.
16
17 Status of This Memo
18
19 This document specifies an Internet standards track protocol for the
20 Internet community, and requests discussion and suggestions for
21 improvements. Please refer to the current edition of the "Internet
22 Official Protocol Standards" (STD 1) for the standardization state
23 and status of this protocol. Distribution of this memo is unlimited.
24
25 Copyright Notice
26
27 Copyright (c) 2009 IETF Trust and the persons identified as the
28 document authors. All rights reserved.
29
30 This document is subject to <a href="https://www.rfc-editor.org/bcp/bcp78">BCP 78</a> and the IETF Trust's Legal
31 Provisions Relating to IETF Documents
32 (<a href="http://trustee.ietf.org/license-info">http://trustee.ietf.org/license-info</a>) in effect on the date of
33 publication of this document. Please review these documents
34 carefully, as they describe your rights and restrictions with respect
35 to this document. Code Components extracted from this document must
36 include Simplified BSD License text as described in Section 4.e of
37 the Trust Legal Provisions and are provided without warranty as
38 described in the BSD License.
39
40 This document may contain material from IETF Documents or IETF
41 Contributions published or made publicly available before November
42 10, 2008. The person(s) controlling the copyright in some of this
43 material may not have granted the IETF Trust the right to allow
44 modifications of such material outside the IETF Standards Process.
45 Without obtaining an adequate license from the person(s) controlling
46 the copyright in such materials, this document may not be modified
47
48
49
50
51
52 <span class="grey">Hansen &amp; Daboo Standards Track [Page 1]</span></pre>
53 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-2" ></span>
54 <span class="grey"><a href="./rfc5703">RFC 5703</a> Sieve MIME Operations October 2009</span>
55
56
57 outside the IETF Standards Process, and derivative works of it may
58 not be created outside the IETF Standards Process, except to format
59 it for publication as an RFC or to translate it into languages other
60 than English.
61
62 Table of Contents
63
64 <a href="#section-1">1</a>. Introduction ....................................................<a href="#page-2">2</a>
65 <a href="#section-2">2</a>. Conventions Used in This Document ...............................<a href="#page-3">3</a>
66 <a href="#section-3">3</a>. Sieve Loops: Actions "foreverypart" and "break" .................<a href="#page-3">3</a>
67 <a href="#section-4">4</a>. Changes to Sieve Tests ..........................................<a href="#page-4">4</a>
68 <a href="#section-4.1">4.1</a>. Test "header" ..............................................<a href="#page-4">4</a>
69 <a href="#section-4.2">4.2</a>. Test "address" .............................................<a href="#page-7">7</a>
70 <a href="#section-4.3">4.3</a>. Test "exists" ..............................................<a href="#page-8">8</a>
71 <a href="#section-5">5</a>. Action "replace" ................................................<a href="#page-8">8</a>
72 <a href="#section-6">6</a>. Action "enclose" ...............................................<a href="#page-10">10</a>
73 <a href="#section-7">7</a>. Action "extracttext" ...........................................<a href="#page-11">11</a>
74 <a href="#section-8">8</a>. Sieve Capability Strings .......................................<a href="#page-11">11</a>
75 <a href="#section-9">9</a>. Examples .......................................................<a href="#page-12">12</a>
76 <a href="#section-9.1">9.1</a>. Example 1 .................................................<a href="#page-12">12</a>
77 <a href="#section-9.2">9.2</a>. Example 2 .................................................<a href="#page-12">12</a>
78 <a href="#section-9.3">9.3</a>. Example 3 .................................................<a href="#page-13">13</a>
79 <a href="#section-10">10</a>. Acknowledgements ..............................................<a href="#page-13">13</a>
80 <a href="#section-11">11</a>. Security Considerations .......................................<a href="#page-14">14</a>
81 <a href="#section-12">12</a>. IANA Considerations ...........................................<a href="#page-14">14</a>
82 <a href="#section-12.1">12.1</a>. foreverypart capability ..................................<a href="#page-15">15</a>
83 <a href="#section-12.2">12.2</a>. mime capability ..........................................<a href="#page-15">15</a>
84 <a href="#section-12.3">12.3</a>. replace capability .......................................<a href="#page-15">15</a>
85 <a href="#section-12.4">12.4</a>. enclose capability .......................................<a href="#page-16">16</a>
86 <a href="#section-12.5">12.5</a>. extracttext capability ...................................<a href="#page-16">16</a>
87 <a href="#section-13">13</a>. References ....................................................<a href="#page-16">16</a>
88 <a href="#section-13.1">13.1</a>. Normative References .....................................<a href="#page-16">16</a>
89 <a href="#section-13.2">13.2</a>. Informative References ...................................<a href="#page-17">17</a>
90
91 <span class="h2"><a class="selflink" id="section-1" href="#section-1">1</a>. Introduction</span>
92
93 MIME messages ([<a href="./rfc2045" title="&quot;Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies&quot;">RFC2045</a>]) are often complex objects, consisting of
94 many parts and sub-parts. This Sieve ([<a href="./rfc5228" title="&quot;Sieve: An Email Filtering Language&quot;">RFC5228</a>]) extension defines
95 mechanisms for performing tests on MIME body parts, looping through
96 the MIME body parts, extracting information from a MIME body part,
97 changing the contents of a MIME body part, and enclosing the entire
98 message within a wrapper.
99
100
101
102
103
104
105
106
107
108 <span class="grey">Hansen &amp; Daboo Standards Track [Page 2]</span></pre>
109 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-3" ></span>
110 <span class="grey"><a href="./rfc5703">RFC 5703</a> Sieve MIME Operations October 2009</span>
111
112
113 <span class="h2"><a class="selflink" id="section-2" href="#section-2">2</a>. Conventions Used in This Document</span>
114
115 Conventions for notations are as in <a href="./rfc5228#section-1.1">[RFC5228], Section&nbsp;1.1</a>.
116
117 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
118 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
119 document are to be interpreted as described in [<a href="./rfc2119" title="&quot;Key words for use in RFCs to Indicate Requirement Levels&quot;">RFC2119</a>].
120
121 <span class="h2"><a class="selflink" id="section-3" href="#section-3">3</a>. Sieve Loops: Actions "foreverypart" and "break"</span>
122
123 The base Sieve language has no looping mechanism. Given that
124 messages may contain multiple parts, in order to support filters that
125 apply to any and all parts, we introduce a new control command:
126 "foreverypart", which is an iterator that walks though every MIME
127 part of a message, including nested parts, depth first, and applies
128 the commands in the specified block to each of them. The iterator
129 will start with the first MIME part (as its current context) and will
130 execute a command block (Sieve commands enclosed by {...}). Upon
131 completion of this command block, the iterator advances to the next
132 MIME part (as its current context) and executes the same command
133 block again.
134
135 The iterator can be terminated prematurely by a new Sieve control
136 command, "break".
137
138 Usage: foreverypart [":name" string] block
139
140 Usage: break [":name" string];
141
142 "foreverypart" commands can be nested inside other "foreverypart"
143 commands. When this occurs, the nested "foreverypart" iterates over
144 the MIME parts contained within the MIME part currently being
145 targeted by the nearest enclosing "foreverypart" command. (That is,
146 the inner loop only operates on children of the bodypart currently
147 accessed by the outer loop.) If that MIME part is a terminal MIME
148 part (i.e., does not contain other MIME parts), then the nested
149 "foreverypart" loop is simply ignored.
150
151 Sieve implementations MAY limit the number of nested loops that occur
152 within one another; however, they MUST support at least one nested
153 loop inside another loop.
154
155 If a name is given to a "break" command, it terminates the closest
156 enclosing loop with the identical matching name. (If a nested
157 "foreverypart" name is the same as a "foreverypart" name in an outer
158 level, the outer level name is hidden.) It is an error if there is
159 no enclosing loop with that name.
160
161
162
163
164 <span class="grey">Hansen &amp; Daboo Standards Track [Page 3]</span></pre>
165 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-4" ></span>
166 <span class="grey"><a href="./rfc5703">RFC 5703</a> Sieve MIME Operations October 2009</span>
167
168
169 If no name is given in a "break" command (i.e., the ":name" parameter
170 is omitted), the break command terminates the closest enclosing loop.
171
172 <span class="h2"><a class="selflink" id="section-4" href="#section-4">4</a>. Changes to Sieve Tests</span>
173
174 This specification extends the base Sieve "header", "address", and
175 "exists" tests to support targeting those tests at a specific MIME
176 part or at all MIME parts in the enclosing scope.
177
178 <span class="h3"><a class="selflink" id="section-4.1" href="#section-4.1">4.1</a>. Test "header"</span>
179
180 The "header" test is extended with the addition of new ":mime" and
181 ":anychild" tagged arguments and their associated options.
182
183 Usage: header [":mime"] [":anychild"] [MIMEOPTS]
184 [COMPARATOR] [MATCH-TYPE]
185 &lt;header-names: string-list&gt; &lt;key-list: string-list&gt;
186
187 The definition of [MIMEOPTS] is:
188
189 Syntax: ":type" / ":subtype" / ":contenttype" /
190 ":param" &lt;param-list: string-list&gt;
191
192 When the ":mime" tagged argument is present in the "header" test, it
193 will parse the MIME header lines in the message so that tests can be
194 performed on specific elements. The ":anychild" tagged argument may
195 only appear when the ":mime" tagged argument is present, and only
196 modifies the semantics of the ":mime" tagged argument. That is,
197 presence of the ":anychild" in absence of ":mime" is an error.
198
199 When used outside the context of a "foreverypart" iterator, and
200 without an ":anychild" tagged argument, the "header" test will
201 examine only the outer top-level [<a href="./rfc5322" title="&quot;Internet Message Format&quot;">RFC5322</a>] headers of the message.
202
203 When used inside the context of a "foreverypart" iterator, and
204 without an ":anychild" tagged argument, the "header" test will
205 examine the headers associated with the current MIME part context
206 from the loop.
207
208 When used outside the context of a "foreverypart" iterator, and with
209 an ":anychild" tagged argument, the "header" test will examine all
210 MIME body parts and return true if any of them satisfies the test.
211
212 When used inside the context of a "foreverypart" iterator, and with
213 an ":anychild" tagged argument, the "header" test will examine the
214 current MIME part context and all its nested MIME body parts,
215 returning true if any of them satisfies the test.
216
217
218
219
220 <span class="grey">Hansen &amp; Daboo Standards Track [Page 4]</span></pre>
221 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-5" ></span>
222 <span class="grey"><a href="./rfc5703">RFC 5703</a> Sieve MIME Operations October 2009</span>
223
224
225 The "header" test with the ":mime" tagged argument can test various
226 aspects of certain structured MIME headers. Implementations SHOULD
227 support desegmentation, decoding, and charset translation of
228 parameter values encoded according to [<a href="./rfc2231" title="&quot;MIME Parameter Value and Encoded Word Extensions: Character Sets, Languages, and Continuations&quot;">RFC2231</a>] as part of this test.
229 Additionally, [<a href="./rfc2047" title="&quot;MIME (Multipurpose Internet Mail Extensions) Part Three: Message Header Extensions for Non-ASCII Text&quot;">RFC2047</a>] describes a process whereby [<a href="./rfc5322" title="&quot;Internet Message Format&quot;">RFC5322</a>] headers
230 can be encoded in various ways. That encoding is not strictly
231 allowed in MIME parameters; however, in practice, it has been used in
232 many email implementations. So, Sieve implementations MAY decode
233 [<a href="./rfc2047" title="&quot;MIME (Multipurpose Internet Mail Extensions) Part Three: Message Header Extensions for Non-ASCII Text&quot;">RFC2047</a>]-encoded words in parameter values as part of this test.
234
235 These options are available:
236
237 :type for a "Content-Type" MIME header field, parses and
238 tests the value of the MIME type specified in the
239 header; for a "Content-Disposition" MIME header field,
240 parses and tests the value of the disposition
241 specified in the header; for other MIME headers, uses
242 a blank string for the test.
243
244 :subtype for a "Content-Type" MIME header field, parses and
245 tests the value of the MIME subtype specified in the
246 header; for a "Content-Disposition" MIME header field,
247 uses a blank string for the test; for other MIME
248 headers, uses a blank string for the test.
249
250 :contenttype for a "Content-Type" MIME header field, parses and
251 tests the combined value of the MIME type and subtype
252 specified in the header; for a "Content-Disposition"
253 MIME header field, behaves the same as the ":type"
254 option; for other MIME headers, uses a blank string
255 for the test.
256
257 :param parses the header looking for MIME parameters in the
258 header. The supplied string-list lists the names of
259 any parameters to be tested. If any one named
260 parameter value matches any of the test string values,
261 the test will return true.
262
263 When the ":count" option from [<a href="./rfc5231" title="&quot;Sieve Email Filtering: Relational Extension&quot;">RFC5231</a>] is used, the following
264 applies:
265
266 a. for ":type", ":subtype", or ":contenttype", return a count of the
267 number of headers that parsed successfully
268
269 b. for ":param", return a count of the number of parameters with the
270 given name that were found
271
272
273
274
275
276 <span class="grey">Hansen &amp; Daboo Standards Track [Page 5]</span></pre>
277 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-6" ></span>
278 <span class="grey"><a href="./rfc5703">RFC 5703</a> Sieve MIME Operations October 2009</span>
279
280
281 Example:
282
283 require ["mime", "fileinto"];
284
285 if header :mime :type "Content-Type" "image"
286 {
287 fileinto "INBOX.images";
288 }
289
290 In this example, any message that contains a MIME image type part at
291 the top-level is saved to the mailbox "INBOX.images".
292
293 Example:
294
295 require ["mime", "fileinto"];
296
297 if header :mime :anychild :contenttype
298 "Content-Type" "text/html"
299 {
300 fileinto "INBOX.html";
301 }
302
303 In this example, any message that contains any MIME part with a
304 content-type of "text/html" is saved to the mailbox "INBOX.html".
305
306 Example:
307
308 require ["mime", "foreverypart", "fileinto"];
309
310 foreverypart
311 {
312 if allof (
313 header :mime :param "filename" :contains
314 "Content-Disposition" "important",
315 header :mime :subtype "Content-Type" "pdf",
316 size :over "100K")
317 {
318 fileinto "INBOX.important";
319 break;
320 }
321 }
322
323 In this example, any message that contains a MIME part that has a
324 content-disposition with a filename parameter containing the text
325 "important", has a content-subtype of "pdf" and is bigger than 100 Kb
326 is saved to the mailbox "INBOX.important".
327
328
329
330
331
332 <span class="grey">Hansen &amp; Daboo Standards Track [Page 6]</span></pre>
333 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-7" ></span>
334 <span class="grey"><a href="./rfc5703">RFC 5703</a> Sieve MIME Operations October 2009</span>
335
336
337 <span class="h3"><a class="selflink" id="section-4.2" href="#section-4.2">4.2</a>. Test "address"</span>
338
339 The "address" test is extended with the addition of new ":mime" and
340 ":anychild" tagged arguments and their associated options.
341
342 Usage: address [":mime"] [":anychild"] [COMPARATOR]
343 [ADDRESS-PART] [MATCH-TYPE]
344 &lt;header-list: string-list&gt; &lt;key-list: string-list&gt;
345
346 When the ":mime" tagged argument is present in the "address" test, it
347 will parse the MIME header lines as if they were standard address
348 header lines in a message so that tests can be performed on specific
349 elements.
350
351 The behavior of the ":anychild" tagged argument and the interaction
352 with the "foreverypart" iterator is the same as for the extended
353 "header" test in <a href="#section-4.1">Section 4.1</a>.
354
355 That is,
356
357 the use of "address" when both the ":mime" and ":anychild" tagged
358 arguments are omitted is the test defined in [<a href="./rfc5228" title="&quot;Sieve: An Email Filtering Language&quot;">RFC5228</a>], i.e., it
359 will *only* operate on top-level header fields, whether or not it
360 is inside "foreverypart".
361
362 the use of "address" with ":mime" and no ":anychild" operates on
363 the current MIME part only (or on the top-level header fields, if
364 outside "foreverypart").
365
366 the use of "address" with ":mime" and ":anychild" operates on the
367 current MIME part and all of its descendants.
368
369 Example:
370
371 require ["mime", "fileinto"];
372
373 if address :mime :is :all "content-from" "[email protected]"
374 {
375 fileinto "INBOX.part-from-tim";
376 }
377
378 In this example, any message that contains a MIME Content-From header
379 at the top-level matching the text "[email protected]" is saved to the
380 mailbox "INBOX.part-from-tim".
381
382
383
384
385
386
387
388 <span class="grey">Hansen &amp; Daboo Standards Track [Page 7]</span></pre>
389 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-8" ></span>
390 <span class="grey"><a href="./rfc5703">RFC 5703</a> Sieve MIME Operations October 2009</span>
391
392
393 <span class="h3"><a class="selflink" id="section-4.3" href="#section-4.3">4.3</a>. Test "exists"</span>
394
395 The "exists" test is extended with the addition of the new ":mime"
396 and ":anychild" tagged arguments and their associated options.
397
398 Usage: exists [":mime"] [":anychild"] &lt;header-names: string-list&gt;
399
400 When the ":mime" tagged argument is present in the "exists" test, the
401 test is extended to check for the existence of MIME headers in MIME
402 parts.
403
404 The behavior of the ":anychild" tagged argument and the interaction
405 with the "foreverypart" iterator is the same as for the extended
406 "header" test <a href="#section-4.1">Section 4.1</a>.
407
408 That is,
409
410 the use of "exists" when both the ":mime" and ":anychild" tagged
411 arguments are omitted is the test defined in [<a href="./rfc5228" title="&quot;Sieve: An Email Filtering Language&quot;">RFC5228</a>], i.e., it
412 will *only* operate on top-level header fields, whether or not it
413 is inside "foreverypart".
414
415 the use of "exists" with ":mime" and no ":anychild" operates on
416 the current MIME part only (or on the top-level header fields, if
417 outside "foreverypart").
418
419 the use of "exists" with ":mime" and ":anychild" operates on the
420 current MIME part and all of its descendants.
421
422 Example:
423
424 require ["mime", "fileinto"];
425
426 if exists :mime :anychild "content-md5"
427 {
428 fileinto "INBOX.md5";
429 }
430
431 In this example, any message that contains a MIME Content-MD5 header
432 in any MIME part is saved to the mailbox "INBOX.md5".
433
434 <span class="h2"><a class="selflink" id="section-5" href="#section-5">5</a>. Action "replace"</span>
435
436 Usage: replace [":mime"] [":subject" string] [":from" string]
437 &lt;replacement: string&gt;
438
439 The "replace" command is defined to allow a MIME part to be replaced
440 with the text supplied in the command.
441
442
443
444 <span class="grey">Hansen &amp; Daboo Standards Track [Page 8]</span></pre>
445 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-9" ></span>
446 <span class="grey"><a href="./rfc5703">RFC 5703</a> Sieve MIME Operations October 2009</span>
447
448
449 When used in the context of a "foreverypart" iterator, the MIME part
450 to be replaced is the "current" MIME part. If the current MIME
451 context is a multipart MIME part, the entire multipart MIME part is
452 replaced, which would alter the MIME structure of the message by
453 eliminating all of the children of the multipart part. (Replacing a
454 non-multipart MIME part within a "foreverypart" loop context does not
455 alter the overall message structure.) If the MIME structure is
456 altered, the change takes effect immediately: the "foreverypart"
457 iterator that is executing does not go into the no-longer existing
458 body parts, and subsequent "foreverypart" iterators would use the new
459 message structure.
460
461 When used outside the context of a "foreverypart" loop, the MIME part
462 to be replaced is the entire message.
463
464 If the ":mime" parameter is not specified, the replacement string is
465 a text/plain part in UTF-8 [<a href="./rfc3629" title="&quot;UTF-8, a transformation format of ISO 10646&quot;">RFC3629</a>].
466
467 If the ":mime" parameter is specified, then the replacement string
468 is, in fact, a MIME entity as defined in <a href="./rfc2045#section-2.4">[RFC2045], Section&nbsp;2.4</a>,
469 including both MIME headers and content.
470
471 If the entire message is being replaced, the optional ":subject"
472 parameter specifies a subject line to attach to the message that is
473 generated. UTF-8 characters can be used in the string argument;
474 implementations MUST convert the string to [<a href="./rfc2047" title="&quot;MIME (Multipurpose Internet Mail Extensions) Part Three: Message Header Extensions for Non-ASCII Text&quot;">RFC2047</a>]-encoded words if
475 and only if non-ASCII characters are present. If the ":subject"
476 parameter is used, implementations MUST preserve any previous Subject
477 header as an Original-Subject header. Implementations MUST preserve
478 all other header fields from the original message with the exception
479 of those relating to the MIME structure that is being replaced.
480
481 If the entire message is being replaced, as an indication that the
482 message is no longer as created by the original author of the
483 message, the optional ":from" parameter may be used to specify an
484 alternate address to use in the From field of the message that is
485 generated. The string must specify a valid [<a href="./rfc5322" title="&quot;Internet Message Format&quot;">RFC5322</a>] mailbox-list.
486 Implementations SHOULD check the syntax and generate an error when a
487 syntactically invalid ":from" parameter is specified.
488 Implementations MAY also impose restrictions on what addresses can be
489 specified in a ":from" parameter; it is suggested that values that
490 fail such a validity check simply be ignored rather than causing the
491 "replace" action to fail. If the From header is changed,
492 implementations MUST preserve the previous From header as an
493 Original-From header.
494
495
496
497
498
499
500 <span class="grey">Hansen &amp; Daboo Standards Track [Page 9]</span></pre>
501 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-10" ></span>
502 <span class="grey"><a href="./rfc5703">RFC 5703</a> Sieve MIME Operations October 2009</span>
503
504
505 Implementations that support the "editheader" extension [<a href="./rfc5293" title="&quot;Sieve Email Filtering: Editheader Extension&quot;">RFC5293</a>]
506 MUST ensure that any Original-Subject or Original-From headers added
507 by the system cannot be modified or removed. Implementations MAY
508 prevent the addition of Original-Subject and Orignal-From headers via
509 the "editheader" extension.
510
511 If ":mime" is specified and either ":subject" or ":from" is
512 specified, the ":subject:" or ":from" parameter MUST be ignored.
513 This SHOULD be flagged as a compilation error.
514
515 <span class="h2"><a class="selflink" id="section-6" href="#section-6">6</a>. Action "enclose"</span>
516
517 Usage: enclose &lt;:subject string&gt; &lt;:headers string-list&gt; string
518
519 A new Sieve action command is defined to allow an entire message to
520 be enclosed as an attachment to a new message. After enclosure,
521 subsequent actions affecting the message header or content, as well
522 as tests operating on the MIME structure or accessing MIME header
523 fields, use the newly created message instead of the original
524 message; this means that any use of a "replace" action or other
525 similar actions should be executed before the "enclose" action.
526
527 If multiple "enclose" actions are executed by a script, the message
528 is enclosed multiple times. (If a Sieve script desires to choose
529 between different enclosures, or wants to delay the enclosure to the
530 end of the script, it can use variables with appropriate tests
531 [<a href="./rfc5229" title="&quot;Sieve Email Filtering: Variables Extension&quot;">RFC5229</a>].)
532
533 This action does not affect messages that are forwarded via a
534 "redirect" action.
535
536 Specifically, the original message becomes a multipart/mixed message
537 with two parts: a text/plain portion with the string argument as its
538 body, and a message/rfc822 portion with the original message
539 enclosed. The Content-Type: header field becomes multipart/mixed.
540 The optional Subject: header is specified by the ":subject" argument;
541 if not present, the subject will be taken from the enclosed message.
542 Any headers specified by ":headers" are copied from the old message
543 into the new message. If not specified by ":headers", Date: and
544 From: headers should be synthesized to reflect the current date and
545 the user running the Sieve action.
546
547
548
549
550
551
552
553
554
555
556 <span class="grey">Hansen &amp; Daboo Standards Track [Page 10]</span></pre>
557 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-11" ></span>
558 <span class="grey"><a href="./rfc5703">RFC 5703</a> Sieve MIME Operations October 2009</span>
559
560
561 <span class="h2"><a class="selflink" id="section-7" href="#section-7">7</a>. Action "extracttext"</span>
562
563 Usage: extracttext [MODIFIER] [":first" number] &lt;varname: string&gt;
564
565 The "extracttext" action may be used within the context of a
566 "foreverypart" loop and is used to store text into a variable as
567 defined by [<a href="./rfc5229" title="&quot;Sieve Email Filtering: Variables Extension&quot;">RFC5229</a>]. Servers MUST support transcoding of any
568 textual body part into UTF-8 for use with this action. This requires
569 decoding any transfer encoding as well as transcoding from the
570 indicated character set into UTF-8. It stores at most ":first"
571 characters of the transcoded content of the current MIME body part in
572 the variable identified by varname. If the ":first" parameter is not
573 present, the whole content of the current MIME body part is stored.
574 In either case, the actually stored data MAY be truncated to conform
575 to implementation specific limit on variable length and/or on MIME
576 body part length. If the transfer encoding or character set is
577 unrecognized by the implementation or recognized but invalid, an
578 empty string will result.
579
580 If "extracttext" is used outside the context of a "foreverypart"
581 loop, the action will set the variable identified by varname to the
582 empty string. This SHOULD be flagged as a compilation error.
583
584 Modifiers are applied on the extracted text before it is stored in
585 the variable.
586
587 <span class="h2"><a class="selflink" id="section-8" href="#section-8">8</a>. Sieve Capability Strings</span>
588
589 A Sieve implementation that defines the "foreverypart" and "break"
590 actions will advertise the capability string "foreverypart".
591
592 A Sieve implementation that defines the ":mime" and ":anychild"
593 tagged arguments to the "header", "address", and "exists" commands
594 will advertise the capability string "mime".
595
596 A Sieve implementation that defines the "replace" action will
597 advertise the capability string "replace".
598
599 A Sieve implementation that defines the "enclose" action will
600 advertise the capability string "enclose".
601
602 A Sieve implementation that defines the "extracttext" action will
603 advertise the capability string "extracttext". Note that to be
604 useful, the "extracttext" action also requires the "variables"
605 [<a href="./rfc5229" title="&quot;Sieve Email Filtering: Variables Extension&quot;">RFC5229</a>] and "foreverypart" capabilities.
606
607
608
609
610
611
612 <span class="grey">Hansen &amp; Daboo Standards Track [Page 11]</span></pre>
613 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-12" ></span>
614 <span class="grey"><a href="./rfc5703">RFC 5703</a> Sieve MIME Operations October 2009</span>
615
616
617 <span class="h2"><a class="selflink" id="section-9" href="#section-9">9</a>. Examples</span>
618
619 <span class="h3"><a class="selflink" id="section-9.1" href="#section-9.1">9.1</a>. Example 1</span>
620
621 Consider a Sieve script to replace some of the Windows executable
622 attachments in a message. (The actual list of executable types and
623 extensions is considerably longer and constantly changing. The tests
624 shown here are an example only.) Such a script might look like this:
625
626 require [ "foreverypart", "mime", "replace" ];
627 foreverypart
628 {
629 if anyof (
630 header :mime :contenttype :is
631 "Content-Type" "application/exe",
632 header :mime :param "filename"
633 :matches ["Content-Type", "Content-Disposition"] "*.com" )
634 {
635 replace "Executable attachment removed by user filter";
636 }
637 }
638
639 <span class="h3"><a class="selflink" id="section-9.2" href="#section-9.2">9.2</a>. Example 2</span>
640
641 Consider a Sieve script to warn the user about some of the executable
642 attachment types. (The actual list of executable types and
643 extensions is considerably longer and constantly changing. The tests
644 shown here are an example only.) Such a script might look like this:
645
646 require [ "foreverypart", "mime", "enclose" ];
647
648 foreverypart
649 {
650 if header :mime :param "filename"
651 :matches ["Content-Type", "Content-Disposition"]
652 ["*.com", "*.exe", "*.vbs", "*.scr",
653 "*.pif", "*.hta", "*.bat", "*.zip" ]
654 {
655 # these attachment types are executable
656 enclose :subject "Warning" :text
657 WARNING! The enclosed message contains executable attachments.
658 These attachment types may contain a computer virus program
659 that can infect your computer and potentially damage your data.
660
661 Before clicking on these message attachments, you should verify
662 with the sender that this message was sent by them and not a
663 computer virus.
664
665
666
667
668 <span class="grey">Hansen &amp; Daboo Standards Track [Page 12]</span></pre>
669 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-13" ></span>
670 <span class="grey"><a href="./rfc5703">RFC 5703</a> Sieve MIME Operations October 2009</span>
671
672
673 .
674 ;
675 break;
676 }
677 }
678
679 <span class="h3"><a class="selflink" id="section-9.3" href="#section-9.3">9.3</a>. Example 3</span>
680
681 A Sieve script to extract subject and text out of messages from the
682 boss might look like this:
683
684 require ["mime", "variables", "extracttext"];
685
686 if header :contains "from" "[email protected]"
687 {
688 # :matches is used to get the value of the Subject header
689 if header :matches "Subject" "*"
690 {
691 set "subject" "${1}";
692 }
693
694 # extract the first 100 characters of the first text/* part
695 foreverypart
696 {
697 if header :mime :type :is "Content-Type" "text"
698 {
699 extracttext :first 100 "msgcontent";
700 break;
701 }
702 }
703
704 # if it's not a 'for your information' message
705 if not header :contains "subject" "FYI:"
706 {
707 # do something using ${subject} and ${msgcontent}
708 # such as sending a notification using a
709 # notification extension
710 }
711 }
712
713 <span class="h2"><a class="selflink" id="section-10" href="#section-10">10</a>. Acknowledgements</span>
714
715 Comments from members of the MTA Filters Working Group, in particular
716 Ned Freed, Kjetil Torgrim Homme, Mark Mallett, Alexey Melnikov, Aaron
717 Stone, and Nigel Swinson are gratefully acknowledged.
718
719
720
721
722
723
724 <span class="grey">Hansen &amp; Daboo Standards Track [Page 13]</span></pre>
725 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-14" ></span>
726 <span class="grey"><a href="./rfc5703">RFC 5703</a> Sieve MIME Operations October 2009</span>
727
728
729 <span class="h2"><a class="selflink" id="section-11" href="#section-11">11</a>. Security Considerations</span>
730
731 The "enclose" action creates an entirely new message, as compared to
732 just redirecting or forwarding the existing message. Therefore, any
733 site policies applicable to message submission should be enforced.
734
735 The looping specification specified here provides easier access to
736 information about the message contents, which may also be achieved
737 through other sieve tests. This is not believed to raise any
738 additional security issues beyond those for the Sieve "envelope" and
739 "body" [<a href="./rfc5173" title="&quot;Sieve Email Filtering: Body Extension&quot;">RFC5173</a>] tests.
740
741 Any change in message content may interfere with digital signature
742 mechanisms that include that content in the signed material. In
743 particular, using "replace" makes direct changes to the body content
744 and will affect the body hash included in Domain Keys Identified Mail
745 (DKIM) signatures [<a href="./rfc4871" title="&quot;DomainKeys Identified Mail (DKIM) Signatures&quot;">RFC4871</a>], or the message signature used for Secure
746 MIME (S/MIME) [<a href="./rfc3851" title="&quot;Secure/Multipurpose Internet Mail Extensions (S/MIME) Version 3.1 Message Specification&quot;">RFC3851</a>], Pretty Good Privacy (PGP) [<a href="./rfc1991" title="&quot;PGP Message Exchange Formats&quot;">RFC1991</a>] or
747 OpenPGP [<a href="./rfc4880" title="&quot;OpenPGP Message Format&quot;">RFC4880</a>].
748
749 It is not possible to examine the MIME structure of decrypted content
750 in a multipart/encrypted MIME part.
751
752 When "enclose" is used on a message containing a multipart/signed
753 MIME part, the Sieve implementation MUST ensure that the original
754 message is copied octet-for-octet to maintain the validity of the
755 digital signature.
756
757 The system MUST be sized and restricted in such a manner that even
758 malicious use of MIME part matching does not deny service to other
759 users of the host system.
760
761 All of the security considerations given in the base Sieve
762 specification also apply to these extensions.
763
764 <span class="h2"><a class="selflink" id="section-12" href="#section-12">12</a>. IANA Considerations</span>
765
766 The Original-Subject and Original-From headers have been registered
767 in the Permanent Message Header Fields registry.
768
769 The following templates specify the IANA registrations of the Sieve
770 extensions specified in this document. This information has been
771 added to the IANA registry of Sieve Extensions (currently found at
772 <a href="http://www.iana.org">http://www.iana.org</a>).
773
774
775
776
777
778
779
780 <span class="grey">Hansen &amp; Daboo Standards Track [Page 14]</span></pre>
781 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-15" ></span>
782 <span class="grey"><a href="./rfc5703">RFC 5703</a> Sieve MIME Operations October 2009</span>
783
784
785 <span class="h3"><a class="selflink" id="section-12.1" href="#section-12.1">12.1</a>. foreverypart capability</span>
786
787 To: [email protected]
788 Subject: Registration of new Sieve extension
789
790 Capability name: foreverypart
791 Description: adds the "foreverypart" and "break" actions for
792 iterating through MIME parts of a message.
793
794 RFC number: <a href="./rfc5703">RFC 5703</a>
795 Contact address: The Sieve discussion list
796 &lt;[email protected]&gt;.
797
798 <span class="h3"><a class="selflink" id="section-12.2" href="#section-12.2">12.2</a>. mime capability</span>
799
800 To: [email protected]
801 Subject: Registration of new Sieve extension
802
803 Capability name: mime
804 Description: adds the ":mime" and ":anychild" tagged arguments to the
805 "header", "address", and "exists" tests. Adds the ":type",
806 ":subtype", ":contenttype", and ":param" options when ":mime" is used
807 with the "header" test.
808
809 RFC number: <a href="./rfc5703">RFC 5703</a>
810 Contact address: The Sieve discussion list
811 &lt;[email protected]&gt;.
812
813 <span class="h3"><a class="selflink" id="section-12.3" href="#section-12.3">12.3</a>. replace capability</span>
814
815 To: [email protected]
816 Subject: Registration of new Sieve extension
817
818 Capability name: replace
819 Description: adds the "replace" action for replacing a MIME body part
820 of a message.
821
822 RFC number: <a href="./rfc5703">RFC 5703</a>
823 Contact address: The Sieve discussion list
824 &lt;[email protected]&gt;.
825
826
827
828
829
830
831
832
833
834
835
836 <span class="grey">Hansen &amp; Daboo Standards Track [Page 15]</span></pre>
837 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-16" ></span>
838 <span class="grey"><a href="./rfc5703">RFC 5703</a> Sieve MIME Operations October 2009</span>
839
840
841 <span class="h3"><a class="selflink" id="section-12.4" href="#section-12.4">12.4</a>. enclose capability</span>
842
843 To: [email protected]
844 Subject: Registration of new Sieve extension
845
846 Capability name: enclose
847 Description: adds the "enclose" action for enclosing a message with a
848 wrapper.
849
850 RFC number: <a href="./rfc5703">RFC 5703</a>
851 Contact address: The Sieve discussion list
852 &lt;[email protected]&gt;.
853
854 <span class="h3"><a class="selflink" id="section-12.5" href="#section-12.5">12.5</a>. extracttext capability</span>
855
856 To: [email protected]
857 Subject: Registration of new Sieve extension
858
859 Capability name: extracttext
860 Description: adds the "extracttext" action for extracting text from a
861
862 MIME body part.
863
864 RFC number: <a href="./rfc5703">RFC 5703</a>
865 Contact address: The Sieve discussion list
866 &lt;[email protected]&gt;.
867
868 <span class="h2"><a class="selflink" id="section-13" href="#section-13">13</a>. References</span>
869
870 <span class="h3"><a class="selflink" id="section-13.1" href="#section-13.1">13.1</a>. Normative References</span>
871
872 [<a id="ref-RFC2045">RFC2045</a>] Freed, N. and N. Borenstein, "Multipurpose Internet Mail
873 Extensions (MIME) Part One: Format of Internet Message
874 Bodies", <a href="./rfc2045">RFC 2045</a>, November 1996.
875
876 [<a id="ref-RFC2047">RFC2047</a>] Moore, K., "MIME (Multipurpose Internet Mail Extensions)
877 Part Three: Message Header Extensions for Non-ASCII Text",
878 <a href="./rfc2047">RFC 2047</a>, November 1996.
879
880 [<a id="ref-RFC2119">RFC2119</a>] Bradner, S., "Key words for use in RFCs to Indicate
881 Requirement Levels", <a href="https://www.rfc-editor.org/bcp/bcp14">BCP 14</a>, <a href="./rfc2119">RFC 2119</a>, March 1997.
882
883 [<a id="ref-RFC2231">RFC2231</a>] Freed, N. and K. Moore, "MIME Parameter Value and Encoded
884 Word Extensions:
885 Character Sets, Languages, and Continuations", <a href="./rfc2231">RFC 2231</a>,
886 November 1997.
887
888
889
890
891
892 <span class="grey">Hansen &amp; Daboo Standards Track [Page 16]</span></pre>
893 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-17" ></span>
894 <span class="grey"><a href="./rfc5703">RFC 5703</a> Sieve MIME Operations October 2009</span>
895
896
897 [<a id="ref-RFC3629">RFC3629</a>] Yergeau, F., "UTF-8, a transformation format of ISO
898 10646", STD 63, <a href="./rfc3629">RFC 3629</a>, November 2003.
899
900 [<a id="ref-RFC5173">RFC5173</a>] Degener, J. and P. Guenther, "Sieve Email Filtering: Body
901 Extension", <a href="./rfc5173">RFC 5173</a>, April 2008.
902
903 [<a id="ref-RFC5228">RFC5228</a>] Guenther, P. and T. Showalter, "Sieve: An Email Filtering
904 Language", <a href="./rfc5228">RFC 5228</a>, January 2008.
905
906 [<a id="ref-RFC5229">RFC5229</a>] Homme, K., "Sieve Email Filtering: Variables Extension",
907 <a href="./rfc5229">RFC 5229</a>, January 2008.
908
909 [<a id="ref-RFC5231">RFC5231</a>] Segmuller, W. and B. Leiba, "Sieve Email Filtering:
910 Relational Extension", <a href="./rfc5231">RFC 5231</a>, January 2008.
911
912 [<a id="ref-RFC5293">RFC5293</a>] Degener, J. and P. Guenther, "Sieve Email Filtering:
913 Editheader Extension", <a href="./rfc5293">RFC 5293</a>, August 2008.
914
915 [<a id="ref-RFC5322">RFC5322</a>] Resnick, P., Ed., "Internet Message Format", <a href="./rfc5322">RFC 5322</a>,
916 October 2008.
917
918 <span class="h3"><a class="selflink" id="section-13.2" href="#section-13.2">13.2</a>. Informative References</span>
919
920 [<a id="ref-RFC1991">RFC1991</a>] Atkins, D., Stallings, W., and P. Zimmermann, "PGP Message
921 Exchange Formats", <a href="./rfc1991">RFC 1991</a>, August 1996.
922
923 [<a id="ref-RFC3851">RFC3851</a>] Ramsdell, B., "Secure/Multipurpose Internet Mail
924 Extensions (S/MIME) Version 3.1 Message Specification",
925 <a href="./rfc3851">RFC 3851</a>, July 2004.
926
927 [<a id="ref-RFC4871">RFC4871</a>] Allman, E., Callas, J., Delany, M., Libbey, M., Fenton,
928 J., and M. Thomas, "DomainKeys Identified Mail (DKIM)
929 Signatures", <a href="./rfc4871">RFC 4871</a>, May 2007.
930
931 [<a id="ref-RFC4880">RFC4880</a>] Callas, J., Donnerhacke, L., Finney, H., Shaw, D., and R.
932 Thayer, "OpenPGP Message Format", <a href="./rfc4880">RFC 4880</a>, November 2007.
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948 <span class="grey">Hansen &amp; Daboo Standards Track [Page 17]</span></pre>
949 <hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-18" ></span>
950 <span class="grey"><a href="./rfc5703">RFC 5703</a> Sieve MIME Operations October 2009</span>
951
952
953 Authors' Addresses
954
955 Tony Hansen
956 AT&amp;T Laboratories
957 200 Laurel Ave.
958 Middletown, NJ 07748
959 USA
960
961 EMail: [email protected]
962
963
964 Cyrus Daboo
965 Apple Inc.
966 1 Infinite Loop
967 Cupertino, CA 95014
968 USA
969
970 EMail: [email protected]
971 URI: <a href="http://www.apple.com/">http://www.apple.com/</a>
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004 Hansen &amp; Daboo Standards Track [Page 18]
1005 </pre>