Debian Codegraph @

doc/bogofilter-faq.html

raw
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
5 <title>Bogofilter FAQ</title>
6 <style type="text/css">
7 h2 {
8 margin-top: 1em;
9 font-size: 125%;
10 }
11 h3 {
12 margin-top: 1em;
13 font-size: 110%;
14 }
15 p {
16 margin-top: 0.5em;
17 margin-bottom: 0.5em;
18 }
19 ul {
20 margin-top: 1.5em;
21 margin-bottom: 0.5em;
22 }
23 ul ul {
24 margin-top: 0.25em;
25 margin-bottom: 0;
26 }
27 li {
28 margin-top: 0;
29 margin-bottom: 1em;
30 }
31 li li {
32 margin-bottom: 0.25em;
33 }
34 dt {
35 margin-top: 0.5em;
36 margin-bottom: 0;
37 }
38 hr {
39 margin-top: 1em;
40 margin-bottom: 1em;
41 }
42 </style>
43 </head>
44
45 <body>
46 <h1>Bogofilter FAQ</h1>
47
48 <p>Official Versions: In
49 <a href="http://bogofilter.sourceforge.net/faq.shtml">English</a> or
50 <a href="http://bogofilter.sourceforge.net/faq_fr.shtml">French</a> or
51 <a href="http://bogofilter.sourceforge.net/faq_it.shtml">Italian</a> or
52 <a href="http://bogofilter.sourceforge.net/faq_bg.shtml">Bulgarian</a><br>
53 Current maintainer since 2013: Matthias Andree &lt;[email protected]&gt;<br>
54 Previous maintainer of ten years: David Relson &lt;[email protected]&gt;</p>
55
56 <p>This document is intended to answer frequently asked
57 questions about bogofilter.</p>
58
59 <h2>Typographic conventions</h2>
60 <ul><li>If we show example commands that start with a
61 dollar sign ($), this means that these commands should be executed
62 by an unprivileged user, NOT the root user.</li>
63 <li>If we show example commands that start with a hash mark (#),
64 this means that these commands need to be executed by the root
65 user.</li>
66 </ul>
67
68 <h1>Frequently asked questions and their answers</h1>
69
70 <ul>
71 <li>
72 General Information
73 <ul>
74 <li><a href="#what-is-bogofilter">What is bogofilter?</a></li>
75 <li><a href="#bogo-what">Bogo what?</a></li>
76 <li><a href="#bogo-how">How does bogofilter work?</a></li>
77 <li><a href="#lists">Bogofilter Mailing Lists</a></li>
78 </ul>
79 </li>
80
81 <li>
82 Operational Questions
83 <ul>
84 <li><a href="#training">How do I start my bogofilter training?</a></li>
85 <li><a href="#training-maildirs">How do I train using maildirs?</a></li>
86 <li><a href="#production">How can I keep the scoring accuracy high?</a></li>
87 <li><a href="#mboxformats">What mailbox (file) formats does bogofilter understand?</a></li>
88 <li><a href="#vvv">What does bogofilter's verbose output mean?</a></li>
89 <li><a href="#unsure">What is <i>Unsure</i> mode?</a></li>
90 <li><a href="#train-on-error">What are "training on error" and
91 "training to exhaustion"?</a></li>
92 <li><a href="#autoupdate">What does the '-u' (autoupdate) switch do?</a></li>
93 <li><a href="#spamassassin">How can I use SpamAssassin to train Bogofilter?</a></li>
94 <li><a href="#asian-spam">What can I do about Asian spam?</a></li>
95 </ul>
96 </li>
97
98 <li>
99 Database Questions
100 <ul>
101 <li><a href="#compact-database">How can I compact my database?</a></li>
102 <li><a href="#query-database">How do I manually query the database?</a></li>
103 <li><a href="#multiple">Can I use multiple wordlists?</a></li>
104 <li><a href="#ignore">Can I tell bogofilter to ignore certain tokens?</a></li>
105 <li><a href="#update">How do I upgrade from separate word
106 databases to the combined wordlist format?</a></li>
107 <li><a href="#unicode">How can I convert my wordlist to/from unicode?</a></li>
108 <li><a href="#rescue">How can I tell if my wordlists are corrupted?</a></li>
109 </ul>
110 </li>
111
112 <li>
113 Berkeley DB Questions
114 <ul>
115 <li><a href="#enable-transactions">How can I switch from
116 non-transaction to transaction mode?</a></li>
117 <li><a href="#disable-transactions">How can I switch from
118 transaction to non-transaction mode?</a></li>
119 <li><a href="#locksize">Why does bogofilter die after printing<br>
120 "Lock table is out of available locks" or<br>
121 "Lock table is out of available object entries"?</a></li>
122 <li><a href="#page-notfound">Why am I getting DB_PAGE_NOTFOUND messages?</a></li>
123 <li><a href="#db-private">Why am I getting &quot;Berkeley DB
124 library configured to support only DB_PRIVATE
125 environments&quot; or<br>
126 &quot;Berkeley DB library configured to support only
127 private environments&quot;?</a>
128 </ul>
129 </li>
130
131 <li>
132 Technical problems
133 <ul>
134 <li><a href="#multi-user">Can bogofilter be used in a multi-user environment?</a></li>
135 <li><a href="#nfs">Can I share wordlists over NFS?</a></li>
136 <li><a href="#return-codes">Why does bogofilter give return codes like 0 and
137 256 when it's run from inside a program?</a></li>
138 <li><a href="#changed-options">Now that I've upgraded why are my scripts broken?</a></li>
139 <li><a href="#changed-tagging">Now that I've upgraded why is bogofilter working less well?</a></li>
140 <li><a href="#remove-spam-or-nonspam">How can I delete all the spam (or non-spam) tokens?</a></li>
141 </ul>
142 </li>
143
144 <li>
145 Build and Portability Problems
146 <ul>
147 <li><a href="#port-notes">How do I get bogofilter working on Solaris, BSD, etc.?</a></li>
148 <li><a href="#make-notes">Can I use the make command on my operating system?</a></li>
149 <li><a href="#build">How do I build bogofilter as non-root
150 user or for a non-standard installation prefix?</a></li>
151 <li><a href="#patch">How do I build bogofilter with patches?</a></li>
152 <li><a href="#smaller">How do I make the executables smaller?</a></li>
153 <li><a href="#relativepath">datastore_db.c does not compile!</a></li>
154 </ul>
155 </li>
156
157 <li>
158 Using Bogofilter with different mail programs
159 <ul>
160 <li><a href="#which-muas">With which mail programs does
161 bogofilter work?</a></li>
162
163 <li><a href="#with-mutt">How do I use bogofilter with
164 mutt?</a></li>
165
166 <li><a href="#with-sc">How do I use bogofilter with Sylpheed
167 Claws?</a></li>
168
169 <li><a href="#with-vm">How do I use bogofilter with VM (an
170 Emacs Mail tool)?</a></li>
171
172 <li><a href="#with-mh-e">How do I use bogofilter with MH-E
173 (the Emacs interface to the MH mail system)?</a></li>
174
175 </ul>
176 </li>
177 </ul>
178
179 <hr>
180
181 <h2 id="what-is-bogofilter">What is bogofilter?</h2>
182
183 <p>Bogofilter is a fast Bayesian spam filter along the lines
184 suggested by <a href="http://www.paulgraham.com/">Paul Graham</a>
185 in his article
186 <a href="http://www.paulgraham.com/spam.html">A Plan For Spam</a>.
187 bogofilter uses
188 <a href="http://radio-weblogs.com/0101454/stories/2002/09/16/spamDetection.html">Gary Robinson</a>'s
189 geometric-mean algorithm with the
190 <a href="http://www.linuxjournal.com/article/6467">Fisher's method modification</a>
191 to classify email as spam or non-spam.</p>
192
193 <p>The bogofilter
194 <a href="http://bogofilter.sourceforge.net/">home page</a> at
195 SourceForge is the central clearinghouse for bogofilter
196 resources.</p>
197
198 <p>Bogofilter was started by
199 <a href="http://catb.org/~esr/">Eric S. Raymond</a> on August 19,
200 2002. It gained popularity in September 2002, and a number of other
201 authors have started to contribute to the project.</p>
202
203 <p>The <a href="http://bogofilter.sourceforge.net/NEWS">NEWS file</a>
204 describes bogofilter's version history starting with version 1.0.0.
205 Older news (before release 1.0.0) are in the <a
206 href="http://bogofilter.sourceforge.net/NEWS.0">NEWS.0 file.</a></p>
207
208 <hr>
209
210 <h2 id="bogo-what">Bogo-what?</h2>
211
212 <p>Bogofilter is some kind of a
213 <a href="http://www.catb.org/~esr/jargon/html/B/bogometer.html">bogometer</a> or
214 <a href="http://www.catb.org/~esr/jargon/html/B/bogon-filter.html">bogon filter</a>,
215 i.e., it tries to identify
216 <a href="http://www.catb.org/~esr/jargon/html/B/bogus.html">bogus</a>
217 mail by measuring the
218 <a href="http://www.catb.org/~esr/jargon/html/B/bogosity.html">bogosity</a>.</p>
219
220 <hr>
221
222 <h2 id="bogo-how">How does bogofilter work?</h2>
223
224 <p>See the man page's
225 <a href="http://bogofilter.sourceforge.net/man_page.shtml#theory">THEORY OF OPERATION</a>
226 section for an introduction. The main source for understanding
227 this is Gary Robinson's Linux Journal article
228 <a href="http://www.linuxjournal.com/article/6467">"A Statistical Approach to the Spam Problem"</a>.</p>
229
230 <p>After you read all this you might ask some questions. The first
231 could be "Is bogofilter really a Bayesian spam filter?"
232 Bogofilter is based on Bayes' theorem and uses it in the initial
233 calculations and other statistical methods later. Without doubt it
234 is a statistical spam filter with a Bayesian flavor.</p>
235
236 <p>Other questions you might have might concern the basic
237 assumptions of Bayes' theory. Two short answers are: "No, they are
238 not satisfied" and "We don't care as long as it works". A longer
239 answer will mention that the basic assumption that "an e-mail is a
240 random collection of words, each independent of the others" is
241 violated. There are several places where practice doesn't follow
242 theory. Some are always present, and some which will depend on
243 the way you use bogofilter:</p>
244
245 <ul>
246 <li>Words in an e-mail are by no means independent. In all languages,
247 the opposite is true.</li>
248 <li>The words used are not random, though some spammers include random
249 words.</li>
250 <li>Full training or using a random sample, follows Bayes'
251 principles. Choosing messages to use for training violates
252 the assumption that the training messages are a random sample of
253 the messages received. This principle is also violated by
254 Bogofilter's auto-update function (with the thresh_update
255 parameter), <a href="#train-on-error">training on error</a>, or
256 anything similar to these approaches.</li>
257 <li>The same applies if you train with the same message more than once.</li>
258 <li>Other problems arise if you modify your database by removing tokens
259 (like using bogoutil with -a or -c).</li>
260 <li>Undoubtedly there are more.</li>
261 </ul>
262
263 <p>As the man page explains, bogofilter tries to understand how
264 badly the null hypothesis fails. Some people argue that "those
265 departures from reality usually work in our favor" (from Gary's
266 article). Some argue that, even then, we should not violate too
267 much. Nobody really <em>knows</em>. Just keep in mind that
268 problems might occur if you push too hard. The key to bogofilter's
269 approach is: What matters most is simply what works in the real
270 world.</p>
271
272 <p>Now that you have been warned, have fun and use bogofilter as
273 suits you best.</p>
274
275 <hr>
276
277 <h2 id="lists">Mailing Lists</h2>
278
279 <p>There are currently four mailing lists for bogofilter:</p>
280
281 <table border="1" width="100%" summary="[You need a table-capable
282 browser to read this overview of mailing lists]">
283 <tr>
284 <th>List Address</th>
285 <th>Links</th>
286 <th>Description</th>
287 </tr>
288
289 <tr>
290 <td>[email protected]</td>
291 <td><a href="http://www.bogofilter.org/mailman/listinfo/bogofilter-announce">[subscribe]</a>
292 [archives: <a
293 href="http://www.bogofilter.org/pipermail/bogofilter-announce/">mailman</a>]
294 </td>
295 <td>An announcement-only list where new versions are
296 announced.</td>
297 </tr>
298
299 <tr>
300 <td>[email protected]</td>
301 <td><a href="http://www.bogofilter.org/mailman/listinfo/bogofilter">[subscribe]</a>
302 [archives: <a
303 href="http://www.bogofilter.org/pipermail/bogofilter/">mailman</a>]
304 </td>
305 <td>A discussion list where any conversation about
306 bogofilter may take place.</td>
307 </tr>
308
309 <tr>
310 <td>[email protected]</td>
311 <td><a href="http://www.bogofilter.org/mailman/listinfo/bogofilter-dev">[subscribe]</a>
312 [archives: <a
313 href="http://www.bogofilter.org/pipermail/bogofilter-dev/">mailman</a>]
314 </td>
315 <td>A list for sharing patches, development, and technical
316 discussions.</td>
317 </tr>
318
319 <tr>
320 <td>[email protected]</td>
321 <td><a href="https://lists.sourceforge.net/lists/listinfo/bogofilter-cvs">[subscribe]</a>
322 <a href="http://sourceforge.net/p/bogofilter/mailman/bogofilter-cvs/">[archive]</a></td>
323 <td>Mailing list for announcing code changes to the SVN
324 archive. (The CVS name is a leftover from before the migration
325 for our users' convenience.)</td>
326 </tr>
327 </table>
328
329 <p>The bogofilter-announce list is moderated and is used only for
330 important announcements (eg: new versions). It is low traffic.
331 If you have subscribed to the user's list or the developer's list,
332 you don't need to subscribe to the announce list. Messages posted
333 to the announce list are also distributed to the others.</p>
334
335 <hr>
336
337 <h2 id="training">How do I start my bogofilter training?</h2>
338
339 <p>To classify messages as ham (non-spam) or spam, bogofilter
340 needs to learn from your mail. To start with it is best to have
341 collections (that are as large as possible) of messages you know
342 for sure are ham or spam. (Errors here will cause problems later,
343 so try hard<code>;-)</code>. Warning: Only use your mail; using other
344 collections (like a spam collection found on the web), might cause
345 bogofilter to draw a wrong conclusion &#8212; after all you want it to
346 understand <em>your</em> mail.</p>
347
348 <p>Once you have the spam and ham collections, you have basically
349 four choices. In all cases it works better if your training base
350 (the above collections) is bigger, rather than smaller. The
351 smaller your training collection is, the higher the number of
352 errors bogofilter will make in production. Let's assume your
353 collection is two mbox files: ham.mbox and spam.mbox.</p>
354
355 <ul>
356 <li><p>Method 1) Full training. Train bogofilter with all your messages. In
357 our example:</p>
358
359 <pre> bogofilter -s &lt; spam.mbox
360 bogofilter -n &lt; ham.mbox</pre></li>
361 </ul>
362
363 <p>Note: Bogofilter's contrib directory includes two scripts that
364 both use a train-on-error technique. This technique scores each
365 message and adds to the database only those messages that were
366 scored incorrectly (messages scored as uncertain, ham scored as
367 spam, or spam scored as ham). The goal is to build a database of
368 those words <em>needed</em> to correctly classify messages. The
369 resulting database is smaller than the one build using full
370 training.</p>
371
372 <ul>
373 <li><p>Method 2) Use the script bogominitrain.pl (in the contrib
374 directory). It checks the messages in the same order as your
375 mailbox files. You can use the <code>-f</code> option which will
376 repeat this until all messages in your training collection are
377 classified correctly (you can even adjust the level of
378 certainty). Since the script makes sure the database understands
379 your training collection &quot;exactly&quot; (with your chosen
380 precision), it works very well. You can use <code>-o</code> to
381 create a security margin around your spam_cutoff. Assuming
382 spam_cutoff=0.6 you might want to score all ham in your
383 collection below 0.3 and all spam above 0.9. Our example is:</p>
384
385 <pre> bogominitrain.pl -fnv ~/.bogofilter ham.mbox spam.mbox '-o 0.9,0.3'</pre></li>
386
387 <li><p>Method 3) Use the script randomtrain (in the contrib
388 directory). The script generates a list of all the messages in the
389 mailboxes, randomly shuffles the list, and then scores each
390 message, with training as needed. In our example:</p>
391
392 <pre> randomtrain -s spam.mbox -n ham.mbox</pre>
393
394 <p>As with method 4, it works better if you start with full
395 training using several thousand messages. This will give a
396 database that is more comprehensive and significantly
397 bigger.</p></li>
398
399 <li><p>Method 4) If you have enough spams and non-spams in your
400 training collection, separate out some 10,000 spams and 10,000
401 non-spams into separate mbox files, and train as in method 1. Then
402 use bogofilter to classify the remaining spams and non-spams. Take
403 any messages that it classifies as unsure or classifies
404 incorrectly, and train with those. Here are two little scripts you
405 can use to classify the train-on-error messages:</p>
406
407 <pre> #! /bin/sh
408 # class3 -- classify one message as bad, good or unsure
409 cat &gt;msg.$$
410 bogofilter $* &lt;msg.$$
411 res=$?
412 if [ $res = 0 ]; then
413 cat msg.$$ &gt;&gt;corpus.bad
414 elif [ $res = 1 ]; then
415 cat msg.$$ &gt;&gt;corpus.good
416 elif [ $res = 2 ]; then
417 cat msg.$$ &gt;&gt;corpus.unsure
418 fi
419 rm msg.$$</pre>
420
421 <pre> #! /bin/sh
422 # classify -- put all messages in mbox through class3
423 src=$1;
424 shift
425 formail -s class3 $* &lt;$src</pre>
426
427 <p>In our example (after the initial full training):</p>
428
429 <pre> classify spam.mbox [bogofilter options]
430 bogofilter -s &lt; corpus.good
431 rm -f corpus.*
432 classify ham.mbox [bogofilter options]
433 bogofilter -n &lt; corpus.bad
434 rm -f corpus.*</pre></li>
435 </ul>
436
437 <h3>Comparing these methods</h3>
438
439 <p>It is important to understand the consequences of the methods
440 just described. Doing full training as in methods 1 and 4 produces
441 a larger database than does training with methods 2 or 3. If your
442 database size needs to be small (for example due to quota
443 limitations), use methods 2 or 3.</p>
444
445 <p>Full training with method 1 is fastest. Training on error (as
446 in methods 2, 3 and 4) is effective, but the initial training takes
447 longer.</p>
448
449 <hr>
450
451 <h2 id="training-maildirs">How do I train using maildirs?</h2>
452
453 <h3>Initial training from mbox:</h3>
454
455 <pre> bogofilter -M -s -I ~/mail/Spam
456 bogofilter -M -n -I ~/mail/NonSpam</pre>
457
458 <h3>Initial training from maildir:</h3>
459
460 <pre> bogofilter -s -B ~/Maildir/.Spam
461 bogofilter -n -B ~/Maildir/.NonSpam</pre>
462
463 <h3>Corrective training from mbox:</h3>
464
465 <pre> bogofilter -M -Ns -I ~/mail/Missed_Spam
466 bogofilter -M -Sn -I ~/mail/False_Spam</pre>
467
468 <h3>Corrective training from maildir:</h3>
469
470 <pre> bogofilter -s -B ~/Maildir/.Missed_Spam
471 bogofilter -n -B ~/Maildir/.False_Spam</pre>
472
473 <hr>
474
475 <h2 id="production">How can I keep the scoring accuracy high?</h2>
476
477 <p>Bogofilter will make mistakes once in a while. So ongoing
478 training is important. There are two main methodologies for doing this.
479 First, you can train with every incoming message (using the -u
480 option). Second, you can train on error only.</p>
481
482 <p>Since you might want to rebuild your database at some point,
483 for example when a major new feature is implemented in bogofilter,
484 it can be very useful to update your training collection
485 continuously.</p>
486
487 <p>Bogofilter always does the best it can with the information
488 available to it. However, it will make mistakes, i.e., classify
489 ham as spam (false positives) or spam as ham (false negatives). To
490 reduce the likelihood of repeating the mistake, it is necessary to
491 train bogofilter with the errant message. If a message is
492 incorrectly classified as spam, use switch <code>-n</code> to
493 train with it as ham. Use switch <code>-s</code> to train with a
494 spam message.</p>
495
496 <p>Bogofilter has a <code>-u</code> switch that automatically
497 updates the wordlists after scoring each message. As bogofilter
498 sometimes misclassifies a message, monitoring is necessary to
499 correct any mistakes. Corrections can be done using
500 <code>-Sn</code> to change a message's classification from spam to
501 non-spam and <code>-Ns</code> to change it from non-spam to spam.</p>
502
503 <p>Correcting a misclassified message may affect classification for
504 other message. The smaller your database is, the higher is the
505 likelihood that a training error will cause a misclassification.</p>
506
507 <p>Using a method like #2 or #3 (above) can compensate for this
508 effect. Repeat the training with your complete training
509 collection (including all the new messages added since the earlier
510 training). This will add messages to the database which show that
511 adverse effect on both sides until you have a new equilibrium.</p>
512
513 <p>An alternative strategy, based on method 4 in the previous
514 section, is the following: Periodically take blocks of messages
515 and use the scripts in method 4 above to classify them. Then
516 manually review the good, bad and unsure files, correct any
517 errors, and split the unsures into spam and non-spam. Until you
518 have accumulated some 10,000 spam and 10,000 non-spam in your
519 training database, train with the good, the bad, and the separated
520 errors and unsures; thereafter, train with only the separated and
521 unsures, discarding the messages that bogofilter already
522 classifies correctly.</p>
523
524 <hr>
525
526 <h2 id="mboxformats">What mailbox (file) formats does bogofilter understand?</h2>
527
528 <p>Bogofilter understands the traditional Unix mbox format, the
529 Maildir and MH formats. Note though that bogofilter does not support
530 subfolders, you will have to explicitly list them in MH or Maildir++
531 folders - just mention the full path to the subfolder.</p>
532
533 <p>For unsupported formats, you will have to convert the mailbox to
534 a format bogofilter understands. Mbox is often convenient because it can
535 be piped into bogofilter.</p>
536
537 <p>For example, to convert UW-IMAP/PINE mbx format to mbox:
538
539 <pre> mailtool copy /full/path/to/mail.mbox '#driver.unix//full/path/to/mbox'</pre>
540
541 <p>or:</p>
542
543 <pre> for MSG in /full/path/to/maildir/* ; do
544 formail -I Status: < "$MSG" >> /full/path/to/mbox
545 done</pre>
546
547 <hr>
548
549 <h2 id="vvv">What does bogofilter's verbose output mean?</h2>
550
551 <p>Bogofilter can instructed to display information on the
552 scoring of a message by running it with flags "-v", "-vv",
553 "-vvv", or "-R".</p>
554
555 <ul>
556 <li>
557 Using "-v" causes bogofilter to generate the "X-Bogosity:"
558 header line, i.e.
559 <pre> X-Bogosity: Ham, tests=bogofilter, spamicity=0.500000</pre></li>
560
561 <li>
562 Using "-vv" causes bogofilter to generate a histogram, i.e.
563 <pre> X-Bogosity: Ham, tests=bogofilter, spamicity=0.500000
564 int cnt prob spamicity histogram
565 0.00 29 0.000209 0.000052 #############################
566 0.10 2 0.179065 0.003425 ##
567 0.20 2 0.276880 0.008870 ##
568 0.30 18 0.363295 0.069245 ##################
569 0.40 0 0.000000 0.069245
570 0.50 0 0.000000 0.069245
571 0.60 37 0.667823 0.257307 #####################################
572 0.70 5 0.767436 0.278892 #####
573 0.80 13 0.836789 0.334980 #############
574 0.90 32 0.984903 0.499835 ################################</pre>
575
576 <p>Each row shows an interval, the count of tokens with
577 scores in that interval, the average spam probability for
578 those tokens, the message's spamicity score (for those
579 tokens and all lesser valued tokens), and a bar graph
580 corresponding to the token count.</p>
581
582 <p>In the above histogram there are a lot of low scoring
583 tokens and a lot of high scoring tokens. They "balance" one
584 another to give the spamicity score of 0.5000</p>
585 </li>
586
587 <li>
588 Using "-vvv" produces a list of <em>all</em> the tokens in
589 the messages with information on each one, i.e.
590 <pre> X-Bogosity: Ham, tests=bogofilter, spamicity=0.500000
591 n pgood pbad fw U
592 "which" 10 0.208333 0.000000 0.000041 +
593 "own" 7 0.145833 0.000000 0.000059 +
594 "having" 6 0.125000 0.000000 0.000069 +
595 ...
596 "unsubscribe.asp" 2 0.000000 0.095238 0.999708 +
597 "million" 4 0.000000 0.190476 0.999854 +
598 "copy" 5 0.000000 0.238095 0.999883 +
599 N_P_Q_S_s_x_md 138 0.00e+00 0.00e+00 5.00e-01
600 1.00e-03 4.15e-01 0.100</pre>
601 The columns printed contain the following information:
602
603 <dl>
604 <dt>"&hellip;"</dt>
605
606 <dd>the token in question</dd>
607
608 <dt>n</dt>
609
610 <dd>number of times this token was encountered in
611 training</dd>
612
613 <dt>pgood</dt>
614
615 <dd>proportion of good messages that contained this
616 token</dd>
617
618 <dt>pbad</dt>
619
620 <dd>proportion of spam messages that contained this
621 token</dd>
622
623 <dt>fw</dt>
624
625 <dd>Robinson's weighted index, which combines pgood and
626 pbad to give a value that will be close to zero if a
627 message containing this token is likely to be non-spam
628 and close to one if it's likely to be spam</dd>
629
630 <dt>U</dt>
631
632 <dd>'<b>+</b>' if this token contributes to the final
633 bogosity value, '<b>-</b>' otherwise. A token is excluded
634 when its score is closer to 0.5 than min_dev.</dd>
635 </dl>
636
637 <p>The final lines show:</p>
638
639 <ul style="margin-top:0;margin-bottom:1em;">
640 <li>The cumulative results of the columns</li>
641
642 <li>The values of Robinson's <b>s</b> and <b>x</b>
643 parameters and of <b>min_dev</b></li>
644 </ul>
645 </li>
646
647 <li>
648 Using "-R" produces the "-vvv" output described above plus
649 two additional columns:
650
651 <dl>
652 <dt>invfwlog</dt>
653
654 <dd>logarithm of fw</dd>
655
656 <dt>fwlog</dt>
657
658 <dd>logarithm of (1-fw)</dd>
659 </dl>
660
661 <p>The "-R" output is formatted for use with the R language
662 for statistical computing. More information is available at
663 <a href="http://www.r-project.org/">The R Project for
664 Statistical Computing</a>.</p>
665 </li>
666 </ul>
667
668 <hr>
669
670 <h2 id="unsure">What is <i>Unsure</i> mode?</h2>
671
672 <p>Bogofilter's default configuration will classify a message as
673 spam or non-spam. The SPAM_CUTOFF parameter is used for this.
674 Messages with scores greater than or equal to SPAM_CUTOFF are
675 classified as spam. Other messages are classified as ham.</p>
676
677 <p>There is also a HAM_CUTOFF parameter. When used, messages must
678 have scores less than or equal to HAM_CUTOFF to be classified as
679 ham. Messages with scores between HAM_CUTOFF and SPAM_CUTOFF are
680 classified as unsure. If you look in bogofilter.cf, you will see
681 the following lines:</p>
682
683 <pre> #### CUTOFF Values
684 #
685 # both ham_cutoff and spam_cutoff are allowed.
686 # setting ham_cutoff to a non-zero value will
687 # enable tri-state results (Spam/Ham/Unsure).
688 #
689 #ham_cutoff = 0.45
690 #spam_cutoff = 0.99
691 #
692 # for two-state classification:
693 #
694 ## ham_cutoff = 0.00
695 ## spam_cutoff= 0.99</pre>
696
697 <p>To turn on Yes/No/Unsure classification, remove the #'s from the last
698 two lines.</p>
699
700 <p>Alternatively, if you'd rather use labels Yes/No/Unsure
701 instead of Spam/Ham/Unsure, remove the #'s from the following
702 bogofilter.cf line:
703
704 <pre> ## spamicity_tags = Yes, No, Unsure</pre>
705
706 <p>Once that's done, you may want to set the filtering rules for your mail
707 program to include rules like:</p>
708
709 <pre> if header contains "X-Bogosity: Spam", put in Spam folder
710 if header contains "X-Bogosity: Unsure", put in Unsure folder</pre>
711
712 <p>Alternatively, bogofilter.cf has directives for modifying the
713 Subject: line, i.e.</p>
714
715 <pre> #### SPAM_SUBJECT_TAG
716 #
717 # tag added to "Subject: " line for identifying spam or unsure
718 # default is to add nothing.
719 #
720 ##spam_subject_tag=***SPAM***
721 ##unsure_subject_tag=???UNSURE???</pre>
722
723 <p>With these subject tags, the filtering rules would look like:</p>
724
725 <pre> if subject contains "***SPAM***", put in Spam folder
726 if subject contains "???UNSURE???", put in Unsure folder</pre>
727
728 <hr>
729
730 <h2 id="train-on-error">What are "training on error" and "training to exhaustion"?</h2>
731
732 <p>"Training on error" involves scanning a corpus of known spam
733 and non-spam messages; only those that are misclassified, or
734 classed as unsure, get registered in the training database. It's
735 been found that sampling just messages prone to misclassification
736 is an effective way to train; if you train bogofilter on the hard
737 messages, it learns to handle obvious spam and non-spam too.</p>
738
739 <p>This method can be enhanced by using a "security margin". By
740 increasing the spam cutoff value and decreasing the ham cutoff
741 value, messages which are close to a cutoff will be used for
742 training. Using security margins improves results when training
743 on error. In general, greater margins help more (although too
744 much also isn't optimal). As a rule of thumb spam cutoff +/- 0.3 gives good
745 results. For tristate mode, you might try the middle of the unsure
746 interval +/- 0.3 for training.</p>
747
748 <p>Repeating training on error on the same message corpus can
749 improve accuracy. The idea is that messages which were rated
750 correctly in the first place might after some more training be
751 rated wrongly which will then be corrected.</p>
752
753 <p>"Training to exhaustion" is repeating training on error, with
754 the same message corpus, until no errors remain. Also this method
755 can be improved with security margins. See
756 <a href="http://www.garyrobinson.net/2004/02/spam_filtering_.html">Gary Robinson's Rants</a>
757 on this topic for more details.</p>
758
759 <p>Note: <code>bogominitrain.pl</code> has a <code>-f</code> option
760 to do "training to exhaustion". Using <code>-fn</code> avoids
761 repeated training for each message.</p>
762
763 <hr>
764
765 <h2 id="autoupdate">What does the '-u' (autoupdate) switch do?</h2>
766
767 <p>The "-u" switch (autoupdate) is used to automatically expand the
768 wordlist. When this switch is used and bogofilter classifies a message
769 as Spam or Ham, the message's tokens are added to the wordlist with a
770 ham/spam tag (as appropriate).</p>
771
772 <p>As an example, suppose a new "Refinance now - best Mortgage rates"
773 message comes in. It will have some words that bogofilter has seen and
774 (probably) some new ones as well. Using '-u' the new words will be
775 added to the wordlist so that bogofilter can better recognize the next,
776 related message.</p>
777
778 <p>If/when you use to use '-u', you need to be on the lookout for
779 classification errors and retrain bogofilter with any messages that have
780 been classified incorrectly. An incorrectly classified message that is
781 auto-updated _may_ cause bogofilter to make additional classification
782 errors in the future. This is the same problem as when you (the sys
783 admin) incorrectly register a ham message as spam (or vice versa).</p>
784
785 <hr>
786
787 <h2 id="spamassassin">How can I use SpamAssassin to train Bogofilter?</h2>
788
789 <p>If you have a working SpamAssassin installation (or care to
790 create one), you can use its return codes to train bogofilter.
791 The easiest way is to create a script for your MDA that runs
792 SpamAssassin, tests the spam/non-spam return code, and runs
793 bogofilter to register the message as spam (or non-spam). The
794 sample procmail recipe below shows one way to do this:</p>
795
796 <pre> BOGOFILTER = "/usr/bin/bogofilter"
797 BOGOFILTER_DIR = "training"
798 SPAMASSASSIN = "/usr/bin/spamassassin"
799
800 :0 HBc
801 * ? $SPAMASSASSIN -e
802 #spam yields non-zero
803 #non-spam yields zero
804 | $BOGOFILTER -n -d $BOGOFILTER_DIR
805 #else (E)
806 :0Ec
807 | $BOGOFILTER -s -d $BOGOFILTER_DIR
808
809 :0fw
810 | $BOGOFILTER -p -e
811
812 :0:
813 * ^X-Bogosity:.Spam
814 spam
815
816 :0:
817 * ^X-Bogosity:.Ham
818 non-spam</pre>
819
820 <hr>
821
822 <h2 id="asian-spam">What can I do about Asian spam?</h2>
823
824 <p>Many people get unsolicited email using Asian language
825 charsets. Since they don't know the languages and don't know
826 people there, they assume it's spam.</p>
827
828 <p>The good news is that bogofilter does detect them quite
829 successfully. The bad news is that this can be expensive. You
830 have basically two choices:</p>
831
832 <ul>
833 <li>
834 <p>You can simply let bogofilter handle it. Just train
835 bogofilter with the Asian language messages identified as
836 spam. Bogofilter will parse the messages as best it can and
837 will add tokens to the spam wordlist. The wordlist will
838 contain many tokens which don't make sense to you (since
839 the charset cannot be displayed), but bogofilter can work
840 with them and successfully identify Asian spam.</p>
841
842 <p>A second method is to use the
843 "replace_nonascii_characters" config file option. This will
844 replace high-bit characters, i.e. those between 0x80 and
845 0xFF, with question marks, '?'. This keeps the database
846 much smaller. Unfortunately this conflicts with European
847 language which have many accented vowels and consonant in
848 the high-bit range.</p>
849 </li>
850
851 <li>
852 <p>If you are sure you will not receive any legitimate
853 messages in those languages, you can kill them right away.
854 This will keep the database smaller. You can do this with
855 an MDA script.</p>
856
857 <p>Here's a procmail recipe that will sideline messages
858 written with Asian charsets:</p>
859 <pre> ## Silently drop all Asian language mail
860 UNREADABLE='[^?"]*big5|iso-2022-jp|ISO-2022-KR|euc-kr|gb2312|ks_c_5601-1987'
861 :0:
862 * 1^0 $ ^Subject:.*=\?($UNREADABLE)
863 * 1^0 $ ^Content-Type:.*charset="?($UNREADABLE)
864 spam-unreadable
865
866 :0:
867 * ^Content-Type:.*multipart
868 * B ?? $ ^Content-Type:.*^?.*charset="?($UNREADABLE)
869 spam-unreadable</pre>
870
871 <p>With the above recipe, bogofilter will <em>never</em>
872 see the message.</p>
873 </li>
874 </ul>
875
876 <hr>
877
878 <h2 id="compact-database">How can I compact my database?</h2>
879
880 <p>You can periodically compact the database so it occupies a
881 minimum of disk space. Assuming your wordlist is in directory
882 ~/.bogofilter, for bogofilter 0.93.0 (or newer) use:</p>
883
884 <pre> bf_compact ~/.bogofilter wordlist.db</pre>
885
886 <p>For bogofilter older than 0.93.0, use:</p>
887
888 <pre> cd ~/.bogofilter
889 bogoutil -d wordlist.db | bogoutil -l wordlist.db.new
890 mv wordlist.db wordlist.db.prv
891 mv wordlist.db.new wordlist.db</pre>
892
893 <p>The script is needed to duplicate your database environment (in
894 order to support BerkeleyDB transaction processing). Your
895 original directory will be renamed to ~/.bogofilter.old and
896 ~/.bogofilter will contain the new database environment.</p>
897
898 <p>Since older versions of bogofilter don't use Berkeley DB
899 transactions, the database is just a single file (wordlist.db) and
900 it isn't necessary to use the script. The commands shown above
901 create a new compact database and rename the original file to
902 wordlist.db.prv</p>
903
904 <p>Note: it's O.K. to use the script with old versions of
905 bogofilter.</p>
906
907 <hr>
908
909 <h2 id="query-database">How do I manually query the database?</h2>
910
911 <p>To find the spam and ham counts for a token (word) use
912 bogoutil's '-w' option. For example, "bogoutil -w
913 $BOGOFILTER_DIR/wordlist.db example.com" gives the good and bad
914 counts for "example.com".</p>
915
916 <p>If you want the spam score in addition to the spam and ham
917 counts for a token (word) use bogoutil's '-p' option. For example,
918 "bogoutil -p $BOGOFILTER_DIR/wordlist.db example.com" gives the
919 good and bad counts for "example.com".</p>
920
921 <p>To find out how many messages are in your wordlists query the
922 special token .MSG_COUNT, i.e., run command "bogoutil -w
923 $BOGOFILTER_DIR/wordlist.db .MSG_COUNT" to see the counts for the
924 spam and ham wordlists.</p>
925
926 <p>To tell how many tokens are in your wordlists pipe the output
927 of bogoutil's dump command to command "wc", i.e. use "bogoutil -d
928 $BOGOFILTER_DIR/wordlist.db | wc -l " to display the count.</p>
929
930 <hr>
931
932 <h2 id="multiple">Can I use multiple wordlists?</h2>
933
934 <p>Yes. Bogofilter can be run with multiple wordlists. For
935 example, if you have both <code>user</code> and
936 <code>system</code> wordlists, bogofilter can be instructed to
937 check the user list and, if the word isn't there, then check the
938 system list. Alternatively, it can be instructed to add together
939 the information from the two lists.</p>
940
941 <p>Following are the config file options and some examples:</p>
942
943 <p>A wordlist has several attributes, notably type, name,
944 filename, and precedence.</p>
945
946 <ul>
947
948 <li>Type: 'R' and 'I' (for "regular" and "ignore"). Current
949 wordlists are of type 'R'. Type 'I' means "don't score the token
950 if found in the ignore list".</li>
951
952 <li>Name: a short identifying symbol used when printing error
953 messages. Examples are "global", "user", and "ignore", but you
954 can use any identifier you want.</li>
955
956 <li>Filename: the name (path) of the file. When opening the
957 wordlist, if the name is fully qualifified (with a leading '/'
958 or '~'), that name is used. If the name isn't fully qualified,
959 bogofilter will prepend the directory, using the usual search
960 order is used, i.e. $BOGOFILTER_DIR, $BOGODIR, $HOME.</li>
961
962 <li>Precedence: an integer like 1, 2, 3, ... Wordlists are
963 searched in ascending order for the token. If the search token
964 is found, lists with the same precedence number will be checked
965 (and counts added together). Lists with higher precedence
966 numbers will not be checked.</li>
967
968 </ul>
969
970 <p>Example 1 - merge user and system lists:</p>
971
972 <pre> wordlist R,user,~/wordlist.db,1
973 wordlist R,system,/var/spool/bogofilter/wordlist.db,1</pre>
974
975 <p>Example 2 - prefer user to system list:</p>
976
977 <pre> wordlist R,user,~/wordlist.db,2
978 wordlist R,system,/var/spool/bogofilter/wordlist.db,3</pre>
979
980 <p>Example 3 - prefer system to user list:</p>
981
982 <pre> wordlist R,user,~/wordlist.db,5
983 wordlist R,system,/var/spool/bogofilter/wordlist.db,4</pre>
984
985 <p>Note 1: bogofilter's registration flags ('-s', '-n', '-u',
986 '-S', '-N' ) will apply to the lowest numbered list.</p>
987
988 <p>Note 2: having lists of types 'R' and 'I' of the same
989 precedence won't be allowed because the types are
990 contradictory.</p>
991
992 <hr>
993
994 <h2 id="ignore">Can I tell bogofilter to ignore certain tokens?</h2>
995
996 <p>Through the use of an ignore list, bogofilter will ignore the
997 listed tokens when scoring the message.</p>
998
999 <p>Example:</p>
1000
1001 <pre> wordlist I,ignore,~/ignorelist.db,7
1002 wordlist R,system,/var/spool/bogofilter/wordlist.db,8</pre>
1003
1004 <p>Because <code>ignorelist.db</code> has a lower index (7), than
1005 <code>wordlist.db</code> (8), bogofilter will stop looking when
1006 finds a token in <code>ignorelist.db</code>.</p>
1007
1008 <p>Note: Technically, bogofilter gives a score of ROBX to the
1009 tokens and expects the min_dev parameter to drop them from the
1010 scoring.</p>
1011
1012 <p>There are two main methods for building/maintaining an ignore list.</p>
1013
1014 <p>First, a text file can be created and maintained using any text
1015 editor. Bogoutil can convert the text file to database format,
1016 e.g. "bogoutil -l ignorelist.db &lt; ignorelist.txt".</p>
1017
1018 <p>Alternatively, <code>echo ... | bogoutil ...</code> can be used
1019 to add a single token, for example "ignore.me", as in:</p>
1020
1021 <pre> echo ignore.me | bogoutil -l ~/ignorelist.db</pre>
1022
1023 <hr>
1024
1025 <h2 id="update">How do I upgrade from separate word databases to
1026 the combined wordlist format?</h2>
1027
1028 <p>Run script bogoupgrade. For more info, run "bogoupgrade -h" to
1029 see its help message or run "man bogoupgrade" and read its man
1030 page.</p>
1031
1032 <hr>
1033
1034 <h2 id="rescue">How can I tell if my wordlists are corrupted?</h2>
1035
1036 <p><strong>NOTE:</strong> some distributors rename all the db_
1037 utilities given below by inserting or appending the version number,
1038 with or without dot, for instance db4.1_verify or db_verify-4.2.
1039 There is no standard on the renaming of these utilities.</p>
1040
1041 <p>If you think your wordlists are hosed, you can see what
1042 BerkeleyDB thinks by running:</p>
1043 <pre> db_verify wordlist.db</pre>
1044
1045 <p>You may be able to recover some (or all) of the tokens and
1046 their counts with the following commands:</p>
1047
1048 <pre> bogoutil -d wordlist.db | bogoutil -l wordlist.new.db</pre>
1049
1050 <p>or - if there has been more damage to the token list - with</p>
1051
1052 <pre> db_dump -r wordlist.db &gt; wordlist.txt
1053 db_load wordlist.new.db &lt; wordlist.txt</pre>
1054
1055 <p>You can also use a text file instead of a pipe, as in:</p>
1056
1057 <pre> bogoutil -d wordlist.db &gt; wordlist.txt
1058 bogoutil -l wordlist.db.new &lt; wordlist.txt</pre>
1059
1060 <hr>
1061
1062 <h2 id="unicode">How can I convert my wordlist to/from unicode?</h2>
1063
1064 <p>Wordlists can be converted from raw storage to unicode using:</p>
1065
1066 <pre> bogoutil -d wordlist.db &gt; wordlist.raw.txt
1067 iconv -f iso-8859-1 -t utf-8 &lt; wordlist.raw.txt &gt; wordlist.utf8.txt
1068 bogoutil -l wordlist.db.new &lt; wordlist.utf8.txt</pre>
1069
1070 <p>or:</p>
1071
1072 <pre> bogoutil --unicode=yes -m wordlist.db</pre>
1073
1074 <p>Wordlists can be converted from unicode to raw storage using:</p>
1075
1076 <pre> bogoutil -d wordlist.db &gt; wordlist.utf8.txt
1077 iconv -f utf-8 -t iso-8859-1 &lt; wordlist.utf8.txt &gt; wordlist.raw.txt
1078 bogoutil -l wordlist.db.new &lt; wordlist.raw.txt</pre>
1079
1080 <p>or:</p>
1081
1082 <pre> bogoutil --unicode=no -m wordlist.db</pre>
1083
1084 <p>The above methods work best when the wordlist is based on the
1085 iso-8859-1 charset. If your wordlist is based on a different
1086 charset, for example CP866 or KOI8-R, use that charset in the
1087 above commands.</p>
1088
1089 <p>For a wordlist containing tokens from multiple languages,
1090 particularly non-european languages, the conversion methods
1091 described above may not work well. Building a new wordlist (from
1092 scratch) will likely work better as the new wordlist will be based
1093 solely on unicode.</p>
1094
1095 <hr>
1096
1097 <h2 id="enable-transactions">How can I switch from non-transaction
1098 to transaction mode?</h2>
1099
1100 <p>How to do this is fully documented in file doc/README.db section
1101 2.2.1. We suggest you read the whole section.</p>
1102
1103 <p>In brief, use these commands:
1104 <pre> cd ~/.bogofilter
1105 bogoutil -d wordlist.db &gt; wordlist.txt
1106 mv wordlist.db wordlist.db.old
1107 bogoutil --db-transaction=yes -l wordlist.db &lt; wordlist.txt</pre>
1108 <p>If everything went well, you can remove the backup files:</p>
1109 <pre> rm wordlist.db.old wordlist.txt</pre>
1110 <hr>
1111
1112 <h2 id="disable-transactions">How can I switch from transaction to
1113 non-transaction mode?</h2>
1114
1115 <p>How to do this is fully documented in file doc/README.db section
1116 2.2.2. We suggest you read the whole section.</p>
1117
1118 <p>In brief, you can use bogoutil to dump/load the wordlist, for example:
1119 <pre> cd ~/.bogofilter
1120 bogoutil -d wordlist.db &gt; wordlist.txt
1121 mv wordlist.db wordlist.db.old
1122 rm -f log.?????????? __db.???
1123 bogoutil --db-transaction=no -l wordlist.db &lt; wordlist.txt</pre>
1124
1125 <hr>
1126
1127 <h2 id="locksize">Why does bogofilter die after printing
1128 "Lock table is out of available locks" or
1129 "Lock table is out of available object entries"</h2>
1130
1131 <p>The transactional and concurrent modes of BerkeleyDB require a
1132 lock table that corresponds to the data base in size. See the
1133 <samp>README.db</samp> file for a detailed explanation and a
1134 remedy.</p>
1135
1136 <p>The size of the lock table can be set in bogofilter.cf or in
1137 DB_CONFIG. Bogofilter.cf uses the db_lk_max_locks and
1138 db_lk_max_objects directives, while DB_CONFIG uses the
1139 set_lk_max_objects and set_lk_max_locks directives.</p>
1140
1141 <p>After changing these values in DB_CONFIG, run command
1142 <pre> bogoutil --db-recover /your/bogofilter/directory</pre>
1143 <p>to rebuild the lock tables.</p>
1144
1145 <hr>
1146
1147 <h2 id="page-notfound">Why am I getting DB_PAGE_NOTFOUND messages?</h2>
1148
1149 <p>You have a problem with your BerkeleyDB database. There are
1150 two likely causes: either you've hit a max size limit or the
1151 database is corrupt.</p>
1152
1153 <p>Some mail transfer agents, such as Postfix, impose file size
1154 limits. When bogofilter's database reaches that limit, write
1155 problems will occur.
1156
1157 <p>To show the database size use:</p>
1158 <pre> ls -lh $BOGOFILTER_DIR/wordlist.db</pre>
1159
1160 <p>To show the postfix setting:</p>
1161 <pre> postconf | grep mailbox_size_limit</pre>
1162
1163 <p>To set the limit to 73MB (or whatever size is right for you):</p>
1164 <pre> postconf -e mailbox_size_limit=73000000</pre>
1165
1166 <p>If you think your database may be corrupt, read
1167 <a href="#rescue">How can I tell if my wordlists are corrupted?</a>
1168 FAQ entry.</p>
1169
1170 <hr>
1171
1172 <h2 id="db-private">Why am I getting &quot;Berkeley DB
1173 library configured to support only DB_PRIVATE
1174 environments&quot; or<br>
1175 &quot;Berkeley DB library configured to support only
1176 private environments&quot;?</h2>
1177
1178 <p>Some distributors (for instance the Fedora Project) package
1179 Berkeley DB with support for POSIX threading and hence POSIX
1180 mutexes, but your system does not support POSIX mutexes
1181 (whether it
1182 does, depends on the kernel version and exact processor
1183 type).</p>
1184
1185 <p>To work around this problem:
1186 <ol>
1187 <li>download, compile and install <a
1188 href="http://www.sleepycat.com/products/db.shtml">Berkeley
1189 DB</a> on your own and the reconfigure bogofilter:
1190 <ol>
1191 <li><kbd>cd build_unix</kbd></li>
1192 <li><kbd>../dist/configure --enable-cxx</kbd></li>
1193 <li><kbd>make</kbd></li>
1194 <li><kbd>make install</kbd></li>
1195 </ol>
1196 <li>recompile and install bogofilter:
1197 <ol>
1198 <li><kbd>./configure
1199 --with-libdb-prefix=/usr/local/BerkeleyDB.4.3</kbd>
1200 <em>(replace your Berkeley DB version number)</em></li>
1201 <li><kbd>make &amp;&amp; make check</kbd></li>
1202 <li><kbd>make install</kbd> <em>(if space is a
1203 premium, use <kbd>make install-strip)</kbd></em></li>
1204 </ol>
1205 </ol>
1206
1207 <hr>
1208
1209 <h2 id="multi-user">Can bogofilter be used in a multi-user environment?</h2>
1210
1211 <p>Yes, it can. There are multiple, distinct strategies for doing
1212 this. The two extremes are:</p>
1213
1214 <ul>
1215 <li>Having a bogofilter administrator who maintains a global
1216 wordlist that everybody uses.</li>
1217 <li>Having each user maintain his/her own wordlist.</li>
1218 </ul>
1219
1220 <p>As a middle ground, the bogofilter administrator can create and
1221 maintain the global wordlists and each user can be given the
1222 choice of using the global wordlist or a private wordlist. An
1223 MDA, such as procmail, can be programmed to first apply the global
1224 wordlist (with a very stringent spam cutoff) and then (if
1225 necessary) apply the user's wordlist.</p>
1226
1227 <hr>
1228
1229 <h2 id="nfs">Can I share wordlists over NFS?</h2>
1230
1231 <p>If you're just reading from them, there are no problems.
1232 When you're updating them, you need to use the correct file
1233 locking to avoid data corruption. When you compile bogofilter, you
1234 will need to verify that the configure script has set "#define
1235 HAVE_FCNTL 1" in your config.h file. Popular UNIX operating
1236 systems will all support this. If you are running an unusual, or
1237 an older version of an operating system, make sure it supports
1238 fcntl(). If your system does not
1239 support fcntl(), then you will not be able to share wordlist
1240 files over NFS without the risk of data corruption.</p>
1241
1242 <p>Next, make sure you have NFS set up properly, with "lockd"
1243 running. Refer to your NFS documentation for more information
1244 about running "lockd" or "rpc.lockd". Most operating systems
1245 with NFS turn this on by default.</p>
1246
1247 <p>For shared directories (NFS directories used by multiple
1248 machines, for instance, Sparc/Itanium/Alpha and x86), the
1249 architecture-specific parts can be installed separately by giving
1250 a different <code>--exec-prefix</code> (it will default to
1251 <code>--prefix</code>)
1252
1253 <hr>
1254
1255 <h2 id="return-codes">Why does bogofilter give return codes
1256 like 0 and 256 when it's run from inside a program?</h2>
1257
1258 <p>Likely the return codes are being reformatted by waitpid(2).
1259 In C use WEXITSTATUS(status) in sys/wait.h, or comparable macro,
1260 to get the correct value. In Perl you can just use
1261 'system("bogofilter $input") &gt;&gt; 8'. If you want more info, run
1262 <code>"man waitpid"</code>.</p>
1263
1264 <hr>
1265
1266 <h2 id="changed-options">Now that I've upgraded why are
1267 my scripts broken?</h2>
1268
1269 <p>Over time bogofilter accumulated a large number of functions.
1270 Some of those were discontinued or changed. Please read the
1271 <a href="http://bogofilter.sourceforge.net/NEWS">NEWS</a> file
1272 for details.</p>
1273
1274 <hr>
1275
1276 <h2 id="changed-tagging">Now that I've upgraded why is
1277 bogofilter working less well?</h2>
1278
1279 <p>The lexer, i.e., that part of bogofilter which extracts tokens
1280 from a message, evolves. This results in different readings of messages
1281 with the consequence that some tokens in the database can no longer be
1282 used.</p>
1283
1284 <p>If you encounter this problem, you are strongly advised to rebuild your
1285 database. If this is not an option for you, you might want to use version
1286 <a href="http://sourceforge.net/project/showfiles.php?group_id=62265&amp;package_id=59357">0.15.13</a>
1287 and read the documentation which comes with it for how to migrate your
1288 database.</p>
1289
1290 <hr>
1291
1292 <h2 id="remove-spam-or-nonspam">How can I
1293 delete all the spam (or non-spam) tokens?</h2>
1294
1295 <p>Bogoutil lets you dump a wordlist and load the tokens into a
1296 new wordlist. With the added use of awk and grep, counts can be
1297 zeroed and tokens with zero counts for both spam and non-spam can be
1298 deleted.</p>
1299
1300 <p>The following commands will delete the tokens from spam messages:</p>
1301
1302 <pre> bogoutil -d wordlist.db | \
1303 awk '{print $1 " " $2 " 0"}' | grep -v " 0 0" | \
1304 bogoutil -l wordlist.new.db</pre>
1305
1306 <p>The following commands will delete the tokens from non-spam messages:</p>
1307
1308 <pre> bogoutil -d wordlist.db | \
1309 awk '{print $1 " 0 " $3}' | grep -v " 0 0" | \
1310 bogoutil -l wordlist.new.db</pre>
1311
1312 <hr>
1313
1314 <h2 id="port-notes">How do I get bogofilter working on Solaris, BSD, etc?</h2>
1315
1316 <p>If you don't already have a v3.0+ version of
1317 <a href="http://www.sleepycat.com/">BerkeleyDB</a>, then
1318 <a href="http://www.sleepycat.com/download/db/">download it (take
1319 one of the 4.4.X, 4.3.X or 4.2.X versions)</a>,
1320 unpack it, and do these commands in the db directory:</p>
1321 <pre> $ cd build_unix
1322 $ sh ../dist/configure
1323 $ make
1324 # make install</pre>
1325
1326 <p>Next, download a
1327 <a href="http://sourceforge.net/projects/bogofilter/files/">portable version</a>
1328 of bogofilter.</p>
1329
1330 <h3>On Solaris</h3>
1331
1332 <p>Be sure that your PATH environment variable begins with
1333 /usr/xpg6/bin:/usr/xpg4/bin:/usr/ccs/bin (/usr/xpg6/bin is only
1334 present on Solaris 10 and can be omitted on Solaris 9 and older
1335 versions). That is required for POSIX compliance.</p>
1336
1337 <p>Unpack it, and then do:</p>
1338 <pre> $ ./configure --with-libdb-prefix=/usr/local/BerkeleyDB.4.4
1339 $ make
1340 # make install-strip</pre>
1341
1342 <p>You will either want to put a symlink to libdb.so in
1343 /usr/lib, or use a modified LD_LIBRARY_PATH environment
1344 variable before you start bogofilter. On newer systems, the most
1345 convenient way is probably to use the crle(1) tool to set the path
1346 permanently so BerkeleyDB is available to all applications.</p>
1347 <pre> $ LD_LIBRARY_PATH=/usr/lib:/usr/local/lib:/usr/local/BerkeleyDB.4.4
1348 $ export LD_LIBRARY_PATH</pre>
1349
1350 <p>Note that some "make" versions shipped with older Solaris version
1351 break when you try to build bogofilter outside of its source
1352 directory. Either build in the source directory (as suggested
1353 above) or use GNU make (gmake).</p>
1354
1355 <p>If your Solaris GCC complains with "ld: fatal: file values-Xa.o:
1356 open failed: No such file or directory", install the SUNWarc
1357 package.</p>
1358
1359 <h3>On FreeBSD</h3>
1360
1361 <p>The FreeBSD ports collection carries the latest stable versions of
1362 bogofilter to be compiled from source. The bogofilter ports are also auto-built and provided as binary packages for you to install.</p>
1363
1364 <p>The <a href="https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/pkgng-intro.html">binary
1365 packages approach</a> uses default installed software. To install
1366 bogofilter from binary package, type, as the privileged user:</p>
1367 <pre> pkg install -y bogofilter</pre>
1368
1369 <p>The ports from-source approach uses the highly recommended
1370 portmaster and portsnap software packages. To install portmaster,
1371 type (you need to do this only once), as root:</p>
1372 <pre> pkg install -y portmaster</pre>
1373
1374 <p>To install or upgrade bogofilter, just
1375 <a
1376 href="https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports-using.html">upgrade
1377 your portstree using portsnap</a>,
1378 then type, as root:</p>
1379 <pre> portmaster mail/bogofilter</pre>
1380
1381 <p><em>Note: This assumes you are root.</em> If not, read through
1382 the remainder of this FreeBSD section and then see how you can
1383 <a href="#build">build</a> if you haven't got root privileges.</p>
1384
1385 <h3>On NetBSD and other systems that use "pkgsrc"</h3>
1386
1387 <p>pkgsrc should be offering a reasonably recent stable bogofilter
1388 release. See <a
1389 href="http://www.pkgsrc.org/">http://www.pkgsrc.org/</a> for
1390 information on pkgsrc.</p>
1391
1392 <h3>On HP-UX</h3>
1393
1394 <p>See the file
1395 <a
1396 href="http://bogofilter.cvs.sourceforge.net/*checkout*/bogofilter/bogofilter/doc/programmer/README.hp-ux?content-type=text%2Fplain&amp;revision=HEAD">doc/programmer/README.hp-ux</a>
1397 in the source distribution.</p>
1398
1399 <hr>
1400
1401 <h2 id="make-notes">Can I use the make command on my operating system?</h2>
1402
1403 <p>Bogofilter has been successfully built on many operating
1404 systems using GNU make and the native make commands. However,
1405 bogofilter's Makefile doesn't work with some make commands.</p>
1406
1407 <p>GNU make is recommended for building bogofilter because we
1408 know it works. We cannot support less capable make commands. If
1409 your non-GNU make command can successfully build bogofilter,
1410 that's great. If you encounter problems, the right thing to do is
1411 install GNU make. If your non-GNU make can't build bogofilter,
1412 we're sorry but you're on your own. If it takes just a minor and clean
1413 patch to make it compatible, we might take it.</p>
1414
1415 <hr>
1416
1417 <h2 id="build">How do I build bogofilter as non-root user or for
1418 a non-standard installation prefix?</h2>
1419
1420 <p>To install bogofilter to a non-standard path (as non-root user
1421 you don't have the permission to the normal paths), you need to
1422 provide the installation prefix when you run <code>./configure</code>.
1423
1424 <p> After downloading and unpacking the <a
1425 href="http://sourceforge.net/projects/bogofilter/files/">
1426 source code</a>, run <code>./configure --prefix=PATH</code> where
1427 PATH is the installation prefix for the generated files (binaries,
1428 man pages etc.). Then run the usual build commands &#8212;
1429 <code>make &amp;&amp; make check &amp;&amp; make install</code>.
1430 </p>
1431
1432 <hr>
1433
1434 <h2 id="patch">How do I build bogofilter with patches?</h2>
1435
1436 <p>If you need to apply patches, get the <a
1437 href="http://sourceforge.net/projects/bogofilter/files/">source
1438 code</a> and unpack it using <code>tar -xzf</code> or <code>gunzip
1439 | tar -xf -</code> (as appropriate). Change to the
1440 source directory and run <code>./configure --prefix=PATH</code>
1441 where PATH is the installation prefix for the generated files
1442 (binaries, man pages etc.). Apply your patches than run
1443 <code>make &amp;&amp; make install</code>.
1444
1445 <hr>
1446
1447 <h2 id="smaller">How do I make the executables smaller?</h2>
1448
1449 <p>When space is tight, you can use <code>make
1450 install-strip</code> instead of <code>make install</code>. Doing
1451 this will save space, but crashes can't be debugged unless more
1452 information on reproducing the bug is provided to the
1453 developers.</p>
1454
1455 <hr>
1456
1457 <h2 id="relativepath">datastore_db.c does not compile!</h2>
1458
1459 <p>If you are configuring a data base path for instance with
1460 --with-libdb-prefix or via CPPFLAGS and LIBS, be sure to pass in an
1461 <em>absolute path</em> (with leading slash), a relative path will
1462 not work. Example: use
1463 <kbd>--with-libdb-prefix=/usr/local/BerkeleyDB.4.2</kbd>, but
1464 <em>not</em> <kbd>--with-libdb-prefix=../BerkeleyDB.4.2</kbd></p>
1465
1466 <hr>
1467
1468 <h2 id="which-muas">With which mail programs does bogofilter work?</h2>
1469
1470 <p>Bogofilter is known to work with kmail, mozilla-mail, mutt,
1471 alpine, sylpheed-claws. A google search will help you
1472 find more information on using bogofilter with the mail program
1473 you use.</p>
1474
1475 <hr>
1476
1477 <h2 id="with-mutt">How do I use bogofilter with mutt?</h2>
1478
1479 <p>Use a mail filter (procmail, maildrop, etc.) to filter mail
1480 into different folders based on bogofilter's return code and set
1481 mutt key bindings to train bogofilter on errors:</p>
1482
1483 <pre> macro index S "|bogofilter -s\ns=junkmail" "Learn as spam and save to junk"
1484 macro pager S "|bogofilter -s\ns=junkmail" "Learn as spam and save to junk"
1485 macro index H "|bogofilter -n\ns=" "Learn as ham and save"
1486 macro pager H "|bogofilter -n\ns=" "Learn as ham and save"</pre>
1487
1488 <p>These will pipe the selected message through bogofilter,
1489 training a false-ham as spam or vice versa, then offer to save the
1490 message to a different folder.</p>
1491
1492 <hr>
1493
1494 <h2 id="with-sc">How do I use bogofilter with Sylpheed Claws?</h2>
1495
1496 <p> Add a filtering rule to run bogofilter on incoming messages
1497 and an action to perform if it's spam </p>
1498
1499 <pre> condition:
1500 * test "bogofilter &lt; %F"
1501 action:
1502 * move "#mh/YOUR_SPAM_BOX"</pre>
1503
1504 <p>Note: this assumes that bogofilter is in your path!</p>
1505
1506 <p> Create two Claws actions - one for marking messages as spam
1507 and one for marking messages as ham. Use the "Mark As Spam"
1508 action for messages incorrectly classified as ham and use the "Mark As Ham"
1509 action for messages incorrectly classified as spam.</p>
1510
1511 <pre> Mark as ham / spam:
1512 * bogofilter -n -v -B "%f" (mark ham)
1513 * bogofilter -s -v -B "%f" (mark spam)</pre>
1514
1515 <p>Another approach is to save incorrectly classified messages in
1516 a folder (or folders) and run a script like:</p>
1517
1518 <pre> #!/bin/sh
1519 CONFIGDIR=~/.bogofilter
1520 SPAMDIRS="$CONFIGDIR/spamdirs"
1521 MARKFILE="$CONFIGDIR/lastbogorun"
1522 for D in `cat "$SPAMDIRS"`; do
1523 find "$D" -type f -newer "$MARKFILE" -not -name ".sylpheed*"
1524 done|bogofilter -bNsv
1525 touch "$MARKFILE"</pre>
1526
1527 <p>This script can be used as an action and/or made into a toolbar
1528 button. It will register as spam the messages in ${SPAMDIRS} that
1529 are newer than ${MARKFILE}.</p>
1530
1531 <p>Additional information is available at the <a
1532 href="http://www.sylpheed-claws.net/faq/index.php/Using_Sylpheed-Claws_with_other_programs">
1533 Sylpheed-Claws's wiki</a>.</p>
1534
1535 <hr>
1536
1537 <p>Another approach is to run bogofilter from procmail, maildrop,
1538 etc and have Claws check the X-Bogosity header and filter messages
1539 into Spam and Unsure folders, e.g.:</p>
1540
1541 <pre> Condition:
1542 header "X-Bogosity" matchcase "Spam"
1543 Action:
1544 move "#mh/Mailbox/Spam"
1545 Condition:
1546 header "X-Bogosity" matchcase "Unsure"
1547 Action:
1548 move "#mh/Mailbox/Unsure"</pre>
1549
1550 <p>Any messages in the Unsure folder should be used for training,
1551 as should messages incorrectly classified as ham or spam. The
1552 actions below will handle these cases:</p>
1553
1554 <pre> Register Spam:
1555 bogofilter -s &lt; "%f"
1556
1557 Register Ham:
1558 bogofilter -n &lt; "%f"
1559
1560 Unregister Spam:
1561 bogofilter -S &lt; "%f"
1562
1563 Unregister Ham:
1564 bogofilter -N &lt; "%f"</pre>
1565
1566 <p>To look inside the bogofilter scoring mechanism, the following
1567 diagnostic are useful:</p>
1568
1569 <pre> BogoTest -vv:
1570 bogofilter -vv &lt; "%f"
1571
1572 BogoTest -vvv:
1573 bogofilter -vvv &lt; "%f"</pre>
1574
1575 <p>Additional information on this approach is available <a
1576 href="http://www.bogofilter.org/pipermail/bogofilter/2005-March/007815.html">here</a>.</p>
1577
1578 <hr>
1579
1580 <h2 id="with-vm">How do I use bogofilter with VM (an Emacs Mail
1581 tool)?</h2>
1582
1583 <p>You need to include the separate file vm-bogofilter.el
1584 (included in bogofilter's contrib directory). The latest version
1585 of the file is at
1586 http://www.cis.upenn.edu/~bjornk/bogofilter/vm-bogofilter.el) in
1587 your emacs path.</p>
1588
1589 <p>Then, just add in your ~/.vm configuration file:</p>
1590
1591 <pre>;; load bogofilter capabilities (spam)
1592 ;;
1593 (require 'vm-bogofilter)
1594
1595 ;; short-key for bogofilter
1596 ;; C (shift-c) means spam message
1597 ;; K (shift-k) means ham message
1598 (define-key vm-mode-map "K" 'vm-bogofilter-is-spam)
1599 (define-key vm-mode-map "C" 'vm-bogofilter-is-clean)
1600 </pre>
1601
1602 <p>All the messages are filtered by bogofilter each time you check
1603 newly arrived e-mail. When you change the status of an e-mail,
1604 the bogofilter header is changed (X-Bogosity: header).</p>
1605
1606 <p>There is a limit: you cannot change multiple message headers at
1607 one time in VM; you have to do it message by message.</p>
1608
1609 <hr>
1610
1611 <h2 id="with-mh-e">How do I use bogofilter with MH-E (the Emacs
1612 interface to the MH mail system)?</h2>
1613
1614 <p>The default setting of the 'mh-junk-program' option is
1615 'Auto-detect' which means that MH-E will automatically choose one
1616 of SpamAssassin, Bogofilter, or SpamProbe in that order. If, for
1617 example, you have both SpamAssassin and Bogofilter installed and
1618 you want to use BogoFilter, then you can set this option to
1619 'Bogofilter'.</p>
1620
1621 <p>The 'J b' ('mh-junk-blacklist') command trains the spam program
1622 in use with the content of the range and then handles the
1623 message(s) as specified by the 'mh-junk-disposition' option. By
1624 default, this option is set to 'Delete Spam' but you can also
1625 specify the name of the folder which is useful for building a
1626 corpus of spam for training purposes.</p>
1627
1628 <p>In contrast, the 'J w' ('mh-junk-whitelist') command
1629 reclassifies a range of messages as ham if it were incorrectly
1630 classified as spam. It then refiles the message into the '+inbox'
1631 folder.</p>
1632
1633 <p> For more information, see the <a
1634 href="http://mh-e.sourceforge.net/">MH-E home page</a>
1635
1636 </body>
1637 </html>