Hi John,
again you're hitting the point!
I put a "report-spam.sieve fired!" and "report-ham.sieve fired!" debug message in the scripts and monitored with "journalctl -u dovecot -f | grep fired". The APPEND event (move to junk) triggers BOTH scripts while the APPEND (move from junk to elsewhere) do nothing.
With your second listing it runs as expected. Now I will crawling some RFCs about the commands and a possible solution.
But I wonder am I the only one with this problem? I expected Outlook, even the older 2016, to be very popular?!
Jens
-----Ursprüngliche Nachricht----- Von: John Fawcett via dovecot <dovecot@dovecot.org> Gesendet: Dienstag, 2. Juli 2024 16:21 An: dovecot@dovecot.org Betreff: Re: AW: AW: AW: AW: AW: IMAPSieve plugin will not run rspamd script
(Resending because of size limit exceeded on previous post)
Hi Jens
that looks much better, though not yet completely solved. What you're now getting is both rules firing when you move a message to Junk, whereas you only want the first one firing. I guess you will have no rules firing when you move from Junk to elsewhere. My suspicion is that for APPEND event the target and destination mailboxes are set to the same value. i.e. APPEND event for moving to Junk will have mailbox=INBOX/Junk and from=INBOX/Junk which fires both rules, whereas when moving from Junk to INBOX mailbox=INBOX and from=INBOX, leading to KO for rule one on "mailbox" and KO on rule 2 for "from".
Static mailbox rule [1]: mailbox=INBOX/Junk' from=
*' causes=(COPY APPEND) => before=file:/usr/lib/dovecot/sieve/report-spam.sieve' after=(none) Static mailbox rule [2]: mailbox=
*' from=INBOX/Junk' causes=(COPY APPEND) => before=
file:/usr/lib/dovecot/sieve/report-ham.sieve' after=(none)
Whenever I do the move of the message I get a MOVE (which is treated like COPY). I don't see these APPEND events. Not sure why your email client generates APPEND instead of MOVE. That could be a point to investigate. If you're going to have to manage APPEND events you'll probably need different rules. If you'll going to manage MOVE/COPY and APPEND events then you can probably combine sets of rules (adjusting the sequential numbering).
The following work for MOVE/COPY events
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 = *
The following should work for APPEND events, but it won't support wildcards fo rule 2 else it will fire when moving to Junk as well as from Junk. I'm pretty sure you can't specify negation e.g. imapsieve_mailbox2_name = !INBOX/Junk, which is what would be needed to make it work for moving from Junk to any mailbox. As written rule 2 fires for moving from Junk to INBOX
imapsieve_mailbox1_before =file:/usr/lib/dovecot/sieve/report-spam.sieve imapsieve_mailbox1_causes = APPEND imapsieve_mailbox1_name = INBOX/Junk imapsieve_mailbox2_before =file:/usr/lib/dovecot/sieve/report-ham.sieve imapsieve_mailbox2_causes = APPEND imapsieve_mailbox2_name = INBOX
John