[Dovecot] Delete antispam emails
I'm using dovecot with the antispam plugin to allow for training, but how do I delete emails once they've been trained? If I delete them from the folder using an email client they get retrained as valid emails when they're moved to the trash folder! D'oh.
I'm looking, ideally, for a solution that doesn't need a script to be run per user as I have a number of users using this feature. Also, the cleanspam script doesn't seem to be able to find the folder I'm using ('SpamTrain') so what format should I use?
Thanks.
david
David Reid wrote:
I'm using dovecot with the antispam plugin to allow for training, but how do I delete emails once they've been trained? If I delete them from the folder using an email client they get retrained as valid emails when they're moved to the trash folder! D'oh.
I'm looking, ideally, for a solution that doesn't need a script to be run per user as I have a number of users using this feature. Also, the cleanspam script doesn't seem to be able to find the folder I'm using ('SpamTrain') so what format should I use?
Thanks.
david
When you configure the trash folder in the antispam plugin correctly, messages moved from spam to trash are not retrained as ham. With Thunderbird as your client in default configuation, the dovecot plugin config should look like:
antispam_trash: Trash antispam_spam: Junk
You need to add the appropriate (default) folder names for all used clients though, or standardize the folders and let users adapt the settings in their clients.
-- Tom
Tom Hendrikx wrote:
David Reid wrote:
I'm using dovecot with the antispam plugin to allow for training, but how do I delete emails once they've been trained? If I delete them from the folder using an email client they get retrained as valid emails when they're moved to the trash folder! D'oh.
I'm looking, ideally, for a solution that doesn't need a script to be run per user as I have a number of users using this feature. Also, the cleanspam script doesn't seem to be able to find the folder I'm using ('SpamTrain') so what format should I use?
Thanks.
david
When you configure the trash folder in the antispam plugin correctly, messages moved from spam to trash are not retrained as ham. With Thunderbird as your client in default configuation, the dovecot plugin config should look like:
antispam_trash: Trash antispam_spam: Junk
Hmm, I thought I had done that! These are the lines I have
antispam_trash = trash;Trash;Deleted Items antispam_spam = SpamTrain;INBOX.SpamTrain
You need to add the appropriate (default) folder names for all used clients though, or standardize the folders and let users adapt the settings in their clients.
Have I messed up the syntax? Thanks for the prompt reply!
-- Tom
!DSPAM:16,48009999124071709054984!
When you configure the trash folder in the antispam plugin correctly, messages moved from spam to trash are not retrained as ham. With Thunderbird as your client in default configuation, the dovecot plugin config should look like:
antispam_trash: Trash antispam_spam: Junk
Hmm, I thought I had done that! These are the lines I have
antispam_trash = trash;Trash;Deleted Items antispam_spam = SpamTrain;INBOX.SpamTrain
That looks fine; the alternative would be to make Thunderbird not use trash but rather imap's deleted functionality.
Can you enable debugging (to syslog) and see what it prints?
johannes
Johannes Berg wrote:
When you configure the trash folder in the antispam plugin correctly, messages moved from spam to trash are not retrained as ham. With Thunderbird as your client in default configuation, the dovecot plugin config should look like:
antispam_trash: Trash antispam_spam: Junk Hmm, I thought I had done that! These are the lines I have
antispam_trash = trash;Trash;Deleted Items antispam_spam = SpamTrain;INBOX.SpamTrain
That looks fine; the alternative would be to make Thunderbird not use
Cool.
trash but rather imap's deleted functionality.
There are too many users for me to be able to do that... :-(
Can you enable debugging (to syslog) and see what it prints?
Hmm, that would make sense, but how do I do that? I'll try the docs again :-)
johannes
!DSPAM:16,4800a40b124078766919089!
David Reid wrote:
Johannes Berg wrote:
When you configure the trash folder in the antispam plugin correctly, messages moved from spam to trash are not retrained as ham. With Thunderbird as your client in default configuation, the dovecot plugin config should look like:
antispam_trash: Trash antispam_spam: Junk Hmm, I thought I had done that! These are the lines I have
antispam_trash = trash;Trash;Deleted Items antispam_spam = SpamTrain;INBOX.SpamTrain That looks fine; the alternative would be to make Thunderbird not use
Cool.
trash but rather imap's deleted functionality.
There are too many users for me to be able to do that... :-(
Can you enable debugging (to syslog) and see what it prints?
This is what I found in syslog...
Apr 12 21:28:15 kosh imap: antispam: plugin initialising Apr 12 21:28:15 kosh imap: antispam: "trash" is trash folder Apr 12 21:28:15 kosh imap: antispam: "Trash" is trash folder Apr 12 21:28:15 kosh imap: antispam: "Deleted Items" is trash folder Apr 12 21:28:15 kosh imap: antispam: "SpamTrain" is spam folder Apr 12 21:28:15 kosh imap: antispam: "INBOX.SpamTrain" is spam folder ...
It looks like all the folders are being recognised correctly. Is it possible to get more info when messages are being processed?
Hmm, that would make sense, but how do I do that? I'll try the docs again :-)
johannes
!DSPAM:16,4800f10e124072031210566!
This is what I found in syslog...
Apr 12 21:28:15 kosh imap: antispam: plugin initialising Apr 12 21:28:15 kosh imap: antispam: "trash" is trash folder Apr 12 21:28:15 kosh imap: antispam: "Trash" is trash folder Apr 12 21:28:15 kosh imap: antispam: "Deleted Items" is trash folder Apr 12 21:28:15 kosh imap: antispam: "SpamTrain" is spam folder Apr 12 21:28:15 kosh imap: antispam: "INBOX.SpamTrain" is spam folder ...
It looks like all the folders are being recognised correctly.
Good, yes, that confirms at least the configuration is working.
Is it possible to get more info when messages are being processed?
Not as-is, but you can try something like the patch below: diff --git a/antispam-storage-1.0.c b/antispam-storage-1.0.c index 1949454..da21ba4 100644 --- a/antispam-storage-1.0.c +++ b/antispam-storage-1.0.c @@ -88,12 +88,18 @@ antispam_copy(struct mailbox_transaction_context *t, struct mail *mail, return -1; } + debug("mail copy: from trash: %d, to trash: %d\n", + mailbox_is_trash(mail->box), mailbox_is_trash(t->box)); + if (!mailbox_is_trash(mail->box) && !mailbox_is_trash(t->box)) { bool src_spam = mailbox_is_spam(mail->box); bool dst_spam = mailbox_is_spam(t->box); bool src_unsu = mailbox_is_unsure(mail->box); + debug("mail copy: src spam: %d, dst spam: %d, src unsure: %d\n", + src_spam, dst_spam, src_unsu); + if ((src_spam || src_unsu) && !dst_spam) asbox->movetype = MMT_TO_CLEAN; else if ((!src_spam || src_unsu) && dst_spam)
Johannes Berg wrote:
This is what I found in syslog...
Apr 12 21:28:15 kosh imap: antispam: plugin initialising Apr 12 21:28:15 kosh imap: antispam: "trash" is trash folder Apr 12 21:28:15 kosh imap: antispam: "Trash" is trash folder Apr 12 21:28:15 kosh imap: antispam: "Deleted Items" is trash folder Apr 12 21:28:15 kosh imap: antispam: "SpamTrain" is spam folder Apr 12 21:28:15 kosh imap: antispam: "INBOX.SpamTrain" is spam folder ...
It looks like all the folders are being recognised correctly.
Good, yes, that confirms at least the configuration is working.
Is it possible to get more info when messages are being processed?
Not as-is, but you can try something like the patch below:
diff --git a/antispam-storage-1.0.c b/antispam-storage-1.0.c index 1949454..da21ba4 100644 --- a/antispam-storage-1.0.c +++ b/antispam-storage-1.0.c @@ -88,12 +88,18 @@ antispam_copy(struct mailbox_transaction_context *t, struct mail *mail, return -1; }
+ debug("mail copy: from trash: %d, to trash: %d\n", + mailbox_is_trash(mail->box), mailbox_is_trash(t->box)); + if (!mailbox_is_trash(mail->box) && !mailbox_is_trash(t->box)) { bool src_spam = mailbox_is_spam(mail->box); bool dst_spam = mailbox_is_spam(t->box); bool src_unsu = mailbox_is_unsure(mail->box);
+ debug("mail copy: src spam: %d, dst spam: %d, src unsure: %d\n", + src_spam, dst_spam, src_unsu); + if ((src_spam || src_unsu) && !dst_spam) asbox->movetype = MMT_TO_CLEAN; else if ((!src_spam || src_unsu) && dst_spam)
I'll try it and let you know how I get on. Thanks for your continued support on this. I'd really like to get it sorted out!
!DSPAM:16,4801b7e5124073413946613!
Johannes Berg wrote:
This is what I found in syslog...
Apr 12 21:28:15 kosh imap: antispam: plugin initialising Apr 12 21:28:15 kosh imap: antispam: "trash" is trash folder Apr 12 21:28:15 kosh imap: antispam: "Trash" is trash folder Apr 12 21:28:15 kosh imap: antispam: "Deleted Items" is trash folder Apr 12 21:28:15 kosh imap: antispam: "SpamTrain" is spam folder Apr 12 21:28:15 kosh imap: antispam: "INBOX.SpamTrain" is spam folder ...
It looks like all the folders are being recognised correctly.
Good, yes, that confirms at least the configuration is working.
Is it possible to get more info when messages are being processed?
Not as-is, but you can try something like the patch below:
Apologies for taking so long to reply, but have been travelling...
Anyways, this is what I see with your patch (date/time stamp truncated to allow the details to be on a single line)...
... map: antispam: mail copy: from trash: 0, to trash: 0 ... map: antispam: mail copy: src spam: 1, dst spam: 0, src unsure: 0
So, it looks as though my trash detection is broken. I guess I need to look at the mailbox_is_trash() function next? Can you suggest a patch to debug that?
I'll try and reply quicker as have stopped travelling for the moment!
david
Anyways, this is what I see with your patch (date/time stamp truncated to allow the details to be on a single line)...
... map: antispam: mail copy: from trash: 0, to trash: 0 ... map: antispam: mail copy: src spam: 1, dst spam: 0, src unsure: 0
So, it looks as though my trash detection is broken. I guess I need to look at the mailbox_is_trash() function next? Can you suggest a patch to debug that?
Hmm. Odd. Let's try this. Are you using namespaces? johannes diff --git a/antispam-plugin.c b/antispam-plugin.c index c83d225..1f33820 100644 --- a/antispam-plugin.c +++ b/antispam-plugin.c @@ -60,7 +60,10 @@ static bool mailbox_in_list(struct mailbox *box, char **list) if (!list) return FALSE; + debug("mailbox_in_list"); + while (*list) { + debug(" - list item: %s, box: %s\n", *list, mailbox_get_name(box)); if (mailbox_equals(box, box->storage, *list)) return TRUE; list++; @@ -76,6 +79,7 @@ bool mailbox_is_spam(struct mailbox *box) bool mailbox_is_trash(struct mailbox *box) { + debug("checking trash %s\n", mailbox_get_name(box)); return mailbox_in_list(box, trash_folders); }
Johannes Berg wrote:
Anyways, this is what I see with your patch (date/time stamp truncated to allow the details to be on a single line)...
... map: antispam: mail copy: from trash: 0, to trash: 0 ... map: antispam: mail copy: src spam: 1, dst spam: 0, src unsure: 0
So, it looks as though my trash detection is broken. I guess I need to look at the mailbox_is_trash() function next? Can you suggest a patch to debug that?
Hmm. Odd. Let's try this. Are you using namespaces?
I needed to add an additional entry to the list of trash folders, INBOX.Trash, and then all was fine. IMAP folder names and hierachy do confuse me a bit at times. Thanks for your help and apologies for the noise.
BTW, your debugging patch was really helpful, so maybe it could be added with a conditional? If I code it up, would you be interested?
david
On Sat, 2008-04-19 at 12:17 +0100, David Reid wrote:
Johannes Berg wrote:
Anyways, this is what I see with your patch (date/time stamp truncated to allow the details to be on a single line)...
... map: antispam: mail copy: from trash: 0, to trash: 0 ... map: antispam: mail copy: src spam: 1, dst spam: 0, src unsure: 0
So, it looks as though my trash detection is broken. I guess I need to look at the mailbox_is_trash() function next? Can you suggest a patch to debug that?
Hmm. Odd. Let's try this. Are you using namespaces?
I needed to add an additional entry to the list of trash folders, INBOX.Trash, and then all was fine. IMAP folder names and hierachy do confuse me a bit at times. Thanks for your help and apologies for the noise.
Ah :) I'm not entirely sure about INBOX. vs. just plain names myself.
BTW, your debugging patch was really helpful, so maybe it could be added with a conditional? If I code it up, would you be interested?
I could add a debug_verbose() statement that you need to enable in the .config, what do you think?
johannes
participants (3)
-
David Reid
-
Johannes Berg
-
Tom Hendrikx