procmail
[Top] [All Lists]

Message body, assign to a variable everything except lines starting with "content-" or "--"

2009-11-04 23:54:34
Hiya,
While lots is written about header management, there seems to be less
material on managing the body of a message, which is the dilema I find
myself in.

My goal is to assign to a variable (MIME), everything in the body apart
from the MIME boundary delimiters and content definitions that are
consistently returned from one mail server only.

For example, here is the body with the words "test of the syntax":

------=_Part_100_1910259966.1257375844852
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

test of the syntax
------=_Part_100_1910259966.1257375844852--

The syntax probably needs to say something like:
Assign to variable MIME any lines except those that start with "content-"
OR "--"

So, in this example I want the variable MIME = "test of the syntax"

I tried the following and of course that returned nil because it looked at
the whole body, so I clearly needed a line by line assessment.

:0B
*!B ?? \/(content|--)
 {
 MIME=$MATCH
 }

This got me part of the way there but still MIME was blank.

:0B
*!B ?? ^\/(content-|--)
 {
 MIME=$MATCH
 }

I can match the word "test" and whatever else follows with:
:0B
*B ?? ^\/(test.*)
 {
 MIME=$MATCH
 }

BUT if I wanted to NOT match test viz: match lines without test, then I am
struggling.

So I even changed tack with the negation and tried character class
negation - without square brackets:

:0B
*B ?? ^\/(^content-|^--)
 {
 MIME=$MATCH
 }

But this doesn't look right and the result is not what I am looking for.
I'm sure its tied up in egrep somehow, and I have already usefully learnt
that using "^" before the match lets me make my way line by line through
the body, but I can't quite finish the problem.

I would be grateful for any learning that assists this.

Thanks

Shane






____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail