File: spamprobe.1

package info (click to toggle)
spamprobe 1.4d-15
  • links: PTS
  • area: main
  • in suites: bookworm, sid
  • size: 2,516 kB
  • sloc: cpp: 15,044; sh: 823; ansic: 675; makefile: 274; ruby: 178; lisp: 73
file content (927 lines) | stat: -rw-r--r-- 29,561 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
'\" t
.\"     Title: SPAMPROBE
.\"    Author: [see the "AUTHOR" section]
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
.\"      Date: 05/24/2010
.\"    Manual: User commands
.\"    Source: User commands
.\"  Language: English
.\"
.TH "SPAMPROBE" "1" "05/24/2010" "User commands" "User commands"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
spamprobe \- A Bayesian spam filter
.SH "SYNOPSIS"
.HP \w'\fBspamprobe\fR\ 'u
\fBspamprobe\fR [\fIoptions\fR] \fI\ command\ \fR [\fIfiles\fR\ \&.\&.\&.]
.SH "DESCRIPTION"
.PP
SpamProbe
is a spam filter relying on a Bayesian analysis of the frequency of words used in spam and non\-spam emails received by an individual person\&. The process is completely automatic and tailors itself to the kinds of emails that each person receives\&.
.PP
SpamProbe
recognizes and decodes MIME attachments in quoted\-printable and base64 encoding\&. Image attachments are considered as words that can signal a spam\&. By default, it ignores HTML tags for scoring purpose\&.
.PP
SpamProbe
supports MBOX, MBX and Maildir mailbox formats\&. These formats are automatically detected for mailboxes used as parameters of
SpamProbe
commands\&.
.PP
\fBspamprobe\fR
is designed to be used in mail delivery agents (MDAs) like
\fBprocmail\fR(1)
or
\fBmaildrop\fR(1)
to help in identifying spam\&.
.SH "OPTIONS"
.PP
The recognized options are:
.PP
\fB\-a \fR\fB\fIchar\fR\fR
.RS 4
By default
SpamProbe
converts non\-ascii characters (characters with the most significant bit set to 1) into the letter \*(Aqz\*(Aq\&. This is useful for lumping all Asian characters into a single word for easy recognition\&. The \-a option allows you to change the character to something else if you don\*(Aqt like the letter \*(Aqz\*(Aq for some reason\&.
.RE
.PP
\fB\-c\fR
.RS 4
Tells
SpamProbe
to create the database directory if it does not already exist\&. Normally
SpamProbe
exits with a usage error if the database directory does not already exist\&.
.RE
.PP
\fB\-C \fR\fB\fInumber\fR\fR
.RS 4
Tells
SpamProbe
to assign a default, somewhat neutral, probability to any term that does not have a weighted (good count doubled) count of at least
\fInumber \fRin the database\&. This prevents terms which have been seen only a few times from having an unreasonable influence on the score of an email containing them\&.
.sp
The default value is 5\&. For example if
\fInumber \fRis 5 then in order for a term to use its calculated probability it must have been seen 3 times in good mails, or 2 times in good mails and once in spam, or 5 times in spam, or some other combination adding up to at least 5\&.
.RE
.PP
\fB\-d \fR\fB\fI[type:]directory\fR\fR\fB \fR
.RS 4
By default
SpamProbe
stores its database in a directory named
\&.spamprobe
under your home directory\&. The
\fB\-d\fR
option allows you to specify a different directory to use\&. This is necessary if your home directory is
NFS
mounted for example\&.
.sp
The directory name can be prefixed with a special code to force
SpamProbe
to use a particular type of data file format\&.
Defined types include:
.PP
\fB\-d bdb:path\fR
.RS 4
Forces the use of Berkeley DB data file\&.
.RE
.PP
\fB\-d hash:path\fR
.RS 4
Forces the use of an mmapped hash file\&.
.RE
.PP
\fB\-d split:path\fR
.RS 4
Forces the use of a hash file and ISAM file (may provide better precision than plain hash in some cases)\&.
.RE
.sp
The
\fIhash:\fR
option can also specify a desired file size in megabytes before the path\&. For example
\fB\-d hash:19:path\fR
would cause
SpamProbe
to use a 19 MB hash file\&. The size must be in the range of 1\-100\&. The default hash file size is 16 MB\&. Because hash files have a fixed size and capacity they should be cleaned relatively often using the
\fBcleanup\fR
command (see below) to prevent them from becoming full or being slowed by too many hash key collisions\&.
.sp
Hash files provide better performance than Berkeley DB\&.
However hash files do not store the original terms\&. Only a 32 bit hash key is stored with each term\&. This prevents a user from exploring the terms in the database using the dump command to see what words are particularly spammy or hammy\&. The default data file format is Berkeley BD (bdb)\&.
.RE
.PP
\fB\-D \fR\fB\fIdirectory\fR\fR
.RS 4
Tells
SpamProbe
to use the database in the specified directory (must be different than the one specified with the
\fB\-d \fRoption) as a shared database from which to draw terms that are not defined in the user\*(Aqs own database\&. This can be used to provide a baseline database shared by all users on a system (in the
\fB\-D \fR
directory) and a private database unique to each user of the system ($HOME/\&.spamprobe
or
\fB\-d\fR
directory)\&.
.RE
.PP
\fB\-g \fR\fB\fIfieldname\fR\fR
.RS 4
Tells
SpamProbe
what header to look for previous score and message digest in\&. Default is X\-SpamProbe\&. Field name is not case sensitive\&. Used by all commands except
\fBreceive\fR\&.
.RE
.PP
\fB\-h\fR
.RS 4
By default
SpamProbe
removes
HTML
markup from the text in emails to help avoid false positives\&. The
\fB\-h\fR
option allows you to override this behavior and force
SpamProbe
to include words from within
HTML
tags in its word counts\&. Note that
SpamProbe
always counts any URLs in hrefs within tags whether
\fB\-h\fR
is used or not\&. Use of this option is discouraged\&. It can increase the rate of spam detection slightly but unless the user receives a significant amount of
HTML
emails it also tends to increase the number of false positives\&.
.RE
.PP
\fB\-H \fR\fB\fIoption\fR\fR
.RS 4
By default
SpamProbe
only scans a meaningful subset of headers from the email message when searching for words to score\&. The
\fB\-H\fR
option allows the user to specify additional headers to scan\&. Legal values are
\fBall\fR,
\fBnox\fR,
\fBnone\fR, or
\fBnormal\fR\&.
\fBall\fR
scans all headers,
\fBnox \fRscans all headers except those starting with X\-,
\fBnone \fRdoes not scan headers, and
\fBnormal \fRscans the normal set of headers\&.
.sp
In addition to those values you can also explicitly add a header to the list of headers to process by adding the header name in lower case preceded by a plus sign\&. Multiple headers can be specified by using multiple
\fB\-H \fRoptions\&. For example, to include only the
\fBFrom\fR
and
\fBReceived\fR
headers in your
\fBtrain\fR
command you could run
SpamProbe
as follows:
.sp
.if n \{\
.RS 4
.\}
.nf
spamprobe \-Hnone \-H+from \-H+received train
.fi
.if n \{\
.RE
.\}
.sp
To process the normal set of headers but also add the SpamAssassin header X\-SpamStatus you could run
SpamProbe
as follows:
.sp
.if n \{\
.RS 4
.\}
.nf
spamprobe \-H+x\-spam\-status train
.fi
.if n \{\
.RE
.\}
.sp
.RE
.PP
\fB\-l \fR\fB\fInumber\fR\fR
.RS 4
Changes the spam probability threshold for emails from the default (\fB0\&.7\fR) to
\fInumber\fR\&. The number must be a value between 0 and 1\&. Generally the value should be above 0\&.5 to avoid a high false positive rate\&. Lower numbers tend to produce more false positives while higher numbers tend to reduce accuracy\&.
.RE
.PP
\fB\-m\fR
.RS 4
Forces
SpamProbe
to use
mbox
format for reading emails in
\fBreceive\fR
mode\&. Normally
SpamProbe
assumes that the input to
\fBreceive\fR
mode contains a single message so it doesn\*(Aqt look for message breaks\&.
.RE
.PP
\fB\-M\fR
.RS 4
Forces
SpamProbe
to treat the entire input as a single message\&. This ignores
\fBFrom\fR
lines and
\fBContent\-Length\fR
headers in the input\&.
.RE
.PP
\fB\-o \fR\fB\fIoption\fR\fR
.RS 4
Enables special options by name\&. Currently the only special options are:
.PP
\fB\-o graham\fR
.RS 4
Causes
SpamProbe
to emulate the filtering algorithm originally outlined in
[A Plan For Spam]\&.
.RE
.PP
\fB\-o honor\-status\-header\fR
.RS 4
Causes
SpamProbe
to ignore messages if they have a Status: header containing a capital D\&. Some mail servers use this status to indicate a message that has been flagged for deletion but has not yet been purged from the file\&.
.sp
DO NOT use this option with the receive or train command in your procmailrc file! Doing so could allow spammers to bypass the filter\&. This option is meant to be used with the
\fBtrain\-spam\fR
and
\fBtrain\-good\fR
commands in scripts that periodically update the database\&.
.RE
.PP
\fB\-o orig\-score\fR
.RS 4
Causes
SpamProbe
to use its original scoring algorithm that produces excellent results but tends to generate scores of either 0 or 1 for all messages\&.
.RE
.PP
\fB\-o suspicious\-tags\fR
.RS 4
Causes
SpamProbe
to scan the contents of
\(lqsuspicious\(rq
tags for tokens rather than simply throwing them out\&. Currently only font tags are scanned but other tags may be added to this list in later versions\&.
.RE
.PP
\fB\-o tokenized\fR
.RS 4
Causes
SpamProbe
to read tokens one per line rather than processing the input as mail format\&. This allows users to completely replace the standard
SpamProbe
tokenizer if they wish and instead use some external program as a tokenizer\&.
.sp
In this mode
SpamProbe
considers a blank line to indicate the end of one message\*(Aqs tokens and the start of a new message\*(Aqs tokens\&.
SpamProbe
computes a message digest based on the lines of text containing the tokens\&.
.RE
.sp
The
\fB\-o\fR
option can be used multiple times and all requested options will be applied\&. Note that some options might conflict with each other in which case the last option would take precedence\&.
.RE
.PP
\fB\-p \fR\fB\fInumber\fR\fR
.RS 4
Changes the maximum number of words per phrase\&. Default value is two\&. Increasing the limit improves accuracy somewhat but increases database size\&. Experiments indicate that increasing beyond two is not worth the extra cost in space\&.
.RE
.PP
\fB\-P \fR\fB\fInumber\fR\fR
.RS 4
Causes
SpamProbe
to perform a purge of all terms with junk count less than or equal 2 after every number messages are processed\&. Using this option when classifying a large collection of spam can prevent the database from growing overly large at the cost of more processing time and possible loss of precision\&.
.RE
.PP
\fB\-r \fR\fB\fInumber\fR\fR
.RS 4
Changes the number of times that a single word/phrase can occur in the top words array used to calculate the score for each message\&. Allowing repeats reduces the number of words overall (since a single word occupies more than one slot) but allows words which occur frequently in the message to have a higher weight\&. Generally this is changed only for optimization purposes\&.
.RE
.PP
\fB\-R\fR
.RS 4
Causes
SpamProbe
to treat the input as a single message and to base its exit code on whether or not that message was spam\&. The exit code will be 0 if the message was spam or 1 if the message was good\&.
.RE
.PP
\fB\-s \fR\fB\fInumber\fR\fR
.RS 4
SpamProbe
maintains an in memory cache of the words it has seen in previous messages to reduce disk I/O and improve performance\&. By default the cache will contain the most recently accessed 2,500 terms\&. This number can be changed using the
\fB\-s\fR
option\&. Using a larger the cache size will cause
SpamProbe
to use more memory and, potentially, to perform less database I/O\&. A value of zero causes
SpamProbe
to use 100,000 as the limit which effectively means that the cache will only be flushed at program exit (unless you have really enormous mailbox files)\&. The cache doesn\*(Aqt affect receive, dump, or export but has a significant impact on the others\&.
.RE
.PP
\fB\-T\fR
.RS 4
Causes
SpamProbe
to write out the top terms associated with each message in addition to its normal output\&. Works with
\fBfind\-good\fR,
\fBfind\-spam\fR, and
\fBscore\fR\&.
.RE
.PP
\fB\-v\fR
.RS 4
When it appears once on the command line this option tells
SpamProbe
to write verbose information during processing\&. When it appears twice on the command line this option tells
SpamProbe
to write debugging information to stderr\&. This can be useful for debugging or for seeing which terms
SpamProbe
used to score each email\&.
.RE
.PP
\fB\-V\fR
.RS 4
Prints version and copyright information and then exits\&.
.RE
.PP
\fB\-w \fR\fB\fInumber\fR\fR
.RS 4
Changes the number of most significant words/phrases used by
SpamProbe
to calculate the score for each message\&. Generally this is changed only for optimization purposes\&.
.RE
.PP
\fB\-x\fR
.RS 4
Normally
SpamProbe
uses only a fixed number of top terms (as set by the
\fB\-w\fR
command line option) when scoring emails\&. The
\fB\-x\fR
option can be used to allow the array to be extended past the max size if more terms are available with probabilities <= 0\&.1 or >= 0\&.9\&.
.RE
.PP
\fB\-X\fR
.RS 4
An interesting variation on the scoring settings\&. Equivalent to using
\fB\-w5 \-r5 \-x\fR
so that generally only words with probabilites <= 0\&.1 or >= 0\&.9 are used and word frequencies in the email count heavily towards the score\&. Tests have shown that this setting tends to be safer (fewer false positives) and have higher recall (proper classification of spams previously scored as spam) although its predictive power isn\*(Aqt quite as good as the default settings\&. WARNING: This setting might work best with a fairly large corpus, it has not been tested with a small corpus so it might be very inaccurate with fewer than 1000 total messages\&.
.RE
.PP
\fB\-Y\fR
.RS 4
Assume traditional Berkeley mailbox format, ignoring any Content\-Length: fields\&.
.RE
.PP
\fB\-7\fR
.RS 4
Tells
SpamProbe
to ignore any characters with the most significant bit set to 1 instead of mapping them to the letter \*(Aqz\*(Aq\&.
.RE
.PP
\fB\-8\fR
.RS 4
Tells
SpamProbe
to store all characters even if their most significant bit is set to 1\&.
.RE
.SH "COMMANDS"
.PP
SpamProbe
recognizes the following commands:
.PP
.PP
\fBspamprobe help\fR [ \fIcommand\fR ]
.RS 4
With no arguments
SpamProbe
lists all of the valid commands\&. If one or more commands are specified after the word help,
SpamProbe
will print a more verbose description of each command\&.
.RE
.PP
\fBspamprobe create\-db\fR
.RS 4
If no database currently exists
SpamProbe
will attempt to create one and then exit\&. This can be used to bootstrap a new installation\&. Strictly speaking this command is not necessary since the
\fBtrain\-spam\fR,
\fBtrain\-good\fR, and
\fBauto\-train\fR
commands will also create a database if none already exists but some users like to create a database as a separate installation step\&.
.RE
.PP
\fBspamprobe create\-config\fR
.RS 4
Writes a new configuration file named
spamprobe\&.hdl
into the database directory (normally
$HOME/\&.spamprobe)\&. Any existing configuration file will be overwritten so be sure to make a copy before invoking this command\&.
.RE
.PP
\fBspamprobe receive\fR [ \fIfilename\fR\&.\&.\&. ]
.RS 4
Tells
SpamProbe
to read its standard input (or a file specified after the receive command) and score it using the current databases\&. Once the message has been scored the message is classified as either spam or non\-spam and its word counts are written to the appropriate database\&. The message\*(Aqs score is written to stdout along with a single word\&. For example:
.sp
.if n \{\
.RS 4
.\}
.nf
SPAM 0\&.9999999 595f0150587edd7b395691964069d7af
GOOD 0\&.0200000 595f0150587edd7b395691964069d7af
          
.fi
.if n \{\
.RE
.\}
.sp
The string of hex digits after the score is the message\*(Aqs
\(lqMD5\-digest\(rq, a 128 bit number which uniquely identifies the message\&. The digest is used by
SpamProbe
to recognize messages that it has processed previously so that it can keep its word counts consistent if the message is reclassified\&.
.sp
Using the
\fB\-T\fR
option additionally lists the terms used to produce the score along with their counts (number of times they were found in the message)\&.
.RE
.PP
\fBspamprobe train\fR [ \fIfilename\fR\&.\&.\&. ]
.RS 4
Functionally identical to
\fBreceive\fR
except that the database is only modified if the message was
\(lqdifficult\(rq
to classify\&. In practice this can reduce the number of database updates to as little as 10% of messages received\&.
.RE
.PP
\fBspamprobe score\fR [ \fIfilename\fR\&.\&.\&. ]
.RS 4
Similar to receive except that the database is not modified in any way\&.
.RE
.PP
\fBspamprobe summarize\fR [ \fIfilename\fR\&.\&.\&. ]
.RS 4
Similar to
\fBscore\fR
except that it prints a short summary and score for each message\&. This can be useful when testing\&. Using the
\fB\-T\fR
option additionally lists the terms used to produce the score along with their counts (number of times they were found in the message)\&.
.RE
.PP
\fBspamprobe find\-spam\fR [ \fIfilename\fR\&.\&.\&. ]
.RS 4
Similar to
\fBscore\fR
except that it prints a short summary and score for each message that is determined to be spam\&. This can be useful when testing\&. Using the
\fB\-T\fR
option additionally lists the terms used to produce the score along with their counts (number of times they were found in the message)\&.
.RE
.PP
\fBspamprobe find\-good\fR [ \fIfilename\fR\&.\&.\&. ]
.RS 4
Similar to
\fBscore\fR
except that it prints a short summary and score for each message that is determined to be good\&. This can be useful when testing\&. Using the
\fB\-T\fR
option additionally lists the terms used to produce the score along with their counts (number of times they were found in the message)\&.
.RE
.PP
\fBspamprobe auto\-train\fR { SPAM|GOOD \fIfilename\fR \&.\&.\&. } \&.\&.\&.
.RS 4
Attempts to efficiently build a database from all of the named files\&. You may specify one or more file of each type\&. Prior to each set of file names you must include the word
\fBSPAM\fR
or
\fBGOOD\fR
to indicate what type of mail is contained in the files which follow on the command line\&.
.sp
The case of the
\fBSPAM\fR
and
\fBGOOD\fR
keywords is important\&. Any number of file names can be specified between the keywords\&. The command line format is very flexible\&. You can even use a find command in backticks to process whole directory trees of files\&. For example:
.sp
.if n \{\
.RS 4
.\}
.nf
spamprobe auto\-train SPAM spams/* GOOD `find  hams \-type f`
.fi
.if n \{\
.RE
.\}
.sp
SpamProbe
pre\-scans the files to determine how many emails of each type exist and then trains on hams and spams in a random sequence that balances the inflow of each type so that the train command can work most effectively\&. For example if you had 400 hams and 400 spams, auto\-train will generally process one spam, then one ham, etc\&. If you had 4000 spams and 400 hams then auto\-train will generally process 10 spams, then one ham, etc\&.
.sp
Since this command will likely take a long time to run it is often desirable to use it with the \-v option to see progress information as the messages are processed\&.
.sp
.if n \{\
.RS 4
.\}
.nf
spamprobe \-v auto\-train SPAM spams/* GOOD hams/*
.fi
.if n \{\
.RE
.\}
.sp
.RE
.PP
\fBspamprobe good\fR [ \fIfilename\fR\&.\&.\&. ]
.RS 4
Scans each file (or stdin if no file is specified) and reclassifies every email in the file as non\-spam\&. The databases are updated appropriately\&. Messages previously classified as good (recognized using their MD5 digest) are ignored\&. Messages previously classified as spam are reclassified as good\&.
.RE
.PP
\fBspamprobe train\-good\fR [ \fIfilename\fR\&.\&.\&. ]
.RS 4
Functionally identical to
\fBgood\fR
command except that it only updates the database for messages that are either incorrectly classified (i\&.e\&. classified as spam) or are
\(lqdifficult\(rq
to classify\&. In practice this can reduce amount of database updates to as little as 10% of messages\&.
.RE
.PP
\fBspamprobe spam\fR [ \fIfilename\fR\&.\&.\&. ]
.RS 4
Scans each file (or stdin if no file is specified) and reclassifies every email in the file as spam\&. The databases are updated appropriately\&. Messages previously classified as spam (recognized using their MD5 digest of message ids) are ignored\&. Messages previously classified as good are reclassified as spam\&.
.RE
.PP
\fBspamprobe train\-spam\fR [ \fIfilename\fR\&.\&.\&. ]
.RS 4
Functionally identical to
\fBspam\fR
command except that it only updates the database for messages that are either incorrectly classified (i\&.e\&. classified as good) or are
\(lqdifficult\(rq
to classify\&. In practice this can reduce amount of database updates to as little as 10% of messages\&.
.RE
.PP
\fBspamprobe remove\fR [ \fIfilename\fR\&.\&.\&. ]
.RS 4
Scans each file (or stdin if no file is specified) and removes its term counts from the database\&. Messages which are not in the database (recognized using their MD5 digest of message ids) are ignored\&.
.RE
.PP
\fBspamprobe cleanup\fR [ \fIjunk_count\fR [ \fImax_age\fR ] ]
.RS 4
Scans the database and removes all terms with
\fIjunk_count\fR
or less (default 2) which have not had their counts modified in at least
\fImax_age\fR
days (default 7)\&. You can specify multiple count/age pairs on a single command line but must specify both a count and an age for all but the last count\&. This should be run periodically to keep the database from growing endlessly\&.
.RE
.PP
\fBspamprobe purge\fR [ \fIjunk_count\fR ]
.RS 4
Similar to cleanup but forces the immediate deletion of all terms with total count less than
\fIjunk_count \fR
(default is 2) no matter how long it has been since they were modified (i\&.e\&. even if they were just added today)\&. This could be handy immediately after classifying a large mailbox of historical spam or good email to make room for the next batch\&.
.RE
.PP
\fBspamprobe purge\-terms\fR \fIregex\fR
.RS 4
Similar to purge except that it removes from the database all terms which match the specified regular expression\&. Be careful with this command because it could remove many more terms than you expect\&. Use
\fBdump\fR
with the same
\fIregex\fR
before running this command to see exactly what will be deleted\&.
.RE
.PP
\fBspamprobe edit\-term\fR \fIterm\fR \fIgood_count\fR \fIspam_count\fR
.RS 4
Can be used to specifically set the good and spam counts of a term\&. Whether this is truly useful is doubtful but it is provided for completeness sake\&.
.RE
.PP
\fBspamprobe dump\fR [ \fIregex\fR ]
.RS 4
Prints the contents of the word counts database one word per line in human readable format with spam probability, good count, spam count, flags, and word in columns separated by whitespace\&. When given, the
\fIregex\fR
argument limits output to matching tokens\&.
.RE
.PP
\fBspamprobe tokenize\fR [ \fIfilename\fR ]
.RS 4
Prints the tokens found in the file one word per line in human readable format with spam probability, good count, spam count, message count, and word in columns separated by whitespace\&. Terms are listed in the order in which they were encountered in the message\&. The standard unix sort command can be used to sort the terms as desired\&.
.RE
.PP
\fBspamprobe export\fR
.RS 4
Similar to the
\fBdump\fR
command but prints the counts and words in a comma separated format with the words surrounded by double quotes\&. This can be more useful for importing into some databases\&.
.RE
.PP
\fBspamprobe import\fR
.RS 4
Reads the specified files which must contain export data written by the
\fBexport\fR
command\&. The terms and counts from this file are added to the database\&. This can be used to convert a database from a prior version\&.
.RE
.SH "EXAMPLES"
.SS "External Tokenizers"
.PP
Assuming you have a tokenizer tokenize\&.pl, in your procmailrc file you could use:
.sp
.if n \{\
.RS 4
.\}
.nf
SCORE=| tokenize\&.pl | /usr/bin/spamprobe \-o tokenized train
        
.fi
.if n \{\
.RE
.\}
.sp
.SS "Querying Mailboxes"
.PP
To list all words from
\(lqmost good\(rq
to
\(lqleast good\(rq
use this command:
.sp
.if n \{\
.RS 4
.\}
.nf
spamprobe tokenize \fIfilename\fR | sort \-k 1n \-k 2nr
        
.fi
.if n \{\
.RE
.\}
.PP
To list all words from
\(lqmost spammy\(rq
to
\(lqleast spammy\(rq
use this command:
.sp
.if n \{\
.RS 4
.\}
.nf
spamprobe tokenize \fIfilename\fR | sort \-k 1nr \-k 3nr
        
.fi
.if n \{\
.RE
.\}
.sp
.SS "Querying The Database"
.PP
Use
\fBspamprobe dump\fR
to get a human readable list of tokens in
SpamProbe\*(Aqs database\&.
Berkeley DB
sorts terms alphabetically; piping output into the standard unix
\fBsort\fR(1)
command can be used to sort the terms as desired\&.
.PP
To list all words in
SpamProbe\*(Aqs database from
\(lqmost good\(rq
to
\(lqleast good\(rq
use this command:
.sp
.if n \{\
.RS 4
.\}
.nf
spamprobe dump | sort \-k 1n \-k 2nr
        
.fi
.if n \{\
.RE
.\}
.PP
To list all words from
\(lqmost spammy\(rq
to
\(lqleast spammy\(rq
use this command:
.sp
.if n \{\
.RS 4
.\}
.nf
spamprobe dump | sort \-k 1nr \-k 3nr
        
.fi
.if n \{\
.RE
.\}
.PP
Optionally you can specify a regular expression\&. If specified
SpamProbe
will only dump terms matching the regular expression\&. For example:
.sp
.if n \{\
.RS 4
.\}
.nf
spamprobe dump \*(Aqfinance\*(Aq
spamprobe dump \*(Aq\e\ebfinance\e\eb\*(Aq
spamprobe dump \*(AqHSubject_\&.*finance\*(Aq
.fi
.if n \{\
.RE
.\}
.sp
.SH "DATABASE MAINTAINANCE"
.PP
When no provision is taken,
SpamProbe\*(Aqs databases will constantly grow while classifying messages\&. In order to remove old unused entries, you should run
\fBcleanup\fR
on a regular basis, most easily from
\fBcron\fR(1)\&.
.sp
.if n \{\
.RS 4
.\}
.nf
# daily at 00:03
#    remove entries with count <= 2 that haven\*(Aqt
#    been touched during the last 2 weeks from
#    spamprobe\*(Aqs database
3 0 * * * /usr/bin/spamprobe cleanup 2 14
.fi
.if n \{\
.RE
.\}
.PP
Alternatively you might want to use a much higher count (1000 in this example) for terms that have not been seen in roughly six months:
.sp
.if n \{\
.RS 4
.\}
.nf
3 0 * * * /home/brian/bin/spamprobe cleanup 1000 180 2 14
.fi
.if n \{\
.RE
.\}
.PP
Because of the way that
Berkeley DB
works the database file will not actually shrink, but newly added terms will be able to use the space previously occupied by any removed terms so that the file\*(Aqs growth should be significantly slower if this command is used\&.
.PP
To actually shrink the database you can build a new one using the
Berkeley DB
utility programs
\fBdb_dump\fR(1)
and
\fBdb_load\fR(1)
or the
SpamProbe
\fBimport\fR
and
\fBexport\fR
commands\&. For example:
.sp
.if n \{\
.RS 4
.\}
.nf
cd ~
mkdir new\&.spamprobe
spamprobe export | spamprobe \-d ~/new\&.spamprobe import
mv \&.spamprobe old\&.spamprobe
mv new\&.spamprobe \&.spamprobe
      
.fi
.if n \{\
.RE
.\}
.PP
The
\fB\-P\fR
option can also be used to limit the rate of growth of the database when importing a large number of emails\&. For example if you want to classify 1000 emails and want
SpamProbe
to purge rare terms every 100 messages use a command such as:
.sp
.if n \{\
.RS 4
.\}
.nf
spamprobe \-P 100 good goodmailboxname
      
.fi
.if n \{\
.RE
.\}
.PP
Using
\fB\-P\fR
slows down the classification but can avoid the need to use the
\fBexport\fR/\fBimport\fR
trick\&. Note that
\fB\-P\fR
only makes sense when classifying a large number of messages\&.
.PP
You may want to force a particular word to be very spammy or extremely good:
.sp
.if n \{\
.RS 4
.\}
.nf
spamprobe edit\-term xanax 0 1000000
spamprobe edit\-term debian 10000000 0
      
.fi
.if n \{\
.RE
.\}
.sp
At least pinning good terms tends to help spammers\&.
.SH "BUGS"
.PP
This manual page is still work in progress\&. In particular it\*(Aqs lacking a description of which headers are processed with
\fB\-H normal\fR
and how terms are generated from headers as well as a reference to the regex syntax applicable to
\fBdump\fR
and
\fBpurge\-term\fR
commands\&.
.SH "FILES"
.PP
~/\&.spamprobe
.RS 4
When not otherwise specified with the
\fB\-d \fR\fB\fIdirectory\fR\fR
option,
SpamProbe
stores its database files in this directory\&.
\fIIt does not automatically create database directories except when explicitly asked to by the \fR\fI\fB\-c\fR\fR\fI command line flag or the \fR\fI\fBcreate\-db\fR\fR\fI command\fR\&. If your home directory is
NFS
mounted, use a different directory on a local disk, since
Berkeley DB
performance suffers badly over
NFS\&.
.RE
.PP
~/\&.spamprobe/spamprobe\&.hdl
.RS 4
Configuration file for
\fBspamprobe\fR\&. This file is optional\&. It can be initialized with all the default values by the
\fBcreate\-config\fR
command\&.
.RE
.SH "SEE ALSO"
.PP

\fBprocmail\fR(1) , \fBmaildrop\fR(1)
.SH "AUTHOR"
.PP
SpamProbe
has been written by Brian Burton <bburton@users\&.sourceforge\&.net> and is published under the
QPL
(Qt Public License)\&.
.PP
This manual page was compiled by Siggy Brentrup
bsb@debian\&.org
from the distributed one for the
Debian GNU/Linux
system but may be used by others\&. Permission is granted to copy, distribute and/or modify this document under the terms of the
GPL
version 2\&.