Wed 98-02-11 Alex Hall <ah(_at_)besteadresse(_dot_)com> list.procmail
| Unfortunately, it does encode only very simple messages with old mailers.
| If they use Netscape or send more than one file in the same message,
| the recipe does not work.
Unfortunately, procmail is not the right tool for parsing complex
mime. Extracting one attachement (two is more job) is almost within
limits, but anything more than that is best left to dedicated mime
tools: there exist Perl modules that understand mime structure and in
Era's page I remember seeing more mime tools. Era will you remind me
about the Unix binary you mentioned some time ago that exploded MIME
to separate files....
I suggest that, before you unpack the MIME, you check how many attachements
it contains. I made a module that finds out some basic MIME information
from the message, see exanmle below. (pm-code.shar available from
file server mentioned in X-info header)
RC_MIME = $PMSRC/pm-jamime-tag.rc
...Somewhere where you need mime information
INCLUDERC = $RC_MIME
# if structure was like this, then count of boundary strings is 3
* MIME_BOUNDARY_COUNT ?? ^^3^^
... do something
# Hm, message was formatted according to mime standard, but
# it had no attachements. We can handle this easily.
# MIME_BOUNDARY string does not exist in body
* MIME ?? yes
* MIME_BOUNDARY ?? ^^^^
# @(#) pm-jamime.rc -- subroutine to read mime boundary etc. variables
# @(#) $Id: pm-jamime.rc,v 1.7 1998/02/12 12:46:23 jaalto Exp $
o Variable MIME is set to "yes" or "no" if messages has mime version
o MIME_VER contains the mime version string from the header.
o MIME_TYPE contains the Content-Type from the header.
o MIME_CTE contains Content-Transfer-Encoding from the header.
o MIME_H_QP is "yes" if Content-Transfer-Encoding: quoted-printable
is in the header.
o MIME_B_QP is "yes" if Content-Transfer-Encoding: quoted-printable
is found from the body.
o MIME_BOUNDARY contains the boundary string, which is used to
differentiate mime sections in the body.
o MIME_BOUNDARY_COUNT is the number of boundary strings found
fromt her body. The value is 3 if there is two mime sections,
and 4 if 3 etc. MIME_BOUNDARY_COUNT -1 = count of sections.