procmail
[Top] [All Lists]

Re: Possible procmail filter to trap spam relays?

1998-06-09 05:42:04
Tristan Horn <tristan+p(_at_)ethereal(_dot_)net> writes:
What's the best method to filter based on the -a argument provided to
procmail?  (sendmail, when configured to use procmail as a local mailer,
passes the part after the + in the username of the sender to procmail
this way.)

You can't do variable matching directly against $@ or $1, etc, so you
have to copy $1 into a normal variable and match against it there:

        ARG = $1
        :0
        * ARG ?? ^^something^^
        some-folder


Also, any suggestions on the best method to modify the Subject line
(i.e. with sed) on incoming messages?  I could just do:

      :0:
      * ^From linux-mac68k-owner(_at_)wave(_dot_)lm(_dot_)com
      | sed 's/^Subject: \[linux-mac68k\] /Subject: /' >> linux-mac68k

However, that also changes the body.  formail lets me grab only the
headers, but I don't know how to tack the body back onto the message
after I'm done with it.

If you know that all of the messages to the list have that subject tag,
then the following will be pretty efficient:

        :0:
        * ^From linux-mac68k-owner(_at_)wave(_dot_)lm(_dot_)com
        * ^Subject: \[linux-mac68k\] \/.+
        | formail -I"Subject: $MATCH" >>linux-mac68k

However, if a message doesn't then it would not be refiled by the above
recipe.  If that's a problem, then the following would be preferable:

        :0
        * ^From linux-mac68k-owner(_at_)wave(_dot_)lm(_dot_)com
        {
            # If it has a subject tag, rewrite the subject and save it
            :0:
            * ^Subject: \[linux-mac68k\] \/.+
            | formail -I"Subject: $MATCH" >>linux-mac68k

            # No tag, just save it
            :0:
            linux-mac68k
        }


Philip Guenther