
Hard-coded rules are fine for catching spam, but an even smarter solution is to combine these rules with a score from a probabilistic spam classifier. To add your own rules, you’ll need to incorporate them into your local configuration and set the parameter ‘allow_local_rules’ to 1. Have a look at all of SpamAssassin’s default rules here. While the McGrail Foundation which developed the KAM rules is closely associated with Apache’s SpamAssassin, the ruleset is not strictly speaking part of SA’s core rule collection. Remember when we said that a score of 5.0 often suffices for a spam classification? So if your email uses the above pattern, it gets dangerously close to the spam folder. When this meta rule is triggered, a spam score increases by 4.3 points. This is ensured by a ‘meta’ rule (a complex combination of expressions) which requires that the sum of two individual patterns is at least two. Interestingly, the rule only gets triggered if the text includes the claim that the recipient can make ‘twice as much’ (not more, not less) money than with their current employer. Together, the regexes describe a pattern often used in spammy email in which a sender describes a job offer with unrealistically great conditions. Regexes are powerful expressions for pattern-matching in text and are frequently part of the SpamAssassin filter. The next two lines are more interesting: tagged as ‘body’, they consist of two Perl regular expressions (‘regexes’). The first line is simply a comment for the developer that isn’t very descriptive. You can probably figure out the type of scam targeted here, but let’s go through it line-by-line. So what does a SpamAssassin rule look like? Let’s look at an example that uses the KAM rules, a widely used custom rule set: Rather, you should aim for the lowest possible score. Therefore, when you test your emails against the SpamAssassin filter, simply being under the 5.0 threshold may not be enough. That’s why your email might make it into the inbox of one recipient, but land in the spam folder of another-they might be using an email service with more restrictive anti-spam settings. It’s common to tweak the threshold to reach a good balance between low numbers of false positives (genuine email wrongly classified as spam) and false negatives (spam email that tricks the filter into thinking it’s genuine). By default that threshold is set to 5.0 in the SpamAssassin configuration, though it can be adjusted by the user. If an email passes a certain threshold, it’s regarded as spam. Therefore, when passing your transactional emails through the SpamAssassin filter, you should aim for a lower rather than a higher score. Perhaps counterintuitively, a higher score signifies a higher probability that an email is spam. It then returns an aggregated SpamAssassin score. The SpamAssassin filter runs its tests on each incoming email and adds up the values for the rules that are triggered.

The SpamAssassin scoreĮach SpamAssassin rule is associated with a value that can be either negative or positive.



Many email providers rely on SpamAssassin scores to classify incoming email as spam or the opposite, ‘ham’. Users can add and adapt rules, or simply resort to SpamAssassin’s spam classifier and train it with their own data. These include scanning an email’s body and header, and checking a sender’s IP against several different block and allow lists. The filter employs a range of different tests. It was initially released in 2001 with the aim of providing a robust and customisable filter for detecting ‘email spam’, the Monty Python-inspired term for the practice of sending out unsolicited emails en masse.
SPAMASSASSIN RULE SOFTWARE
SpamAssassin (officially, ‘Apache SpamAssassin’) is an open-source project developed and operated by the Apache Software Foundation. Inspecting and improving your SpamAssassin results will help you write better emails that your recipients will be happy to receive. In this article, we’ll look at how a SpamAssassin score is calculated and what you can do it improve it. The filter assigns scores to emails to separate the genuine from the unwanted. It uses comprehensive spam-fighting methods to keep inboxes clear of unwanted email. SpamAssassin (SA) is a well-established email filtering system designed to live up to its name.
