Movatterモバイル変換


[0]ホーム

URL:


 / 
MIME-Explode-0.39
River stage one • 1 direct dependent • 1 total dependent
/MIME::Explode

NAME

MIME::Explode - Perl extension for explode MIME messages

SYNOPSIS

  use MIME::Explode;  my $explode = MIME::Explode->new(    output_dir         => "tmp",    mkdir              => 0755,    decode_subject     => 1,    check_content_type => 1,    content_types      => ["image/gif", "image/jpeg", "image/bmp"],    types_action       => "exclude"  );  print "Number of messages: ", $explode->nmsgs, "\n";  open(MAIL, "<file.mbox") ordie("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 $part (sort{ $a cmp $b } keys(%{$headers})) {    for my $k (keys(%{$headers->{$part}})) {      if(ref($headers->{$part}->{$k}) eq "ARRAY") {        for my $i (0 .. $#{$headers->{$part}->{$k}}) {          print "$part => $k => $i => ", $headers->{$part}->{$k}->[$i], "\n";        }      } elsif(ref($headers->{$part}->{$k}) eq "HASH") {        for my $ks (keys(%{$headers->{$part}->{$k}})) {          if(ref($headers->{$part}->{$k}->{$ks}) eq "ARRAY") {            print "$part => $k => $ks => ", join(($ks eq "charset") ? " " : "", @{$headers->{$part}->{$k}->{$ks}}), "\n";          } else {            print "$part => $k => $ks => ", $headers->{$part}->{$k}->{$ks}, "\n";          }          print "$part => $k => $ks => ", $headers->{$part}->{$k}->{$ks}, "\n";        }      } else {        print "$part => $k => ", $headers->{$part}->{$k}, "\n";      }    }  }  if(my $e = $explode->clean_all()) {    print "Error: $e\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

decode_subject => 0 or 1

If the value is set to 1 then the subject is decoded into a list.

$header->{'0.0'}->{subject}->{value} = [ARRAYREF];$header->{'0.0'}->{subject}->{charset} = [ARRAYREF];$subject = join("", @{$header->{'0.0'}->{subject}->{value}});
exclude_types => [ARRAYREF]

Not save files with specified content types (deprecated in next versions)

content_types => [ARRAYREF]

Array reference with content types for "include" or "exclude"

types_action => "include" or "exclude"

If the action is a "include", all attached files with specified content types are saved but if the action is a "exclude", no files are saved except if its in the array of content types. If no array is specified, but the action is a "include", all attached files are saved, otherwise all files are removed if action is a "exclude". The default action is "include".

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.

nmsgs

Returns the number of parsed messages.

clean_all

Cleans all files from the "output_dir" directory and then removes the directory. If an error happens returns it.

AUTHOR

Henrique Dias <henrique.ribeiro.dias@gmail.com>

CREDITS

Thanks to Rui Castro for the revision.

SEE ALSO

MIME::Tools, perl(1).

Module Install Instructions

To install MIME::Explode, copy and paste the appropriate command in to your terminal.

cpanm

cpanm MIME::Explode

CPAN shell

perl -MCPAN -e shellinstall MIME::Explode

For more information on module installation, please visitthe detailed CPAN module installation guide.

Keyboard Shortcuts

Global
sFocus search bar
?Bring up this help dialog
GitHub
gpGo to pull requests
gigo to github issues (only if github is preferred repository)
POD
gaGo to author
gcGo to changes
giGo to issues
gdGo to dist
grGo to repository/SCM
gsGo to source
gbGo to file browse
Search terms
module: (e.g.module:Plugin)
distribution: (e.g.distribution:Dancer auth)
author: (e.g.author:SONGMU Redis)
version: (e.g.version:1.00)

[8]ページ先頭

©2009-2025 Movatter.jp