MIME:
arser works for me. It is a bit slow and tends to use ridiculuous
amounts of memory if you want to avoid temporary files, but I have yet
to find a (syntactically correct) email which can't parse.
hp
Thanks Peter for the posting.. can you provide some guidance then.. I
tried the below code and figured the skeleton would report the base64
image attachments in a MIME message, but isnt picking it up. I need
to be able to deal with text body, base64 body, and image attachments,
and want to parse them out correctly. I can do the base64 decoding,
etc. - how do I accomplish this with MIME:
arser ??
Code:
use MIME:
arser;
if (@ARGV[0] eq undef) {
$filename1="no dest filename" ;
} else {
$filename1=@ARGV[0];
}
### Create a new parser object:
my $parser = new MIME:
arser;
### Tell it where to put things:
$parser->output_under("e:\\tmp");
### Parse an input filehandle:
$entity = $parser->parse($filename1);
### Congratulations: you now have a (possibly multipart) MIME
entity!
$entity->dump_skeleton;
####HERES THE OUTPUT
Content-type: text/plain
Effective-type: text/plain
Content-encoding: 7bit
Body-location: (IN CORE)
Body-size: 0
--
####
It appears to not picking up this from the email itself -
Content-Type: image/jpeg; name="cardamage1.jpg"
Content-Disposition: attachment; filename="cardamage1.jpg"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_fqzhlhly0
###
Also I tried to build my own parser based on the "boundary" definition
but as you can see from the below example, its not clear why I have >
1 boundary !
Date: Sun, 24 Aug 2008 06:46:48 -0700
From: "Ben Brewster" <
[email protected]>
To: (e-mail address removed)
Subject: car for sale two images
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_13503_152406.1219585608169"
------=_Part_13503_152406.1219585608169
Content-Type: multipart/alternative;
boundary="----=_Part_13504_19292996.1219585608169"
------=_Part_13504_19292996.1219585608169
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Hi
------=_Part_13504_19292996.1219585608169
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
<div dir="ltr"></div>
------=_Part_13504_19292996.1219585608169--
------=_Part_13503_152406.1219585608169
Content-Type: image/jpeg; name=masertione.jpg
Content-Transfer-Encoding: base64
X-Attachment-Id: f_fk9pr8s20
Content-Disposition: attachment; filename=masertione.jpg