Image

Knowledge base → Self-learning Spamassassin on the Spam folder

[Virtual servers]
Date of publication: 31.05.2023

To increase the effectiveness of the Spamassassin spam filter, let's configure its training for all spam folders that are present in all users. Once a day, we will run synchronization to update the database. 

1. Let's update the data:

sa-update
sa-compile

2. Let's create a training script:

nano /usr/local/bin/spam-learn.sh

#!/usr/bin/env bash

sa-learn --no-sync --spam /home/mail///.Junk >> /var/log/sa-learn.log 2>&1 sa-learn --no-sync --ham /home/mail///cur >> /var/log/sa-learn.log 2>&1 sa-learn --sync

2.1 Assign execution rights:

chmod +x /usr/local/bin/spam-learn.sh

3. Let's add a script to run in cron, we will execute it every day at 4 am.

crontab -e

0 4 * * * /usr/local/bin/spam-learn.sh

Done, sync report:

more /var/log/sa-learn.log

Learned tokens from 14 message(s) (14 message(s) examined)





No Comments Yet