biohisham has asked for the wisdom of the Perl Monks concerning the following question:

Hello Guys,
First steps with Web Programming, I tried using the module Mail::POP3Client to check letters in an email account I have and download the messages from there. I noticed that explicitly setting the port number in constructing the $mail object would cause "$mail->Count" to return -1 which indicates a connection error:
you have -1 new Message(s)
Whereas setting the SSL connectivity to true instead would make the program work just fine... It is not immediately clear to me why -1 is returned in the first case, I have configured POP settings and support including the port numbers as per instructions from Gmail. An explanation of this behavior is what I am curious to find out about...

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; }

My other pending issue is with the module Mail::Mailer, since it is based on the 'sendmail' *nix program what alternatives are there for me on Win systems so that I can send emails through, I'm considering Mail::Sender, what do you advice me of?...


Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind.

Replies are listed 'Best First'.
Re: Mail::POP3Client USESSL=> and PORT=>
by almut (Canon) on Dec 22, 2009 at 22:12 UTC
    #PORT=> 995, #returns -1, not working USESSL =>'true' #changes the port# to 995,working.

    Wouldn't setting PORT to 995 alone (without setting USESSL) try to talk to the service at port 995 in non-SSL mode (which I'd expect to fail...)?

      wow this works just great, but I think it doesn't let you see your inbox letters or select certain folders to view from the inbox, it just plainly downloads every single email letter in there which takes a long time to execute... any walk-arounds?
Re: Mail::POP3Client USESSL=> and PORT=>
by gmargo (Hermit) on Dec 22, 2009 at 22:06 UTC