Skip to content
Snippets Groups Projects
README 7.97 KiB
Newer Older
Sieve implementation for Dovecot v1.2
Stephan Bosch's avatar
Stephan Bosch committed
(NOTE: This is the UNSTABLE development branch)
Introduction
------------

Stephan Bosch's avatar
Stephan Bosch committed
Sieve is a machine language specifically tailored for internet message 
filtering. This package compiles into a Sieve plugin for the Dovecot local 
delivery agent called Deliver. The plugin adds Sieve filtering support to the 
delivery process.  

Previously, the same functionality was provided by the cmusieve plugin for 
Dovecot. This old plugin is based on the CMU Sieve implementation included with
the Cyrus project. This new package provides a complete rewrite of the Sieve 
engine integrating it tightly with Dovecot. The actual execution of the Sieve 
actions is based on the original cmusieve plugin, but only on the code added to 
Stephan Bosch's avatar
Stephan Bosch committed
interface the CMU Sieve implementation with Dovocot. 

The main reason for rewriting the Sieve engine is to provide more reliable 
script execution and to provide better error messages to users and system 
Stephan Bosch's avatar
Stephan Bosch committed
administrators. Also, since the Sieve language evolves quickly, with new 
language extensions published every year, the aim is to provide support for 
quickly extending the engine with new features. 
Stephan Bosch's avatar
Stephan Bosch committed
Features
--------

Stephan Bosch's avatar
Stephan Bosch committed
* Well-structured 3-stage compiler:
 
  Uses dovecot framework and avoids using lex/yacc. Compiler doesn't bail on 
  first error, but tries to find more. Produced errors are aimed to be useful 
  and generally user-comprehensible. Things like 'Generic error' are a nuisance 
  of the past. 

* Highly extendable with new sieve capabilities: 

  This keeps the possibility of plugins in mind. It should eventually provide 
  the necessary infrastructure for at least all currently known (proposed) 
  extensions. The goal is to keep the extension interface provided by sieve 
  engine as generic as possible, i.e. without explicit support for specific 
  extensions. New similar extensions can then use the same interface methods 
  without changes to the sieve engine code. If an extension is not loaded using 
  the require command, the compiler truly does not know of its existance. 

* Supports almost all extensions provided by the original CMUSieve plugin:
 
  Currently only the notify extension is missing. In addition, it has support 
  for the new and very useful variables extension (see next section).

* Supported by ManageSieve service:

  This Sieve implementation is supported by the ManageSieve implementation for 
  Dovecot v1.2. Therefore, ManageSieve support can be added to Dovecot for the
  new Sieve plugin just as for the cmusieve plugin.

* Testsuite included:
	
	This package includes a testsuite to automatically asses whether the compiled 
  sieve engine works correctly. The testsuite is an extension to the Sieve 
  language and is therefore easily extended with new tests. Currently, the 
  testsuite is limited to testing script processing. The performed actions are 
  not tested automatically yet. 
Stephan Bosch's avatar
Stephan Bosch committed

Implementation Status
---------------------

The the core of the language (as specified in RFC 5228) is fully supported. In 
addition to that, this Sieve implementation features various extensions. The 
following list outlines the implementation status of each supported extension:
Stephan Bosch's avatar
Stephan Bosch committed
	
  Base specification (RFC5228):
    fileinto: full
    reject: full (without Dovecot LMTP currently no refuse support)
Stephan Bosch's avatar
Stephan Bosch committed
    envelope: full
    encoded-character: full

  Other RFCs/drafts:
    subaddress: mostly full; not configurable
    comparator-i;ascii-numeric: full
    relational: full 
    copy: full
    regex: mostly full; but suboptimal and no UTF-8
Stephan Bosch's avatar
Stephan Bosch committed
    body: mostly full, but text body-transform implementation is simple
Stephan Bosch's avatar
Stephan Bosch committed
          and some issues make it still not RFC incompliant. 
Stephan Bosch's avatar
Stephan Bosch committed
    include: mostly full; needs some more work (no external binaries)
Stephan Bosch's avatar
Stephan Bosch committed
    vacation: mostly full; no support for required References header and
Stephan Bosch's avatar
Stephan Bosch committed
          and handling of utf-8 in headers is non-existant
Stephan Bosch's avatar
Stephan Bosch committed
    imapflags: full
    variables: mostly full; currently no support for future namespaces 

