[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Two copies of E-Mail (Re: I wish to advocate linux)



Miles Fidelman grabbed a keyboard and wrote:
> David Guntner wrote:
>> Miles Fidelman grabbed a keyboard and wrote:
>>> AND PLEASE STOP HITTING REPLY ALL - I DON'T NEED TWO COPIES OF EVERY ONE
>>> OF YOUR POSTINGS - REPLY TO THE LIST, ONLY
>> If you're using Procmail to filter your E-Mail, I can send you a recipe
>> that deletes the duplicate when things like that happen... :-)
> 
> Sure... thanks! Still, it's a good thing to train folks to reply
> appropriately :-)

Agreed. :-)

Anyway, the recipe is dirt simple.  The bit of code below assumes that
somewhere near the top of your .procmailrc file, you're assigning values
to the two variables that points to where those items are.  On my
system, $MAILDIR points to $HOME/Mail and $FORMAIL points to
/usr/bin/formail.

Here's the code:


# Duplicate Suppression.
:0Whc: $MAILDIR/.msgid.cache.lock
| $FORMAIL -D 8192 $MAILDIR/.msgid.cache

        # Take out the Trash.
        :0 a:
        /dev/null


That's all there is to it.  The formail program is used to grab the
Message-ID of the incoming message.  Even if it is sent To: one address
and CC: another, both "copies" will have the same Message-ID.  When the
first one comes in, it stores that ID in the $MAILDIR/.msgid.cache file
after first comparing the message to see if that ID has already been
stored there.  If not, then it stores the ID and returns a FALSE so that
the second part ("take out the trash") won't process.  If the Message-ID
already *has* been stored in the cache file, then it returns a TRUE and
the second part then dumps the message into /dev/null.

Note that the locks *are* critical to prevent corruption, so keep the
trailing ":" characters where they are. :-)

                   --Dave


Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: