Batch Learn

Questions and answers about how to do stuff
Post Reply
nicola.piazzi
Posts: 389
Joined: 23 Apr 2015 09:45

Batch Learn

Post by nicola.piazzi »

It can be useful to query spamassassin database and learn bayes basing on results
In this batch file an example , we scan for messages that have RRWL_D in the report and then invoke sa-learn on the file using find on the message number (it is very simple to use also for learn spam) :


# hamlearn.sh
# Daily scheduled it train spamassassin regard some selected messages
# Put in cron
# 05 04 * * * /batch/hamlearn.sh

# Variables
Q="/var/spool/MailScanner/quarantine" # Quarantine folder
L="/usr/bin/sa-learn --ham --no-sync" # Message learn command


# START

# Retrieve in array m all message id that have RRWL_D in spamreport
vsql="SELECT id FROM maillog WHERE spamreport LIKE '%RRWL_D%';"
m=( $( echo $vsql | mysql -N -u root -p<YOURPASSWORD> -D mailscanner ) )

# Scan array and learn ham
for i in ${m[@]}; do
# Learn
find $Q -type f -name $i | $L
done
User avatar
pdwalker
Posts: 1583
Joined: 18 Mar 2015 09:16

Re: Batch Learn

Post by pdwalker »

Nicola,

You should make one definitive post for the RRWL feature. You have posts everywhere and newcomers might find it confusing.

Include the latest code and features (like using the batch learn script above)
User avatar
shawniverson
Posts: 3783
Joined: 13 Jan 2014 23:30
Location: Indianapolis, Indiana USA
Contact:

Re: Batch Learn

Post by shawniverson »

Post Reply