Network Working Group S. Bosch Internet-Draft Dovecot Oy Intended status: Standards Track May 16, 2019 Expires: November 17, 2019 Internet Message Access Protocol (IMAP) - FILTER=SIEVE Extension draft-bosch-imap-filter-sieve-00 Abstract This document adds a new capability called "FILTER=SIEVE" to the Internet Message Access Protocol (IMAP). [FIXME] Status of This Memo This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet- Drafts is at https://datatracker.ietf.org/drafts/current/. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." This Internet-Draft will expire on November 17, 2019. Copyright Notice Copyright (c) 2019 IETF Trust and the persons identified as the document authors. All rights reserved. This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) 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 Simplified BSD License. Bosch Expires November 17, 2019 [Page 1] Internet-Draft IMAP - FILTER=SIEVE Extension May 2019 Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 2. Conventions Used in This Document . . . . . . . . . . . . . . 3 3. IMAP Protocol Changes . . . . . . . . . . . . . . . . . . . . 3 3.1. General Considerations . . . . . . . . . . . . . . . . . 3 3.2. FILTER and UID FILTER Commands . . . . . . . . . . . . . 3 3.3. FILTERED Untagged Response . . . . . . . . . . . . . . . 6 3.4. FILTER Untagged Response . . . . . . . . . . . . . . . . 8 4. Semantics of Sieve Actions . . . . . . . . . . . . . . . . . 9 4.1. The "keep" Action . . . . . . . . . . . . . . . . . . . . 9 4.2. The "fileinto" Action . . . . . . . . . . . . . . . . . . 10 4.3. The "redirect" Action . . . . . . . . . . . . . . . . . . 10 4.4. The "discard" Action . . . . . . . . . . . . . . . . . . 10 4.5. The "notify" Action . . . . . . . . . . . . . . . . . . . 11 4.6. The "addheader" and "deleteheader" Actions . . . . . . . 11 4.7. The "setflag", "deleteflag", and "removeflag" Actions . . 11 4.8. MIME Part Tests and Replacement . . . . . . . . . . . . . 11 4.9. The "imapsieve" extension . . . . . . . . . . . . . . . . 11 4.10. Ignored Actions . . . . . . . . . . . . . . . . . . . . . 12 4.11. Future Sieve Actions . . . . . . . . . . . . . . . . . . 12 5. Semantics of Sieve Tests . . . . . . . . . . . . . . . . . . 12 5.1. The "hasflag" Test . . . . . . . . . . . . . . . . . . . 13 5.2. The "spamtest" and "virustest" tests . . . . . . . . . . 13 5.3. The "duplicate" test . . . . . . . . . . . . . . . . . . 13 5.4. Future Sieve Tests . . . . . . . . . . . . . . . . . . . 13 6. Interaction with Sieve Environment . . . . . . . . . . . . . 13 6.1. Base Sieve Environment Items: location and phase . . . . 13 7. Formal Syntax . . . . . . . . . . . . . . . . . . . . . . . . 14 8. Security Considerations . . . . . . . . . . . . . . . . . . . 14 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 15 10. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 15 11. Normative References . . . . . . . . . . . . . . . . . . . . 15 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 17 1. Introduction Currently, Sieve filters [SIEVE] can either be applied at initial mail delivery [SIEVE] or triggered by certain events in the Internet Message Access Protocol (IMAP) [IMAPSIEVE]. The user can configure which Sieve scripts to run at these instances, but it is not possible to trigger the execution of Sieve scripts manually. However, this could be very useful; e.g, to test new Sieve rules and to re-filter messages that were erroneously handled by an earlier version of the Sieve scripts involved. This document extends IMAP [IMAP4rev1] with a new capability called "FILTER=SIEVE". This adds a new generic "FILTER" command that allows Bosch Expires November 17, 2019 [Page 2] Internet-Draft IMAP - FILTER=SIEVE Extension May 2019 applying a mail filter on a set of messages that match the specified searching criteria. Although this command is defined such that it can be extended for use with any (future) mail filter language, this specification only adds support for invoking the "FILTER" command with Sieve filters. 2. Conventions Used in This Document In examples, "C:" indicates lines sent by a client that is connected to a server. "S:" indicates lines sent by the server to the client. 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 [KEYWORDS]. 3. IMAP Protocol Changes 3.1. General Considerations [FIXME] 3.2. FILTER and UID FILTER Commands The FILTER=SIEVE extension adds the FILTER and UID FILTER commands. These allow clients to apply message filters to messages in the selected mailbox that match the given searching criteria. These commands are only available in the selected state [IMAP4rev1]. Arguments: filter specification OPTIONAL [CHARSET] specification searching criteria (one or more) Responses: REQUIRED untagged response: FILTERED Result: OK - filter completed NO - command failure: can't search that [CHARSET] or criteria, or filter failed BAD - command arguments invalid The filter specification describes the filter that is to be applied to all matching messages. It consists of an identifier for the filter type, followed by arguments specific to that filter type. This specification defines only the "SIEVE" filter type, which uses the Sieve Email Filtering Language [SIEVE]. The arguments of this filter are one of the following. Refer to the Formal Syntax section for the precise syntactic definitions of the arguments. Bosch Expires November 17, 2019 [Page 3] Internet-Draft IMAP - FILTER=SIEVE Extension May 2019 DELIVERY The Sieve filtering normally applied at delivery is applied to the matching messages. This allows e.g. re-filtering messages that were handled wrong at actual delivery. This at least means that the "active script" as configured through [MANAGESIEVE] is run for the matching messages. Some installations apply certain Sieve rules in addition to (before or after) the user's active script which are outside the user's control. These MAY also be applied for DELIVERY filtering. PERSONAL The Sieve script with the specified name that is stored in the user's own personal (private) Sieve repository is applied to the matching messages. Implementations that support ManageSieve [MANAGESIEVE] can use the PUTSCRIPT command to store named scripts in the personal repository. This is the same repository from which the Sieve "include" control structure [SIEVE-INCLUDE] retrieves ":personal" scripts. Implementations MUST restrict script names according to [MANAGESIEVE], Section 1.6. GLOBAL The Sieve script with the specified name that is stored in the global (site-wide) Sieve repository is applied to the matching messages. This the same repository from which the Sieve "include" control structure [SIEVE-INCLUDE] retrieves ":global" scripts. Implementations MUST restrict script names according to [MANAGESIEVE], Section 1.6. SCRIPT