$linuxjunkies
>

spamassassin(1)

SpamAssassin is a mail filter that uses various techniques to identify and score spam messages.

UbuntuDebianFedoraArch

Synopsis

spamassassin [OPTION]... [FILE]...

Description

SpamAssassin analyzes email messages and assigns spam scores based on content analysis, DNS blocklists, Bayesian filtering, and other heuristics. It can be used as a standalone filter or integrated into mail systems like Postfix or Exim.

The command reads messages from files or stdin, performs tests, and outputs results with headers showing the spam score and detected rules. Configuration is typically stored in /etc/mail/spamassassin/ or ~/.spamassassin/.

Common options

FlagWhat it does
-tRun in test mode; exit with status 0 if not spam, 1 if spam
-rPrint SpamAssassin report to stdout (detailed results)
-eExit with status 1 if message is spam, 0 otherwise
-dRun in daemon mode (requires spamd); process via socket
-lSet the threshold score; messages scoring above this are spam
-c <file>Use alternate configuration file instead of default
--cf=<file>Specify configuration file with long option syntax
-DPrint debug output to stderr; useful for troubleshooting
--versionPrint SpamAssassin version and exit
--helpDisplay help message with available options

Examples

Analyze an email file and output with spam headers added

spamassassin < message.eml

Test if a message is spam using exit status

spamassassin -t < message.eml && echo 'not spam' || echo 'spam'

Generate a detailed spam report with all rules triggered

spamassassin -r message.eml

Pipe message through SpamAssassin and exit with status 1 if spam

cat message.eml | spamassassin -e

Classify message as spam if score exceeds 5.0

spamassassin -l 5.0 message.eml

Use a custom configuration file for analysis

spamassassin -c /etc/spamassassin/custom.cf message.eml

Enable debug output and filter for matching rules

spamassassin -D < message.eml 2>&1 | grep -i rule

Generate spam reports for all email files in a directory

find /var/mail -name '*.eml' -exec spamassassin -r {} \;

Related commands