This article covers:
We are using dovecot pigeonhole project for sieve support.
apt-get install dovecot-sieve dovecot-managesieved
Please note that, installing sieve without spamassassin won’t filter spam messages automatically.
vim /etc/dovecot/conf.d/20-lmtp.conf
Add following:
protocol lmtp {
postmaster_address = admin@example.com
mail_plugins = $mail_plugins sieve
}
vim /etc/dovecot/conf.d/90-sieve.conf
Add following:
plugin {
sieve = ~/.dovecot.sieve
sieve_global_path = /var/lib/dovecot/sieve/default.sieve
sieve_dir = ~/sieve
sieve_global_dir = /var/lib/dovecot/sieve/
}
Restart dovecot for changes to take effect:
service dovecot restart
You can see managesieve service running on port number 4190 by using telnet command:
telnet example.com 4190
Will output something like:
Trying 162.243.12.140...
Connected to test3.rtcamp.com.
Escape character is '^]'.
"IMPLEMENTATION" "Dovecot Pigeonhole"
"SIEVE" "fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date ihave"
"NOTIFY" "mailto"
"SASL" "PLAIN LOGIN"
"STARTTLS"
"VERSION" "1.0"
OK "Dovecot ready."
You can find sieve commands here which you can run inside telnet shell to manage sieve filters. Or you can use following method to manipulate global sieve rules directly.
You can use sieve to implement/enforce server-wise rules/organization policies.
mkdir /var/lib/dovecot/sieve/
Then create/open global sieve rules files:
vim /var/lib/dovecot/sieve/default.sieve
Following example rules moves spam emails from Inbox to Junk folder automatically. X-Spam-Flag
is added by spamassassin and amavis.
require "fileinto";
if header :contains "X-Spam-Flag" "YES" {
fileinto "Junk";
}
Change Ownership:
chown -R vmail:vmail /var/lib/dovecot
Compile sieve rules:
sievec /var/lib/dovecot/sieve/default.sieve
At this point you have sieve interpreter and managesieve service running.
Roundcube has 2 plugins for sieve:managesieve
andsieverules
.
Both provides similar functionality but I like support for extended mail-headers in UI provided by sieverules. So we will be using sieverules plugin.
Open
vim /etc/roundcube/main.inc.php
Add sieverules
to list of roundcube plugins
$rcmail_config['plugins'] = array('sieverules');
Open
vim /etc/roundcube/plugins/sieverules/config.inc.php
Add/Update following line:
$rcmail_config['sieverules_port'] = 4190;
If you are using spamassasin, you can test global filters using this spam testing guide.
Comments