Ok, I'm not an expert on procmail, and experts might cringe at my
recipe. It works for me, etc.
You will need to have procmail installed on your system and rename the
attached file to .procmailrc. Procmail in this case expects messages to
arrive at /var/mail/user - you may need to run fetchmail to get them off
a POP or IMAP server. In my recipe procmail delivers the messages it
picks up to ~/incoming-mail and Evolution gets them from there. Please
note the locking mechanisms invoked. They are compatible with Evolution.
To filter duplicates based on a hash of the body of the message you will
need dbtool. You will also need to change one condition in the recipe.
Let me know if you need help (perhaps off the list?).
Antonio
On Wed, 2002-08-28 at 14:14, Mertens Bram wrote:
> On Wed, 2002-08-28 at 20:06, Antonio Bemfica wrote:
> > This is trivial to do using procmail (by checking the Message-ID
> > header). You can get a bit more sophisticated and do an MD5 hash of the
> > body of incoming messages and store it on a database (dbtool, for
> > example: http://www.daemon.de/dbtool/).
> >
> > If you or anyone else is interested I can post a recipe that does the
> > above.
>
> Well I certainly am interested!
>
> I don't know anything about procmail though, would I have to configure
> much to get this working? I am running Evo 1.0.8 btw...
>
> TIA
############################################################################
# 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 [EMAIL PROTECTED]
#
:0: antonio_at_axolotl.lock
* ^TO([EMAIL PROTECTED])
antonio_at_axolotl
############################################################################
# File messages to [EMAIL PROTECTED]
#
:0: antonio_at_bemfi.lock
* ^TO([EMAIL PROTECTED])
antonio_at_bemfi
############################################################################
# last chance is below!
#
:0: inbox.lock
inbox