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