I have recently set up a Cyrus IMAP email system on ClearOs 7 - it is configured as it comes out of the box, to deliver mail locally, and to receive mail for my users from elsewhere.
A lot of spam from people who claim to be Russian has been arriving. It seems to be detected as such (the Subject is prefixed by [SPAM]
), but it still appears in the user's inboxes.
Also some ham has been filed in the SPAM folder.
I want to set up a system for the users to tell spamassassin about unrecognised spam, and incorrectly spammed ham. To that end I set up additional folders in each user's mailboxes for Junk and NotSpam. The users move any spam they find in their inbox to Junk, and and normal mail they find in their spam to NotSpam.
I now want to write or find a script which will look in the Junk folder, send the contents to sa-learn --spam
, then move the messages to the regular spam folder. It should also look in the NotSpam folder, send the contents to sa-learn --ham
, and move them into the inbox.
I have tried to write shell scripts for this, and I have also downloaded and tried to follow sa-learn-cyrus, plus looked at the script I found at wiki.apache.org/spamassassin/RemoteImapFolder.
My script finds the email files OK, and sends them to sa-learn
(although I worry that the Spam score and subject alteration should really be reversed before doing this, and I don't know how). I'm stuck on moving the messages to the correct folder, as I suspect a plain Linux mv command will just confuse cyrus, as it has cache, header, index and squat files in the folder, which presumably need to be updated.
sa-learn-cyrus seems to be able to find emails ok, but (as far as I can tell from running it in simulate mode) it does not attempt to move the mails to the right folder, just purges them.
The other script runs OK (after suitable modifications for my setup), but the Junk emails keep reappearing in the inbox.
Specific questions I need to answer are:
1) Why does mail with [SPAM] in the Subject still appear in the INBOX?
2) Is there an existing script which does what I want?
3) What is the proper method to move an email from one mailbox folder to another in Cyrus? Ideally callable from a shell script.