-e option suggestion with doc update
Matthias Andree
matthias.andree at gmx.de
Sun Oct 6 13:00:03 CEST 2002
I have this "-e" patch ready for commit. Check the embedded
documentation changes for details.
Outline: bogofilter -p -e will exit(0) if the mail is non-spam and drop
the old-style procmail recipe. Recommended for the current procmail
recipes, required for maildrop integration via 'xfilter'. No need to
confuse the user with needless examples.
Boris, how do I figure in the current procmail recipes that the
preceding filter has failed? I tried :0e and :0E lines at no avail.
bogofilter.xml | 45 ++++++++++++++++++++++-----------------------
main.c | 12 ++++++++++--
2 files changed, 32 insertions(+), 25 deletions(-)
Index: bogofilter.xml
===================================================================
RCS file: /cvsroot/bogofilter/bogofilter/bogofilter.xml,v
retrieving revision 1.12
diff -u -r1.12 bogofilter.xml
--- bogofilter.xml 4 Oct 2002 23:21:23 -0000 1.12
+++ bogofilter.xml 6 Oct 2002 10:52:50 -0000
@@ -21,6 +21,7 @@
<arg choice='opt'>-N</arg>
<arg choice='opt'>-d</arg>
<arg choice='opt'>-p</arg>
+ <arg choice='opt'>-e</arg>
<arg choice='opt'>-u</arg>
<arg choice='opt'>-v</arg>
<arg choice='opt'>-V</arg>
@@ -107,6 +108,11 @@
"No" according as the mail is judged to be spam or non-spam
respectively.</para>
+<para>The <option>-e</option> (embed) option is only effective when
+ <option>-p</option> is also active. If both options are used, then
+ bogofilter will exit with code 0 even if the mail is not spam. This
+ simplifies using bogofilter from procmail or maildrop.</para>
+
<para>The <option>-u</option> (update) option tells
<application>bogofilter</application>
to automatically update the appropriate wordfile.
@@ -148,35 +154,25 @@
intervene (with <option>-N</option> or <option>-S</option>) when
<application>bogofilter</application> miscategorizes something.</para>
<programlisting class="procmail">
- :0HB
- * ? bogofilter
- {
- :0c
- | bogofilter -s
-
- :0:
- spam-bogofilter
- }
-
- :0Ec
- | bogofilter -n
-</programlisting>
-
-<para> An alternate approach is to use the update ('-u') option. When it is specified
-<application>bogofilter</application> will classify the text and update either the spam wordlist or the good wordlist, as appropriate.
-Here's a procmail recipe that does three things. The '-u' option causes updating of the word lists; the '-p' option adds a "X-Spam-Status: Yes/No" line to the message; and the "spam-bogofilter" action line puts all spam into file spam-bogofilter.
-</para>
-
-<programlisting class="procmail">
:0fw
- | bogofilter -u -p
+ | bogofilter -u -e -p
:0:
- * ^X-Spam-Status: Yes
+ * ^X-Spam-Status: Yes, tests=bogofilter
spam-bogofilter
</programlisting>
+<para>This one is for maildrop:</para>
+<programlisting class="maildrop">
+ xfilter "bogofilter -u -e -p"
+ if (/^X-Spam-Status: Yes, tests=bogofilter/)
+ {
+ to "spam-bogofilter"
+ }
+
+</programlisting>
+
<para>The following <filename>.muttrc</filename> lines will create
mutt macros for dispatching mail to
<application>bogofilter</application>.</para>
@@ -188,10 +184,13 @@
<refsect1 id='returns'><title>RETURN VALUES</title>
<para>0 for spam; 1 for non-spam; 2 for I/O or other errors.</para>
+<para>If both <option>-p</option> and <option>-e</option> are used, the
+ return values are: 0 for spam or non-spam; 2 for I/O or other
+ errors.</para>
<para>Error 2 usually means that the wordlist files
<application>bogofilter</application> wants to read at startup
-are missing.</para>
+are missing or the hard disk has filled up in <option>-p</option> mode.</para>
</refsect1>
<refsect1 id='files'><title>FILES</title>
Index: main.c
===================================================================
RCS file: /cvsroot/bogofilter/bogofilter/main.c,v
retrieving revision 1.26
diff -u -r1.26 main.c
--- main.c 6 Oct 2002 02:36:21 -0000 1.26
+++ main.c 6 Oct 2002 10:52:50 -0000
@@ -23,7 +23,7 @@
#include "xmalloc.h"
#include "datastore.h"
-int verbose, passthrough, update;
+int verbose, passthrough, update, nonspam_exits_0;
char *dirnames[] = { "BOGOFILTER_DIR", "HOME", NULL };
@@ -34,7 +34,7 @@
char *directory = NULL;
int exitcode = 0;
- while ((ch = getopt(argc, argv, "d:hsnSNvVpu")) != EOF)
+ while ((ch = getopt(argc, argv, "d:ehsnSNvVpu")) != EOF)
switch(ch)
{
case 'd':
@@ -42,6 +42,10 @@
setup_lists(directory);
break;
+ case 'e':
+ nonspam_exits_0 = 1;
+ break;
+
case 's':
register_type = REG_SPAM;
break;
@@ -68,6 +72,7 @@
printf( "\t-h\t- print this help message.\n" );
printf( "\t-d path\t- specify directory for wordlists.\n" );
printf( "\t-p\t- passthrough.\n" );
+ printf( "\t-e\t- in -p mode, exit with code 0 when the mail is not spam.\n");
printf( "\t-s\t- register message as spam.\n" );
printf( "\t-n\t- register message as non-spam.\n" );
printf( "\t-S\t- move message's words from non-spam list to spam list.\n" );
@@ -156,6 +161,9 @@
}
close_lists();
+
+ if (nonspam_exits_0 && passthrough && exitcode == 1)
+ exitcode = 0;
exit(exitcode);
}
--
Matthias Andree
More information about the bogofilter-dev
mailing list