buy
How to Train SpamAssassin

Overview

SpamAssassin is used to filter unwanted emails. Over time, spam patterns change, so you may need to train SpamAssassin to improve its accuracy.
Training SpamAssassin means teaching it which emails are spam and which are legitimate (ham) using real messages from your mailbox.
Note:
To use the sa-learn tool, the SpamAssassin service will need to be running and enabled for the related account, and Auto-delete must be disabled for SpamAssassin so that any false positives can be marked as 'ham.' 
⚠️Warning
The sa-learn utility should not be run as the root user. Always execute it as the corresponding Webuzo user to ensure the training is applied to the correct SpamAssassin configuration.

Procedure

Step 1: Prepare Your Emails
  • Log in to Webmail and prepare your mailboxes:
  • Move unwanted emails to the Junk folder
  • Keep legitimate emails in the Inbox
This ensures accurate training.
Step 2: Access the Server
You can access the server as the Webuzo user using one of the following methods:
Option 1: Using Webuzo Panel 
  • Log in to the Webuzo Enduser Panel
  • Navigate to Terminal
  • This will open a shell session as the Webuzo user

Option 2: Using SSH
Connect to the server via SSH and switch to the Webuzo user:
su - USERNAME
Step 3: Train SpamAssassin
After preparing your emails and accessing the server, you can train SpamAssassin using the sa-learn utility.
  • Train Spam (Junk Emails):-
Run the following command to train SpamAssassin with spam emails:
sa-learn --spam /home/USERNAME/mail/DOMAIN/EMAIL/.Junk/{cur,new}
  • Train Ham (Legitimate Emails):-
    Training ham means teaching SpamAssassin to recognize legitimate emails so they are not marked as spam.
Run the following command to train SpamAssassin with legitimate emails:
sa-learn --ham /home/USERNAME/mail/DOMAIN/EMAIL/{cur,new}
  • Alternate Spam Folder:-
In some configurations, spam emails may be stored in the .Spam folder. In such cases, use:
sa-learn --spam /home/USERNAME/mail/DOMAIN/EMAIL/.spam/{cur,new}
(Replace USERNAME with the Webuzo user’s username, DOMAIN with the domain name, and EMAIL with the email account name before running the commands.)
Note:
For better accuracy, train SpamAssassin with a sufficient number of emails. A small number of messages will not significantly improve filtering.
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list