Trying to replace anti spam plugin with IMAPSieve; no joy

Aki Tuomi aki.tuomi at open-xchange.com
Wed Nov 6 14:10:29 EET 2019


On 5.11.2019 18.50, Brad Koehn via dovecot wrote:
> I’m trying to follow the instructions on the wiki to move from antispam to IMAPSieve, but it’s not working at all. A bit of a background:
>
> dovecot-core              2:2.3.8-4~buster
> dovecot-imapd             2:2.3.8-4~buster
> dovecot-lmtpd             2:2.3.8-4~buster
> dovecot-managesieved      2:2.3.8-4~buster
> dovecot-pgsql             2:2.3.8-4~buster
> dovecot-pop3d             2:2.3.8-4~buster
> dovecot-sieve             2:2.3.8-4~buster
> dovecot-solr              2:2.3.8-4~buster
>
> My regular sieve scripts work fine for messages arriving through LMTP. I’ve updated my 20-imap.conf thusly:
>
> ##
> ## IMAP specific settings
> ##
>
> protocol imap {
>   mail_max_userip_connections = 30
>
>   # Space separated list of plugins to load (default is global mail_plugins).
>   mail_plugins = $mail_plugins imap_acl imap_sieve
> }
>
> plugin {
>   sieve_plugins = sieve_imapsieve sieve_extprograms
>
>   sieve_trace_dir = /tmp
>   sieve_trace_level = matching
>
>   # From elsewhere to Spam folder
>   imapsieve_mailbox1_name = Spam
>   imapsieve_mailbox1_causes = COPY
>   imapsieve_mailbox1_before = file:/usr/lib/dovecot/sieve/report-spam.sieve
>
>   # From Spam folder to elsewhere
>   imapsieve_mailbox2_name = *
>   imapsieve_mailbox2_from = Spam
>   imapsieve_mailbox2_causes = COPY
>   imapsieve_mailbox2_before = file:/usr/lib/dovecot/sieve/report-ham.sieve
>
>   sieve_pipe_bin_dir = /usr/lib/dovecot/sieve
>
>   sieve_global_extensions = +vnd.dovecot.pipe +vnd.dovecot.environment
> }
>
> ========
>
> I created the report-spam.sieve and report-ham.sieve scripts in /usr/lib/dovecot/sieve and compiled them with sievec:
>
> require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"];
>
> if environment :matches "imap.mailbox" "*" {
>   set "mailbox" "${1}";
> }
>
> if string "${mailbox}" "Trash" {
>   stop;
> }
>
> pipe :copy "sa-learn-pipe.sh" [ "ham" ];
>
> ========
>
> require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"];
>
> pipe :copy "sa-learn-pipe.sh" [ "spam" ];
>
> ========
>
> Lastly, I have the sa-learn-pipe.sh script in /usr/lib/dovecot/sieve:
>
> #!/bin/bash
>
> echo "`date` learning $*" >> /tmp/sa-learn
>
> # We run amavisd-new on another Kubernetes pod and communicate with it via socat on both ends; this worked with the old antispam plugin.
>
> if [ "$*" = "ham" ] ; then
>   socat - TCP:amavis:4443
> else
>   socat - TCP:amavis:4444
> fi
>
> exit 0
>
> ========
>
> The /usr/lib/dovecot/sieve directory looks like this:
> drwxr-xr-x 1 root root 4096 Nov  4 20:49 .
> drwxr-xr-x 1 root root 4096 Nov  3 20:06 ..
> -rwxr-xr-x 1 root root  237 Nov  3 15:56 report-ham.sieve
> -rw-r--r-- 1 root root  384 Nov  4 20:49 report-ham.svbin
> -rwxr-xr-x 1 root root  122 Nov  3 15:56 report-spam.sieve
> -rw-r--r-- 1 root root  290 Nov  4 20:49 report-spam.svbin
> -rwxr-xr-x 1 root root  208 Nov  3 17:58 sa-learn-pipe.sh
>
> When the sieve scripts run when mail arrives during LMTP delivery they dutifully log their work in /tmp, so I know sieve works and sieve logging works too. The sieve scripts above never log anything, nor does /tmp/sa-learn ever get created as it would if sa-learn-pipe.sh were ever run. As far as I can tell I’ve duplicated the configuration from the wiki almost exactly, but dovecot is just not running the sieve scripts when messages are moved into/out of Junk. 
>
> What am I missing?

IMAPSieve only works when you MOVE/COPY mail over IMAP connection. It
does not affect LMTP delivery.

Try enabling 'mail_debug=yes' to see why it does not work.

Aki



More information about the dovecot mailing list