#!/usr/bin/perl -w use strict; use MIME::Parser; my $file = 'Beispielnachricht.txt'; my $parser = MIME::Parser->new(); $parser->output_to_core('ALL'); open(INPUT,$file) or die $!; my $entity = $parser->read(\*INPUT); close(INPUT) or die $!; my $head = $entity->head(); print "From: " , $entity->head->get('From'); print "Subject: " , $entity->head->get('Subject'); print "MIME type: " , $entity->mime_type,"\n"; print "MIME enc: ", $head->mime_encoding, "\n"; if ($head->mime_type() =~ m/multipart/i) { my $part = $entity->parts(); my $part_entity = $entity->parts(0); my $body = $part_entity->as_string; print "Parts: $part\n"; print "$body\n"; } else{ my $body = $entity->as_string; print "$body\n"; }