# pm-jaube-prg-ifile -- Interface to ifile program # $Id: pm-jaube-prg-ifile.rc,v 1.8 2004/12/15 21:07:07 jaalto Exp $ # # File id # # .Copyright (C) Jari Aalto # .$Keywords: procmail, subroutine, UBE, spam, filter $ # # This code is free software in terms of GNU Gen. pub. Lic. v2 or later # Refer to http://www.gnu.org/copyleft/gpl.html # # Warning # # Put all your Unsolicited Bulk Emacil (aka spam) filters towards the # end of your `~/.procmailrc'. The idea is that valid messages are filed # first (mailing lists, your work and private mail, bounces) and only # the uncategorized messages are checked last. # # YOU CANNOT USE THIS PROCMAIL SUBROUTINE UNLESS YOU HAVE TRAINED THE # BAYESIAN PROGRAM FIRST! # # To train: # # $ rm ~/.idata # delete database # $ echo herbalife | ifile -i spam # initialize database # $ ifile -h -i good good.msg ... # $ ifile -h -i spam spam.msg ... # # Overview of features # # o Implements interface to http://freshmeat.net/projects/ifile # project. # o variable `ERROR' is set to the result of ifile check. This # usually holds the "folder" name the ifile was trained at the # time. E.g. if the folder used for training Unsolicited Bulk # Email was "ifile -i spam", then the return value is "spam". # o Results are available by default in header `X-Spamifile'. # # Description # # There are several Bayesian based statistical analysis programs that # study the message's tokens and then classify it into two categories: # good or bad, or if you like, ham and spam. All the Bayesian programs # are not the same, so if you want to achive magic 99.99% probability # the only methodology to do that is to chain several programs in # serially. There is no single program that can solve the UBE detection. # This procmail subroutine implements call interface to program # `ifile', which must already have been installed. # # About bouncing message back # # The general consensus is, that you should not send bounces. The UBE # sender is not there, because the address forged. Do not increase # the network traffic; you will not do any good to anybody by # bouncing messgas -- you just increase mail traffic even more. # Instead save the messages to folders and periodically periodically # check their contents. # # Required settings # # If `ifile' program is available, define this variable in your # `~/.procmailrc'. Use absolute path to make the external shell # quick; it'll save server load considerably. # # JA_UBE_IFILE_PRG = /usr/bin/ifile # # If you _do_ _not_ have program installed, do not leave the # variable lying aroung, because it will keep this subroutine active. # Calling a non existing program is not a good idea, so it better to # empty the variable if the program is not available. # # Required settings # # None. No dependencies to other procmail modules. # # Call arguments (variables to set before calling) # # o JA_UBE_IFILE_PRG, path to the program # o JA_UBE_IFILE_HEADER, the header name where the results # are put. If not defined, no header is added. # Defaults to `X-Spam-Ifile-Status' # o JA_UBE_IFILE_FORCE, if set to _yes_ then call program no matter # what. Normally if there already is header, # it is assumed that the message has already been checked # and no new checking is needed. # # Return values # # o ERROR, is set to the return value of `ifile' program. # # If header output is enabled, it will contain the folder name # `ifile' thinks the message belongs to. Assuming that trained # folders used for messages were *spam* and *good*, then the headers # read: # # X-Spam-Ifile-Status: spam # X-Spam-Ifile-Status: good # # Usage example # # PMSRC = $HOME/procmail # procmail recipe dir # # # # JA_UBE_IFILE_PRG = "/usr/bin/nice -n 5 /usr/bin/ifile" # INCLUDERC = $PMSRC/pm-jaube-prg-ifile.rc # # # The ERROR will contains reason if program classified # # the message into "bad" category. # # :0 : # * ! ERROR ?? ^^^^ # junk.mbox # # File layout # # The layout of this file is managed by Emacs packages tinyprocmail.el # and tinytab.el for the 4 tab text placement. # See project http://tiny-tools.sourceforge.net/ # # Change Log # # None dummy = " ======================================================================== pm-jaube-prg-ifile.rc: init:" # ................................................... User variables ... # You must define program path, because we don't know # if it has been installed in this system or not JA_UBE_IFILE_PRG = ${JA_UBE_IFILE_PRG:-""} # No user options cannot be passed to ifile, because the output would # change. This variable is not used. # JA_UBE_IFILE_PRG_OPT = ${JA_UBE_IFILE_PRG_OPT:-""} # The header name with no colon at the end. If this variable # is empty, then external formail call is saved - results can still # be checked from variable ERROR. JA_UBE_IFILE_HEADER = ${JA_UBE_IFILE_HEADER:-\ "X-Spam-Ifile-Status"} # Should we check even if there already was header # JA_UBE_IFILE_HEADER ? JA_UBE_IFILE_FORCE = ${JA_UBE_IFILE_FORCE:-"no"} # ............................................................ do it ... ERROR # Kill variable :0 * JA_UBE_IFILE_PRG ?? [a-z] *$ ! 9876543210^0 ^$JA_UBE_IFILE_HEADER * 9876543210^0 JA_UBE_IFILE_FORCE ?? yes { :0 w : ifile$LOCKEXT jaubeIfileFolder=|$JA_UBE_IFILE_PRG --strip-header --query --concise :0 * ! jaubeIfileFolder ?? ^^^^ { ERROR = $jaubeIfileFolder :0 fhw * ! JA_UBE_IFILE_HEADER ?? ^^^^ | ${FORMAIL:-formail} -I "$JA_UBE_IFILE_HEADER: $jaubeIfileFolder" } } dummy = "pm-jaube-prg-ifile.rc: end: $ERROR" # End of file