procmail
[Top] [All Lists]

Re: Message with text/plain and text/html

2003-02-15 01:57:24

On Friday, Feb 14, 2003, at 14:57 Canada/Mountain, LuKreme wrote:

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)

This mostly works, although it leaves some cruft behind I want to get cleaned up.

VERBOSE=ON
# Currently I am processing a COPY of the html mail so I can compare the two versions easily

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

  :0 A
  {
# doesn't seem to work right or is not clipping all the $BOUNDARY matches # All of the messages that are stripped are starting with a $BOUNDARY line
        :0 Afw
        | sed -e '/$BOUNDARY/d'
        :0 Afw
        | sed -e '/Content-Type: text/d'
        :0 fw
        | sed -e '/charset=/d'
        :0 fw
        | sed -e '/Content-Transfer-Encoding:/d'
  }

  :0 Afw
  | formail -i"Content-Type: text/plain" \
            -i"X-HTML: Altered text/html to text/plain"
}
VERBOSE=OFF
--
Do not meddle in the affairs of wizards for they are subtle and quick to anger.


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