Jesper wrote this perl script a few months ago as we worked out such a "training" process for our 6.0 servers. He shared it with me, and I do the same with you. It is approproate to leave his name, etc. intact or you are subverting the notion.
SA needs to see 200 such SPAM before autolearn will initiate. This script will help get to that number and then continue to feed it.
Jesper is quite busy with his new company and at the same time, quite happy with his 6.0 servers. I have moved to the 7.0 series for my own reasons. However, this script works perfectly with the 7.0 servers. You just need to create your own cron job, I run it every 8 hours. We named it LearnAsSpam.pl (and the folders are named the same) but obviously you may do as you wish and modify the script to meet your naming needs. It works out of the box, BUT the users must be granted ssh access for it to run without issue. If your users do NOT have ssh access you need to enter this line..
# chsh -s /bin/bash <user>
patrick
---- snip -----------
#!/usr/bin/perl
#############################################################################
#
# This script has been developed
# by Jesper Knudsen at
http://sme.swerts-knudsen.dk#
# Revision History:
#
# January 18, 2006: Initial version
#############################################################################
use Sys::Hostname;
use esmith::AccountsDB;
my $hostname = hostname();
my $adb = esmith::AccountsDB->open_ro()
or die "Couldnt' open AccountsDB\n";
my @users = $adb->users;
foreach my $user (@users)
{
my $firstname = $user->prop('FirstName');
my $lastname = $user->prop('LastName');
my $key = $user->key;
printf("Checking for user (%s): %s %s\n", $key,$firstname, $lastname);
$MailDir = "/home/e-smith/files/users/" . $key . "/Maildir";
opendir(LOGDIR, $MailDir);
my $dirname = sprintf "LearnAsSpam";
my @logdirs = sort grep { /$dirname/ } readdir(LOGDIR);
closedir(LOGDIR);
foreach my $logdir (@logdirs) {
my $SpamDir = $MailDir . "/" . $logdir . "/cur/";
# printf("Checking Dir: %s\n",$SpamDir);
opendir(SPAMDIR, $SpamDir);
my @spamfiles = sort grep { /$hostname/ } readdir(SPAMDIR);
closedir(SPAMDIR);
foreach $spamfile (@spamfiles) {
my $filetolearn = $Maildir . $SpamDir . $spamfile;
$filetolearn =~ s/;/\\;/g;
$filetolearn =~ s/:/\\:/g;
printf("Learning Spammail: %s\n",$filetolearn);
my $result = su - $key -c "/usr/bin/sa-learn --spam $filetolearn";
printf("Result of sa-learn: %s\n",$result);
# Now delete the file after learning
my $delete = su - $key -c "rm -f $filetolearn";
# printf("Result of delete: %s\n",$delete);
}
}
}
--------------- snip --------------------