Page 1 of 1

Autolearn Mails that are sent to a spamtrap Address

Posted: 24 Jun 2019 15:00
by benscha
Hi Guys

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

i have created a symlink to /etc/cron.hourly so the script will run every hour. ;)

enjoy and stay tuned...

Re: Autolearn Mails that are sent to a spamtrap Address

Posted: 11 Feb 2020 09:21
by akos
Hi Benscha,
it's works with efa 4?
could you describe in more detail how to do it?
thx,
รก