procmail
[Top] [All Lists]

Re: Recipe to test from "From" and "To" being equal?

1997-04-21 13:51:00
ariel(_at_)best(_dot_)com (Catherine Hampton) writes:
I'd like to be able to test for "From:|Reply-To:" and "^TO" being 
identical -- I've noticed that's the case with many spams, and 
almost never for anything else.  But I can't figure out how one 
would do that in procmail.  Is there a way to extract the contents
of a header and assign them to a variable without calling a perl
program?  Or is there another obvious way to do this which I'm
missing?


The following is a fairly direct translation of your idea above.  The
one semantic change I've made is to exclude any message with Resent-*
headers.  This is to avoid problems with bogus lists that set the
Reply-To: header to point back to the list, while the To: header still
contains the listaddress as was originally mailed to.

Philip Guenther


        # Extract Reply-To: or From: (try that order).  The negation
        # is to pull a deMorgan's law trick and get OR like semantics
        # with short circuiting.
        :0
        * ! ^Reply-To: *\/[^ ].*
        * ! ^From: *\/[^ ].*
        {
           # No Reply-To: or From: header was found.  What to do here
           # is your choice.  *Every* message should have a From: header,
           # and some MTAs (e.g., sendmail) will create one, so this
           # may very well be impossible, in which case anything you put
           # here will be ignored, except for comments which you'll continue
           # to read and ponder until you realize how silly they are.
        }

        # If the previous recipe failed it's conditions, then a match was
        # found.  Use the match as the target of a ^TO_ search.  ^TO_ was
        # introduced in procmail 3.11pre4.  If you don't have at least that,
        # just use ^TO
        # We exclude anything with a Resent- header to avoid problems with
        # lists that change the Reply-To: to point back to the list.
        :0E
        * $ ^TO_$\MATCH\\>
        * ! ^Resent-
        probably-spam-mailbox

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