<?xml version="1.0"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<rfc ipr="full3978" docName="draft-freed-sieve-environment-02">
<?rfc toc="no" ?>
<?rfc symrefs="yes" ?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<?rfc comments="yes" ?>
	
<front>

<title abbrev="Sieve Environment Extension">
Sieve Email Filtering: 
Environment Extension
</title>
<author initials="N." surname="Freed" fullname="Ned Freed">
<organization>Sun Microsystems</organization>
<address>
<postal>
<street>3401 Centrelake Drive, Suite 410</street>
<city>Ontario</city> <region>CA</region>  <code>92761-1205</code>
<country>USA</country>
</postal>
<phone>+1 909 457 4293</phone>
<email>ned.freed@mrochek.com</email>
</address>
</author>
<date year="2008" />
<area>Applications</area>
<keyword>RFC</keyword>
<keyword>Request for Comments</keyword>
<keyword>SMTP</keyword>
<keyword>ESMTP</keyword>
<keyword>Sieve</keyword>
<keyword>I-D</keyword>
<keyword>Internet-Draft</keyword>

<abstract><t>
This document describes the "environment" extension to the Sieve
email filtering language.  The "environment" extension gives Sieve access to
information about the environment where the Sieve interpreter is running. 
</t></abstract>

<note title='Change History (to be removed prior to publication as an RFC'>
<t>
Changed one place string result from "UA" to "MUA".
</t>
<t>
Updated the IANA registration template.
</t>
<t>
Moved the ihave extension to a separate document.
</t>
<t>
Added remote-host and remote-ip environment items to the initial set.
</t>
<t>
Updated references.
</t>
</note>

</front>

<middle>

<section anchor="intro" title="Introduction">

<t>
Sieve <xref target='RFC5228' /> is a language for filtering email
messages at or around the time of final delivery.  It is designed to be
implementable on either a mail client or mail server. It is suitable for
running on a mail server where users may not be allowed to execute arbitrary
programs, such as on black box Internet Message Access Protocol <xref target="RFC3501" />
servers, as it has no user-controlled loops or the ability to run external
programs.
</t>

<t>
Although sieve is intended to be independent of access protocol, mail
architecture, and operating system, in some cases it is useful to allow
scripts to access information about their execution context.
The "environment" extension provides a new environment test that can
be used to implement scripts that behave differently when moved from
one system to another, when messages arrive from different remote sources
or when otherwise operated in different contexts.
</t>

</section>

<section anchor="conventions" title="Conventions used in this document">

<t>
The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED",  "MAY", and "OPTIONAL" in this
document are to be interpreted as described in
<xref target="RFC2119">BCP 14</xref>.
</t>

<t>
The terms used to describe the various components of the Sieve
language are taken from <xref target='RFC5228' /> section 1.1.
</t>

</section>

<section title='Capability Identifiers'>

<t>
The capability string associated with the extension defined in this
document is "environment".
</t>

</section>

<section anchor="environment" title="Environment Test">

<figure><artwork><![CDATA[
Usage:   environment [COMPARATOR] [MATCH-TYPE]
                     <name: string>
                     <key-list: string-list>
]]></artwork></figure>

<t>
The environment test retrieves the item of environment information
specified by the name string and matches it to the values
specified in the key-list.  The test succeeds if a match occurs. The type of
match defaults to ":is" and the default comparator is "i;ascii-casemap".
</t>

<t>
The current message is not a direct source of information for the environment
test; the item of information specified by the name string is extracted from the
script's operating environment and key-list comes from the script.
</t>

<t>
The environment test MUST fail unconditionally if the specified information 
item does not exist. A script MUST NOT fail with an error if the item does not
exist. This allows scripts to be written that handle nonexistent items
gracefully.
</t>

<t>
The "relational" extension <xref target='RFC5231' /> adds a match
type called ":count".  The count of an environment test is 0 if the environment
information returned is the empty string, or 1 otherwise. 
</t>

<t>
Environment items can be standardized or vendor-defined. An IANA registry
is defined for both types of items.
</t>

<section anchor="standarditems" title="Initial Standard Environment Items">

<t>
The initial set of standardized environment items is as follows:
</t>

