Mailinglist Archive: opensuse (3217 mails)

< Previous Next >
Re: [SLE] sa-learn refuses to learn.
  • From: John Andersen <jsa@xxxxxxxxxxxxxx>
  • Date: Sun, 29 Feb 2004 23:09:54 -0900
  • Message-id: <200402292309.54798.jsa@xxxxxxxxxxxxxx>
On Sunday 29 February 2004 20:55, Bob S. wrote:
> On Saturday 28 February 2004 10:39 pm, Ralph Sanford wrote:
> > On Fri, 2004-02-27 at 00:40, Bob S. wrote:
> > > On Wednesday 25 February 2004 01:15 am, John Andersen wrote:
> > > > On Tuesday 24 February 2004 21:07, Bob S. wrote:
> > > > > Originally set up spamassassin and had it learn from my
> > > > > mailboxes in Kmail. worked fine. I set up a special spam
> > > > > mailbox with a sub-mailbox named MissedSpam in which I placed
> > > > > spam that was slipping through. Now I want sa-learn to check on
> > > > > that mailbox and learn from it.
> > > > >
> > > > > What I do is, cd into: '/home/bob/Mail' and then do a: "#
>
> ......<snip>.............
>
> > A quick suggestion based on how I use sa-learn with Evolution mbox.
> > I found that I needed to absolutely specify the missed spam folder
> > mbox.
> >
> > sa-learn --spam --mbox /home/mylocation/MissedSpam/mbox
> >
> > Without the mbox at the end of the directory location, sa-learn would
> > not work.
>
> Thanks for replying Ralph, and you also David
>
> Alas, neither of your suggestions worked for me. Beginning to tick me
> off !!!
>
> I would like to really try John Amderson's little script, but I don't
> know where to put it or what to do with it.

It goes in a file that gets run once in a while.
Put it somewhere where root can run it, and name it whatever you
wish. Then set its permissions so that it is executable
chmod 700 mylittlescript

I run mine out of cron job at 3am every night. (as root).
The script (repeated below) has been modified to work
with maildir NOT mbox...
pen:~/bin # cat my-sa-learn.pl
#!/usr/bin/perl

###################################################################
# A script to automatically update SpamAssassin's Bayesian filter
# Michael Reynolds - michael@xxxxxxxxxxx
# SpinWeb Net Designs - http://www.spinweb.net
###################################################################

# set some variables
$SA_LEARN = "/usr/bin/sa-learn";
$HOME = "/home";
$FOLDER_DIR = "Mail";
$MISSEDSPAM_FOLDER = "MissedSpam";
$NOTSPAM_FOLDER = "NotSpam";

# get a listing of users
@user = `ls -1 $HOME`;

# loop and process
for($i=0;$i<@user;$i++)
{
# trim carriage return
chop($user[$i]);

# define where ham is located
my $user_notspam_folder =
"$HOME/$user[$i]/$FOLDER_DIR/$NOTSPAM_FOLDER/cur";

# if the folder exists, learn from it
if(-e $user_notspam_folder)
{
system("$SA_LEARN --ham $user_notspam_folder/*");
system("rm $user_notspam_folder/*");
}

# define where spam is located
my $user_missedspam_folder =
"$HOME/$user[$i]/$FOLDER_DIR/$MISSEDSPAM_FOLDER/cur";

# if the folder exists, learn from it
if(-e $user_missedspam_folder)
{
system("$SA_LEARN --spam $user_missedspam_folder/*");
system("rm $user_missedspam_folder/*");
}
}

# rebuild the database
system("$SA_LEARN --rebuild");





--
_____________________________________
John Andersen

< Previous Next >
References