📄 bogofilter.htmlin
字号:
robs and robx values. With three values, min-dev, robs, and robx are all set. If fewer values are given, parameters are set as described in the note below.</p><p>The <code class="option">-o <em class="replaceable"><code>value[<span class="optional">,value</span>]</code></em></code> option allows setting the spam-cutoff ham-cutoff values. With two values, both spam-cutoff and ham-cutoff are set. If only one value is given, parameters are set as described in the note below.</p><p>Note: All of these options allow fewer values to be provided. Values can be skipped by using just the comma delimiter, in which case the corresponding parameter(s) won't be changed. If only the first value is provided, then only the first parameter is set. Trailing values can be skipped, in which case the corresponding parameters won't be changed. Within the parameter list, spaces are not allowed after commas.</p><p>INFO OPTIONS</p><p>The <code class="option">-v</code> option produces a report to standardoutput on <span class="application">bogofilter</span>'s analysis of theinput. Each additional <code class="option">v</code> will increase the verbosity ofthe output, up to a maximum of 4. With <code class="option">-vv</code>, the reportlists the tokens with highest deviation from a mean of 0.5 associationwith spam.</p><p>Option <code class="option">-y date</code> can be used to override thecurrent date when timestamping tokens. A value of zero (0) turns offtimestamping.</p><p>The <code class="option">-D</code> option redirects debug output tostdout.</p><p>The <code class="option">-x <em class="replaceable"><code>flags</code></em></code> optionallows setting of debug flags for printing debug information. Seeheader file debug.h for the list of usable flags.</p><p>CONFIG FILE OPTIONS</p><p>Using GNU longopt <code class="option">--</code> syntax, a config file's<code class="option"><em class="replaceable"><code>name=value</code></em></code> statementbecomes a command line's<code class="option">--<em class="replaceable"><code>option=value</code></em></code>. Usecommand <span><strong class="command">bogofilter --help</strong></span> for a list of options andsee <code class="filename">bogofilter.cf.example</code> for more info onthem. For example to change the X-Bogosity header to "X-Spam-Header", use:</p><p><code class="option"><em class="replaceable"><code>--spam-header-name=X-Spam-Header</code></em></code></p></div><div class="refsect1" lang="en"><a name="environment"></a><h2>ENVIRONMENT</h2><p><span class="application">Bogofilter</span> uses a database directory,which can be set in the config file. If not set there,<span class="application">bogofilter</span> will use the value of<code class="envar">BOGOFILTER_DIR</code>. Both can be overridden by the<code class="option">-d <em class="replaceable"><code>dir</code></em></code> option. If none ofthat is available, <span class="application">bogofilter</span> will use directory<code class="filename">$HOME/.bogofilter</code>.</p></div><div class="refsect1" lang="en"><a name="configuration"></a><h2>CONFIGURATION</h2><p>The <span class="application">bogofilter</span> command line allowssetting of many options that determine how<span class="application">bogofilter</span> operates. File<code class="filename">@sysconfdir@/bogofilter.cf</code> can be used to setadditional parameters that affect its operation. File<code class="filename">@sysconfdir@/bogofilter.cf.example</code> has samples ofall of the parameters. Status and logging messages can be customizedfor each site.</p></div><div class="refsect1" lang="en"><a name="returns"></a><h2>RETURN VALUES</h2><p>0 for spam; 1 for non-spam; 2 for unsure ; 3 for I/O or other errors.</p><p>If both <code class="option">-p</code> and <code class="option">-e</code> are used, the return values are: 0 for spam or non-spam; 3 for I/O or other errors.</p><p>Error 3 usually means that the wordlist file<span class="application">bogofilter</span> wants to read at startupis missing or the hard disk has filled up in <code class="option">-p</code> mode.</p></div><div class="refsect1" lang="en"><a name="integration"></a><h2>INTEGRATION WITH OTHER TOOLS</h2><p>Use with procmail</p><p>The following recipe (a) spam-bins anything that<span class="application">bogofilter</span> rates as spam, (b) registers thewords in messages rated as spam as such, and (c) registers thewords in messages rated as non-spam as such. Withthis in place, it will normally only be necessary for the user tointervene (with <code class="option">-Ns</code> or <code class="option">-Sn</code>) when<span class="application">bogofilter</span> miscategorizes something.</p><pre class="programlisting"><em class="lineannotation"><span class="lineannotation"># filter mail through bogofilter, tagging it as Ham, Spam, or Unsure,# and updating the wordlist</span></em>:0fw| bogofilter -u -e -p<em class="lineannotation"><span class="lineannotation"># if bogofilter failed, return the mail to the queue;# the MTA will retry to deliver it later# 75 is the value for EX_TEMPFAIL in /usr/include/sysexits.h</span></em>:0e{ EXITCODE=75 HOST }<em class="lineannotation"><span class="lineannotation"># file the mail to <code class="filename">spam-bogofilter</code> if it's spam.</span></em>:0:* ^X-Bogosity: Spam, tests=bogofilterspam-bogofilter<em class="lineannotation"><span class="lineannotation"># file the mail to <code class="filename">unsure-bogofilter</code> # if it's neither ham nor spam.</span></em>:0:* ^X-Bogosity: Unsure, tests=bogofilterunsure-bogofilter# With this recipe, you can train bogofilter starting with an empty# wordlist. Be sure to check your unsure-folder regularly, take the# messages out of it, classify them as ham (or spam), and use them to# train bogofilter.</pre><p>The following procmail rule will take mail on stdin and saveit to file <code class="filename">spam</code> if<span class="application">bogofilter</span> thinks it's spam:</p><pre class="programlisting">:0HB:* ? bogofilterspam</pre><p>and this similar rule will also register the tokens in the mailaccording to the <span class="application">bogofilter</span> classification:</p><pre class="programlisting">:0HB:* ? bogofilter -uspam</pre><p></p><p>If <span class="application">bogofilter</span> fails (returning 3) themessage will be treated as non-spam.</p><p>This one is for <span class="application">maildrop</span>, it automatically defers the mail and retries later when the <span class="application">xfilter</span> command fails, use this in your <code class="filename">~/.mailfilter</code>:</p><pre class="programlisting">xfilter "bogofilter -u -e -p"if (/^X-Bogosity: Spam, tests=bogofilter/){ to "spam-bogofilter"}</pre><p>The following <code class="filename">.muttrc</code> lines will createmutt macros for dispatching mail to<span class="application">bogofilter</span>.</p><pre class="programlisting">macro index d "<enter-command>unset wait_key\n\<pipe-entry>bogofilter -n\n\<enter-command>set wait_key\n\<delete-message>" "delete message as non-spam"macro index \ed "<enter-command>unset wait_key\n\<pipe-entry>bogofilter -s\n\<enter-command>set wait_key\n\<delete-message>" "delete message as spam"</pre><p>Integration with Mail Transport Agent (MTA)</p><div class="procedure"><ol type="1"><li><p><span class="application">bogofilter</span> can also be integrated into an MTA to filter all incoming mail. While the specific implementation is MTA dependent, the general steps are as follows:</p></li><li><p>Install <span class="application">bogofilter</span> on the mail server</p></li><li><p>Prime the <span class="application">bogofilter</span> databases with a spamand non-spam corpus. Since <span class="application">bogofilter</span> will beserving a larger community, it is important to prime it with a representativeset of messages.</p></li><li><p>Set up the MTA to invoke <span class="application">bogofilter</span> on each message. While this is an MTA specific step, you'll probably need to use the <code class="option">-p</code>, <code class="option">-u</code>, and <code class="option">-e</code> options.</p></li><li><p>Set up a mechanism for users to register spam/non-spam messages, as well as to correct mis-classifications. The most generic solution is to set up alias email addresses to which users bounce messages.</p></li><li><p>See the <code class="filename">doc</code> and <code class="filename">contrib</code> directories for more information.</p></li></ol></div><p>Use of R to verify <span class="application">bogofilter</span>'scalculations</p><p>The -R option tells <span class="application">bogofilter</span> togenerate an R data frame. The data frame contains one row per tokenanalyzed. Each such row contains the token, the sum of its database"good" and "spam" counts, the "good" count divided by the number ofnon-spam messages used to create the training database, the "spam"count divided by the spam message count, Robinson's f(w) for the token,the natural logs of (1 - f(w)) and f(w), and an indicator character (+if the token's f(w) value exceeded the minimum deviation from 0.5, - ifit didn't). There is one additional row at the end of the table thatcontains a label in the token field, followed by the number of wordsactually used (the ones with + indicators), Robinson's P, Q, S, s and xvalues and the minimum deviation.</p><p>The R data frame can be saved to a file and later readinto an R session (see <a href="http://cran.r-project.org/" target="_top">the Rproject website</a> for information about the mathematics packageR). Provided with the <span class="application">bogofilter</span>distribution is a simple R script (file bogo.R) that can be used toverify <span class="application">bogofilter</span>'s calculations.Instructions for its use are included in the script in the form ofcomments.</p></div><div class="refsect1" lang="en"><a name="logmessages"></a><h2>Log messages</h2><p><span class="application">Bogofilter</span> writes messages to the system log when the <code class="option">-l</code> option is used. What is written depends on which other flags are used.</p><p>A classification run will generate (we are not showing the date and host part here): </p><pre class="screen">bogofilter[1412]: X-Bogosity: Ham, spamicity=0.000227bogofilter[1415]: X-Bogosity: Spam, spamicity=0.998918</pre><p>Using <code class="option">-u</code> to classify a message and update a wordlist will produce (one a single line): </p><pre class="screen">bogofilter[1426]: X-Bogosity: Spam, spamicity=0.998918, register -s, 329 words, 1 messages </pre><p>Registering words (<code class="option">-l</code> and <code class="option">-s</code>, <code class="option">-n</code>, <code class="option">-S</code>, or <code class="option">-N</code>) will produce: </p><pre class="screen">bogofilter[1440]: register-n, 255 words, 1 messages</pre><p>A registration run (using <code class="option">-s</code>, <code class="option">-n</code>, <code class="option">-N</code>, or <code class="option">-S</code>) will generate messages like:</p><pre class="screen">bogofilter[17330]: register-n, 574 words, 3 messagesbogofilter[6244]: register-s, 1273 words, 4 messages</pre></div><div class="refsect1" lang="en"><a name="files"></a><h2>FILES</h2><div class="variablelist"><dl><dt><span class="term"><code class="filename">@sysconfdir@/bogofilter.cf</code></span></dt><dd><p>System configuration file.</p></dd><dt><span class="term"><code class="filename">~/.bogofilter.cf</code></span></dt><dd><p>User configuration file.</p></dd><dt><span class="term"><code class="filename">~/.bogofilter/wordlist.db</code></span></dt><dd><p>Combined list of good and spam tokens.</p></dd></dl></div></div><div class="refsect1" lang="en"><a name="author"></a><h2>AUTHOR</h2><div class="literallayout"><p><br>Eric S. Raymond <code class="email"><<a href="mailto:esr@thyrsus.com">esr@thyrsus.com</a>></code>.<br>David Relson <code class="email"><<a href="mailto:relson@osagesoftware.com">relson@osagesoftware.com</a>></code>.<br>Matthias Andree <code class="email"><<a href="mailto:matthias.andree@gmx.de">matthias.andree@gmx.de</a>></code>.<br>Greg Louis <code class="email"><<a href="mailto:glouis@dynamicro.on.ca">glouis@dynamicro.on.ca</a>></code>.<br></p></div><p>For updates, see the <a href="http://bogofilter.sourceforge.net/" target="_top"> bogofilter project page</a>.</p></div><div class="refsect1" lang="en"><a name="also"></a><h2>SEE ALSO </h2><p>bogolexer(1), bogotune(1), bogoupgrade(1), bogoutil(1)</p></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -