spamassassin(1)
SpamAssassin is a mail filter that uses various techniques to identify and score spam messages.
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
| Flag | What it does |
|---|---|
-t | Run in test mode; exit with status 0 if not spam, 1 if spam |
-r | Print SpamAssassin report to stdout (detailed results) |
-e | Exit with status 1 if message is spam, 0 otherwise |
-d | Run in daemon mode (requires spamd); process via socket |
-l | Set 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 |
-D | Print debug output to stderr; useful for troubleshooting |
--version | Print SpamAssassin version and exit |
--help | Display help message with available options |
Examples
Analyze an email file and output with spam headers added
spamassassin < message.emlTest 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.emlPipe message through SpamAssassin and exit with status 1 if spam
cat message.eml | spamassassin -eClassify message as spam if score exceeds 5.0
spamassassin -l 5.0 message.emlUse a custom configuration file for analysis
spamassassin -c /etc/spamassassin/custom.cf message.emlEnable debug output and filter for matching rules
spamassassin -D < message.eml 2>&1 | grep -i ruleGenerate spam reports for all email files in a directory
find /var/mail -name '*.eml' -exec spamassassin -r {} \;