Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

how to use Net::POP3::SSLWrapper

by swilting (Beadle)
on Jan 21, 2012 at 10:27 UTC ( #949145=perlquestion: print w/replies, xml ) Need Help??
swilting has asked for the wisdom of the Perl Monks concerning the following question:

I recently wrote this text which I think is not bad writing. but the script fails for no reason. I do not understand the reason for the error

#!/usr/bin/perl -w use strict; ##use Email::Simple; use Net::POP3; use Net::POP3::SSLWrapper; pop3s { my$server = ''; ##la tu dois mettre ton identifiant de connexion my $login = 'serge******'; ##la tu dois mettre tonmot de passe my$passwd = '*****'; $| = 1; print "connecting to $server..\n"; my $pop = new Net::POP3 $server or die "error: can't connect to $server: $!\n"; print "ok\n"; $pop->login($login,$passwd); $pop->ok or die "error: wrong username or password\n"; my($undelete,$size) = $pop->popstat; my$last = $pop ->last; print "mail box size: $size\n", "$undelete unread mail(s).\n", "last read mail was number $last\n\n"; my$fetched = 0; for my $num (1..$undelete) { my$msg = $pop->get($num); next unless ref $msg; $fetched += $pop->list($num); printf "\rfetched %2.0f%%",$fetched *100/$size; $pop->delete($num); } print $/; $pop->quit; }

Can you help me master the perl "Fu" to find a solution to my problem

Replies are listed 'Best First'.
Re: how to use Net::POP3::SSLWrapper
by planetscape (Chancellor) on Jan 21, 2012 at 10:49 UTC

    "Fails", how? What is the error?

    Do you need a sub before pop3s? Some spaces between my and $SomeVariableName (several instances)?



      the script fail during the prime parcourt of the loop I made ​​some minor changes to the code

      print "connecting to $server..\n"; my $pop = Net::POP3->new($server, Port => 995) or die "error: can't connect to $server: $!\n"; print "ok\n";

      this is my error to stderr

      localhost ~]$ perl connecting to ok Use of uninitialized value in concatenation (.) or string at deletemai line 28. mail box size: 12914033 313 unread mail(s). last read mail was number Use of uninitialized value in numeric eq (==) at /usr/lib/perl5/5.8.8/ +Net/ line 311. Use of uninitialized value in numeric eq (==) at /usr/lib/perl5/5.8.8/ +Net/ line 311. ...etc...

        Examining the first waarning message and the following output indicates that $last is undef which implies that my $last = $pop->last; failed. The following warnings pertaining to badness inside is pretty much consistent with $pop already being in a bad state.

        What did the code look before you changed it?

        True laziness is hard work
Re: how to use Net::POP3::SSLWrapper
by Khen1950fx (Canon) on Jan 22, 2012 at 00:35 UTC
    Mail::POP3Client worked better for me.
    #!/usr/bin/perl -l use strict; use warnings; use Mail::POP3Client; my $host = ''; my $user = 'user'; my $password = 'password'; my $pop = Mail::POP3Client->new( HOST => $host, USESSL => 1, USER => $user, PASSWORD => $password, ); print "You have ", $pop->Count, "messages";

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://949145]
Approved by planetscape
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2018-03-22 06:43 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (273 votes). Check out past polls.