if anyone has published some spamtrap Mailaddresses here you can find a small script that will autolearn each mail that arrives to this addresses.
Before Start:
You need to create a file with your spamtrap addresses listed. in my case the file is in "/scripts/spamtrap_addresses"
Code: Select all
#Read a File with some Spamtrap Addresses and extracts information from maillog
while read sender
do
grep $sender /var/log/maillog >>/tmp/autolearn_spam_raw
done < /scripts/spamtrap_addresses #Create this file and put in some spamtrap addresses
#gets the message ID from the last output
grep ': Message' /tmp/autolearn_spam_raw | awk '{print $7 >"/tmp/autolearn_spam"; }'
#set date for spam path
d=`date +%Y%m%d`
#sa-learn the specific mails
while read mail
do
sa-learn --spam /var/spool/MailScanner/quarantine/$d/spam/$mail --progress
done < /tmp/autolearn_spam
rm -rf /tmp/autolearn_spam
rm -rf /tmp/autolearn_spam_raw
enjoy and stay tuned...