By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,811 Members | 1,978 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,811 IT Pros & Developers. It's quick & easy.

Retrieve mails from mailserver

100+
P: 121
Hi everybody,

Iam struggling for retrieve mails from mail server using perl
iam facing some problem in blow my code
even i have the mails in my mailserver iam not getting the count of mails
only iam getting count as -1
what was the problem can any body reply back

look at my code
Expand|Select|Wrap|Line Numbers
  1. $pop = new Mail::POP3Client(USER => $username,PASSWORD => $passwd, HOST=> $host,PORT=> $port,TIMEOUT =>20,AUTH_MODE => 'BEST',DEBUG => 1) ||  die "cannot establish connection with the pop3 mail server $host, $!";
  2. print "Connection  established";
  3. print $pop->Count();
  4. print "<table align=center>";
  5. for ($i=1; $i<=$pop->Count(); $i++)
  6. {
  7.     foreach ( $pop->Retrieve( $i ) )
  8.     {
  9.         print "<tr><td>$_</td></tr>\n";
  10.     }
  11. }
  12. print "</table>";
  13.  


thanking you.

Regards,
shiva krishna
Jul 2 '08 #1
Share this Question
Share on Google+
1 Reply


numberwhun
Expert Mod 2.5K+
P: 3,503
In looking at the page on CPAN for Mail::POP3Client , I found the following line:

Expand|Select|Wrap|Line Numbers
  1. new returns a valid Mail::POP3Client object in all cases. To test for a connection failure, you will need to check the number of messages: -1 indicates a connection error.
  2.  
The -1 that you are getting is saying that there is a problem with the connection. I would check and make sure that you can login with the ID/Password you are specifying. Also, I would ensure that the mail system you are connecting to supports POP3.

Regards,

Jeff
Jul 11 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.