############################################################################ # Procmail recipe to process incoming mail. Here it goes: # # 1. check for duplicates, using either formail or dbtool # 2. check for SPAM or other things to avoid # 3. check for autoresponding # 4. save the headers # 5. strip all but the essential headers # 6. save the message # # Usage on command line: # # cat existing_mbox | formail -bczf -s procmail ./this_recipe_file ############################################################################ # Change these to suit VERBOSE=NO MAILDIR=$HOME/incoming-mail # you'd better make sure it exists LOGFILE=$MAILDIR/.from # recommended RECIPEDIR=$HOME/procmail.recipes HEADERS_FILE=$MAILDIR/headers-`date +%B-%Y` ############################################################################ # Do not change these SHELL=/bin/sh PATH=/bin:/usr/bin:/usr/local/bin:bin:/sbin SUBJECT=`formail -xSubject:` # regular field FROM=`formail -rt -xTo:` # special case FROM_=`formail -xFrom:` ARGUMENT=$1 MID=`formail -xMessage-ID:` ## Section 1 ############################################################################ # if we have no Message-ID header, then we create one based on an MD5 hash # of the message body # :0 * ! MID ?? [^\n] { MID=`formail -I "" | /sbin/md5` # None of these worked! # MD5MID=| `/sbin/md5` # MD5MID=`/sbin/md5 -q` # MD5MID=`| cat | /sbin/md5 -q` # MD5MID = `/sbin/md5 -q $B` } ############################################################################ # if the recipe above was invoked we add the generated Message-ID to the # headers # :0 afhw | formail -I "Message-ID: $MID" ############################################################################ # intercepts all duplicate messages using formail # :0 Wh: .msgid.lock | formail -D 32768 .msgid.cache.formail ############################################################################ # intercepts all duplicate messages using dbtool - try to insert a key, if # it succeeds the message is new, revert the exit code to proceed. # #:0 hbw #* ! ? dbtool -d .msgid.cache.dbtool -i -k $MID -v "1" #incoming_duplicates ## Section 2 ############################################################################ # Some viruses spam from different addresses but always same content # INCLUDERC=$RECIPEDIR/body_based_refuse ############################################################################ # Refuse based on specific headers (spam avoidance) # INCLUDERC=$RECIPEDIR/header_based_refuse ############################################################################ # Refuse based on Sender (some people are annoying, etc.) # # INCLUDERC=$RECIPEDIR/refuse_simple ############################################################################ # let's get rid of this annoying chinese spam # INCLUDERC=$RECIPEDIR/uchinese.rc ## Section 3 ############################################################################ # auto-reply, uncomment everything below # # INCLUDERC=$RECIPEDIR/auto_reply ## Section 4 ############################################################################ # log all the headers # :0 hc: $HEADERS_FILE ## Section 5 ############################################################################ # we clean up the headers of the message, leaving only the essential stuff # :0 fhbw | formail -k -X From -X Cc: -X Content- -X Date: -X From: \ -X Message-ID: -X MIME-Version: -X Reply-To: \ -X Subject: -X To: -X Sender: ############################################################################ # if the Reply-To field is the same as the From there is no point in # keeping it. # :0 fhbw *$ ^Reply-To:${FROM_} | formail -I "Reply-To:" ## Section 6 ############################################################################ # Process argument # # INCLUDERC=$RECIPEDIR/argument_proc ############################################################################ # process root messages, operator messages, etc. # # INCLUDERC=$RECIPEDIR/manager ############################################################################ # File messages to antonio axolotl ic gc ca # :0: antonio_at_axolotl.lock * ^TO(antonio axolotl ic gc ca) antonio_at_axolotl ############################################################################ # File messages to antonio bemfi ca # :0: antonio_at_bemfi.lock * ^TO(antonio bemfi ca) antonio_at_bemfi ############################################################################ # last chance is below! # :0: inbox.lock inbox