procmail
[Top] [All Lists]

Re: MATCH operator and subject adjustment

2001-11-12 01:54:59

This is sort of related to something for which I'm trying to figure out
a more elegant solution.

I'm stripping out listnames from subject lines that match certain
criteria.  At the moment, I've written the following:

:0
*       ^(Sender: courier-users(_dot_)*(_at_)lists(_dot_)sourceforge(_dot_)net|\
        Mailing-List:.*(imp|horde)-help(_at_)lists(_dot_)horde(_dot_)org|\
        Mailing-List:(_dot_)*twig-help(_at_)screwdriver(_dot_)net|\
        Delivered-To:(_dot_)*hylafax-users(_at_)dazza(_dot_)org|\
        Sender: owner-ga(_at_)dnso(_dot_)org|\
        
Return-Path:(_dot_)*isp-equipment(_dot_)*(_at_)lists(_dot_)isp-lists(_dot_)com)
*       ^Subject:[      ]\/.*\[[a-z0-9]+\].*
{
        :0
        { NEWSUBJ=`echo "${MATCH}" | sed -E 's/\[[a-zA-Z0-9-]+] //'` }

        :0 f
        | formail -I "Subject: $NEWSUBJ"
}

This is obviously followed by other recipes which (correctly) shunt
particular mailing list content into the appropriate folders by means
other than tags in subject lines.

The goal is to remove a list tag in the subject line while maintaining
*all* of the rest of the subject line, including a prefixed "Re:".

Is there a more elegant way to do this?  In particular, is there a way
to do this without calling a subshell to run sed?  Would I be farther
ahead running the subshell, or using a construct like:

:0
*       ^(Sender: foo|Mailing-List: bar)
*       ^Subject:[      ]\/.*\[[a-z0-9]+\].*
{
        FULL="$MATCH"
        :0
        * FULL ?? ()\/[^\[]+
        {
                LEFT="$MATCH"
                :0
                * FULL ?? ()[^\]]+ \/.*
                {
                        RIGHT="$MATCH"
                        :0 f
                        | formail -I "Subject: $LEFT $RIGHT"
                }
        }
}

This seems inordinately ugly to me....

p


On Sun, Nov 11, 2001 at 08:50:43AM -0800, Professional Software Engineering 
wrote:

At 07:54 2001-11-11 -0800, Harry Putnam wrote:
This may be another case of not having pounded theh Docs enough but

.. or the list archives.  There's always been lots of talk about tweaking 
the subject line (such as adding listnames and such, which is the same 
principle you're talking about).

How can I combine this rule with code that inserts the date into
existing subject line?

By insert, where do you mean?  Beginning or end of complete subject is 
trivial:

:0fh
* Subject:[     ]*\/[^  ]*.*
| formail -I "Subject: `date` $MATCH"

or a delivery of:
| formail -I "Subject: $MATCH `date`"

Then, to add that to your delivery filter, just add it in...

Note that if the Subject header DOES NOT exist, this won't do a thing.  So 
you might want to EXTRACT the SUBJECT separatley, so you end up creating a 
subject with the date in it if necessary:

:0fh
* Subject:[     ]*\/[^  ]*.*
{
         $ORIGSUBJ=$MATCH
}

:0
| formail -I "Subject: `date` $ORIGSUBJ" \
         -I "X-Delivered-Via: reader(_at_)somewhere(_dot_)com" \
         | $SENDMAIL $SENDMAILFLAGS reader(_at_)somewhere(_dot_)else(_dot_)com


'man date' will give you plenty of options for formatting the date to your 
taste.

---
  Sean B. Straw / Professional Software Engineering

  Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
  Please DO NOT carbon me on list replies.  I'll get my copy from the list.

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

-- 
  Paul Chvostek                                             
<paul(_at_)it(_dot_)ca>
  Operations / Development / Abuse / Whatever       vox: +1 416 598-0000
  IT Canada                                            http://www.it.ca/

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