Subscribe to the RSS Feed


Sieve, Dovecot LDA, Roundcube howto

Sieve is a standardized e-mail filtering language with many extensions. Its goal is to provide a small flexible framework for various server/client based implementations.
One of the best implementations is the Dovecot Sieve plugin, implemented as a Dovecot LDA (Local Delivery Agent) plugin.
To get global filtering and per user filtering enabled, you have to create an entry into the plugins sections similar to this:



Don’t get confused: there is a sieve_global_* directive as well, but such rules are only executed when the user doesn’t have any rules set in their file.

This way global.rules is always executed before the user’s sieve rules, so you can force SPAM delivery to the Junk folder for every user.
Sieve rules are not run as text-file. At first use the rule files are interpreted and a binary is created with the .svbin extension. Since we have been using per user (UID) delivery we ran into some problems with permissions in the global rule directory. To overcome this you can manually compile the sieve file as for example root, as long as the users will be able to read the .svbin file:

The sievec command accepts two arguments: the script-file argument specifies the script to be compiled and the out-file argument specifies where the (binary) output is to be written. This Sieve implementation reconizes files with a .sieve extension as Sieve scripts and corre- sponding files with a .svbin extension as the associated compiled binary. This means for example that Dovecot’s deliver process will look for a binary file ‘dovecot.svbin’ when it needs to execute ‘dove- cot.sieve’. Such filename is chosen automatically for the binary output when the out-file argument is missing.

To enable the plugin place sieve into mail_plugins:
protocol lda { .. # Support for dynamically loadable plugins. mail_plugins is a space separated # list of plugins to load. mail_plugins = sieve # ... other plugins like quota }

Ok but how should I get the users to write an upload sieve files on their own?
You don’t.

Managesieve is a service for remote management of sieve rules installed on a mail-server. Users logging in with their e-mail accounts are able to install/change/delete rules on their own. Sieve rules are checked and compiled before upload, preventing the user to broke their delivery system.

Managesieve implementation of Dovecot let’s you to get Managesieve listen on a TCP port, so by choosing a port only available locally you can have your webmail application communicating with your sever exclusively.

Lucky for you, there is a Managesieve plugin for Roundcube which allows your users to manage their rules through a Web UI without ever knowing the protocol or the technology behind the scenes.

Initial configuration is easy. In edit the host and port to connect to:
// managesieve server address $sieverules_config['managesieve_host'] = 'localhost';

// managesieve server port $sieverules_config['managesieve_port'] = 13000;

And the result of your hard work:

Posted 2009/11/22 14:57 by jos


Leave a Comment

Add your comment. Preview then Submit.


Textile Help