procmail
[Top] [All Lists]

Message with text/plain and text/html

2003-02-14 15:08:47
I'd like to take messages that include both a text/plain and a text/html and strip the text/html from them. I don't think I have a problem with the recipe, but will the content-type header always be

Content-Type: multipart/alternative;

(I'm not talking about spam here, but just the messages people send to varous mailing lists where they send text and html)

:0
* ^Content-type:(.*\<)multipart.*boundary="\/.*[^"]"
{
  BOUNDARY=$MATCH
  :0 B
  * ^Content-type:(.*\<)text/html
  | sed -e '/Content-Type: text/html;/,/$BOUNDARY/d'

  :0 A
  | sed -e '/$BOUNDARY/d'

  :0 A
  | formail -i"Content-Type: text/plain" \
            -i"X-HTML: Original text/html portion stripped"
}

If I'm parsing this in my brain right the first sed will strip all the lines in the html portion and the second will remove the boundaries and the third will rewrite the content-type header. My only concern is that the COntent-type header might vary somewhat.

Should I check for MIME-Version: 1.0 as well?

(remember, this is only going to execute on mail that has already passed spam/virus filters)

--
BUGS: There is no conversion specification for the phase of the moon." strftime(3) man page


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