Retrieve mail using perl plz help me

rahul_mawana's Avatar, Join Date: Apr 2009
Contributor
Hello frnds,
I am trying to makd a perl propram by that i can retrieve my email from a server that requires SSL
authentication. I used
Net::POP3 and I tried all the
different types of logging in such as auth(..), login(..),
which are sub routines defined in
Net::POP3.
But not working plz tell me any method or perl module by that i can retrive mail.
Thanks
0
murugaperumal's Avatar, Join Date: Feb 2010
Go4Expert Member
Dear Friend,

You can use the following modules

Mail::POP3Client

It will help your requirement.
0
ungalnanban's Avatar, Join Date: Feb 2010
Go4Expert Member
Refer the following link

http://bumppo.net/lists/macperl-webcgi/2000/05/msg00027.html
0
murugaperumal's Avatar, Join Date: Feb 2010
Go4Expert Member
You can use the following code

Code:
 
 use warnings;
use strict;
use Mail::POP3Client;
use lib "/home/murugaperumal/.perl_m/share/perl/5.8.8/" ;
use IO::Socket::SSL;
use CGI qw(:standard);
my $cgi = new CGI;
my $LOG ;
open $LOG , ">>filename" ;
my $username  = 'username@gmail.com';
my $password  = '********' ;
 chomp($password);
my $mailhost  = 'pop.gmail.com';
my $port      = '995';

$cgi->header();

my $pop = new Mail::POP3Client(
USER     => $username,
PASSWORD => $password,
HOST     => $mailhost,
PORT     => $port,
USESSL   => 'true',
DEBUG     => 0,
);

if (($pop->Count()) < 1) {
exit;
}

print $pop->Count() . " messages found!:$!\n";

for(my $i = 1; $i <= $pop->Count(); $i++) {
 foreach($pop->Head($i)) {
 /^(From|Subject|Email):\s+/i && print $_, "\n";
 }
$pop->BodyToFile($LOG,$i);
}
$pop->Close();
exit;