I'm trying to learn MIME::Parser. I've written this test script:

#!/usr/bin/perl -w use strict; use warnings; use MIME::Parser; my ($body, $i, $io, $subEntity); my $parser = new MIME::Parser; $parser->ignore_errors(1); $parser->output_to_core(1); my $MIME_entity = $parser->parse(\*STDIN); my $error = ($@ || $parser->last_error); #get from, to and subject headers. my $header = $MIME_entity->head; my $subject = $header->get('Subject'); my $to = $header->get('To'); my $from = $header->get('From'); chomp($subject); chomp($to); chomp($from); #get body if ($MIME_entity->parts > 0){ for ($i=0; $i<$MIME_entity->parts; $i++){ $subEntity = $MIME_entity->parts($i); if (($subEntity->mime_type =~ m/text\/html/) || ($subEntity->m +ime_type =~ m/text\/plain/)){ if ($io = $subEntity->open("r")){ while (defined($_=$io->getline)){ $body .= $_; } $io->close; } } } } else { $body = join "", @{$MIME_entity->body}; } # email report back to sender showing the # parts of original messages open MAIL, ("|/usr/sbin/sendmail -t") || die "Unable to send mail: $!" +; print MAIL "To: $from\n"; print MAIL "From: root\n"; print MAIL "Subject: mime parser test\n\n"; print MAIL "Messege was contructed as follows: \$from: $from \$to: $to \$subject: $subject \$body: $body "; close(MAIL);

The from, to, and subject headers return fine. The body returns properly when I test using Kmail but not the devil's client, Outlook. Can anyone offer some suggestions?

Neil Watson
watson-wilson.ca


In reply to MIME::Parser and mail from MS Outlook by neilwatson

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.