# ---------------------------------------------------------------------------------------- use MIME::Parser; $tmp_dir = "/tmp"; $tmp_dir = $tmp_dir.'/'."$$" while -d $tmp_dir; $message_source = 'From root@domainname.localdomain Mon Nov 27 19:42:47 2006 Return-Path: Received: from domainname.localdomain (domainname.localdomain [127.0.0.1]) by domainname.localdomain (8.13.7/8.13.7) with ESMTP id kARHgljo025235 for ; Mon, 27 Nov 2006 19:42:47 +0200 Received: (from root@localhost) by domainname.localdomain (8.13.7/8.13.7/Submit) id kARHglZA025234 for root@localhost; Mon, 27 Nov 2006 19:42:47 +0200 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----_=_NextPart_001_01C7070D.D848F424" Subject: email subject Date: Mon, 13 Nov 2006 10:26:06 -0000 Message-ID: From: test@test.com To: test@tete.com This is a multi-part message in MIME format. ------_=_NextPart_001_01C7070D.D848F424 Content-Type: multipart/alternative; boundary="----_=_NextPart_002_01C7070D.D848F424" ------_=_NextPart_002_01C7070D.D848F424 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable DM for is attached (56287) ------_=_NextPart_002_01C7070D.D848F424 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
DM for = is attached=20 (56287)
------_=_NextPart_002_01C7070D.D848F424-- ------_=_NextPart_001_01C7070D.D848F424 Content-Type: application/msword; name="test ().doc" Content-Transfer-Encoding: base64 Content-Description: test ().doc Content-Disposition: attachment; filename="test ().doc" ------_=_NextPart_001_01C7070D.D848F424--'; my $parser = MIME::Parser->new(); $parser->extract_nested_messages(0); $parser->output_dir($tmp_dir); $entity = $parser->parse_data($message_source); for(glob("$tmp_dir/*")) { # ..... } rmtree("$tmp_dir", 0); # ----------------------------------------------------------------------------------------