blog
SpamAssassin spam filters: setup, testing, and tuning playbook
Set up SpamAssassin spam filters, run SpamAssassin tests, tune rule thresholds, and operate production mail filtering safely.
SpamAssassin spam filters are effective when you combine correct installation with a controlled tuning process, not ad-hoc rule edits.
Quick answer: when should you use SpamAssassin?
Use SpamAssassin when you need local or self-managed filtering decisions, transparent rule scoring, and tunable policy behavior for inbound or relay-proxied mail environments.
A useful SpamAssassin test should run against the final rendered message, not a draft. Pair each rule-change test with SpamAssassin score interpretation and a broader spam score checker workflow.
Architecture choices before setup
Choose your operating model first:
- Mail gateway filtering (preferred for centralized control)
- Per-host filtering (simpler but harder to standardize)
- Hybrid mode with policy boundaries by domain or tenant
Key decision factors:
- Team ownership (platform vs app team)
- Required auditability
- Expected message volume and burst profile
Baseline installation and service model
Debian or Ubuntu
sudo apt-get update
sudo apt-get install spamassassin spamc
sudo systemctl enable spamassassin
sudo systemctl start spamassassin
macOS (local lab)
brew install spamassassin
spamd
Core file to tune
Most environments use:
/etc/spamassassin/local.cf
Initial tuning profile
Start conservative, then tighten with evidence:
required_score 5.0
use_bayes 1
bayes_auto_learn 1
Add explicit sender controls only when justified:
whitelist_from trusted-sender@example.com
blacklist_from bad-sender@example.com
Avoid large manual whitelist growth without periodic review.
Safe tuning workflow
| Phase | Goal | Action |
|---|---|---|
| Baseline | Avoid false positives | Keep default score near 5.0 and collect samples |
| Observation | Identify noisy rules | Track top triggered rules weekly |
| Adjustment | Improve precision | Tune rule weights incrementally |
| Validation | Prevent regressions | Re-test known-good and known-bad corpora |
Testing strategy for rule updates
Run three test sets every time you tune filters:
- Legitimate transactional emails (OTP, reset, invoices)
- Marketing and lifecycle campaigns
- Known malicious or spam-like samples
Include an automated rollback path if false positives spike.
For each test set, record the SpamAssassin score, the highest-impact rules, and whether the same message passes sender-auth and inbox-placement checks. A lower score is useful only if real messages still render, authenticate, and arrive where expected.
Operational metrics to monitor
Track these signals continuously:
- Spam catch rate
- False positive rate
- Rule hit concentration (top noisy rules)
- Score distribution by message class
- Time-to-remediate after filter incidents
If one rule dominates failures, tune that rule family first.
Common anti-patterns
- Lowering threshold aggressively without historical baseline
- Whitelisting entire domains to bypass bad templates
- Ignoring authentication drift (SPF, DKIM, DMARC)
- Mixing test and production tuning without isolated validation
MailSlurp-assisted validation workflow
Use MailSlurp to validate filter policy changes before full rollout:
- Email sandbox for deterministic send/receive checks
- Email spam checker for pre-rollout scoring
- SpamAssassin score guide for score-band interpretation
- Spam score checker for release-gate triage
- Email deliverability test for placement validation
- DMARC monitoring for authentication and policy drift
- Email integration testing for CI gates
Final take
SpamAssassin is strongest as an operational system: baseline, measure, tune, validate, and repeat. Teams that treat spam filters like code changes ship safer email programs with fewer inbox surprises.