Mail filter and rules

You can filter your incoming mails with Sieve. Sieve scripts can be used to automatically delete or forward messages, to send autoreplies, to sort emails into folders as they arrive, to mark messages as read or flagged or to reject messages at or after delivery.

A Sieve script consists of a number of conditions which are applied to incoming mail; if an email matches a test, then the actions associated with that test are performed.


The spamfolder needs to be enabled to use Sieve filtering.


Many E-Mail clients support the ManageSieve protocol to control and manage your Sieve filtering scripts. You can find a list of tools and plugins at We plan to implement a rule editor in our webmailer soon.


We recommend the Sieve Script Editor which has a GUI to drag and drop the rules and is available for many platforms.


Server your Hostname
Port 4190
Username Your email address, including the domain
Password Your password for the email address


You can store as many Sieve scripts as you like but only one can be active at a time. There’s a good Sieve reference online which describes the components which make up a script.


In this example we sort mails from a mailinglist into a folder, sort mails to *@allcolorsarebeautiful.example into another folder and lower the maximum spam score to 4.

require ["fileinto", "reject", "comparator-i;ascii-numeric","relational"];

# Mails with a spam score greater than 4 are probably SPAM, sort them and stop
if header :value "ge" :comparator "i;ascii-numeric" "X-Rspamd-Score" "4"
    fileinto "Spam";

# Sort mails from mailinglist into folder mailinglist
if address :is "from" ["mailinglist@allcolorsarebeautiful.example", "anothermailinglist@allcolorsarebeautiful.example" ]
    fileinto "mailinglist";

# Sort mails to *@allcolorsarebeautiful.example into a special folder
if address :is :domain "to" "allcolorsarebeautiful.example"
    fileinto "important";

# The command "keep" is executed automatically, if no other action is taken.


stop; tells the Sieve engine to stop here, without checking for more rules.

You can find many more examples in the Dovecot Wiki.


If something does not work check the logs at ~/users/$MAILBOX/.dovecot.sieve.log. You can also use Fastmail’s Sieve Tester to test the syntax of scripts and checks what actions a script causes to the provided email message.


Sieve scripts are stored in the corresponding mailbox folder ~/users/$MAILBOX/sieve/. The active script is symlinked from ~/users/$MAILBOX/.dovecot.sieve:

[eliza@dolittle ~/users/anna]$ readlink -f .dovecot.sieve

Dovecot will compile a ~/users/$MAILBOX/.dovecot.svbin from this script for the first mail delivered to the mailbox. It will also recompile for each new mail if the symlink or the script has been changed and the timestamp is updated. You can also trigger this by using sievec /path/to/script.sieve and check if it compiles correctly.


When using ManageSieve the scripts are compiled and validated before they are uploaded and installed by symlinking. This can prevent you from inadvertently installing a broken Sieve script.