All implemented extensions are like the engine itself currently experimental. 
A status of 'full' does not necessarily mean that the extension is bug-free or 
even fully RFC-compliant.
 
Many more extensions to the language exist. Not all of these extensions are 
useful for Dovecot in particular, but many of them are. Currently, the author 
has taken notice of the following extensions:

Stephan Bosch's avatar
Stephan Bosch committed
    notify: planned, first mailto only 
Stephan Bosch's avatar
Stephan Bosch committed
    environment: planned
    date,index: planned
Stephan Bosch's avatar
Stephan Bosch committed
    editheader: planned, needs additional support from Dovecot though.
    mimeloop: planned

These extensions will be added as soon as the necessary infrastructure is 
available. Extensions already supported by cmusieve have priority, meaning that 
notify is next in line.
Compiling and Configuring
-------------------------
The main purpose of this package is to replace the existing cmusieve plugin that 
Stephan Bosch's avatar
Stephan Bosch committed
is currently available for Dovecot's deliver. With this respect it is currently 
not very different from the cmusieve plugin implementation. 
Stephan Bosch's avatar
Stephan Bosch committed
Unlike cmusieve, this sieve module logs runtime errors to <scriptfile>.log if 
it can and not <scriptfile>.err. It appends new timestamped log entries to the 
end of the logfile. If the log grows too large (currently > 10kB), the logfile 
is rotated to <scriptfile>.log.0 and <scriptfile>.log starts out empty again. 
The cmusieve plugin compiled the script into a file with an appended c, e.g. 
'test.sievec'. This new implementation recognizes scripts to have the .sieve 
extension. The binary is (by default) written to a file with extension .svbin. 
This means that the default .dovecot.sieve is compiled into .dovecot.svbin. 
Included scripts are currently always compiled into the main binary, meaning 
that no other files are written and no permission to do so is necessary for the 
global script directories. 

To test the sieve engine outside deliver it is useful to execute the binaries 
that exist in the src/sieve-bin/ directory of this package. After installation, 
these scripts are available in the dovecot lib directory. The following commands
are available:
Stephan Bosch's avatar
Stephan Bosch committed
sievec [-d] <sieve-file> <out-file>
Stephan Bosch's avatar
Stephan Bosch committed
Compiles the script and produces a sieve binary. However, when the -d option is
Stephan Bosch's avatar
Stephan Bosch committed
provided, a code dump is written to the output file. When the output file is '-'
Stephan Bosch's avatar
Stephan Bosch committed
the dump output is written to stdout (only if -d is specified). 

--

sieved <bin-file> [<dump-file>]

Reads a sieve binary and produces a code dump. The optional dump-file parameter
provides the means to specify a file to which the dump is to be written. 
Otherwise, the dump is printed to stdout. 
Stephan Bosch's avatar
Stephan Bosch committed
sieve-test [-r <recipient address>][-s <envelope sender>]
Stephan Bosch's avatar
Stephan Bosch committed
           [-m <mailbox>][-d <dump filename>][-c][-t] <scriptfile> <mailfile>
Reads mail message from the specified mailfile and executes the specified sieve 
script to produce a verdict. This prints a list of actions that would 
have been performed on this message.
Stephan Bosch's avatar
Stephan Bosch committed

Options:
  -r  envelope recipient address
  -s  envelope sender
  -m  the mailbox where the keep action should store
  -d  causes a dump of the generated code to be written to the specified
      file. Using - as filename causes the dump to be written to stdout
  -c  force compilation (ignore any existing binary)
  -t  enable trace simple debugging; prints all encountered byte code
      instructions on stdout. 
Currently undocumented (will be merged with sieve-test).
Various example scripts are bundled in the directory 'examples'. 
Known issues
------------

Most open issues are outlined in the TODO file. The more generic ones are (re-)
listed here:

- Compile errors are sometimes a bit obscure and long. This needs work. 
  Suggestions for improvement are welcome. 

Stephan Bosch's avatar
Stephan Bosch committed
Authors
-------

Refer to AUTHORS file.

Contact Info
------------

Stephan Bosch <stephan at rename-it dot nl>
IRC: Freenode, #dovecot, S[r]us
Please use the Dovecot mailing list <dovecot at dovecot.org> for questions about 
this package. You can post to the list without subscribing, the mail then waits 
in a moderator queue for a while. See http://dovecot.org/mailinglists.html

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.