#!/use/bin/perl BEGIN {(*STDERR = *STDOUT) || die;} use diagnostics; use warnings; use strict; $| = 1; { package Net::POP3::SSL; # $Id: SSL.pm,v 1.1 2004/07/20 03:22:18 cwest Exp $ use strict; use vars qw[$VERSION @ISA]; $VERSION = sprintf "%d.%02d", split m/\./, (qw$Revision: 1.1 $)[1]; use IO::Socket::SSL; use Net::POP3; @ISA = ( 'IO::Socket::SSL', grep { $_ ne 'IO::Socket::INET' } @Net::POP3::ISA ); no strict 'refs'; foreach ( keys %Net::POP3:: ) { next unless defined *{$Net::POP3::{$_}}{CODE}; *{$_} = \&{"Net::POP3::$_"}; } 1; } my $pop_host = ''; my $pop_port = 995; my $user_id = ''; my $password = ''; my %pop_options = ( Host => $pop_host, LocalPort => $pop_port, #ResvPort => 1, # Timeout => 30, Debug => 4, ); my %pop_ssl_options = ( Host => $pop_host, Port => $pop_port, #ResvPort => 1, # Timeout => 30, Debug => 4, ); test_pop(); sub test_pop { my $mail =''; if(!($mail = Net::POP3::SSL->new(%pop_ssl_options))) #if(!($mail = Net::POP3->new(%pop_options))) { print "ERROR: Could not open $pop_host\n$!\n"; return -1; } my $number_of_messages = $mail->login($user_id, $password); if(!$number_of_messages) { (defined $number_of_messages) or print "ERROR: Login error for $pop_host\n$!\n"; $mail->quit(); return -1; } print "Number of messages: $number_of_messages\n"; } __END__ Output: Net::POP3>>> Net::POP3(2.29) Net::POP3>>> Net::Cmd(2.29) Net::POP3>>> Exporter(5.60) Net::POP3>>> IO::Socket::INET(1.31) Net::POP3>>> IO::Socket(1.30) Net::POP3>>> IO::Handle(1.27) Net::POP3=GLOB(0x1d699cc)<<< +OK hello from popgate on pop104.plus.mail.stuff.com 2.38.1 Net::POP3=GLOB(0x1d699cc)>>> USER Net::POP3=GLOB(0x1d699cc)<<< +OK password required. Net::POP3=GLOB(0x1d699cc)>>> PASS .... Net::POP3=GLOB(0x1d699cc)<<< +OK maildrop ready, 452 messages (5836296 octets) (6062525 3105357824) Number of messages: 452 Net::POP3::SSL>>> Net::POP3::SSL(1.01) Net::POP3::SSL>>> IO::Socket::SSL(1.08) Net::POP3::SSL>>> IO::Socket::INET(1.31) Net::POP3::SSL>>> IO::Socket(1.30) Net::POP3::SSL>>> IO::Handle(1.27) Net::POP3::SSL>>> Exporter(5.60) Net::POP3::SSL>>> Net::Cmd(2.29) Net::POP3::SSL=GLOB(0x1d69a0c)<<< +OK hello from popgate on pop106.plus.mail.stuff.com 2.38.1 Net::POP3::SSL=GLOB(0x1d69a0c)>>> USER Net::POP3::SSL=GLOB(0x1d69a0c)<<< +OK password required. Net::POP3::SSL=GLOB(0x1d69a0c)>>> PASS .... Net::POP3::SSL=GLOB(0x1d69a0c)<<< +OK maildrop ready, 447 messages (5808500 octets) (6034729 3105357824) Number of messages: 447