in reply to Re: Parse a Mail
in thread Parse a Mail
my $firstline=1; while (<STDIN>) { if (!($firstline)) { push(@mail, $_); } $firstline=0; } $msg = Mail::Message->read(\@mail); $sender = $msg->sender; $replyto = Mail::Address->parse($msg->head->get('Reply-To')); if ($replyto) { $sender =$replyto; } $subject = $msg->subject; if($msg->isMultipart) { $summary = $msg->body->preamble; $summary .= "Number of attachments: ".scalar $msg->body->parts +('ACTIVE')."\n\n"; my $number =0; foreach my $part ($msg->body->parts) { $number++; $summary .= "======== Attachment ".$number." Type: ".$ +part->get('Content-Type')." =========\n"; # Attachment handling if ($part->get('Content-Type') eq "text/plain" ) { $summary .= $part->decoded."\n"; } $summary .= "========================================= +=================\n\n"; } $summary .= $msg->body->epilogue; } else { $summary = $msg->decoded; } $summary.="\nMail from: ".$sender->format();
|
|---|