Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

how to read the Gmail Inbox using pop3client module?

by vasanthgk91 (Sexton)
on Aug 09, 2013 at 05:16 UTC ( #1048685=perlquestion: print w/replies, xml ) Need Help??
vasanthgk91 has asked for the wisdom of the Perl Monks concerning the following question:

I tried the following codes.But i did not get pop count.what mistake i did don't please suggest solution

use warnings; use strict; use Mail::POP3Client; use IO::Socket::SSL; my $username =''; my $password ='password'; chomp($password); my $mailhost =''; my $port ='995'; my $pop = new Mail::POP3Client( USER => $username, PASSWORD => $password, HOST => $mailhost, PORT => $port, USESSL => 'true', DEBUG => 0, ); if (($pop->Count()) < 1) { print "I Can't get pop count"; exit; }

Just I get "I Can't get pop count"

Replies are listed 'Best First'.
Re: how to read the Gmail Inbox using pop3client module?
by syphilis (Chancellor) on Aug 09, 2013 at 06:12 UTC
    Maybe there's no mail waiting there for you ? In that case $pop->Count() will be 0.
    You should check to see whether the connection succeeded. The documentation says:
    To test for a connection failure, you will need to check the number of + messages: -1 indicates a connection error.
    For USESSL to be successful, the documentation also says that you need to have IO::Socket::SSL installed. Do you have that module ?
    I would expect that you'd get an error if you don't have that module installed .... however, the documentation suggests that the absence of that module will simply cause the connection to silently fail.


      Yes I received pop->count() values "-1"..this is connection error i got it.But me IO::Socket::SSL installed properly.In previously yahoo Inbox i read through IO::Socket::SSL module.So IO::Socket::SSL not get problem.But how to solve the connection error in pop3client.This really don't know.

      thank you for your kind replay

        Consult with your network administrator, use a network analysis tool to see what goes over the wire and what connections are made. Maybe Mail::POP3Client has some hints on debugging?

        Also consider the more verbose approach, also listed in the documentation:

        ... $pop2 = new Mail::POP3Client( HOST => "pop3.otherdo.main" ); $pop2->User( "somebody" ); $pop2->Pass( "doublesecret" ); $pop2->Connect() >= 0 || die $pop2->Message(); ...

        That way, you get more information from ->Mesage() maybe.

        I strongly recommend you start reading the documentation of the module and follow the practices outlined there.

Re: how to read the Gmail Inbox using pop3client module?
by jakeease (Friar) on Aug 09, 2013 at 08:40 UTC

    I ran your code in the debugger and did get a proper count, but first I got this:

    main::( my $port ='995'; DB<2> main::( my $pop = new Mail::POP3Client( main::( USER => $username, main::( PASSWORD => $password, main::( HOST => $mailhost, main::( PORT => $port, main::( USESSL => 'true', main::( DEBUG => 0, main::( ); DB<2> ******************************************************************* Using the default of SSL_verify_mode of SSL_VERIFY_NONE for client is deprecated! Please set SSL_verify_mode to SSL_VERIFY_PEER together with SSL_ca_file|SSL_ca_path for verification. If you really don't want to verify the certificate and keep the connection open to Man-In-The-Middle attacks please set SSL_verify_mode explicitly to SSL_VERIFY_NONE in your application. ******************************************************************* at C:/strawberry/perl/site/lib/Mail/ line 376. at C:/strawberry/perl/vendor/lib/IO/Socket/ line 312. IO::Socket::SSL::configure_SSL('IO::Socket::SSL=GLOB(0x3b909d0 +)', 'HASH(0x2adc148)') called at C:/strawberry/perl/vendor/lib/IO/Soc +ket/ line 264 IO::Socket::SSL::configure('IO::Socket::SSL=GLOB(0x3b909d0)', +'HASH(0x2adc148)') called at C:/strawberry/perl/lib/IO/ line + 49 IO::Socket::new('IO::Socket::SSL', 'Proto', 'tcp', 'PeerAddr', + '', 'Type', 1, 'PeerPort', 995, ...) called at C:/straw +berry/perl/vendor/lib /IO/Socket/ line 331 IO::Socket::IP::new('IO::Socket::SSL', 'PeerAddr', ' +com', 'PeerPort', 995, 'Proto', 'tcp', 'Type', 1, ...) called at C:/s +trawberry/perl/site/l ib/Mail/ line 376 Mail::POP3Client::Connect('Mail::POP3Client=HASH(0x3b8f088)') +called at C:/strawberry/perl/site/lib/Mail/ line 79

    So, for me it worked at the next step

    DB<2> l 26==> if (($pop->Count()) < 1) 27 { 28: print "I Can't get pop count"; 29: exit; 30 } 31 DB<2> p $pop->Count() 320 DB<3>
    but definitely hints at potential snags in the network/security configuration arena.

      IMAP via I got the output

      on a browser.

      I follow the link and unlock the captcha after i read the gmail inbox

      Thank you

Re: how to read the Gmail Inbox using pop3client module?
by hulfordp (Initiate) on Jun 24, 2014 at 11:59 UTC
    I had very similar code working in an old version of perl. I upgraded and then only received connection failure. Connection failure was silent.

    I moved back to old version of perl and connections worked fine (also made sure I used the same packages and same code). The perl version that worked on my windows 7 64 bit machine was 5.14.2 build 1402. The version that did not work was 5.16.3 build 1604.

    Best Paul

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1048685]
Approved by kevbot
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2018-11-20 11:29 GMT
Find Nodes?
    Voting Booth?
    My code is most likely broken because:

    Results (223 votes). Check out past polls.