procmail
[Top] [All Lists]

Re: Removing [somelist] from subject lines

2001-01-21 00:32:50
On 20 Jan 2001, Harry Putnam wrote:

Hi Harry.

I looked at the procmail faq's thinking this *must* be an faq,
however I didn't find anything.  I'm on a few lists that
idiotically insist on adding [listname] to the beginning of every
message, and I want to have procmail auto-remove this crap.

I'd prefer it if someone could point me to some faq page or other
resource out there as this almost has to be talked to death.


This can be done quite simply or with more sophicticated (complex)
rules.  I like the simple way.

I also prefer it simple if possible.  ;o)

Most of this is in the procmail man pages..

Hmm.  I guess I didn't look in them hard enough.  I generally
check procmail, procmailex, procmailrc out, then the web.  I
figured for sure it would be in an FAQ, but wasn't in any I
found..


Your spec is to remove unwanted material from a header line.
So `h' will be needed, you want to filter something so `f' will
be needed.

`h' means only headers will be looked at
`f' means to filter thru something (roughly)

Right.  I use procmail a lot, but mostly my filter rules are very
simple.  I've got a dupe filter, backup filter, (both from the
manpages) and the rest are almost entirely in the form:

:0:
* ^Someheader:.*something
SOMEFOLDER

I've dabbled a bit in more complex ones, but not too deeply.  I
usually just ask for help to ensure no mail is lost.

Recently I dabbled too deep, and did lose a bunch.  ;o)


And the always usefull pipe.  Those three elements can make your recipe

   :0hf
   * ^Subject:.*\[lula\]
   | sed 's/\[lula\] //'

( I have one of those obnoxious groups too)

The above first traps messages with the problem subject line
then will remove `[lula]' from the subject line with sed, then let the
mail go on to your spool.  It gets more complicated if you want to
also send the message to a specific destination (not the normal
spool file), since procmail allows exactly one destination in each
rule.  The above supplies a `|' as destination so cannot have another.

If you need more it can be contained in the script you pipe to.

Beauty!  Ok, I don't want the filter to see all messages, just
the ones from the group.  Here is an example header:

Date: Sat, 20 Jan 2001 18:12:49 +0100
From: Michael Vogt <mvogt(_at_)acm(_dot_)org>
To: xpert(_at_)XFree86(_dot_)Org
Content-Type: multipart/mixed; boundary="FCuugMFkClbJLl1L"
Subject: [Xpert]Memory Leak in XmuClientWindow() ?


My rule for this list goes something like:

:0:
* ^X-BeenThere:(_dot_)*xpert(_at_)XFree86(_dot_)Org
XPERT-XFREE

I want to integrate the recipe you provide above into this rule,
so that the filter is only applied to this specific list.

Would the following be correct?

:0
* ^X-BeenThere:(_dot_)*xpert(_at_)XFree86(_dot_)Org
{
        :0hf
        * ^Subject:.*\[Xpert\]
        | sed 's/\[Xpert\] //'

        :0:
        XPERT-XFREE
}

It probably will explode as I'm not too sure on the syntax...


Here is some pseudocode tha reflects my intent though:

if( a header line == regex("^X-BeenThere:(_dot_)*xpert(_at_)XFree86(_dot_)Org") 
)
{
        if( subject header contains "[Xpert]")
        {
                remove "[Xpert]" from subject line
        }

        File the resulting message in XPERT-XFREE
}


Before:
[...]
       Date: Wed, 03 Jan 2001 16:36:29 -0000
       Subject: [lula] Re: cable/dsl routers
[...]
       Date: Sat, 20 Jan 2001 08:22:12 -0000
       Subject: [lula] Identd [was Re: Secure your RH6.2/RH7.0 systems!]

After:
[...]
       Date: Wed, 03 Jan 2001 16:36:29 -0000
       Subject: Re: cable/dsl routers
[...]
       Date: Sat, 20 Jan 2001 08:22:12 -0000
       Subject: Identd [was Re: Secure your RH6.2/RH7.0 systems!]

Exactly what I'm looking for.  ;o)

Very close now I think.




----------------------------------------------------------------------
    Mike A. Harris  -  Linux advocate  -  Free Software advocate
          This message is copyright 2001, all rights reserved.
  Views expressed are my own, not necessarily shared by my employer.
----------------------------------------------------------------------

There are two major products that come out of Berkeley: LSD and BSD.
We don't believe this to be a coincidence.
   -- Jeremy S. Anderson

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