This is actually quite a difficult task, much harder than i had anticipated. I have been playing with the following code which produces some weird behavior:
!/usr/bin/perl
#use Email::MIME;
use Email::Simple;
use Data::Dumper;
use MIME::Parser;
use HTML::SimpleParse;
use strict;
use warnings;
undef $/;
my $message = <>;
my $email = Email::Simple->new($message);
print $email->header("To"),"\t",$email->header('Content-Type'), "\n";
my $parser = new MIME::Parser;
my $data = $parser->parse($email->body);
my $results = $parser->results;
print Dumper($results);
I dont know how to handle messages cases where messages are mime/not mime. Plus this doesnt actually seem to "parse" the message. The MIME metadata still is still within the email. suggestions? Thanks!