NAME
MIME::Explode - Perl extension for explode MIME messages
SYNOPSIS
use MIME::Explode;
my $explode = MIME::Explode->new(
output_dir => "tmp",
mkdir => 0755,
check_content_type => 1,
exclude_types => ["image/gif", "image/jpeg", "image/png"],
);
open(MAIL, "<file.mbox") or
die("Couldn't open file.mbox for reading: $!\n");
open(OUTPUT, ">file.tmp")
or die("Couldn't open file.tmp for writing: $!\n");
my $headers = $explode->parse(\*MAIL, \*OUTPUT);
close(OUTPUT);
close(MAIL);
for my $msg (sort{ $a cmp $b } keys(%{$headers})) {
for my $k (keys(%{$headers->{$msg}})) {
if(ref($headers->{$msg}->{$k}) eq "ARRAY") {
for my $i (0 .. $#{$headers->{$msg}->{$k}}) {
print "$msg => $k => $i => ", $headers->{$msg}->{$k}->[$i], "\n";
}
} elsif(ref($headers->{$msg}->{$k}) eq "HASH") {
for my $ks (keys(%{$headers->{$msg}->{$k}})) {
print "$msg => $k => $ks => ", $headers->{$msg}->{$k}->{$ks}, "\n";
}
} else {
print "$msg => $k => ", $headers->{$msg}->{$k}, "\n";
}
}
}
DESCRIPTION
MIME::Explode is perl module for parsing and decoding single or multipart MIME messages, and outputting its decoded components to a given directory ie, this module is designed to allows users to extract the attached files out of a MIME encoded email messages or mailboxes.
METHODS
new([, OPTION ...])
This method create a new MIME::Explode object. The following keys are available:
- output_dir
-
directory where the decoded files are placed
- mkdir => octal_number
-
if the value is set to octal number then make the output_dir directory (example: mkdir => 0755).
- check_content_type => 0 or 1
-
if the value is set to 1 the content-type of file is checked
- exclude_types => [ARRAYREF]
-
not save files with specified content types
parse(FILEHANDLE, FILEHANDLE)
This method parse the stream and splits it into its component entities. This method return a hash reference with all parts. The FILEHANDLE should be a reference to a GLOB. The second argument is optional.
AUTHOR
Henrique Dias <hdias@esb.ucp.pt>
SEE ALSO
MIME::Tools, perl(1).