Jason Morrill wrote: > I'm hoping that somebody here has done what I'm attempting to do. > > My users use a web-mail front end for reading email. There is an > option to Mark-As-Spam which moves the message into a SPAM folder and > removes it from their current folder. Very easy to train even the > most inexperienced users to do this! > > The tricky part comes when training Spam Assassin. I'd like a nightly > script to run for every user without the need for a cron job for > every single user. This ideal single script would train Spam Assassin > as if it were each user in turn and sync their personal database. > > Something like this pseudo-script: > for each user in /home > sa-learn --ham the-ham-folder > sa-learn --spam the-spam-folder > sa-learn --sync > next user > > It seems so simple but I'm having all kinds of trouble getting > sa-learn to understand that I'm changing users and databases. > > I've tried using 'sudo' and 'sa-learn' with limited success. > > I've also tried Mail::SpamAssassin but I can't get it to spit back > anything. Instead I get messages like this: > "Can't call method "dump_bayes_db" on an undefined value at > /usr/share/perl5/Mail/SpamAssassin.pm line 538." > > All suggestions are appreciated. Here's the technical info if you'd > like: Debian Woody > SpamAssassin version 3.0.4 > Exim version 3.35 > MailScanner version 4.40.11
If these are real users, then the script should be fairly simple. For each user do this: su - username -c sa-learn --ham /path/to/ham su - username -c sa-learn --spam /path/to/spam For virtual users, it's a bit more complicated. You should be able to do something like this for each user: $HOME=/virtual/home/directory $SADIR=$HOME/spamassassin sa-learn --ham --dbpath $SADIR/bayes --prefs-file=$SADIR/user_prefs --dir $HOME/path/to/ham sa-learn --spam --dbpath $SADIR/bayes --prefs-file=$SADIR/user_prefs --dir $HOME/path/to/spam The sa-learn commands should be all on one line... Make sure you are logged on as the user who owns the databases. You may be able to leave off the --prefs-file option, I'm not sure. -- Bowie