Hi Jens

that log looks to me like it is for moving a message from Inbox to Junk rather than Junk to Inbox.

The issue I see is that how you defined the rules does not match your namespace naming scheme. Event being received is the following. In that event you can see the name of the mailbox is "INBOX/Junk".

        imap(info@demo.example)<1827><dJVhwj4cJP3AqB4a>: Debug: imapsieve: 
mailbox INBOX/Junk: APPEND event

However the rule you defined has the mailbox as "Junk".

        Static mailbox rule [1]: mailbox=`Junk' from=`*' causes=(COPY) => 
before=`file:/usr/lib/dovecot/sieve/report-spam.sieve' after=(none)

The logging you show confirms that the rule is not matching, else you would get a log line like the one I showed with the text "Debug: imapsieve: Matched static mailbox rule". So I have two possible alternative solutions, that in my tests I found both working:

(1) you define your inbox namespace with blank prefix instead of prefix=INBOX/

OR

(2) you adjust the rules as follows

  imapsieve_mailbox1_before =file:/usr/lib/dovecot/sieve/report-spam.sieve
  imapsieve_mailbox1_causes = COPY
  imapsieve_mailbox1_name = INBOX/Junk
  imapsieve_mailbox2_before =file:/usr/lib/dovecot/sieve/report-ham.sieve
  imapsieve_mailbox2_causes = COPY
  imapsieve_mailbox2_from = INBOX/Junk
  imapsieve_mailbox2_name = *

If you apply one of those solutions and repeat the test unsuccessfully, it would be good to see the logging from that test.
John

On 02/07/2024 11:28, postfix_dovecot--- via dovecot wrote:
Hi John!

You are of course absolutely right - wild experimentation is rarely a good 
approach. But you are surely familiar with the situation when you have done 
everything logical and then, in your desperation, you start to change things 
that you would not otherwise change ;)

I've actually gotten to the point where I'm going to give up on the idea and 
run a cron job at night. Then the spam won't be detected in real time - but 
what the heck?

As I wrote yesterday, I implemented a very popular tutorial for Debian 10 in 
Germany 1:1. The result was the same. Nevertheless, I reset my VM, where I do 
everything with the current releases, and attaching the log here. I would be 
very happy if it still works.

To be sure, I deleted the whole inbox and recreated the account on Outlook to create a fresh, 
new folder structure given by the Dovecot configuration. I also added the plugin 
vnd.dovecot.debug to the sieve_global_extensions line and added >debug_log 
"report-spam.sieve was running!";< to the report-spam.sieve file. So this string 
should appear in the log if the script were running at all. But it doesn't. So I still guess, 
it's not getting triggered.

That's the log if I move a mail from Junk (Spam) to Inbox:

# journalctl -u dovecot -f
imap-login: Login: user=<info@demo.example>, method=PLAIN, rip=192.168.30.26, 
lip=192.168.30.34, mpid=1827, TLS, session=<dJVhwj4cJP3AqB4a>
imap(info@demo.example)<1827><dJVhwj4cJP3AqB4a>: Debug: Loading modules from 
directory: /usr/lib/dovecot/modules
imap(info@demo.example)<1827><dJVhwj4cJP3AqB4a>: Debug: Module loaded: 
/usr/lib/dovecot/modules/lib95_imap_sieve_plugin.so
imap(info@demo.example)<1827><dJVhwj4cJP3AqB4a>: Debug: Effective uid=10000, 
gid=10000, home=/var/mail/vhosts/demo.example/info
imap(info@demo.example)<1827><dJVhwj4cJP3AqB4a>: Debug: open(/proc/self/io) 
failed: Permission denied
imap(info@demo.example)<1827><dJVhwj4cJP3AqB4a>: Debug: Namespace inbox: 
type=private, prefix=INBOX/, sep=/, inbox=yes, hidden=no, list=yes, subscriptions=yes 
location=maildir:~/Maildir
imap(info@demo.example)<1827><dJVhwj4cJP3AqB4a>: Debug: maildir++: 
root=/var/mail/vhosts/demo.example/info/Maildir, index=, indexpvt=, control=, 
inbox=/var/mail/vhosts/demo.example/info/Maildir, alt=
imap(info@demo.example)<1827><dJVhwj4cJP3AqB4a>: Debug: Namespace : 
type=private, prefix=, sep=, inbox=no, hidden=yes, list=no, subscriptions=no 
location=fail::LAYOUT=none
imap(info@demo.example)<1827><dJVhwj4cJP3AqB4a>: Debug: none: root=, index=, 
indexpvt=, control=, inbox=, alt=
imap(info@demo.example)<1827><dJVhwj4cJP3AqB4a>: Debug: Mailbox INBOX/Junk: 
Mailbox opened
imap(info@demo.example)<1827><dJVhwj4cJP3AqB4a>: Debug: imapsieve: mailbox 
INBOX/Junk: APPEND event
imap(info@demo.example)<1827><dJVhwj4cJP3AqB4a>: Debug: duplicate db: Initialize
imap(info@demo.example)<1827><dJVhwj4cJP3AqB4a>: Debug: sieve: Pigeonhole 
version 0.5.19 (4eae2f79) initializing
imap(info@demo.example)<1827><dJVhwj4cJP3AqB4a>: Debug: sieve: include: 
sieve_global is not set; it is currently not possible to include `:global' scripts.
imap(info@demo.example)<1827><dJVhwj4cJP3AqB4a>: Debug: sieve: Sieve imapsieve 
plugin for Pigeonhole version 0.5.19 (4eae2f79) loaded
imap(info@demo.example)<1827><dJVhwj4cJP3AqB4a>: Debug: sieve: Sieve 
Extprograms plugin for Pigeonhole version 0.5.19 (4eae2f79) loaded
imap(info@demo.example)<1827><dJVhwj4cJP3AqB4a>: Debug: imapsieve: Static mailbox 
rule [1]: mailbox=`Junk' from=`*' causes=(COPY) => 
before=`file:/usr/lib/dovecot/sieve/report-spam.sieve' after=(none)
imap(info@demo.example)<1827><dJVhwj4cJP3AqB4a>: Debug: imapsieve: Static mailbox 
rule [2]: mailbox=`*' from=`Junk' causes=(COPY) => 
before=`file:/usr/lib/dovecot/sieve/report-ham.sieve' after=(none)
imap(info@demo.example)<1827><dJVhwj4cJP3AqB4a>: Debug: Mailbox INBOX/Junk: 
Mailbox opened
imap(info@demo.example)<1825><zjYMvz4c/PzAqB4a>: Debug: imapsieve: mailbox 
INBOX: FLAG event (changed flags: \Deleted)
imap(info@demo.example)<1825><zjYMvz4c/PzAqB4a>: Debug: Mailbox INBOX: UID 1: 
Expunge requested
imap(info@demo.example)<1825><zjYMvz4c/PzAqB4a>: Debug: Mailbox INBOX: UID 1: 
Mail expunged

# doveconf -n
# 2.3.19.1 (9b53102964): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.5.19 (4eae2f79)
# OS: Linux 6.1.0-21-amd64 x86_64 Debian 12.5
# Hostname: ServerIV-home.demo.example
auth_mechanisms = plain login
mail_debug = yes
mail_location = maildir:~/Maildir
mail_privileged_group = mail
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 imapsieve vnd.dovecot.imapsieve
namespace inbox {
   hidden = no
   ignore_on_failure = no
   inbox = yes
   list = yes
   location =
   mailbox Drafts {
     auto = subscribe
     special_use = \Drafts
   }
   mailbox Junk {
     auto = subscribe
     special_use = \Junk
   }
   mailbox Sent {
     auto = subscribe
     special_use = \Sent
   }
   mailbox "Sent Messages" {
     auto = subscribe
     special_use = \Sent
   }
   mailbox Trash {
     auto = subscribe
     special_use = \Trash
   }
   prefix = INBOX/
   separator = /
   subscriptions = yes
   type = private
}
passdb {
   driver = pam
}
passdb {
   args = scheme=CRYPT username_format=%u /etc/dovecot/users
   driver = passwd-file
}
plugin {
   imapsieve_mailbox1_before =file:/usr/lib/dovecot/sieve/report-spam.sieve
   imapsieve_mailbox1_causes = COPY
   imapsieve_mailbox1_name = Junk
   imapsieve_mailbox2_before =file:/usr/lib/dovecot/sieve/report-ham.sieve
   imapsieve_mailbox2_causes = COPY
   imapsieve_mailbox2_from = Junk
   imapsieve_mailbox2_name = *
   sieve =file:~/sieve;active=~/.dovecot.sieve
   sieve_after = /etc/dovecot/conf.d/custom-sieve/global_after.sieve
   sieve_before = /etc/dovecot/conf.d/custom-sieve/global_before.sieve
   sieve_global_extensions = +vnd.dovecot.pipe +vnd.dovecot.environment 
+vnd.dovecot.debug
   sieve_pipe_bin_dir = /usr/lib/dovecot/sieve
   sieve_plugins = sieve_imapsieve sieve_extprograms
}
protocols = imap lmtp sieve
service auth {
   unix_listener /var/spool/postfix/private/auth {
     mode = 0666
   }
}
service lmtp {
   inet_listener lmtp {
     address = 127.0.0.1 ::1
     port = 24
   }
}
ssl_cert = </etc/dovecot/private/dovecot.pem
ssl_client_ca_dir = /etc/ssl/certs
ssl_dh = # hidden, use -P to show it
ssl_key = # hidden, use -P to show it
userdb {
   driver = passwd
}
userdb {
   args = username_format=%u /etc/dovecot/users
   driver = passwd-file
}
verbose_proctitle = yes
protocol lmtp {
   mail_plugins = " sieve"
}
protocol imap {
   mail_plugins = " imap_sieve"
}

-----Ursprüngliche Nachricht-----
Von: John Fawcett via dovecot<dovecot@dovecot.org> Gesendet: Montag, 1. Juli 2024 23:16
An:dovecot@dovecot.org
Betreff: Re: AW: AW: AW: IMAPSieve plugin will not run rspamd script

Hi Jens

changing random things is rarely a good way to solve these kinds of issues. My 
advice, if you don't need the inbox namespace prefix set for a specific reason, 
would be to go with the default prefix (ie. blank) and then set up the 
imapsieve rules as per your original post and repeat the test. If that does not 
work then post the debug logging and configuration from that test.

There could be multiple places where this is failing but the very first point is to have 
your sieve rules match. They will show something like the following in the logging. 
Notice the "Matched static mailbox rule"
message. If that is not happening it's pointless to look further down the line 
into issues in the scripts themselves.

Jul 01 22:57:55 imola.site24.it dovecot[1145722]: 
imap(t...@site24.it)<1145777><mlKa2TUccLdOhguc>: Debug: imapsieve: mailbox 
INBOX: MOVE event
Jul 01 22:57:55 imola.site24.it dovecot[1145722]: 
imap(t...@site24.it)<1145777><mlKa2TUccLdOhguc>: Debug: Mailbox Spam: UID 2: 
Expunge requested
Jul 01 22:57:55 imola.site24.it dovecot[1145722]: 
imap(t...@site24.it)<1145777><mlKa2TUccLdOhguc>: Debug: duplicate db: Initialize
Jul 01 22:57:55 imola.site24.it dovecot[1145722]: 
imap(t...@site24.it)<1145777><mlKa2TUccLdOhguc>: Debug: sieve: Pigeonhole 
version 0.5.21 (f6cd4b8e) initializing
Jul 01 22:57:55 imola.site24.it dovecot[1145722]: 
imap(t...@site24.it)<1145777><mlKa2TUccLdOhguc>: Debug: sieve: include: 
sieve_global is not set; it is currently not possible to include `:global' scripts.
Jul 01 22:57:55 imola.site24.it dovecot[1145722]: 
imap(t...@site24.it)<1145777><mlKa2TUccLdOhguc>: Debug: sieve: Sieve imapsieve 
plugin for Pigeonhole version 0.5.21 (f6cd4b8e) loaded
Jul 01 22:57:55 imola.site24.it dovecot[1145722]: 
imap(t...@site24.it)<1145777><mlKa2TUccLdOhguc>: Debug: sieve: Sieve 
Extprograms plugin for Pigeonhole version 0.5.21 (f6cd4b8e) loaded
Jul 01 22:57:55 imola.site24.it dovecot[1145722]: 
imap(t...@site24.it)<1145777><mlKa2TUccLdOhguc>: Debug: imapsieve: Static mailbox 
rule [1]: mailbox=`Spam' from=`*' causes=(COPY) => 
before=`file:/usr/lib/dovecot/sieve/report-spam.sieve' after=(none)
Jul 01 22:57:55 imola.site24.it dovecot[1145722]: 
imap(t...@site24.it)<1145777><mlKa2TUccLdOhguc>: Debug: imapsieve: Static mailbox 
rule [2]: mailbox=`*' from=`Spam' causes=(COPY APPEND) => 
before=`file:/usr/lib/dovecot/sieve/report-ham.sieve' after=(none)
Jul 01 22:57:55 imola.site24.it dovecot[1145722]: 
imap(t...@site24.it)<1145777><mlKa2TUccLdOhguc>: Debug: imapsieve: Matched 
static mailbox rule [2]

As for Debian, sorry I can't help on that, I'm using Fedora :-)

John

_______________________________________________
dovecot mailing list --dovecot@dovecot.org  To unsubscribe send an email 
todovecot-le...@dovecot.org

_______________________________________________
dovecot mailing list --dovecot@dovecot.org
To unsubscribe send an email todovecot-le...@dovecot.org
_______________________________________________
dovecot mailing list -- dovecot@dovecot.org
To unsubscribe send an email to dovecot-le...@dovecot.org

Reply via email to