procmail
[Top] [All Lists]

Re: using formail and sed to remove subject cruft

2001-08-14 22:15:43

Philip Guenther wrote:

If you wrote the initial condition differently, you eliminate
the need for that sed command:

      :0
      * ^(List-Id|X-Mailing-List): [^<]*<\/[^.@>]+
      {
              LIST = $MATCH

Ah, thank you very much on that tip.  It should have been obvious
to me...

Ditto, I think:
      :0 fWh
      * $ ^Subject: *\[$\LIST\]\/.*
      | formail -fI"Subject: $MATCH"

Well, the small problem with that is that if there is something
before `[list-name]', like `Re:' then that gets axed too.  I
tried to save boths parts with procmail's built-in matching but
got frustrated and went back to using sed to yank the list name
out of the subject.

David Tamkin mentioned that I wasn't using weak quotes around my
variables and that solved the original problem I was having, so
my thanks to him.  Here is what I am using now, which works.

    :0
    * $ ^Subject: \/.*\[$\LIST\].*
    {   
        SUBJECT=`echo "$MATCH" | sed -e 's/\['"$LIST"'\] *//i'`

        :0 fWH
        | formail -fI"Subject: $SUBJECT"
    }

Seems pretty reasonable to me, but I am open to suggestions on
improving it. :)

[snip]
(you _do_ have a logfile, right?)

Of course.  I keep some extra information in there too for every
message that comes through, such as date -R, X-Envelope-From, and
Message-ID.  That has been quite useful in a few instances.

Btw, I started playing with procmail scoring tonight which is
very nice.  It's making it relatively easy to test for
combinations of a few different possibilities.  I am using this
to help filter both majordomo and similar list servers which
don't add List-Id or X-Mailing-List headers, and those that do in
the same recipe.

- Doug
_______________________________________________
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>