<figure><artwork><![CDATA[
 "domain"  => The primary DNS domain associated with the Sieve
              execution context, usually but not always a proper
              suffix of the host name.
 "evaluation-time"
           => Sieve processing is normally performing around or after
              the time of final delivery. This item provides
              additional information about the relationship to final
              delivery. Possible return values are "MTA", meaning the
              Sieve is being evaluated before final delivery, "MDA",
              meaning evaluation is occurring during final delivery",
              and "MUA", meaning evaluation is occurring after final
              delivery.
 "host"    => The fully-qualified domain name of the host where the
              Sieve script is executing.
 "name"    => The product name associated with the Sieve interpreter.
 "remote-host"
           => Host name of remote SMTP client, if applicable and
              available. 
 "remote-ip"
           => IP address of remote SMTP client, if applicable and
              available.
 "version" => The product version associated with the Sieve
              interpreter.
]]></artwork></figure>

<t>
Implementations SHOULD support as many of the items on this initial list as
possible. Additional standardized items can only be defined in standards-track
or experimental RFCs.
</t>

</section>

<section anchor="vendoritems" title="Vendor-defined Environment Items">

<t>
Environment item names beginning with "vnd." represent vendor-defined
extensions.  Such extensions are not defined by Internet standards or
RFCs, but are still registered with IANA in order to prevent
conflicts.  Environment item names starting with "vnd." SHOULD be followed by
the name of the vendor and product, such as "vnd.acme.rocket-sled-status".
</t>

</section>

<section anchor="IANA-env" title="IANA Registration of Environment Items">

<t>
A registry of environment items is
provided by IANA. Item names may be registered on a first-come, first-served
basis.  Extensions designed for interoperable use
SHOULD be defined as standards track or IESG approved experimental
RFCs.
</t>

<section title="Template for Environment Registrations">

<t>
The following template is to be used for registering new Sieve
environment item names with IANA.
</t>

<figure><artwork><![CDATA[
   To: iana@iana.org
   Subject: Registration of new Sieve environment item

   Item name: [the string for use in the 'environment' test]
   Description:     [a brief description of the semantics of the
                     value the item returns]

   RFC number:      [for extensions published as RFCs]
   Contact address: [email and/or physical address to contact for
                     additional information]
]]></artwork></figure>

<t>
Multiple items and descripions MAY be specified in a single registration
request. Both standardized and vender-defined items use this form.
</t>

</section>

</section>

</section>


<section anchor="security" title="Security Considerations">

<t>
The environment extension may be used to obtain information about the system
the sieve implementation is running on. This information in turn may reveal
details about service provider or enterprise infrastructure.
</t>

<t>
All of the security considerations given in the base Sieve
specification also apply to this extension. 
</t>

</section>

<section anchor="IANA" title="IANA Considerations">

<figure>
<preamble>
The following template specifies the IANA registration of the Sieve
extension specified in this document:
</preamble>
<artwork>
   To: iana@iana.org
   Subject: Registration of new Sieve extension

   Capability name: environment
   Description:     The "environment" extension provides a new
                    environment test that can be used to implement
                    scripts that behave differently when moved
                    from one system to another or otherwise
                    operated in different contexts.
   RFC number:      RFC &rfc.number;
   Contact address: Sieve discussion list &lt;ietf-mta-filters@imc.org&gt;
</artwork>
</figure>

<t>
This specification also defines a new IANA registry for Sieve environment item names.
The specifics of this registry are given in <xref target="IANA-env" />. The initial
contents of the registry are given in the following section.
</t>

<section title="Initial Environment Item Registrations">

<figure>
<preamble>
The following template specifies the initial IANA registrations for the
environment items defined in this document:
</preamble>
<artwork>
   To: iana@iana.org
   Subject: Registration of new Sieve environment items

   Capability name: domain
   Description:     The primary DNS domain associated with the Sieve
                    execution context, usually but not always a
                    proper suffix of the host name.

   Capability name: evaluation-time
   Description:     Time at which this Sieve processing is being
                    performed.

   Capability name: host
   Description:     The fully-qualified domain name of the host
                    where the Sieve script is executing.

   Capability name: name
   Description:     The product name associated with the Sieve
                    interpreter.

   Capability name: remote-host
   Description:     Host name of remote SMTP client, if applicable
                    and available. 

   Capability name: remote-ip
   Description:     IP address of remote SMTP client, if applicable
                    and available.

   Capability name: version
   Description:     The product version associated with the Sieve
                    interpreter.

   RFC number:      RFC &rfc.number;
   Contact address: Sieve discussion list &lt;ietf-mta-filters@imc.org&gt;
</artwork>
</figure>

</section>

</section>

</middle>

<back>

<references title="Normative references">

<?rfc include="reference.RFC.2119" ?>
<?rfc include="reference.RFC.5228" ?>
<?rfc include="reference.RFC.5231" ?>

</references>

<references title="Informative references">

<?rfc include="reference.RFC.3501" ?>

</references>

</back>

</rfc>
