Hi,
Using https://wiki.dovecot.org/HowTo/AntispamWithSieve I'm trying to execute scripts when moving to/from Spam folder, however nothing's happening. The actions are:
- Move to Spam: redirect :copy "spamcop_spam@domain.local";
- Move from Spam: redirect :copy "spamcop_ham@domain.local";
Here's the configuration I'm working with: doveconf: Warning: service anvil { client_limit=1000 } is lower than required under max. load (1153) # Pigeonhole version 0.4.16 (fed8554) # OS: Linux 4.14.80-6.el7xen.x86_64 x86_64 CentOS Linux release 7.5.1804 (Core) ext4 auth_mechanisms = plain login digest-md5 cram-md5 apop auth_username_chars = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890&.-_@' disable_plaintext_auth = no first_valid_uid = 30 imap_client_workarounds = delay-newmail imap_logout_format = rcvd=%i, sent=%o mail_attribute_dict = file:/var/qmail/mailnames/%Ld/dovecot-attributes mail_fsync = never mail_home = /var/qmail/mailnames/%Ld/%Ln mail_location = maildir:/var/qmail/mailnames/%Ld/%Ln/Maildir mail_log_prefix = "service=%s, user=%u, ip=[%r]. " mail_max_userip_connections = 100 mail_plugins = " quota" mailbox_list_index = yes maildir_very_dirty_syncs = yes managesieve_logout_format = rcvd=%i, sent=%o managesieve_notify_capability = mailto managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date index ihave duplicate mime foreverypart extracttext imapflags notify imapsieve mmap_disable = yes namespace { hidden = no list = children location = maildir:/var/qmail/mailnames/%Ld/%%Ln/Maildir:INDEXPVT=/var/qmail/mailnames/%Ld/%Ln/user/%%u/Maildir prefix = Other Users.%%n. separator = . subscriptions = no type = shared } namespace { list = children location = maildir:/var/qmail/mailnames/%Ld/public/Maildir:INDEXPVT=/var/qmail/mailnames/%Ld/%Ln/public/Maildir prefix = Public. separator = . subscriptions = no type = public } namespace inbox { inbox = yes location = mailbox Archives { auto = subscribe special_use = \Archive } mailbox Drafts { auto = subscribe special_use = \Drafts } mailbox Sent { auto = subscribe special_use = \Sent } mailbox Spam { auto = subscribe autoexpunge = 90 days special_use = \Junk } mailbox Templates { auto = subscribe } mailbox Trash { auto = subscribe special_use = \Trash } prefix = INBOX. separator = . type = private } passdb { driver = plesk } plugin { acl = vfile acl_shared_dict = file:/var/qmail/mailnames/%Ld/shared-mailboxes imapsieve_mailbox1_before = file:/usr/lib64/dovecot/sieve/report-spam.sieve imapsieve_mailbox1_causes = COPY imapsieve_mailbox1_name = Spam imapsieve_mailbox2_before = file:/usr/lib64/dovecot/sieve/report-ham.sieve imapsieve_mailbox2_causes = COPY imapsieve_mailbox2_from = Spam imapsieve_mailbox2_name = * quota = maildir:User quota quota_grace = 0 quota_warning = storage=95%% quota-warning 95 %u quota_warning2 = storage=99%% quota-warning 99 %u sieve = ~/.dovecot.sieve sieve_after = /etc/dovecot/sieve/after sieve_dir = ~/sieve sieve_extensions = +notify +imapflags sieve_global_extensions = +vnd.dovecot.pipe +vnd.dovecot.environment sieve_pipe_bin_dir = /usr/lib64/dovecot/sieve sieve_plugins = sieve_imapsieve sieve_extprograms } pop3_client_workarounds = outlook-no-nuls oe-ns-eoh pop3_logout_format = rcvd=%i, sent=%o, top=%t/%p, retr=%r/%b, del=%d/%m, size=%s protocols = imap pop3 sieve service auth-worker { group = user = } service auth { group = unix_listener auth-userdb { group = popuser mode = 0600 user = popuser } user = } service imap-login { process_limit = 850 service_count = 1 } service imap { process_limit = 700 service_count = 1 } service pop3 { process_limit = 700 service_count = 1 } service quota-warning { executable = script /usr/local/bin/mail-quota-warning.sh group = popuser unix_listener quota-warning { group = popuser user = popuser } user = popuser } ssl_cert =
/usr/lib64/dovecot/sieve/report-spam.sieve contains: require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"]; redirect :copy "spamcop_spam@domain.local"; /usr/lib64/dovecot/sieve/report-ham.sieve contains: require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"]; redirect :copy "spamcop_ham@domain.local";
I must be missing something obvious. Thanks,
-- Adi Pircalabu
On 2018-11-14 13:11, Adi Pircalabu wrote:
Hi,
Using https://wiki.dovecot.org/HowTo/AntispamWithSieve I'm trying to execute scripts when moving to/from Spam folder, however nothing's happening. The actions are:
- Move to Spam: redirect :copy "spamcop_spam@domain.local";
- Move from Spam: redirect :copy "spamcop_ham@domain.local"; [...] /usr/lib64/dovecot/sieve/report-spam.sieve contains: require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"]; redirect :copy "spamcop_spam@domain.local"; /usr/lib64/dovecot/sieve/report-ham.sieve contains: require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"]; redirect :copy "spamcop_ham@domain.local";
More information after enabling mail_debug, in maillog I see:
Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local,
ip=[::1]. Debug: Module loaded:
/usr/libexec/dovecot/modules/lib95_imap_sieve_plugin.so
Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local,
ip=[::1]. Debug: imapsieve: Mail set keywords
Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local,
ip=[::1]. Debug: imapsieve: mailbox INBOX.Spam: FLAG event (changed
flags: Junk)
Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local,
ip=[::1]. Debug: sieve: Pigeonhole version 0.4.16 (fed8554) initializing
Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local,
ip=[::1]. Debug: sieve: include: sieve_global is not set; it is
currently not possible to include :global' scripts. Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: Sieve imapsieve plugin for Pigeonhole version 0.4.16 (fed8554) loaded Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: Sieve Extprograms plugin for Pigeonhole version 0.4.16 (fed8554) loaded Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: Static mailbox rule [1]: mailbox=
Spam'
from=*' causes=(COPY) => before=
file:/usr/lib64/dovecot/sieve/report-spam.sieve' after=(none)
Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local,
ip=[::1]. Debug: imapsieve: Static mailbox rule [2]: mailbox=*' from=
Spam' causes=(COPY) =>
before=file:/usr/lib64/dovecot/sieve/report-ham.sieve' after=(none) Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: Module loaded: /usr/libexec/dovecot/modules/lib95_imap_sieve_plugin.so Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: mailbox INBOX: MOVE event Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: Pigeonhole version 0.4.16 (fed8554) initializing Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: include: sieve_global is not set; it is currently not possible to include
:global' scripts.
Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local,
ip=[::1]. Debug: sieve: Sieve imapsieve plugin for Pigeonhole version
0.4.16 (fed8554) loaded
Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local,
ip=[::1]. Debug: sieve: Sieve Extprograms plugin for Pigeonhole version
0.4.16 (fed8554) loaded
Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local,
ip=[::1]. Debug: imapsieve: Static mailbox rule [1]: mailbox=Spam' from=
*' causes=(COPY) =>
before=file:/usr/lib64/dovecot/sieve/report-spam.sieve' after=(none) Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: Static mailbox rule [2]: mailbox=
*'
from=Spam' causes=(COPY) => before=
file:/usr/lib64/dovecot/sieve/report-ham.sieve' after=(none)
So imapsieve "sees" the configuration, then I went and enabled debugging in the 2 sieve scripts which now read:
- /usr/lib64/dovecot/sieve/report-spam.sieve require ["vnd.dovecot.pipe", "copy", "imapsieve", "vnd.dovecot.debug"]; debug_log "/var/tmp/report-spam.sieve.debug"; redirect :copy "spamcop_spam@domain.local";
- /usr/lib64/dovecot/sieve/report-ham.sieve require ["vnd.dovecot.pipe", "copy", "imapsieve", "vnd.dovecot.debug"]; debug_log "/var/tmp/report-ham.sieve.debug"; redirect :copy "spamcop_ham@domain.local";
Should I expect to see debugging in /var/tmp/report-ham.sieve.debug and /var/tmp/report-spam.sieve.debug, respectively? The 2 files aren't created, nothing in that directory. BTW, getenforce=Disabled.
-- Adi Pircalabu
On 2018-11-14 13:51, Adi Pircalabu wrote:
On 2018-11-14 13:11, Adi Pircalabu wrote:
Hi,
Using https://wiki.dovecot.org/HowTo/AntispamWithSieve I'm trying to execute scripts when moving to/from Spam folder, however nothing's happening. The actions are:
- Move to Spam: redirect :copy "spamcop_spam@domain.local";
- Move from Spam: redirect :copy "spamcop_ham@domain.local"; [...] /usr/lib64/dovecot/sieve/report-spam.sieve contains: require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"]; redirect :copy "spamcop_spam@domain.local"; /usr/lib64/dovecot/sieve/report-ham.sieve contains: require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"]; redirect :copy "spamcop_ham@domain.local";
More information after enabling mail_debug, in maillog I see: Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: Module loaded: /usr/libexec/dovecot/modules/lib95_imap_sieve_plugin.so Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: Mail set keywords Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: mailbox INBOX.Spam: FLAG event (changed flags: Junk) Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: Pigeonhole version 0.4.16 (fed8554) initializing Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: include: sieve_global is not set; it is currently not possible to include
:global' scripts. Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: Sieve imapsieve plugin for Pigeonhole version 0.4.16 (fed8554) loaded Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: Sieve Extprograms plugin for Pigeonhole version 0.4.16 (fed8554) loaded Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: Static mailbox rule [1]: mailbox=
Spam' from=*' causes=(COPY) => before=
file:/usr/lib64/dovecot/sieve/report-spam.sieve' after=(none) Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: Static mailbox rule [2]: mailbox=*' from=
Spam' causes=(COPY) => before=file:/usr/lib64/dovecot/sieve/report-ham.sieve' after=(none) Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: Module loaded: /usr/libexec/dovecot/modules/lib95_imap_sieve_plugin.so Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: mailbox INBOX: MOVE event Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: Pigeonhole version 0.4.16 (fed8554) initializing Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: include: sieve_global is not set; it is currently not possible to include
:global' scripts. Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: Sieve imapsieve plugin for Pigeonhole version 0.4.16 (fed8554) loaded Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: Sieve Extprograms plugin for Pigeonhole version 0.4.16 (fed8554) loaded Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: Static mailbox rule [1]: mailbox=Spam' from=
*' causes=(COPY) => before=file:/usr/lib64/dovecot/sieve/report-spam.sieve' after=(none) Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: Static mailbox rule [2]: mailbox=
*' from=Spam' causes=(COPY) => before=
file:/usr/lib64/dovecot/sieve/report-ham.sieve' after=(none)So imapsieve "sees" the configuration, then I went and enabled debugging in the 2 sieve scripts which now read:
- /usr/lib64/dovecot/sieve/report-spam.sieve require ["vnd.dovecot.pipe", "copy", "imapsieve", "vnd.dovecot.debug"]; debug_log "/var/tmp/report-spam.sieve.debug"; redirect :copy "spamcop_spam@domain.local";
- /usr/lib64/dovecot/sieve/report-ham.sieve require ["vnd.dovecot.pipe", "copy", "imapsieve", "vnd.dovecot.debug"]; debug_log "/var/tmp/report-ham.sieve.debug"; redirect :copy "spamcop_ham@domain.local";
Should I expect to see debugging in /var/tmp/report-ham.sieve.debug and /var/tmp/report-spam.sieve.debug, respectively? The 2 files aren't created, nothing in that directory. BTW, getenforce=Disabled.
Tried with another set of ham/spam scripts that are supposed to log to syslog. Now using:
- log-ham.sieve which contains: require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"];
if environment :matches "imap.mailbox" "*" { set "mailbox" "${1}"; }
if string "${mailbox}" "Trash" { stop; }
if environment :matches "imap.user" "*" { set "username" "${1}"; }
pipe :copy "sa-learn-ham.sh" [ "${username}" ];
- log-spam.sieve which contains: require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"];
if environment :matches "imap.user" "*" { set "username" "${1}"; }
pipe :copy "sa-learn-spam.sh" [ "${username}" ];
And the 2 sa-learn scripts:
- sa-learn-ham.sh contains: #!/bin/bash
exec /usr/bin/logger basename $0
Called for mailbox $1
- sa-learn-spam.sh contains: #!/bin/bash
exec /usr/bin/logger basename $0
Called for mailbox $1
After compiling log-ham.sieve and log-spam.sieve, making sa-learn-spam.sh and sa-learn-ham.sh executable and reloading dovecot I should see syslog entries like this: Nov 14 14:19:08 plesk12 root: sa-learn-spam.sh Called for mailbox test@test.com
But I see nothing. Needless to say the sa-learn scripts are running from command line. I'm a bit lost at the moment, any ideas?
Adi Pircalabu
On 2018-11-14 14:25, Adi Pircalabu wrote:
On 2018-11-14 13:51, Adi Pircalabu wrote:
On 2018-11-14 13:11, Adi Pircalabu wrote:
Hi,
Using https://wiki.dovecot.org/HowTo/AntispamWithSieve I'm trying to execute scripts when moving to/from Spam folder, however nothing's happening. The actions are:
- Move to Spam: redirect :copy "spamcop_spam@domain.local";
- Move from Spam: redirect :copy "spamcop_ham@domain.local"; [...] /usr/lib64/dovecot/sieve/report-spam.sieve contains: require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"]; redirect :copy "spamcop_spam@domain.local"; /usr/lib64/dovecot/sieve/report-ham.sieve contains: require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"]; redirect :copy "spamcop_ham@domain.local";
More information after enabling mail_debug, in maillog I see: Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: Module loaded: /usr/libexec/dovecot/modules/lib95_imap_sieve_plugin.so Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: Mail set keywords Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: mailbox INBOX.Spam: FLAG event (changed flags: Junk) Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: Pigeonhole version 0.4.16 (fed8554) initializing Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: include: sieve_global is not set; it is currently not possible to include
:global' scripts. Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: Sieve imapsieve plugin for Pigeonhole version 0.4.16 (fed8554) loaded Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: Sieve Extprograms plugin for Pigeonhole version 0.4.16 (fed8554) loaded Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: Static mailbox rule [1]: mailbox=
Spam' from=*' causes=(COPY) => before=
file:/usr/lib64/dovecot/sieve/report-spam.sieve' after=(none) Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: Static mailbox rule [2]: mailbox=*' from=
Spam' causes=(COPY) => before=file:/usr/lib64/dovecot/sieve/report-ham.sieve' after=(none) Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: Module loaded: /usr/libexec/dovecot/modules/lib95_imap_sieve_plugin.so Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: mailbox INBOX: MOVE event Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: Pigeonhole version 0.4.16 (fed8554) initializing Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: include: sieve_global is not set; it is currently not possible to include
:global' scripts. Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: Sieve imapsieve plugin for Pigeonhole version 0.4.16 (fed8554) loaded Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: Sieve Extprograms plugin for Pigeonhole version 0.4.16 (fed8554) loaded Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: Static mailbox rule [1]: mailbox=Spam' from=
*' causes=(COPY) => before=file:/usr/lib64/dovecot/sieve/report-spam.sieve' after=(none) Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: Static mailbox rule [2]: mailbox=
*' from=Spam' causes=(COPY) => before=
file:/usr/lib64/dovecot/sieve/report-ham.sieve' after=(none)So imapsieve "sees" the configuration, then I went and enabled debugging in the 2 sieve scripts which now read:
- /usr/lib64/dovecot/sieve/report-spam.sieve require ["vnd.dovecot.pipe", "copy", "imapsieve", "vnd.dovecot.debug"]; debug_log "/var/tmp/report-spam.sieve.debug"; redirect :copy "spamcop_spam@domain.local";
- /usr/lib64/dovecot/sieve/report-ham.sieve require ["vnd.dovecot.pipe", "copy", "imapsieve", "vnd.dovecot.debug"]; debug_log "/var/tmp/report-ham.sieve.debug"; redirect :copy "spamcop_ham@domain.local";
Should I expect to see debugging in /var/tmp/report-ham.sieve.debug and /var/tmp/report-spam.sieve.debug, respectively? The 2 files aren't created, nothing in that directory. BTW, getenforce=Disabled.
Tried with another set of ham/spam scripts that are supposed to log to syslog. Now using:
- log-ham.sieve which contains: require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"];
if environment :matches "imap.mailbox" "*" { set "mailbox" "${1}"; }
if string "${mailbox}" "Trash" { stop; }
if environment :matches "imap.user" "*" { set "username" "${1}"; }
pipe :copy "sa-learn-ham.sh" [ "${username}" ];
- log-spam.sieve which contains: require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"];
if environment :matches "imap.user" "*" { set "username" "${1}"; }
pipe :copy "sa-learn-spam.sh" [ "${username}" ];
And the 2 sa-learn scripts:
- sa-learn-ham.sh contains: #!/bin/bash
exec /usr/bin/logger
basename $0
Called for mailbox $1
- sa-learn-spam.sh contains: #!/bin/bash
exec /usr/bin/logger
basename $0
Called for mailbox $1After compiling log-ham.sieve and log-spam.sieve, making sa-learn-spam.sh and sa-learn-ham.sh executable and reloading dovecot I should see syslog entries like this: Nov 14 14:19:08 plesk12 root: sa-learn-spam.sh Called for mailbox test@test.com
But I see nothing. Needless to say the sa-learn scripts are running from command line. I'm a bit lost at the moment, any ideas?
After more digging I've ended up with this sieve spam script: require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables", "vnd.dovecot.debug"];
---CUT HERE--- if environment :matches "imap.user" "*" { set "username" "${1}"; }
debug_log "In log-spam.sieve, username = ${username}";
pipe :copy "sa-learn-spam.sh" [ "${username}" ]; ---CUT HERE---
Can't see anything in maillog. Where can I read more about debugging imapsieve?
-- Adi Pircalabu, System Administrator DDNS, a Total Internet Company 159 Barkly Avenue, Burnley, Vic 3121, T +61 3 9815 6868
For the archives: after reading https://www.dovecot.org/list/dovecot/2017-February/107039.html I found & fixed the issue, it appears I *must* use the inbox prefix, hence the configuration should be:
plugin { sieve_plugins = sieve_imapsieve sieve_extprograms imapsieve_mailbox1_name = INBOX.Spam imapsieve_mailbox1_causes = COPY imapsieve_mailbox1_before = file:/usr/lib64/dovecot/sieve/report-spam.sieve imapsieve_mailbox2_name = * imapsieve_mailbox2_from = INBOX.Spam imapsieve_mailbox2_causes = COPY imapsieve_mailbox2_before = file:/usr/lib64/dovecot/sieve/report-ham.sieve sieve_pipe_bin_dir = /usr/lib64/dovecot/sieve sieve_global_extensions = +vnd.dovecot.pipe +vnd.dovecot.environment }
Perhaps worth adding a note to https://wiki.dovecot.org/HowTo/AntispamWithSieve for this case?
-- Adi Pircalabu
On 2018-11-14 15:08, Adi Pircalabu wrote:
On 2018-11-14 14:25, Adi Pircalabu wrote:
On 2018-11-14 13:51, Adi Pircalabu wrote:
On 2018-11-14 13:11, Adi Pircalabu wrote:
Hi,
Using https://wiki.dovecot.org/HowTo/AntispamWithSieve I'm trying to execute scripts when moving to/from Spam folder, however nothing's happening. The actions are:
- Move to Spam: redirect :copy "spamcop_spam@domain.local";
- Move from Spam: redirect :copy "spamcop_ham@domain.local"; [...] /usr/lib64/dovecot/sieve/report-spam.sieve contains: require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"]; redirect :copy "spamcop_spam@domain.local"; /usr/lib64/dovecot/sieve/report-ham.sieve contains: require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"]; redirect :copy "spamcop_ham@domain.local";
More information after enabling mail_debug, in maillog I see: Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: Module loaded: /usr/libexec/dovecot/modules/lib95_imap_sieve_plugin.so Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: Mail set keywords Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: mailbox INBOX.Spam: FLAG event (changed flags: Junk) Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: Pigeonhole version 0.4.16 (fed8554) initializing Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: include: sieve_global is not set; it is currently not possible to include
:global' scripts. Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: Sieve imapsieve plugin for Pigeonhole version 0.4.16 (fed8554) loaded Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: Sieve Extprograms plugin for Pigeonhole version 0.4.16 (fed8554) loaded Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: Static mailbox rule [1]: mailbox=
Spam' from=*' causes=(COPY) => before=
file:/usr/lib64/dovecot/sieve/report-spam.sieve' after=(none) Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: Static mailbox rule [2]: mailbox=*' from=
Spam' causes=(COPY) => before=file:/usr/lib64/dovecot/sieve/report-ham.sieve' after=(none) Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: Module loaded: /usr/libexec/dovecot/modules/lib95_imap_sieve_plugin.so Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: mailbox INBOX: MOVE event Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: Pigeonhole version 0.4.16 (fed8554) initializing Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: include: sieve_global is not set; it is currently not possible to include
:global' scripts. Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: Sieve imapsieve plugin for Pigeonhole version 0.4.16 (fed8554) loaded Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: sieve: Sieve Extprograms plugin for Pigeonhole version 0.4.16 (fed8554) loaded Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: Static mailbox rule [1]: mailbox=Spam' from=
*' causes=(COPY) => before=file:/usr/lib64/dovecot/sieve/report-spam.sieve' after=(none) Nov 14 13:41:52 plesk12 dovecot: service=imap, user=adi1@adit1.local, ip=[::1]. Debug: imapsieve: Static mailbox rule [2]: mailbox=
*' from=Spam' causes=(COPY) => before=
file:/usr/lib64/dovecot/sieve/report-ham.sieve' after=(none)So imapsieve "sees" the configuration, then I went and enabled debugging in the 2 sieve scripts which now read:
- /usr/lib64/dovecot/sieve/report-spam.sieve require ["vnd.dovecot.pipe", "copy", "imapsieve", "vnd.dovecot.debug"]; debug_log "/var/tmp/report-spam.sieve.debug"; redirect :copy "spamcop_spam@domain.local";
- /usr/lib64/dovecot/sieve/report-ham.sieve require ["vnd.dovecot.pipe", "copy", "imapsieve", "vnd.dovecot.debug"]; debug_log "/var/tmp/report-ham.sieve.debug"; redirect :copy "spamcop_ham@domain.local";
Should I expect to see debugging in /var/tmp/report-ham.sieve.debug and /var/tmp/report-spam.sieve.debug, respectively? The 2 files aren't created, nothing in that directory. BTW, getenforce=Disabled.
Tried with another set of ham/spam scripts that are supposed to log to syslog. Now using:
- log-ham.sieve which contains: require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"];
if environment :matches "imap.mailbox" "*" { set "mailbox" "${1}"; }
if string "${mailbox}" "Trash" { stop; }
if environment :matches "imap.user" "*" { set "username" "${1}"; }
pipe :copy "sa-learn-ham.sh" [ "${username}" ];
- log-spam.sieve which contains: require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"];
if environment :matches "imap.user" "*" { set "username" "${1}"; }
pipe :copy "sa-learn-spam.sh" [ "${username}" ];
And the 2 sa-learn scripts:
- sa-learn-ham.sh contains: #!/bin/bash
exec /usr/bin/logger
basename $0
Called for mailbox $1
- sa-learn-spam.sh contains: #!/bin/bash
exec /usr/bin/logger
basename $0
Called for mailbox $1After compiling log-ham.sieve and log-spam.sieve, making sa-learn-spam.sh and sa-learn-ham.sh executable and reloading dovecot I should see syslog entries like this: Nov 14 14:19:08 plesk12 root: sa-learn-spam.sh Called for mailbox test@test.com
But I see nothing. Needless to say the sa-learn scripts are running from command line. I'm a bit lost at the moment, any ideas?
After more digging I've ended up with this sieve spam script: require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables", "vnd.dovecot.debug"];
---CUT HERE--- if environment :matches "imap.user" "*" { set "username" "${1}"; }
debug_log "In log-spam.sieve, username = ${username}";
pipe :copy "sa-learn-spam.sh" [ "${username}" ]; ---CUT HERE---
Can't see anything in maillog. Where can I read more about debugging imapsieve?
I compiled all the needed stuff into a nice repository
https://github.com/darix/dovecot-sieve-antispam-rspamd
-- openSUSE - SUSE Linux is my linux openSUSE is good for you www.opensuse.org
participants (2)
-
Adi Pircalabu
-
Marcus Rueckert