you have -1 new Message(s)
####
use strict;
use warnings;
use Mail::POP3Client;
my $userName = 'name@gmail.com';
my $password = 'password';
my $mail = new Mail::POP3Client(
USER =>$userName,
PASSWORD=>$password,
HOST =>"pop.gmail.com",
#PORT=> 995, #returns -1, not working
USESSL =>'true' #changes the port# to 995,working.
);
#checking for messages:
if($mail->Count){
print "you have @{[$mail->Count]} new Message(s)\n";
print "saving Message(s) to file\n";
open(FileHandle, '>',"gmailMails.txt")or die("$!\n");
for(my $index =1;$index<=$mail->Count;$index++){
print FileHandle $mail->HeadAndBody($index);
}
close FileHandle;
}
####