Linode Forum
https://forum.linode.com/

Moving IMAP messages from shell after learning SA spam
https://forum.linode.com/viewtopic.php?f=11&t=4644
Page 1 of 1

Author:  cboshuizen [ Thu Sep 17, 2009 6:29 pm ]
Post subject:  Moving IMAP messages from shell after learning SA spam

Hi all,

I am trying to train the SpamAssassin Bayes filter from the shell, but instead of deleting the spam messages I want to move them to an archive. Is there an easy way to do the move via a shell script? What I have doesn't work, as my mail clients still think the mail is in the original folder, and then the messages duplicate.

Here is what i have so far (based on http://www.trumphurst.com/weblog/tagspam.html):

Code:
# Tag spam in the spam maildir, and notspam in the notspam maildir
# MOVE the tagged mail
#
# The virtual domain where the spam and notspam mailboxes live
MAILHOME=/var/spool/mail/virtual/USERNAME

# The spam and notspam mailboxes
SPAMDIR=.Junk
SPAMARC=.Junk_Archive
HAMDIR=.Message_Archive

# Run sa-learn on all the mail, whether it has been seen by a mail reader or not
sa-learn --spam $MAILHOME/$SPAMDIR/new
sa-learn --spam $MAILHOME/$SPAMDIR/cur

# Move tagged mail, so it isn't used again
mv $MAILHOME/$SPAMDIR/new/* $MAILHOME/$SPAMARC/new/
mv $MAILHOME/$SPAMDIR/cur/* $MAILHOME/$SPAMARC/cur/
#mv $MAILHOME/$SPAMDIR/courierimapkeywords/.*
#     $MAILHOME/$SPAMARC/courierimapkeywords/
rm $MAILHOME/$SPAMDIR/courierimapkeywords/.*


Anyway, it does seem to move the messages, but clearly isn't doing so in a way valid under IMAP, as as soon as I view the Junk folder in my client the messages reappear, as I mentioned.

Any suggestions on how to properly do this?

Thanks!

Chris

Author:  cboshuizen [ Mon Sep 21, 2009 1:20 am ]
Post subject: 

Did I post this in the wrong forum?

Author:  freedom_is_chaos [ Mon Sep 21, 2009 3:44 am ]
Post subject: 

Try ServerFault, I guess no one here knows the answer.

Author:  kvutza [ Sun Oct 04, 2009 3:52 am ]
Post subject:  Dovecot

I use something similar and it works for me. Well, my setup is based on Dovecot/IMAP.

Author:  cboshuizen [ Mon Oct 05, 2009 12:48 pm ]
Post subject: 

Thanks, are you able to post what you use?

Author:  kvutza [ Mon Oct 05, 2009 2:54 pm ]
Post subject: 

Sorry, I do not use anything special, just mv like you. The difference is that you (according to your paste above) use Courier as IMAP server, while I use Dovecot as IMAP server. Thus the solution should be 'switch to Dovecot'. It does not sound reasonable to switch just because of that. Still, Dovecot is popular and secure, with many features. I myself had used Courier years ago, and switched to the Dovecot, do not regret it.

Author:  cboshuizen [ Mon Oct 05, 2009 3:18 pm ]
Post subject: 

OK, thanks I'll have another shot at it.

Author:  sleddog [ Mon Oct 05, 2009 9:06 pm ]
Post subject: 

Have a look at 'cleanup-maildir', a python script.

The script: http://svn.houseofnate.net/unix-tools/t ... up-maildir

Some discussion: http://www.ducea.com/2006/11/25/cleanup ... old-mails/

Page 1 of 1 All times are UTC-04:00
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/