Enable Sieve for Dovecot and Procmail

This documentation worked well, and does not interfere or otherwise modify anything Virtualmin related except a few configuration files and adding the dovecot-sieve and dovecot-managesieved components to the server. I have followed these instructions (and while my documenting skills leave somewhat to be desired) and updated them as I found changes that needed to be made. This was taken from:
http://blog.lorenzbausch.de/2013/07/15/virtualmin-enable-sieve-for-dovec...
and I am posting it here without Lorenz' permission, but hopefully he does not mind. If you have any questions please let me know.

I think it would be something worth adding to the documentation for those that are interested.

***********************************************************************************

Virtualmin: Enable Sieve for Dovecot and Procmail
by Lorenz Bausch Posted on July 15, 2013 with modifications by Joel Mitchell added October 7, 2015.
http://blog.lorenzbausch.de/2013/07/15/virtualmin-enable-sieve-for-dovec...

I was running Dovecot 2.2.9 and was having a problem connecting to the managesieve server because I forgot to open port 4190 in my firewall. As a result, I ended up moving to version 2.2.18 using the ppa https://launchpad.net/~malte.swart/+archive/ubuntu/dovecot-2.2 to update my Ubuntu 14.04 distro which only had direct support for 25.2.9 at the time.

Also note that as of October 7, 2015 the Thunderbird Sieve addon v0.2.2 found at addons.mozilla.org does not work. Get the dev version from the maintainers git repository (I am successfully using 0.2.3h troublefree).

====================================================================
aptitude install dovecot-sieve dovecot-managesieved
====================================================================

/etc/dovecot/conf.d/15-lda.conf

====================================================================
# Address to use when sending rejection mails.
# Default is postmaster@.
postmaster_address = mail@domain.tld

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

/etc/dovecot/conf.d/20-managesieve.conf

====================================================================
service managesieve-login {
inet_listener sieve {
port = 4190
}
}
====================================================================

NOTE: In my conf file, the last bracket was after a bunch of comments, so I missed it and started getting errors about 'plugin' when I tried to apply the configuration in virtualmin. If you get 'plugin' errors, go back to 20-managesieve.conf and make sure that second closing brace is uncommented!

Edit /etc/procmailrc and fill in the DELIVER parts. It’s important to make continued use of procmail because spam filtering is done there.

====================================================================
# cat /etc/procmailrc

DELIVER=/usr/lib/dovecot/deliver
LOGFILE=/var/log/procmail.log
TRAP=/etc/webmin/virtual-server/procmail-logger.pl
:0wi
VIRTUALMIN=|/etc/webmin/virtual-server/lookup-domain.pl $LOGNAME
EXITCODE=$?
:0
* ?/usr/bin/test "$EXITCODE" = "73"
/dev/null
EXITCODE=0
:0
* ?/usr/bin/test "$VIRTUALMIN" != ""
{
INCLUDERC=/etc/webmin/virtual-server/procmail/$VIRTUALMIN
}
DEFAULT=$HOME/Maildir/
ORGMAIL=$HOME/Maildir/
DROPPRIVS=yes
:0 w
| $DELIVER
:0
$DEFAULT
====================================================================

Finally, to actually turn MANAGESIEVE on, you need to enable it in protocols in /etc/dovecot/dovecot.conf

====================================================================
# Protocols we want to be serving: imap imaps pop3 pop3s sieve
# If you only want to use dovecot-auth, you can set this to "none".
#protocols = imap imaps
#protocols = imap pop3 imaps pop3s
protocols = imap sieve
====================================================================

In vurtualmin, go to Webmin->Servers->Dovecot and click on to make sure everything is working.

You may want to enable the possibility to manage filters in Roundcube by editing its main.inc.php:

====================================================================
PHP
// List of active plugins (in plugins/ directory)
$rcmail_config['plugins'] = array('virtuser_file', 'managesieve');
====================================================================

Status: 
Active

Comments

the same on Centos 6.5 won't work.. :-(

In my case: - Managesive service is detected on port 4190 - Roundcube see the service, and save correctly the rules into the user@doman home directory, correctly..

but the filter is not applied.. any idea where to looking for?

Thanks

Note: In centos the equivalent installation command is: # yum install dovecot-pigeonhole

Solved on Centos 6.5 here my working etc/procmailrc just double check the dovecot deliver file path ;-)

DELIVER=/usr/libexec/dovecot/deliver
LOGFILE=/var/log/procmail.log
TRAP=/etc/webmin/virtual-server/procmail-logger.pl
:0wi
VIRTUALMIN=|/etc/webmin/virtual-server/lookup-domain.pl $LOGNAME
EXITCODE=$?
:0
* ?/usr/bin/test "$EXITCODE" = "73"
/dev/null
EXITCODE=0
:0
* ?/usr/bin/test "$VIRTUALMIN" != ""
{
INCLUDERC=/etc/webmin/virtual-server/procmail/$VIRTUALMIN
}
DEFAULT=$HOME/Maildir/
ORGMAIL=$HOME/Maildir/
DROPPRIVS=yes
:0 w
| $DELIVER
:0
$DEFAULT

My filter doesn't work CentOS 6.7, everything is already configured same as above. The DELIVER path also changed to DELIVER=/usr/libexec/dovecot/deliver

Weird, what went wrong? Did i miss some steps.....