You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by "--[UxBoD]--" <ux...@splatnix.net> on 2006/05/26 19:51:29 UTC

sa-learn

Hi,

i use SpamAssassin with MailScanner and Postfix and was wondering how I get newly spam entered to the bayes database.  I have created a little script
that polls our accounts :-

#!/bin/bash

LOCK_FILE=/var/lock/subsys/spam_check.lock

if [ -f ${LOCK_FILE} ]; then
	logger -p local0.info -t learn-spam "Still running !"
	exit
fi

touch ${LOCK_FILE}

for user in spam xyz abc
do
	typeset -i count=0

	for file in /home/${user}/.maildir/.LEARN-SPAM/cur/*
	do
		if [ -f ${file} ]; then
			sa-learn --spam ${file} && rm ${file}
			let count=${count}+1
		fi
	done 

	for file in /home/${user}/.maildir/.LEARN-HAM/cur/*
	do
		if [ -f ${file} ]; then
			sa-learn --ham ${file} && cat ${file} | \
			spamassassin -d > ${file} && mv ${file} /home/${user}/.maildir/cur
		fi
	done
done

if [ ${count} -gt 0 ]; then
	logger -p local0.info -t learn-spam "${count} email(s) processed"
fi

trap "rm -f ${LOCK_FILE}" exit

exit 0

but for this to work I presume that it will need to be run as the effective user ie. Postfix ?

Thanks all.  And for UK people have a lovely Bank Holiday.

Phil

-- 
This message has been scanned for viruses and dangerous content by MailScanner,
and is believed to be clean.