This works perfect both for text and html messages.
But when I send a html message including an image $body is blank.
In this case, in the email source I found:
------=_NextPart_000_0093_01C4129A.84505FE0
Content-Type: multipart/alternative;
boundary="----=_NextPart_001_0094_01C4129A.84505FE0"
note - boundary is calling the html code part.
I need suggestions!! :(
Code:
use MIME::Parser
my $entity = $parser->parse(\*STDIN) or die "couldn't parse INPUT";
if ($entity->parts > 0) {
for (my $i=0;$i<$entity->parts;$i++) {
my $subEntity = $entity->parts($i);
if (my $io = $subEntity->open("r")) {
my $type = $subEntity->head->mime_attr("Content-Type");
if ($type eq "text/plain" ) {
while (defined($_=$io->getline)) { $body .= $_; }
$io->close;
}
}
}
}
else { $body = $entity->bodyhandle->as_string; }