Signum / ispmail-bookworm-ansible

Ansible playbook to set up a mail server as described in the ISPmail guide at workaround.org
MIT License
26 stars 6 forks source link

Change file learn-ham.sieve #3

Closed FredMa01 closed 3 months ago

FredMa01 commented 4 months ago

This file "roles/ispmail-dovecot/files/learn-ham.sieve" needs to be changed like this :


require ["vnd.dovecot.pipe", "copy", "imapsieve", "variables"];
if string "${mailbox}" "Trash" {
  stop;
}
pipe :copy "rspamd-learn-ham.sh";

https://workaround.org/ispmail-bookworm/catching-spam-with-rspamd/

But problem : emails move from Junk to Trash are indicate as ham.

Fred

Signum commented 3 months ago

Thanks for the hint. I have just fixed it in the repository.

Regarding moving mails from Junk to Trash: I consider that a feature. If there is an email in the Junk folder that does not belong there, I delete it. However I can imagine that this is just my own way of dealing with it.

What would you suggest? Not learn anything if emails go to Trash?

FredMa01 commented 3 months ago

You can look at Cody's problem and his proposed solution here, but which does not work any better. https://workaround.org/ispmail-bookworm/catching-spam-with-rspamd/#comment-201755 I usually delete the contents of the Junk email folder but this action turns them into ham.

I propose :

FredMa01 commented 3 months ago

I propose :

  • learn as SPAM if emails are moved to the Junk folder (it works well).
  • learn as HAM if emails are moved from Junk folder to any folder except Trash. (not lean anything if emails go to Trash).

Something here to change to exclude the Trash directory ? /etc/dovecot/conf.d/90-sieve.conf

# From elsewhere to Junk folder
imapsieve_mailbox1_name = Junk
imapsieve_mailbox1_causes = COPY
imapsieve_mailbox1_before = file:/etc/dovecot/sieve/learn-spam.sieve

# From Junk folder to elsewhere
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 = /etc/dovecot/sieve
sieve_global_extensions = +vnd.dovecot.pipe
sieve_plugins = sieve_imapsieve sieve_extprograms
FredMa01 commented 3 months ago

When moving a mail from the Junk folder to the Trash folder, the mail previously classified as ham due to the wildcard match of *. Because the syntax does not allow for negation, we can only change the behavior in a way that mails are learned as ham when they are moved into INBOX from Junk.

I changed in /etc/dovecot/conf.d/90-sieve.conf :

# From Junk folder to elsewhere 
# imapsieve_mailbox2_name = *

by

# From Junk to Inbox : mails are learned as ham when they are moved into `INBOX` from `Junk`
  imapsieve_mailbox2_name = INBOX