Skip to content

Tuning SpamAssassin scores per user and per domain on cPanel

How to set SpamAssassin scoring thresholds per domain or per user on a cPanel server so newsletters reach the inbox without lowering the bar for the whole host.

The default SpamAssassin score on cPanel is calibrated for general-purpose mail. It works fine for transactional and personal mail. It misfires on legitimate newsletters that score 6 or 7 because they have headers like List-Unsubscribe, multipart bodies with promotional imagery, and tracking domains. Raising the global threshold drops the bar for spam everywhere; the right move is per-domain or per-user tuning that lets one mailbox absorb high-scoring legitimate mail without changing the whole host.

What’s happening

SpamAssassin sums scores from many rules per message. The default threshold is 5: anything at or above is tagged spam. cPanel exposes per-user and per-domain configuration through the user_prefs files in /home/<user>/.spamassassin/user_prefs and the global override in /etc/mail/spamassassin/local.cf. A user with required_score 8.0 in their user_prefs accepts scores up to 8 before flagging, leaving the rest of the host at the stricter default.

How to verify

Inspect the active configuration for a user:

cat /home/<user>/.spamassassin/user_prefs 2>/dev/null
spamassassin -D --lint 2>&1 | grep "required_score"

For a recent message, retrieve the score breakdown:

grep "X-Spam-Status" /home/<user>/mail/example.com/<addr>/cur/<msg> | head

The X-Spam-Status header lists each rule that triggered and its contribution to the total score. That tells you which rules are misfiring on legitimate mail.

The fix

  1. Identify the rules causing the false positives by reading the X-Spam-Status header on a misclassified legitimate message. Common culprits on newsletters: HTML_MESSAGE, MIME_HTML_ONLY, URI_HEX, T_DKIM_INVALID, LIST_PARTIAL_TRUNC.
  2. For a single user, edit /home/<user>/.spamassassin/user_prefs. Add required_score 8.0 to lift the threshold, or add score RULE_NAME 0 to neutralize a specific noisy rule. Restart Dovecot/Exim is not needed; the user_prefs are read per delivery.
  3. For a whole domain, edit /etc/mail/spamassassin/local.cf with per-domain overrides via SpamAssassin’s plugin syntax, or set per-user prefs for each mailbox in that domain. cPanel also exposes per-account spam filtering preferences in the user interface.
  4. Whitelist trusted senders explicitly rather than raising the global threshold. whitelist_from sender@trusted.example.com and whitelist_from_dkim trusted.example.com are scoped exemptions that don’t degrade detection elsewhere.
  5. Never raise the global required_score above 7 unless you accept that spam volume will visibly increase. The right answer for chronic false positives is targeted rule scoring, not a higher threshold.

When the same per-domain tuning has to be maintained across a fleet of cPanel servers, Stack Harbor handles it as part of cPanel server management.