neilwatson has asked for the wisdom of the Perl Monks concerning the following question:
#!/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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: MIME::Parser
by Moonie (Friar) on Aug 06, 2002 at 17:31 UTC | |
by neilwatson (Priest) on Aug 07, 2002 at 15:10 UTC | |
by Moonie (Friar) on Aug 07, 2002 at 16:46 UTC | |
|
Re: MIME::Parser
by danboo (Beadle) on Aug 06, 2002 at 17:36 UTC | |
by neilwatson (Priest) on Aug 06, 2002 at 17:42 UTC | |
|
Re: MIME::Parser
by trs80 (Priest) on Aug 06, 2002 at 18:16 UTC | |
by neilwatson (Priest) on Aug 06, 2002 at 18:27 UTC | |
by trs80 (Priest) on Aug 06, 2002 at 18:34 UTC | |
by neilwatson (Priest) on Aug 06, 2002 at 18:38 UTC | |
|
Re: MIME::Parser and mail from MS Outlook
by blahblahblah (Priest) on Aug 08, 2002 at 20:07 UTC | |
by neilwatson (Priest) on Aug 09, 2002 at 14:49 UTC |