Has anyone done the config for rspamd to learn spam using dovecot? Like moving an email to spam folder, it will learn it is spam. And moving an email from the spam folder it will learn ham. Could not find a tutorial in howtoforge or I did not do the correct search. Of course doing all this without breaking ispconfig.
Mail and Rspamd is not my subject for now, but in its list of tutorials it said "that antispam plugin is deprecated, use IMAPSieve instead" so try to look the latter's how to, as I remember @till said somewhere that this is not currently managed by ISPConfig, so its customization might survive ISPConfig or even Dovecot update for now, unless they changed Dovecot config(s) that you edited directly instead of introducing your own custom IMAPSieve config in there. I hope that makes sense.
Thank you for the reply and the links. I will try this link you shared. https://doc.dovecot.org/2.3/configuration_manual/howto/antispam_with_sieve/#for-rspamd I just hope it does not break or get lost in the next update of ispconfig.
The approach is simple when rspamd is running on the same machine and would look like this: Code: plugin { sieve_plugins = sieve_imapsieve sieve_extprograms # Messages moved into Junk -- learn spam imapsieve_mailbox1_name = Junk imapsieve_mailbox1_causes = COPY imapsieve_mailbox1_before = file:/etc/dovecot/sieve/learn-spam.sieve # Messages moved out of Junk -- learn ham imapsieve_mailbox2_name = * imapsieve_mailbox2_from = Junk imapsieve_mailbox2_causes = COPY imapsieve_mailbox2_before = file:/etc/dovecot/sieve/learn-ham.sieve sieve_pipe_bin_dir = /usr/lib/dovecot sieve_global_extensions = +vnd.dovecot.pipe } This is the sieve filter: Code: #learn-spam.sieve require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment"]; if environment :is "imap.cause" "COPY" { pipe :copy "rspamc" ["learn_spam"]; } Code: # learn-ham.sieve require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"]; if environment :matches "imap.mailbox" "*" { set "mailbox" "${1}"; } if string "${mailbox}" ["Trash"] { stop; } pipe :copy "rspamc" ["learn_ham"]; The ham script includes a guard against learning messages dragged from Junk directly to Trash - that's a deletion, not a reclassification. This approach has a significant operational advantage: it creates a self-correcting feedback loop. When Bayes misclassifies a message and the user corrects it, that correction flows directly back into training. Be aware that this approach is good for small setups. There are several considerations that need to be done when dealing with large scale mail systems.
Thank you very much for sharing the solution. One question. Where should the script "learn-spam.sieve" be stored? In Debian or Centos. Can it be in /root/scripts/dovecot/rspamd/learn-spam.sieve?
In the link I embedded in my post, where you also extracted and quoted, there already are very detailed advices on what to do and where that are to go, though here our friend use "learn", but in there "report", and also some very minor differences, but they are mostly the same, even the overall code, though not for each and every words obviously, which we could all learn why. So basically every official details are there already, except our friend may had proven his, in ISPConfig environment, but again, this is not my focus subject, so good luck.
Code: [root@mail conf.d]# sievec /usr/lib64/dovecot/sieve/learn-spam.sieve learn-spam: line 2: error: require command: unknown Sieve capability `vnd.dovecot.pipe'. learn-spam: line 2: error: require command: unknown Sieve capability `imapsieve'. learn-spam: line 4: error: unknown command 'pipe' (only reported once at first occurrence). learn-spam: error: validation failed. sievec(root): Fatal: failed to compile sieve script '/usr/lib64/dovecot/sieve/learn-spam.sieve' unfortunately getting the above error. Looks like a plugin need to be activated. I will do more searching on the internet. This is in Rocky Linux release 8.10 (Green Obsidian)
This is very embarrassing. The solution to the above problem as already given by @pyte I did not do this. My bad. Code: plugin { sieve_plugins = sieve_imapsieve sieve_extprograms # Messages moved into Junk -- learn spam imapsieve_mailbox1_name = Junk imapsieve_mailbox1_causes = COPY imapsieve_mailbox1_before = file:/etc/dovecot/sieve/learn-spam.sieve # Messages moved out of Junk -- learn ham imapsieve_mailbox2_name = * imapsieve_mailbox2_from = Junk imapsieve_mailbox2_causes = COPY imapsieve_mailbox2_before = file:/etc/dovecot/sieve/learn-ham.sieve sieve_pipe_bin_dir = /usr/lib/dovecot sieve_global_extensions = +vnd.dovecot.pipe }
@pyte I followed the script but I do not see anything in /var/log/rspamd/rspamd.log Is there something else I need to do to check if the script is working? I have restarted dovecot and rspamd. When I move the email to Junk/Spam folder, nothing shows up in the rspamd.log. Did I miss something? I am using Dovecot v2.3.16 on Rocky Linux 8 email client is Thunderbird
You could check the ".dovecot.sieve.log" (maybe the name is different) in the users vmail directory on the server. The file should contain helpful information.