Batch Learn
Posted: 22 Jul 2016 14:58
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
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