in reply to Robust parsing of email messages

I use MIME::Parser, it works quite well even with malicious e-mails.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Replies are listed 'Best First'.
Re^2: Robust parsing of email messages
by downer (Monk) on Mar 25, 2009 at 15:28 UTC
    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!