Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Net::POP3 and SSL

by robmueller (Novice)
on May 28, 2003 at 02:10 UTC ( [id://261177]=perlquestion: print w/replies, xml ) Need Help??

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

I want to connect to a POP3 server via SSL. I had a look at the Net::POP3 class, and thought that it would only take a few changes to make it work with SSL. So I copied the code, and made the following changes to create a new module to test with...

! package Net::POP3SSL; use strict; ! use IO::Socket::SSL; use vars qw(@ISA $VERSION $debug); use Net::Cmd; ! @ISA = qw(Net::Cmd IO::Socket::SSL);

I tried it and it seemed to work fine. Unfortunately, it doesn't work fine all the time. In some cases, with some servers, it just freezes up. I did a bit of tracking, and it seems to come down to that IO::Socket::SSL sometimes returns a 0 when doing a read. Normally this means an EOF condition, but not necessarily in the SSL case apparently...

Does anyone have a quick and reasonable solution to get this to work, or some variation on Net::POP3 that does work with SSL?

Rob

Replies are listed 'Best First'.
Re: Net::POP3 and SSL
by PodMaster (Abbot) on May 28, 2003 at 02:19 UTC
    http://search.cpan.org/author/SDOWD/Mail-POP3Client-2.14/POP3Client.pm says
    use Mail::POP3Client; $pop = new Mail::POP3Client( USER => "me", PASSWORD => "mypassword", HOST => "pop3.do.main" ); for( $i = 1; $i <= $pop->Count(); $i++ ) { foreach( $pop->Head( $i ) ) { /^(From|Subject):\s+/i && print $_, "\n"; } } $pop->Close(); # OR with SSL ##**<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<<<<<<<<<<<< $pop = new Mail::POP3Client( USER => "me", PASSWORD => "mypassword", HOST => "pop3.do.main", USESSL => true, ); # OR $pop2 = new Mail::POP3Client( HOST => "pop3.otherdo.main" ); $pop2->User( "somebody" ); $pop2->Pass( "doublesecret" ); $pop2->Connect() >= 0 || die $pop2->Message(); $pop2->Close(); # OR to use your own SSL socket... my $socket = IO::Socket::SSL->new( PeerAddr => 'pop.securedo.main', PeerPort => 993, Proto => 'tcp') || die "No soc +ket!"; my $pop = Mail::POP3Client->new(); $pop->User('somebody'); $pop->Pass('doublesecret'); $pop->Socket($socket); $pop->Connect();
    so I suggest you try that. This link brought to you by this powerful tutorial.


    MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
    I run a Win32 PPM repository for perl 5.6x+5.8x. I take requests.
    ** The Third rule of perl club is a statement of fact: pod is sexy.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2024-03-28 12:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found