Applicable to:
- Plesk for Linux
- Plesk for Windows
Question
How to train SpamAssassin on a Plesk server?
Answer
-
Enable Apply individual settings to spam filtering option in Tools & Settings > Spam Filter.
-
Go to Domains > example.com > Email Addresses > johndoe@example.com > Spam Filter.
-
Tick the option Move spam to the Spam folder:
Click on the screenshot below to expand -
Press the OK button to apply the changes.
-
Using webmail or mail clients, train the spam filter and improve its accuracy by moving spam messages from
Inbox
toSpam
and non-spam messages fromSpam
toInbox
.Note: Spam training is performed on a daily basis while the Plesk daily task ( For Linux servers / For Windows servers ). In case it is required to run such a process manually, execute the command below via command-line:
# plesk daily ExecuteSpamtrain
Note: All messages are automatically removed from the
Spam
folder after 30 days. Move all non-spam messages back to theInbox
folder after performing the Plesk daily task.
-
Log into the server via SSH.
-
Place all existing spam messages for example into the spam folder of the johndoe@example.com mailbox.
-
Run the command below to generate the antispam database:
# sa-learn --spam /var/qmail/mailnames/example.com/johndoe/Maildir/.Spam/cur/
-
Copy the generated files from the step №3 from
/root/.spamassassin/
to the.spamassassin
folder of the required mailbox, for the example johndoe@example.com:# cp /root/.spamassassin/* /var/qmail/mailnames/example.com/johndoe/.spamassassin/
-
Set the correct ownership for the copied files by executing the command below:
# chown -R popuser:popuser /var/qmail/mailnames/example.com/johndoe/.spamassassin/*
Note: after the steps above the antispam database will be applied to johndoe@example.com mailbox.
Comments
14 comments
Hello @Justin Lnch!
>It says above that "SpamAssassin is not being trained by default." But then below says "there is the utility
spamtrain
in Plesk which is executed during the Daily Maintenance Task." Do we need to put this in a cron job each day to have it run? Or is it being run already?No additional actions are needed - once SpamAssassin is installed and enabled, the utility spamtrain is executed automatically once a day in the scope of the Plesk Daily Maintenance Task.
There was indeed confusing wording in the article, so I updated it accordingly.
>Where do we see which daily maintenance tasks are set to run?
You can see the list of the Plesk Daily Maintenance Task subtasks by executing the command plesk daily -l. All subtasks are executed when the main task is executed once a day.
Are there details on how spamtrain works? Which e-mails / folders does it consider to be ham or spam?
It says above that "SpamAssassin is not being trained by default." But then below says "there is the utility
spamtrain
in Plesk which is executed during the Daily Maintenance Task." Do we need to put this in a cron job each day to have it run? Or is it being run already? I would have thought this is being run to learn that all the messages in a users Spam filter are spam?Where do we see which daily maintenance tasks are set to run?
Whenever I enter "/usr/local/psa/bin/sw-engine-pleskrun" in SSH, the console just hangs and returns nothing. Did I missing anything?
Hi,
Is there a way to add some words directly into its dictionary.
Is there a file (or database table e.a.) which we can modify manually?
Jan van den Broek
https://cwiki.apache.org/confluence/display/spamassassin/WritingRules
where can i find spam folder, if there are many with same name??
Hello Jordan Schelew
It's required to have a deep investigation.
This will be continued in a ticket.
There is no spam folder under /var/qmail/mailnames/
Is there another place this could be?
We're attempting to run `/sbin/plesk daily ExecuteSpamtrain` on cron hourly rather than just sticking to the default daily schedule so that those who like to archive or organize their ham messages can do so sooner than next-day. This generally works, but it seems to take equally as long to run each time.
According to the sa-learn docs:
"if you have previously learnt [any messages] as ham, it'll skip them this time around."
Are we sure that's working as it should be? I would expect that running spamtrain repeatedly would make for much faster runs after the first one as it would essentially be skipping everything but maybe 1 or 2 messages that arrived between runs.
I wonder if because Plesk appears to be piping the message contents into sa-learn, rather than specifying file paths, perhaps it's not able to detect what messages it has already trained. If so, then this creates much greater load than is necessary, not only in our scenario where we're running it more frequently, but also in the normal daily run that Plesk does by default as it would have to rescan *all* messages every single day.
Hello @gernot schabkar,
On Plesk for Linux Spam folder has the following path:
/var/qmail/mailnames/example.com/johndoe/Maildir/.Spam/cur/
On Plesk for Windows Spam folder has the location as below:
C:\Program Files (x86)\Mail Enable\Postoffices\example.com\MAILROOT\johndoe\Junk E-mail
Hello,
Plesk is using sa-lern utility to train SpamAssasin. The description of the utility is available in its documentation:
https://spamassassin.apache.org/full/3.1.x/doc/sa-learn.html
And bayes algorithms (which are used in SpamAssasin) are described on another documentation page:
https://wiki.apache.org/spamassassin/BayesInSpamAssassin
Here is the quote:
The Bayesian classifier in Spamassassin tries to identify spam by looking at what are called tokens; words or short character sequences that are commonly found in spam or ham.
If you need more details regarding that, please contact SpamAssasin developers.
Hello @John Bertin
In the example provided in the article mailbox with the name spam@example.com was created.
So directory var/qmail/mailnames/example.com/spam/ is created for spam@example.com mailbox.
It is just an example and in your case, you can use any other mailbox to train Spam Assasin.
For example, if you will create mailbox spammailbox@example.com directory var/qmail/mailnames/example.com/spammailbox/ will be created for that mailbox.
Hi, @John Bertin.
By default output is empty, however you can enable Plesk debug and run the command again in case you want to see what is actually happening.
Please sign in to leave a comment.