mboxParse.pl:
#!/usr/bin/perl -w
################################################################################
#			mboxParse.pl
################################################################################
# This script reads in an mbox file and outputs each part of each email in its
# own directory. For example, if an email in the mbox file contains a plain text
# component, and html component, and a jpeg attachment, the directory for that
# message will contain a file named Message containing the original multipart
# message, a plain text file, an html file, and the decoded jpeg attachment.
#
# This script requires MIME::Parser and the other modules contained within
# MIME-Tools, available at
# http://search.cpan.org/~eryq/MIME-tools-5.411a/lib/MIME/Parser.pm
#
# Usage:
# 	mboxParse.pl mboxFile
#
# Author: Tom Samstag http://modtwo.com
# Version: 0.1
# Date: 2009-11-20
#
# Copyright 2009 Tom Samstag, modtwo (at) modtwo (dot) com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

use strict;
use MIME::Parser;

my @messages;
my $mime = new MIME::Parser;
$mime->output_under(".");

while (<>){
	if (/^From /)
	{
		push @messages, "";
	}
	$messages[$#messages] .= $_;
}

foreach my $message (@messages)
{
	$mime->parse_data($message);
	open MSG, ">".$mime->filer->output_dir."/Message";
	print MSG $message;
	close MSG;
}
