procmail
[Top] [All Lists]

Re: Duplicates sent from lists

2004-03-08 19:08:10
On 18 Feb 2004, at 09:45, David W. Tamkin wrote:
 * ? formail -iMessage-Id: -R List-Post: Message-Id: \
     -D 1024 listpost.cache

One fork, no shells. Actually, I tried it with From: instead of List-Post: because From: gave me a much larger sample to work with, but surely it would do for List-Post: just as well.

I'm still messing with this (hey, some of us are slower than others!).

The command works great for building a cache of the list-post addresses, the trouble I am having comes in comparing the current ^TO_ of the message to the cache (to see if the message I am receiving is a duplicate off-list reply). The cache file is binary, and fgrep doesn't seem to want to match.

I finally hit upon a solution, ugly though it may be. Since I always have a list of items (the contents of To and Cc) I want to compare to the cache, I decided to use egrep. This meant a little work.

I finally got this working.. It's a bit ugly, but pending a couple more runs in the sandbox:

* ^To:[         ]*\/.*
{ TO=$MATCH }

# /   */ / is three spaces, '*/', and one space (basically 'two
# or more' I tried s/  +/ / and s/ {2,}/ / and various similar
# patterns but they all failed.

# concatenate the addresses collapse all the spaces to ' '
# substitute '|' for all spaces
:0
* ^Cc:[  ]*\/.*
{ ETO=`echo "$TO $MATCH" | sed 's/,//g' | sed 's/ */ /g' |tr ' ' '\|'` }

[Snip]

#Build/Check the list cache, per David Tamkin
:0fw
* ? formail -IMessage-Id: -R List-Post: Message-Id: -D 1024 .cache_lists
| formail -I"X-covisp-list: YES"

# If it's NOT a listmessage, but it contained a Cc header
:0
* LISTNAME ?? ^^^^
* ! ETO ?? ^^^
{
   # Not sure if I need the $ here, but it didn't
   # appear to hurt, so I am loath to remove it for now
   :0:
   * $ ? /usr/bin/strings .cache_lists | egrep -w \"$ETO\"
   duplicates
}

This, of course, still fails if both my address and the list address appear in the To: header, but that is another day, I think.

(and yes, I am ccing myself a copy of the post just to feed this monster)


--
Living is easy with eyes closed, misunderstanding all you see


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>