Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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 = 'pop.wanadoo.fr'; ##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

Comment on how to use Net::POP3::SSLWrapper
Download Code
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)?

    HTH,

    planetscape

      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 deletemailpop3s.pl connecting to pop.wanadoo.fr.. ok Use of uninitialized value in concatenation (.) or string at deletemai +lpop3s.pl 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/POP3.pm line 311. Use of uninitialized value in numeric eq (==) at /usr/lib/perl5/5.8.8/ +Net/POP3.pm 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 POP3.pm 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 = 'pop.example.com'; 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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (15)
As of 2015-07-31 20:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (281 votes), past polls