Postfix content_filter (Was: Re: mailing list speed)

David Relson relson at osagesoftware.com
Tue Oct 8 21:20:57 CEST 2002


At 02:35 PM 10/8/02, Gyepi SAM wrote:
>On Tue, Oct 08, 2002 at 10:28:57AM -0400, David Relson wrote:
> >     cat | $BOGOFILTER -d /var/lib/bogofilter/ -p > msg.$$
>
>For portabibility, this should be:
>
>     cat - | $BOGOFILTER -d /var/lib/bogofilter/ -p > msg.$$
>
>since not all versions of cat default to reading stdin when there are no 
>arguments.
>Technically, since bogofilter reads stdin, one could also drop cat and say:
>
>     $BOGOFILTER -d /var/lib/bogofilter/ -p > msg.$$
>
>which is simpler yet.


Since BOGOFILTER_DIR is defined, the "-d ..." is unnecessary.  Here's the 
improved script:

     #!/bin/sh

     BOGOFILTER=/usr/local/bin/bogofilter
     BOGOFILTER_DIR=/var/spool/filter
     SENDMAIL=/usr/lib/sendmail

     # Exit codes from <sysexits.h>
     EX_TEMPFAIL=75
     EX_UNAVAILABLE=69

     cd $BOGOFILTER_DIR || { echo $BOGOFILTER_DIR does not exist; exit 
$EX_TEMPFAIL; }

     # Clean up when done or when aborting.
     trap "rm -f inp.$$ msg.$$" 0 1 2 3 15

     # bogofilter returns: 0 for spam; 1 for non-spam; 2 for I/O or other 
errors.

     $BOGOFILTER -p > msg.$$

     $SENDMAIL "$@" < msg.$$

     exit $?


For summay digest subscription: bogofilter-digest-subscribe at aotto.com



More information about the Bogofilter mailing list