• Plesk Uservoice will be deprecated by October. Moving forward, all product feature requests and improvement suggestions will be managed through our new platform Plesk Productboard.
    To continue sharing your ideas and feedback, please visit features.plesk.com

Issue SpamAssassin Bayes Training in Plesk: Daily cron disabled by default – bug or by design?

dbmtrde

New Pleskian
Server operating system version
Ubuntu 22.04
Plesk version and microupdate number
Plesk Obsidian 18.0.72 Update 3 / Plesk Obsidian 18.0.72.3
Hello everyone,

I’ve been troubleshooting SpamAssassin on my Plesk server (**Ubuntu 24.04, Plesk Obsidian 18.0.72 Update 3 **, `psa-spamassassin` installed) and discovered what looks like either a bug or at least very confusing behavior.

1. Expectation according to Plesk documentation
Plesk KB states that SpamAssassin (including Bayes) should be trained daily automatically when users move emails into their “Spam” folders.
It also mentions that Bayes will start learning automatically once enough spam/ham samples are present (default: 200 spam + 200 ham).

References:
- How does SpamAssassin training work in Plesk?
- How to train SpamAssassin on Plesk server?

2. Actual behavior on my server
In `/etc/cron.daily/` there is a script called `spamassassin`, but its content is:

Code:
#!/bin/sh
# This task was disabled by psa-spamassassin package
exit 0

→ So the daily training never runs.

Checking logs also shows no sign of `ExecuteSpamtrain` or similar:

Code:
grep -i spamtrain /var/log/plesk/panel.log
grep -i ExecuteSpamtrain /var/log/plesk/panel.log
# no results

Dumping Bayes DB initially showed zero tokens:

Code:
sa-learn --dump magic
# nspam = 0, nham = 0

Only after running manual training like this:

Code:
sa-learn --spam /var/qmail/mailnames/*/*/Maildir/.Spam/cur/

…I finally got a proper Bayes DB (`nspam = XXXX`, `ntokens = XXXXXXX`).

3. The problem
Without daily Bayes training, even very obvious spam was not recognized.
SpamAssassin headers showed `autolearn=no`, despite plenty of spam in user folders.

Only after manual `sa-learn` did Bayes begin working.

4. Questions
- Is it intentional that the `spamassassin` cronjob is disabled by the psa-spamassassin package?
- If yes, how is Bayes supposed to train itself automatically, as advertised in the docs?
- Shouldn’t there be a default task like `ExecuteSpamtrain` enabled on installation?

5. Suggestion
Either Plesk should re-enable the daily training cron by default,
or at least clearly notify admins in the Panel that Bayes will not learn unless a manual cron is set up.

Otherwise, SpamAssassin in a fresh Plesk installation remains practically untrained → resulting in much more spam delivered to end users (which in my case already led to customer complaints).

Question to the Plesk team / community:
Is this a bug or intended behavior? Has anyone else experienced the same issue?

Thanks.
 
The `spamassassin` cronjob is disabled because daily spam training is executed as part of Plesk's daily maintenance script. Which can also be run manually using the plesk daily ExecuteSpamtrain command.

The default configuration for Spamassassin is to have a separate Bayes database for each mailbox, stored in the /var/qmail/mailnames/<domain>/<mailbox>/.spamassassin/ directory. Just running sa-learn --dump magic will show nothing learned as this assumes there is a global Bayes database, but there is none. Instead you'll have to run the sa-learn utility with the --dbpath option (and the path the Bayes database) to get any results.

If you'd rather would like to use a global (server wide) bayes database, you'll have to modify the spamassassin configuration. Which can be done by simply adding the following configration to your local.cf file. (If you have concirable mail traffic any many mailboxes on your server it might be better to setup a MariaDB database for the Bayes database, instead of use a file.)

Code:
use_bayes 1
use_bayes_rules 1
bayes_auto_learn 1
bayes_path /var/lib/spamassassin/bayes/bayes
bayes_file_mode 0777

Make sure to create the /var/lib/spamassassin/bayes/bayes direcoty if it doesn't exist yet.

Hope this helps.
 
Back
Top