Autolearn Mails that are sent to a spamtrap Address

Questions and answers about how to do stuff
Post Reply
benscha
Posts: 19
Joined: 23 Jan 2018 07:19

Autolearn Mails that are sent to a spamtrap Address

Post 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...
always happy for any hints and tipps! :clap: | EFA 3.0.2.6
akos
Posts: 4
Joined: 11 Feb 2020 09:16

Re: Autolearn Mails that are sent to a spamtrap Address

Post by akos »

Hi Benscha,
it's works with efa 4?
could you describe in more detail how to do it?
thx,
á
Post Reply