0
use MIME::Parser;
use Data::Dumper qw(Dumper);
$parser = MIME::Parser->new();
$parser->output_to_core(1); # don't write attachments to disk
while (<STDIN>) {
$MESSAGE .= $_;
}
$message = $parser->parse_data($MESSAGE); # die()s if can't parse
$head = $message->head(); # object--see docs
$preamble = $message->preamble; # ref to array of lines
$epilogue = $message->epilogue; # ref to array of lines
$num_parts = $message->parts;
for (my $i=0; $i < $num_parts; $i++) {
print "part number = $i\n";
my $part = $message->parts(1);
my $content_type = $part->mime_type;
my $body = $part->as_string;
print $body;
}
출력에서 콘텐츠 헤더도 볼 수 있습니다. 메시지 본문 내용 만 배열로 가져 오는 프로세스가 있습니까?MIME :: Parser를 사용하여 메일에서 본문 부분을 가져 오는 방법은 무엇입니까?
미리 감사드립니다.
왜 STDIN을 $ MESSAGE (으)로 읽습니까? 왜 단지 $ parser-> parse (\\ * STDIN)일까요? – runrig