This document explains how to use the Sieve mailfiltering language with the Exim MTA and the Avelsieve Squirrelmail Plugin. It's based on the software versions found in the Debian Etch(4.0) release unless mentioned otherwise.
Sieve
Sieve is a language for email-filtering. It's usually implemented within IMAP servers such as Cyrus. Recent Exim versions contain an implementation of the Sieve language in addition to it's native filtering language. This allows to use sieve scripts for messages filtering with IMAP servers not supporting it directly. This howto deals with Courier, but other servers should work fine as well.
Exim
To enable sieve filtering you need to setup a separate router for it. It checks for a sieve script stored in squirrelmail's data folder, owned by the user the webserver (and therefore squirrelmail) runs as. The reply_transport is needed for vacation messages that can be sent from sieve scripts.
begin routers
...
sieve:
debug_print = "R: sieve for $local_part@$domain"
driver = redirect
check_local_user
file = /var/lib/squirrelmail/data/$local_part.sievesource
sieve_vacation_directory=$home/.sieve_vacation_db
no_verify
no_expn
check_ancestor
owners = www-data
owngroups = www-data
pipe_transport = address_pipe
reply_transport = address_reply
file_transport = sieve_transport
allow_filter = true
...
The sieve router is only a redirect router, so a transport is needed, to file the messages in the folder determined by the sieve script execution by the router. This transport stores messages in the home directory in maildir format. The sg statement cuts of the INBOX prefix added by avelsieve. It might not be needed with IMAP servers other than Courier.
begin transports
...
sieve_transport:
debug_print = "T: maildir_transport for $local_part@$domain"
driver = appendfile
directory = /home/$local_part/Maildir/${sg {$address_file} {^(INBOX|inbox)} {}}
delivery_date_add
envelope_to_add
return_path_add
maildir_format = true
...
Avelsieve
Avelsieve is a plugin for the Squirrelmail webmail system that provides a nice frontend to easily edit filter rules without requiring any knowledge of sieve. This bazaar branch (tarball) contains some fixes to make it work with exim's sieve implementation, because it slightly diverges from the sieve specification. It also contains some unrelated bugfixes. Unfortunately the author of avelsieve has not merged this fixes into the official version yet.
This shows the relevant options in the avelsieve configuration file which is well documented:
$avelsieve_backend = 'File';
...
$avelsieve_file_backend_options = array(
'avelsieve_default_file' => "$data_dir/%u.sievesource"
);
...
$avelsieve_custom_sieve_implementation = 'exim';
Feel free to mail any corrections or feedback to: david@dfoerster.de
$Date: 2008-02-08 16:02:12 +0100 (Fr, 08 Feb 2008) $
