Parsing and displaying MIME multi-user email on a website

I have a raw email (MIME multipart) and I want to display it on a website (e.g. in an iframe, with tabs for part of HTML and part of plain text, etc.). Are there any CPAN modules or Template :: Toolkit plugins that I can use to help me achieve this?

At the moment, it seems to me that I need to parse the message using Email :: MIME, then iterate over all the parts and write a handler for all different mime types.

This is a long shot, but I wonder if everyone has already done this? It will be a long and error-prone process that processes handlers if I try it myself.

Thanks for any help.

+5
source share
3 answers

This does not seem to me a difficult task:

use Email::MIME;
my $parsed = Email::MIME->new($message);
my @parts = $parsed->parts; # These will be Email::MIME objects, too.
print <<EOF;
<html><head><title>!</title></head><body>
EOF
for my $part (@parts) {    
    my $content_type = $parsed->content_type;
    if ($content_type eq "text/plain") {
         print "<pre>", $part->body (), "</pre>\n";
    }
    elsif ($content_type eq "text/html") {
        print $part->body ();
    }        
    # Handle some more cases here
}
print <<EOF;
</body></html>
EOF
+4
source

I actually just dealt with this problem just a few months ago. I have added the email function for the product for which I work, both for sending and for receiving. The first part sent reminders to users, but we did not want to manage reviews for our customers, we decided to have an attached mailbox that administrators could see bounces and replies without us, and administrators could deal with setting an email address if necessary.

, , . VERP, . , , .

. html, . , . , . , sendmail. Outlook, Exchange , multiparts . , , , . MHonArc RFC (RFC2045 RFC2046) . MHonArc, . , , , .

Email:: MIME . get_part . Email:: MIME → parts().

get_part, , , , , . - , .

- . , , :

  • /HTML
  • /
  • / ,
  • /
  • /
  • /

, . , get_parts MIME node . , get_parts. html , html, . , .

, . , get_parts, , .

, . , . , , . . . . (http://en.wikipedia.org/wiki/Same_origin_policy)

+6

. MHonArc HTML MIME.

+2

All Articles