procmail
[Top] [All Lists]

Re: Modifying message, continuing as normal

1997-08-19 14:18:07
Michael Stone <mstone(_at_)itri(_dot_)loyola(_dot_)edu> writes:

Quoting Matt Armstrong (matta(_at_)geoworks(_dot_)com):
I'd like to do something like:

:0:
* Content-Type:.*enriched/text
| my-strip-enriched-executable

But I'd like it to be a non-delivering recipe (but instead a
"modifying" recipe).

OTTOMH:

Huh? :-)

  :0 fHw
  * Content-Type:.*enriched/text
  | formail -I "Content-Type: text/plain" | mystripexec

Thanks for your help.  I ended up with this:

        :0 fhw
        * ^Content-Type:[       ]*text/enriched\/.*
        | formail -i "Content-Type: text/plain$MATCH"

        :0 afbw
        | enriched2plain


Deconstruction:

First rule:

 * f flag means "consider pipe as filter" -- this was the piece I
   was missing.
 * h flag means pipe header only into filter.
 * w means wait till filter is done before continuing.
 * The condition looks for a Content-Type header that begins with
   text/enriched, and remembers everything after that in $MATCH.
   There is a space and tab between the brackets.
 * The formail line replaces the text/enriched with text/plain,
   keeping the rest of the line and adding an Old-Content-Type:
   header with the old value (my own use).
 
Second rule:
 * a flag means execute only if the first did successfully.
 * b flag means pipe body only into filter (enriched2plain screws up
   the mail headers).
 * f and w flags, see above
 * the enriched2plain utility was posted to this list a week ago by
   DanS(_at_)bristol(_dot_)com


No more enriched/text!  Next step is to send an auto-reply reminding
the sender that they annoy most everyone who gets their message.  I'll
just adapt my vacation recipes.

-- 
matta