Spamassassin: Difference between revisions

From Lolly's Wiki
Jump to navigationJump to search
No edit summary
No edit summary
 
Line 1: Line 1:
[[Category:Mail]]
[[Category:Mail]]
= SpamAssassin =
= SpamAssassin =
== Debugging ==
== Razor2 ==
=== Razor2 ===
=== Config ===
 
In spamassassins local.cf:
In spamassassins local.cf:
<syntaxhighlight>
<syntaxhighlight>
razor_config /etc/spamassassin/Razor2/razor-agent.conf
loadplugin Mail::SpamAssassin::Plugin::Razor2
use_razor2 1
razor_config /etc/razor/razor-agent.conf
</syntaxhighlight>
</syntaxhighlight>


The config /etc/spamassassin/Razor2/razor-agent.conf might be like this:
The config /etc/razor/razor-agent.conf might be like this:
<syntaxhighlight>
<syntaxhighlight>
#
#
Line 38: Line 41:
</syntaxhighlight>
</syntaxhighlight>


=== Debugging ===


<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
Line 61: Line 65:
</syntaxhighlight>
</syntaxhighlight>


=== Bayes ===
== Bayes ==
 
=== Debugging ===


<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>

Latest revision as of 16:21, 16 December 2021

SpamAssassin

Razor2

Config

In spamassassins local.cf:

loadplugin Mail::SpamAssassin::Plugin::Razor2
use_razor2 1
razor_config /etc/razor/razor-agent.conf

The config /etc/razor/razor-agent.conf might be like this:

#
# Razor2 config file
# 
# Autogenerated by Razor-Agents v2.82 
# Tue Nov 28 13:36:10 2006
# Created with all default values 
# 
# see razor-agent.conf(5) man page 
#

debuglevel             = 4
identity               = identity
ignorelist             = 0
listfile_catalogue     = servers.catalogue.lst
listfile_discovery     = servers.discovery.lst
listfile_nomination    = servers.nomination.lst
logfile                = /var/log/razor-agent.log
logic_method           = 4
min_cf                 = ac
razordiscovery         = discovery.spamnet.com
rediscovery_wait       = 3600
report_headers         = 1
turn_off_discovery     = 0
use_engines            = 4,8
whitelist              = razor-whitelist
razorhome              = /etc/exim-local/Razor2

Debugging

$ spamassassin --siteconfigpath=/etc/spamassassin -D razor2 < ~/sample-ham.txt 2>&1 | less
Dec 16 15:20:39.223 [26376] dbg: razor2: razor2 is available, version 2.86
 Razor-Log: read_file: 16 items read from /etc/spamassassin/Razor2/razor-agent.conf
 Razor-Log: Found razorhome: /etc/exim-local/Razor2
Dec 16 15:20:41.248733 check[26376]: [ 2] [bootup] Logging initiated LogDebugLevel=9 to stdout
Dec 16 15:20:41.248919 check[26376]: [ 5] computed razorhome=/etc/exim-local/Razor2, conf=/etc/spamassassin/Razor2/razor-agent.conf, ident=/etc/exim-local/Razor2/identity
Dec 16 15:20:41.248996 check[26376]: [ 8] Client supported_engines: 4 8
Dec 16 15:20:41.249307 check[26376]: [ 8]  prep_mail done: mail 1 headers=3944, mime0=562
Dec 16 15:20:41.249571 check[26376]: [ 5] read_file: 1 items read from /etc/exim-local/Razor2/servers.discovery.lst
Dec 16 15:20:41.249819 check[26376]: [ 5] read_file: 4 items read from /etc/exim-local/Razor2/servers.nomination.lst
Dec 16 15:20:41.250038 check[26376]: [ 5] read_file: 3 items read from /etc/exim-local/Razor2/servers.catalogue.lst
Dec 16 15:20:41.250164 check[26376]: [ 9] Assigning defaults to n002.cloudmark.com
Dec 16 15:20:41.250212 check[26376]: [ 9] Assigning defaults to n004.cloudmark.com
Dec 16 15:20:41.250250 check[26376]: [ 9] Assigning defaults to n001.cloudmark.com
Dec 16 15:20:41.250286 check[26376]: [ 9] Assigning defaults to n003.cloudmark.com
Dec 16 15:20:41.250323 check[26376]: [ 9] Assigning defaults to c303.cloudmark.com
Dec 16 15:20:41.250361 check[26376]: [ 9] Assigning defaults to c301.cloudmark.com
Dec 16 15:20:41.250398 check[26376]: [ 9] Assigning defaults to c302.cloudmark.com
...

Bayes

Debugging

$ spamassassin --siteconfigpath=/etc/spamassassin -D bayes < ~/sample-ham.txt 2>&1 | less
Dec 16 15:33:03.945 [3194] dbg: bayes: learner_new self=Mail::SpamAssassin::Plugin::Bayes=HASH(0x1b36a5eb0), bayes_store_module=Mail::SpamAssassin::BayesStore::SQL
Dec 16 15:33:03.976 [3194] dbg: bayes: using username: exim
Dec 16 15:33:03.976 [3194] dbg: bayes: learner_new: got store=Mail::SpamAssassin::BayesStore::SQL=HASH(0x1b4f9ab50)
Dec 16 15:33:04.001 [3194] dbg: bayes: database connection established
Dec 16 15:33:04.002 [3194] dbg: bayes: found bayes db version 3
Dec 16 15:33:04.003 [3194] dbg: bayes: Using userid: 666
Dec 16 15:33:04.183 [3194] dbg: bayes: corpus size: nspam = 345, nham = 925
Dec 16 15:33:04.184 [3194] dbg: bayes: tokenized body: 71 tokens
Dec 16 15:33:04.184 [3194] dbg: bayes: tokenized uri: 34 tokens
Dec 16 15:33:04.184 [3194] dbg: bayes: tokenized invisible: 0 tokens
...

If you find something like:

dbg: bayes: _get_db_version: SQL error: Malformed packet
...
bayes: database version 0 is different than we understand (3), aborting! at .../lib/site_perl/Mail/SpamAssassin/BayesStore/SQL.pm line 139.

You might try to disable the MySQL query_cache:

mysql> set GLOBAL query_cache_type=0;
Query OK, 0 rows affected, 1 warning (0.00 sec)

This is no big deal as it is depricated and will be removed in MySQL 8.0. If it helps, don't foget to put the settings in your MySQL Config as well.

Another way to find out if your bayes store works:

$ sa-learn --siteconfigpath=/etc/spamassassin --dump magic -u <your user>
0.000          0          3          0  non-token data: bayes db version
0.000          0    6801468          0  non-token data: nspam
0.000          0    2184181          0  non-token data: nham
0.000          0    1776152          0  non-token data: ntokens
0.000          0 1639643612          0  non-token data: oldest atime
0.000          0 1639663214          0  non-token data: newest atime
0.000          0          0          0  non-token data: last journal sync atime
0.000          0 1639643616          0  non-token data: last expiry atime
0.000          0      43200          0  non-token data: last expire atime delta
0.000          0       2137          0  non-token data: last expire reduction count