my $parser = new MIME::Parser();
$parser->ignore_errors(1);
$parser->output_dir($output);
$parser->output_prefix("msg");
$parser->extract_nested_messages(0);
$parser->output_to_core(0);
$parser->tmp_to_core(0);
$parser->use_inner_files(0);
$self->{entity} = $parser->parse_data($lines);
# hier könnte man wohl auch
# $self->{entity} = $parser->parse_open("/some/file.msg");
# sagen
my $cfg = Sources::Config->new(-filename => $infofile); # hier speicher ich mir ein paar sachen; brauchst du ggf nicht, oder anders
$self->extract_entity($cfg, $self->{entity});
$cfg->close();
sub extract_entity
{
my ($self, $cfg, $entity) = @_;
my @parts = $entity->parts;
if(scalar(@parts)) {
$self->extract_entity($cfg, $_) foreach (@parts);
} else {
my $type = $entity->head->mime_type || "";
my $location = $entity->head->mime_attr("content-location") || "";
my $charset = $entity->head->mime_attr('content-type.charset') || "";
my $body = $entity->bodyhandle;
my $cntid = $entity->head->mime_attr('content-id');
my $disposition = $entity->head->mime_attr('content-disposition');
if($body) {
my $path = $body->path;
$path =~ s!\\!/!g;
my $folder = Sources::Global::get_filepath($path);
if($cntid) {
$cntid =~ s!^<|>$!!g;
my $temp = "$folder/$cntid";
Sources::Global::move_file($path, $temp);
$path = $temp;
}
$cfg->insert(
$path,
type => $type,
charset = $charset,
location => $location,
disposition => $disposition,
);
# Sources::Global::encrypt($path);
if($type eq "message/rfc822") {
# Spezialfall mail attachments
} elsif($type =~ m!ms-tnef!i) {
# Spezialfall tnef
}
}
}
}