procmail
[Top] [All Lists]

Re: Inserting text in multipart-messages

2001-01-15 02:44:36
Collin,
I'm not sure wether the first part of the message shall always be text/plain. In general, I don't think so: The problem is that the mail-account can receive emails from arbitrary mail-clients. It could be emails with just ascii in it, it could be anything else (some text and arbitrary attachments). The behaviour of the script should be the same as a user typing in one line of text before doing anything else.

Thanks for your help. I'll start with this script.

Stefan Siebert

Collin Park wrote:

Stefan Siebert wrote:

I would like to insert text at the beginning of an email body and then forward the email to another account. For normal ascii emails this is quite easy. However, for multipart-messages this does not work. The text is inserted after the header and before the multipart-statement. So at


Hi Stefan,

A couple of questions.

First, are you assured that the first part of a multipart MIME message
shall always be text/plain?

Second, if it's a multipart/alternative MIME message with text/plain
and text/HTML, is it enough to only modify the text/plain part?

The following is a starting point ONLY!! and hasn't been thoroughly
tested. Nevertheless, it attempts to add a text/plain part before the first part of a multipart/mixed message.


LOGFILE=/dev/tty
VERBOSE=yes
SHELL=/bin/sh

:0
* ^Mime-version:
* ^content-type:.*\<multipart/mixed\>.*boundary=\/.*
{
    BDY=$MATCH

    :0
    * BDY ?? ^^"\/[^"]*
    { BDY=$MATCH }

    :0 fbw
    | set -x; sed -e 1,/$BDY/s//=_yy$BDY/ -e /=_yy$BDY/i"\\
$BDY\\
Content-Type: text/plain\\
\\
text to be added\\
"  -e 1,/=_yy$BDY/s//$BDY/

}



--
___________________________________

Dipl.-Ing. Stefan Siebert iXpoint Informationssysteme GmbH Daimlerstrasse 3 76275 Ettlingen Tel.: 07243/3775-0 Fax: 07243/3775-77
___________________________________

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