Shane,
This is part of a larger body of code that recursively navigates the
mime message searching for html or plain text entities.
If you need more, just ask.
j
[john(_at_)bx1]# H:~/testing> cat sample.msg
To: list(_at_)example(_dot_)net
From: me(_at_)example(_dot_)net
Subject: sample message
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_Part_100_1910259966.1257375844852"
------=_Part_100_1910259966.1257375844852
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
test of the syntax
------=_Part_100_1910259966.1257375844852--
[john(_at_)bx1]# H:~/testing> dry_run.sh sample.rc sample.msg
procmail: [17954] Thu Nov 5 09:02:08 2009
procmail: Assigning "LINEBUF=182"
procmail: Assigning "FOR_INDEX=1"
procmail: Assigning
"MIME_BOUNDARY=----=_Part_100_1910259966.1257375844852"
procmail: Executing "/bin/echo "$MIME_BOUNDARY"|/bin/sed
's/\([()/+.?]\)/\\&/g'"
procmail: Assigning "MIME_e_BOUNDARY=----=_Part_100_1910259966
\.1257375844852"
procmail: Match on ! "^^yes^^"
procmail: Match on "^^^^"
procmail: Match on "^^^^"
procmail: Assigning "MIME_ENTITY_FOUND=yes"
procmail: Assigning "MIME_ENTITY_LEVEL="
procmail: Assigning "MIME_ENTITY_INDEX=1"
procmail: Assigning "MIME_ENTITY_VERSION="
procmail: Assigning "MIME_ENTITY_ENCODING="
procmail: Assigning "MIME_ENTITY_CONTENT="
procmail: Assigning "MIME_ENTITY_TYPE="
procmail: Assigning "MIME_ENTITY_SUBTYPE="
procmail: Assigning
"MIME_ENTITY_BOUNDARY=----=_Part_100_1910259966.1257375844852"
procmail: Assigning
"MIME_ENTITY_e_BOUNDARY=----=_Part_100_1910259966
\.1257375844852"
procmail: No match on "^^1^^"
procmail: Executing "/bin/awk -v i=$MIME_ENTITY_INDEX
'/^--'$MIME_ENTITY_e_BOUNDARY'/{n++};i==n{print}'|/bin/sed -e
'1d'|/usr/bin/formail -cfX ''"
procmail: Assigning "MIME_ENTITY_HEADER="
procmail: Assigning "ECHO=MIME_ENTITY_HEADER=Content-Type:
text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit"
procmail: Executing "/bin/awk -v i=$MIME_ENTITY_INDEX
'/^--'$MIME_ENTITY_e_BOUNDARY'/{n++};i==n{print}'|/bin/sed -e
'1d'|/bin/sed -e '1,/^$/d'"
procmail: Assigning "MIME_ENTITY_BODY="
procmail: Assigning "ECHO=MIME_ENTITY_BODY=test of the syntax"
procmail: Assigning "VERBOSE=no"
[john(_at_)bx1]# H:~/testing> cat sample.rc
# swa-get_mime_part.rc
# Copyright 2009, SwaJime's Cove
# Author John W. Simpson
# Version 1.0.0
# Date 1-Nov-2009
:0
* B ?? 1^1 > 1
{
# These are actually set before including this rc file. I've
only set them here to demonstrate.
VERBOSE=yes
LINEBUF = $=
FOR_INDEX=1
MIME_BOUNDARY="----=_Part_100_1910259966.1257375844852"
MIME_e_BOUNDARY=`/bin/echo "$MIME_BOUNDARY"|/bin/sed
's/\([()/+.?]\)/\\\&/g'`
}
:0
*! MIME_ENTITY_FOUND ?? ^^yes^^
*$ MIME_TYPE ?? ^^$MIME_TYPE_WANTED^^
*$ MIME_SUBTYPE ?? ^^$MIME_SUBTYPE_WANTED^^
{
MIME_ENTITY_FOUND=yes
MIME_ENTITY_LEVEL=$MIME_LEVEL
MIME_ENTITY_INDEX=$FOR_INDEX
MIME_ENTITY_VERSION=$MIME_VERSION
MIME_ENTITY_ENCODING=$MIME_ENCODING
MIME_ENTITY_CONTENT=$MIME_CONTENT
MIME_ENTITY_TYPE=$MIME_TYPE
MIME_ENTITY_SUBTYPE=$MIME_SUBTYPE
MIME_ENTITY_BOUNDARY=$MIME_BOUNDARY
MIME_ENTITY_e_BOUNDARY=$MIME_e_BOUNDARY
:0
* MIME_ENTITY_LEVEL ?? ^^1^^
{
:0 h
MIME_ENTITY_HEADER=|/usr/bin/formail -cX 'mime-' -cX
'content-'
ECHO="MIME_ENTITY_HEADER=$MIME_ENTITY_HEADER"
:0 b
MIME_ENTITY_BODY=|cat
ECHO="MIME_ENTITY_BODY=$MIME_ENTITY_BODY"
}
:0 E
{
:0 b
MIME_ENTITY_HEADER=|/bin/awk -v i=$MIME_ENTITY_INDEX
'/^--'$MIME_ENTITY_e_BOUNDARY'/{n++};i==n{print}'|/bin/sed -e
'1d'|/usr/bin/formail -cfX ''
ECHO="MIME_ENTITY_HEADER=$MIME_ENTITY_HEADER"
:0 b
MIME_ENTITY_BODY=|/bin/awk -v i=$MIME_ENTITY_INDEX
'/^--'$MIME_ENTITY_e_BOUNDARY'/{n++};i==n{print}'|/bin/sed -e
'1d'|/bin/sed -e '1,/^$/d'
ECHO="MIME_ENTITY_BODY=$MIME_ENTITY_BODY"
}
}
[john(_at_)bx1]# H:~/testing>
On Thu, 2009-11-05 at 17:54 +1300, reti(_at_)igrin(_dot_)co(_dot_)nz wrote:
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--
____________________________________________________________
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