procmail
[Top] [All Lists]

Re: Munging Subject field

1996-09-05 11:46:24
Robert Van Zant <rvanzant(_at_)van(_dot_)inc(_dot_)net> writes:
     I'm trying to prepend a tiny list-specific identifier to 
the Subject field.  IE, 'Subject: testing' would become
'Subject: test-list: testing'.  Haven't had much luck so far, using
the examples on extracting variables from headers.  Specifically,
the following does not work.

...down around the main header munger in rc.submit....

 :0 c
   SUBMIT='formail -xSubmit:'
   :0 wfh
     |formail    ....blah...blah...
       -i"Subject: $SUBMIT"
         ....etc.....

   Have tried variations of the -i switch (aAI etc), as well as pipe
symbol on the SUBMIT line, all either bomb, or simply return the
'formail..' string as the variable, rather than actually executing it.

thanks,
bob

P.S.  Solution will also have to look for prepended field in replies, and
not continue adding field if it's already been done in a previous post.

I think your mail problem is that you are using forward quotes instead
of backwards quotes in the SUBMIT=... line.  You may also be missing
backslashes on all but the last of the filter's formail command line.

Anyway, here's a fairly complete solution that tries to handle "Re:"
in a nice fashion.  This will turn the subject:

        Subject: Re: test-list: some subject

into

        Subject: test-list: Re: some subject

If you would prefer that to just remain the way it was, then just read
the comments on the last recipe.  BTW: this requires procmail v3.10 or
later.


# Get the Submit: header (this is the list name?)
:0
* ^Submit: *\/.*
{ SUBMIT = $MATCH }

# Grab the current Subject: header.
:0
* ^Subject: *\/.*
{ SUBJECT = $MATCH }

# Is this a "re:?  If so, chop it, but remember that it's there.
:0
* SUBJECT ?? ^re: *\/.*
{
    RE = "Re: "
    SUBJECT = $MATCH
}

# Chop a the listname from the subject if it's already there.
:0
* $ SUBJECT ?? ^$SUBMIT: *\\/.*
{ SUBJECT = $MATCH }

# Okay, now put it back together.  The commented out action line can be
# used if you want the Re: to come before the listname.
:0 wfh
| formail -i"Subject: $SUBMIT: $RE$SUBJECT"
#| formail -i"Subject: $RE$SUBMIT: $SUBJECT"



Philip Guenther