Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use Mail::POP3Client;
- use MIME::Parser;
- my $pop = new Mail::POP3Client(
- USER => "*****",
- PASSWORD => "*****",
- HOST => "*****",
- USESSL => "true",
- PORT => "995",
- );
- ## for HeadAndBodyToFile() to use
- my $fh = new IO::Handle();
- ## Initialize stuff for MIME::Parser;
- my $outputdir = "./mimemail";
- my $parser = new MIME::Parser;
- $parser->output_dir($outputdir);
- my $i;
- ## process all messages in pop3 inbox
- for ($i = 1; $i <= $pop->Count(); $i++) {
- open (MAILOUT, ">pop3.msg$i");
- $fh->fdopen( fileno( MAILOUT ), "w" );
- ## write current msg to file
- $pop->HeadAndBodyToFile( $fh, $i );
- close MAILOUT;
- ## MIME::Parser handles only one msg at-a-time
- open (MAILIN, "<pop3.msg$i");
- ## flush all attachments this msg to ./mimemail dir using internal filename
- my $entity = $parser->read(\*MAILIN);
- close MAILIN;
- }
Add Comment
Please, Sign In to add comment