Based on Debian 11 "Bullseye" environment.

Dovecot Sieve

Sieve is a script to control how emails should be handled. For example, delivering to the specific directory according to the headers.
This function is integrated into Dovecot as "Pigeonhole project" but the package name is dovecot-sieve in Debian.

Install

# apt install dovecot-managesieved
  • "dovecot-managesieved" enables users to manage their own sieve scripts without ssh connection. Users can use sieve editors on their own PC and access to their own scripts even if they are virtual users. The port 4190 is used for this service.
  • "dovecot-sieve" is the sieve plugin for Dovecot LMTP.

Open the port.

# firewall-cmd --add-service=managesieve --permanent
# firewall-cmd --reload

Configure

Enable sieve plugin for Dovecot LMTP. Add "sieve" to /etc/dovecot/conf.d/20-lmtp.conf mail plugins.

protocol lmtp {
  # Space separated list of plugins to load (default is global mail_plugins).
  mail_plugins = $mail_plugins sieve
}

Reload dovecot to enable the sieve plugin.

# systemctl reload dovecot

Manage Sieve Scripts

Edit scripts

There is a standalone Sieve Editor. If you use Roundcube as a mailer, it can manage sieve scripts with the built-in plugin.
* If you use the sieve editor, make a sieve script and "activate" it to apply that rule.
Sieve script examples are available as follows.

Notice for sdbox

The directory structure between Maildir and sdbox (Dovecot original style) is slightly different.
For example, "folder01" under INOBX.

Maildir style

require "fileinto";
if header :contains ["from"] "folder01@example.com" {
  fileinto "INBOX.folder01";
}

sdbox style

require "fileinto";
if header :contains ["from"] "folder@example.com" {
  fileinto "INBOX/folder01";
}

Maildir uses the period for the folder delimiter, but sdbox makes actual subdirectories same as mail folder structure.


Update History

2021-09-20

  • Update to Bullseye version