Apache SpamAssassin is one of the most widely deployed open-source spam filters. It sits behind many hosting providers, university systems, corporate gateways and self-managed mail servers, and its scoring model has influenced countless commercial products and online "spam test" tools. It works by running a large set of tests on each message, adding or subtracting points for each one that matches, and comparing the total with a threshold. A message above the threshold is treated as spam. Large mailbox providers such as Gmail or Microsoft use their own, far more complex systems, so a SpamAssassin score is never a forecast of what they will do, but it is a useful lens on message quality, and many business recipients really do use it. This guide explains how scoring works, how to read the headers it adds, which rule hits are common for legitimate senders, how to fix them, and how to test your mail without fooling yourself. For wider filter behaviour see how content filters work and the spam checker.
How the score is built
SpamAssassin applies several kinds of tests, each with a configurable score. Positive scores indicate spam-like features, negative scores indicate legitimacy. Typical categories:
| Category | Examples of what is checked | Notes |
|---|---|---|
| Header tests | Missing or malformed Date, Message-ID, From mismatches, forged Received lines | Often point to custom scripts. See the Date header and Message-ID |
| Body and text tests | Phrases, capital letters, exaggerated claims, odd character use | Mostly rule-based patterns |
| HTML and structure tests | HTML-only messages, tiny fonts, hidden text, image-heavy mail | See plain-text alternatives |
| URI and blocklist tests | Links to listed domains, raw IP URLs, URL shorteners, domain blocklists | See shorteners and link reputation |
| Authentication tests | SPF, DKIM, DMARC results and whether the sender is allowlisted | Passing results give small negative scores; failures add points |
| Network tests | DNS blocklists for the sending IP, URL blocklists, checksums of known bulk mail (when enabled) | Depends on server configuration and network access |
| Bayesian classifier | Statistical learning from the site's own spam and ham | Varies between installations; can push a score either way |
| Local rules and plugins | Site-specific additions | Explains why the same message scores differently elsewhere |
The default threshold for marking a message as spam is 5.0 points in many installations, but administrators can raise or lower it, and gateways may use different actions at different levels (tag, quarantine, reject). Treat any single value as a guide.
Reading the headers
X-Spam-Status: No, score=2.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID,
HTML_IMAGE_RATIO_02,HTML_MESSAGE,SPF_PASS,URIBL_BLOCKED autolearn=no
X-Spam-Level: **
X-Spam-Report:
* -0.1 SPF_PASS SPF: sender matches SPF record
* 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid
* -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature
* 0.0 HTML_MESSAGE BODY: HTML included in message
* 1.0 HTML_IMAGE_RATIO_02 BODY: HTML has a low ratio of text to image areaThe status line says whether the message was flagged, the total score and the threshold ("required"), and lists the tests that fired. The report, when present, gives each rule's points and a description. Not all servers add these headers; some strip them before delivery. If you control the recipient server, enable report headers; otherwise send a test message to a mailbox that shows them. See reading headers.
Rule hits that often affect legitimate mail
| Rule (typical name) | What triggered it | What to do |
|---|---|---|
| HTML_IMAGE_RATIO_* | Too little text compared with image area | Add real text; avoid mails made of one large image. See image hosting |
| MIME_HTML_ONLY | No plain-text part | Add a text alternative |
| MISSING_DATE / MISSING_MID / INVALID_DATE | Header problems from custom code | Let a mail library generate headers. See Date header |
| FROM_EXCESS_BASE64 / SUBJ_ALL_CAPS | Encoding or style choices | Use readable subjects and standard encoding. See emoji and encoding |
| SPF_FAIL / SPF_SOFTFAIL / DKIM_INVALID | Authentication problems | Fix records and alignment. See authenticate your domain |
| RDNS_NONE / RCVD_IN_* (blocklists) | Sending IP lacks reverse DNS or is listed | Fix PTR; check the blocklist check |
| URIBL_* / URL shortener rules | Links to listed or abused domains | Use your own domains for links |
| FREEMAIL_FROM with business content | Sending commercial mail from a free mailbox address | Use your own domain |
| TVD_SPACE_RATIO / obfuscation rules | Odd spacing or hidden characters in HTML | Clean the template code |
| BAYES_xx | The site's classifier finds the message close to known spam | Improve relevance; ask recipients to train the filter by marking wanted mail as not spam |
| LOTS_OF_MONEY / FREE_ type body phrases | Promotional wording | Write plainly; avoid exaggerated claims |
Testing your own mail
- Send a test message to an address that shows SpamAssassin headers, such as a mailbox on a server you control, or use an online test that reports the rules. Prefer tools that state which version and ruleset they use.
- Test the real message, sent from your real sending path, not a copy pasted into a different system. Authentication and IP reputation are part of the score.
- Read the rule list, not only the total. Fix causes in order of points.
- Change one thing at a time and retest, so you know which fix worked.
- Test variants: different recipients, with and without images, with the plain-text part, and with the final links and tracking.
- Keep a baseline. A template that normally scores 0.5 and suddenly scores 4 deserves a look at what changed.
- Build the check into your release routine. See rendering tests and template versioning.
Why a good score is not enough
- Large providers use machine-learned models and reputation data you cannot see, with engagement as a major input.
- Sender reputation (IP and domain) matters more than content for most major providers. See email reputation.
- A low score on a test server says nothing about how Gmail, Microsoft or Yahoo will treat a message from a new domain with no history.
- Conversely, a message with a few points of penalty can reach the inbox of a recipient who has engaged with you before.
- Test tools differ in rules, versions and weights, so scores from two tools will differ.
Running SpamAssassin yourself
If you operate SpamAssassin for your own users, keep rules updated, train the Bayesian database with confirmed spam and ham, tune thresholds to your tolerance for false positives, and review quarantined mail regularly. Allowlist sparingly: an allowlist entry bypasses scoring and attackers will exploit it. Use authentication-aware allowlists (for example allowing a sender only if DKIM passes) where possible. Log scores to spot trends, and give users a simple way to report false positives. See allowing senders and gateway allowlisting.
A workflow for senders
- Authenticate fully and align (SPF, DKIM, DMARC) and fix reverse DNS.
- Send multipart messages with sensible text, restrained HTML and a healthy text-to-image ratio.
- Use your own domain for From and links.
- Keep subjects honest and avoid shouting styles.
- Run the final message through a test and fix any rule worth more than a point.
- Monitor real-world results: complaints, bounces, placement. See placement testing.
SpamAssassin scores are a tidy way to find the avoidable mistakes in a message. Use them to clean up your content and structure, then rely on authentication, list quality and engagement for the rest.
Check your authentication first Many rule hits disappear when SPF, DKIM and DMARC are right.
References and further reading
Frequently asked questions
What is a SpamAssassin score?
The total points from rules that matched a message. A score above the site threshold, often 5.0, marks it as spam.
Does a low score guarantee inbox delivery?
No. Large providers use their own systems and reputation data, so a test score is only a guide to content quality.
Where can I see which rules fired?
In the X-Spam-Status and X-Spam-Report headers, if the receiving server adds them.
What is the easiest way to lower a score?
Fix authentication and reverse DNS, add a plain-text part, balance text and images and use your own link domains.
Why do two spam test tools give different scores?
They use different SpamAssassin versions, rulesets, network tests and local settings.