09 June 2015

Mime extractor suitable for use in Evolution filter.

#!/usr/bin/perl
# http://www.perlmonks.org/?node_id=12287
# apt-get install libmime-tools-perl
# yum install perl-MIME-tools

use strict;
use MIME::Parser;
use File::Path qw(make_path);

sub read_email {
    my $dir = $ENV{'HOME'} . "/Desktop/email";
    make_path($dir) unless -d $dir;
    die unless -d $dir;

    my $parser = new MIME::Parser;
    $parser->output_dir($dir);
    my $entity = $parser->read(\*STDIN) || die "couldn't parse MIME stream";
}

&read_email();

exit 0;

No comments: