#!/usr/bin/perl
use Mail::POP3Client;
use MIME::Parser;
#usage() unless scalar @ARGV == 3;
my $pop = new Mail::POP3Client( HOST => 'server',
USER => 'my',
PASSWORD => 'pass' );
my $tmp_directory = "/tmp/attach";
my $parser = new MIME::Parser;
$parser->output_dir($tmp_directory);
$parser->output_prefix("attachment");
$parser->output_to_core();
open (FH,">>/tmp/msgtxt");
for (my $i = 1; $i <= $pop->Count(); $i++){
my $head = $pop->Head($i);
if ($head =~ /X-MS-Has-Attach: yes/i){
foreach ( $pop->Head( $i ) ) {
if( /^(From|Subject):\s+/i ) {
if ( /Vincent/) {
my $msg = $pop->HeadAndBody($i);
if ($msg =~/^To: /) {
print FH " $msg \n";
}
my $entity = $parser->parse_data($msg)
+;
}
}
}
# print "\n";
}
}
close(FH);
$pop->Close();
sub usage {
print "Usage: $0 <mail_server> <username> <password>\n";
exit;
}
Above is updated code, it stores almost all attachment according to condition. Now I need to parse thos attachment and find the header from that attachment.
Ex: In all attachment "To" address will be 'hotmail address'.
Is there any way to get all hotmail addresses from that header inside attachment.
Thnks
|