Re: pop3s support - rough patch now attached.

Jim Cromie <[email protected]> Tue, 08 Nov 2005 13:01:23 -0700
Newsgroups gmane.comp.lang.perl.modules.mail-box
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------000806040507060503000306
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Jim Cromie wrote:

> gents,
>
> after a 1 word 'ssl' search on the archives, I concluded that pop3s 
> wasnt started yet.
> so I started it.
>
> Whats attached sort of works, it gives the following progress:
>
cripes.  now attached.


heres a -d session, where it uses the SSL connection, but doesnt do the 
pop-stuff.

MBOX: pop3s://[email protected]:995
  got `+OK
' (5:0 bytes, VM=vm_unknown)
 at blib/lib/Net/SSLeay.pm (autosplit into 
blib/lib/auto/Net/SSLeay/debug_read.al) line 1585
        Net::SSLeay::debug_read('SCALAR(0x9aebd98)', 
'SCALAR(0x9aebd74)') called at blib/lib/Net/SSLeay.pm (autosplit into 
blib/lib/auto/Net/SSLeay/ssl_read_until.al) line 1750
        Net::SSLeay::ssl_read_until(158976552) called at 
/usr/local/lib/perl5/site_perl/5.8.7/IO/Socket/SSL.pm line 290
        IO::Socket::SSL::readline('IO::Socket::SSL=GLOB(0x9ae0ee4)') 
called at /usr/local/lib/perl5/site_perl/5.8.7/IO/Socket/SSL.pm line 543
        
IO::Socket::SSL::SSL_HANDLE::READLINE('IO::Socket::SSL::SSL_HANDLE=REF(0x9a9032c)') 
called at 
/home/jimc/perl/cpan/Mail-Box-2.063-ssl/lib/Mail/Transport/POP3s.pm line 267
        
Mail::Transport::POP3s::_connection('Mail::Transport::POP3s=HASH(0x9aaf2c4)') 
called at 
/home/jimc/perl/cpan/Mail-Box-2.063-ssl/lib/Mail/Transport/POP3s.pm line 188
        
Mail::Transport::POP3s::socket('Mail::Transport::POP3s=HASH(0x9aaf2c4)') 
called at 
/home/jimc/perl/cpan/Mail-Box-2.063-ssl/lib/Mail/Transport/POP3s.pm line 141
        
Mail::Transport::POP3s::disconnect('Mail::Transport::POP3s=HASH(0x9aaf2c4)') 
called at /home/jimc/perl/cpan/Mail-Box-2.063-ssl/lib/Mail/Box/POP3.pm 
line 86
        Mail::Box::POP3::close('Mail::Box::POP3s=HASH(0x994e4c4)') 
called at /home/jimc/perl/cpan/Mail-Box-2.063-ssl/lib/Mail/Box/POP3s.pm 
line 84
        Mail::Box::POP3s::close('Mail::Box::POP3s=HASH(0x994e4c4)') 
called at 
/home/jimc/perl/cpan/Mail-Box-2.063-ssl/lib/Mail/Box/Manager.pm line 313
        
Mail::Box::Manager::closeAllFolders('Mail::Box::Manager=HASH(0x9209e80)') 
called at mail-handler.pl line 133
  got `+OK Farewell.
' (15:0 bytes, VM=vm_unknown)
 at blib/lib/Net/SSLeay.pm (autosplit into 
blib/lib/auto/Net/SSLeay/debug_read.al) line 1585
        Net::SSLeay::debug_read('SCALAR(0x9aebd98)', 
'SCALAR(0x9aebd74)') called at blib/lib/Net/SSLeay.pm (autosplit into 
blib/lib/auto/Net/SSLeay/ssl_read_until.al) line 1750
        Net::SSLeay::ssl_read_until(158976552) called at 
/usr/local/lib/perl5/site_perl/5.8.7/IO/Socket/SSL.pm line 290
        IO::Socket::SSL::readline('IO::Socket::SSL=GLOB(0x9ae0ee4)') 
called at /usr/local/lib/perl5/site_perl/5.8.7/IO/Socket/SSL.pm line 543
        
IO::Socket::SSL::SSL_HANDLE::READLINE('IO::Socket::SSL::SSL_HANDLE=REF(0x9a9032c)') 
called at 
/home/jimc/perl/cpan/Mail-Box-2.063-ssl/lib/Mail/Transport/POP3s.pm line 214
        
Mail::Transport::POP3s::send('Mail::Transport::POP3s=HASH(0x9aaf2c4)', 
'IO::Socket::SSL=GLOB(0x9ae0ee4)', 'QUIT\x{d}\x{a}') called at 
/home/jimc/perl/cpan/Mail-Box-2.063-ssl/lib/Mail/Transport/POP3s.pm line 148
        
Mail::Transport::POP3s::disconnect('Mail::Transport::POP3s=HASH(0x9aaf2c4)') 
called at /home/jimc/perl/cpan/Mail-Box-2.063-ssl/lib/Mail/Box/POP3.pm 
line 86
        Mail::Box::POP3::close('Mail::Box::POP3s=HASH(0x994e4c4)') 
called at /home/jimc/perl/cpan/Mail-Box-2.063-ssl/lib/Mail/Box/POP3s.pm 
line 84
        Mail::Box::POP3s::close('Mail::Box::POP3s=HASH(0x994e4c4)') 
called at 
/home/jimc/perl/cpan/Mail-Box-2.063-ssl/lib/Mail/Box/Manager.pm line 313
        
Mail::Box::Manager::closeAllFolders('Mail::Box::Manager=HASH(0x9209e80)') 
called at mail-handler.pl line 133
done
Debugged program terminated.  Use q to quit or R to restart,


--------------000806040507060503000306
Content-Type: text/plain;
 name="patch-MBox-add-Pop3s-v001"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="patch-MBox-add-Pop3s-v001"

Only in Mail-Box-2.063-ssl/: blib
diff -ru Mail-Box-2.063/lib/Mail/Box/Manager.pm Mail-Box-2.063-ssl/lib/Mail/Box/Manager.pm
--- Mail-Box-2.063/lib/Mail/Box/Manager.pm	2005-11-01 01:19:27.000000000 -0700
+++ Mail-Box-2.063-ssl/lib/Mail/Box/Manager.pm	2005-11-08 10:49:25.000000000 -0700
@@ -24,6 +24,7 @@
   , [ maildir => 'Mail::Box::Maildir' ]
   , [ pop     => 'Mail::Box::POP3'    ]
   , [ pop3    => 'Mail::Box::POP3'    ]
+  , [ pop3s   => 'Mail::Box::POP3s'   ]
   , [ imap    => 'Mail::Box::IMAP4'   ]
   , [ imap4   => 'Mail::Box::IMAP4'   ]
   );
@@ -156,6 +157,12 @@
         my $port = $args{server_port} ||= 110;
         $args{folder} = $name = "pop3://$un\@$srv:$port";
     }
+    elsif(defined $type && $type eq 'pop3s')
+    {   my $un   = $args{username}    ||= $ENV{USER} || $ENV{LOGIN};
+        my $srv  = $args{server_name} ||= 'localhost';
+        my $port = $args{server_port} ||= 995;
+        $args{folder} = $name = "pop3s://$un\@$srv:$port";
+    }
 
     unless(defined $name && length $name)
     {   $self->log(ERROR => "No foldername specified to open.");
@@ -530,7 +537,7 @@
        my ($type, $username, $password, $hostname, $port, $path)
           = $name =~ m!^(\w+)\:             # protocol
                        (?://
-                          (?:([^:@./]*)     # username
+                          (?:([^:@/]*)     # username (allow dot)
                             (?:\:([^@/]*))? # password
                            \@)?
                            ([\w.-]+)?       # hostname
Only in Mail-Box-2.063-ssl/lib/Mail/Box: Manager.pm~
diff -ru Mail-Box-2.063/lib/Mail/Box/POP3.pm Mail-Box-2.063-ssl/lib/Mail/Box/POP3.pm
--- Mail-Box-2.063/lib/Mail/Box/POP3.pm	2005-11-01 01:19:25.000000000 -0700
+++ Mail-Box-2.063-ssl/lib/Mail/Box/POP3.pm	2005-11-07 21:25:48.000000000 -0700
@@ -125,6 +125,8 @@
     return $self->{MBP_client}
         if defined $self->{MBP_client};
 
+    $DB::single = 1;
+
     my $auth = $self->{auth};
 
     require Mail::Transport::POP3;
Only in Mail-Box-2.063-ssl/lib/Mail/Box: POP3.pm~
diff -ru Mail-Box-2.063/lib/Mail/Box/POP3s.pm Mail-Box-2.063-ssl/lib/Mail/Box/POP3s.pm
--- Mail-Box-2.063/lib/Mail/Box/POP3s.pm	2005-11-01 01:19:25.000000000 -0700
+++ Mail-Box-2.063-ssl/lib/Mail/Box/POP3s.pm	2005-11-08 10:09:27.000000000 -0700
@@ -1,7 +1,8 @@
 
-package Mail::Box::POP3;
+package Mail::Box::POP3s;
 use vars '$VERSION';
 $VERSION = '2.063';
+use base 'Mail::Box::POP3';
 use base 'Mail::Box::Net';
 
 use strict;
@@ -19,7 +20,7 @@
 sub init($)
 {   my ($self, $args) = @_;
 
-    $args->{server_port} ||= 110;
+    $args->{server_port} ||= 995;      # googles anyway
     $args->{folder}      ||= 'inbox';
 
     $self->SUPER::init($args);
@@ -127,8 +128,8 @@
 
     my $auth = $self->{auth};
 
-    require Mail::Transport::POP3;
-    my $client  = Mail::Transport::POP3->new
+    require Mail::Transport::POP3s;
+    my $client  = Mail::Transport::POP3s->new
       ( username     => $self->{MBN_username}
       , password     => $self->{MBN_password}
       , hostname     => $self->{MBN_hostname}
Only in Mail-Box-2.063-ssl/lib/Mail/Box: POP3s.pm~
diff -ru Mail-Box-2.063/lib/Mail/Transport/POP3s.pm Mail-Box-2.063-ssl/lib/Mail/Transport/POP3s.pm
--- Mail-Box-2.063/lib/Mail/Transport/POP3s.pm	2005-11-01 01:19:26.000000000 -0700
+++ Mail-Box-2.063-ssl/lib/Mail/Transport/POP3s.pm	2005-11-08 10:23:52.000000000 -0700
@@ -2,12 +2,14 @@
 use strict;
 use warnings;
 
-package Mail::Transport::POP3;
+package Mail::Transport::POP3s;
+use base 'Mail::Transport::POP3';
+
 use vars '$VERSION';
 $VERSION = '2.063';
 use base 'Mail::Transport::Receive';
 
-use IO::Socket  ();
+use IO::Socket::SSL qw(debug4);
 use Socket      qw/$CRLF/;
 
 use Digest::MD5 ();
@@ -15,8 +17,8 @@
 
 sub init($)
 {   my ($self, $args) = @_;
-    $args->{via}    = 'pop3';
-    $args->{port} ||= 110;
+    $args->{via}    = 'pop3s';
+    $args->{port} ||= 995;
 
     $self->SUPER::init($args) or return;
 
@@ -286,7 +288,7 @@
         return;
     }
 
-    my $socket = eval {IO::Socket::INET->new("$host:$port")};
+    my $socket = eval {IO::Socket::SSL->new("$host:$port")};
     unless($socket)
     {   $self->log(ERROR => "Cannot connect to $host:$port for POP3: $!");
         return;
Only in Mail-Box-2.063-ssl/lib/Mail/Transport: POP3s.pm~
Only in Mail-Box-2.063-ssl/: Makefile
Only in Mail-Box-2.063-ssl/: pm_to_blib
Only in Mail-Box-2.063-ssl/tests/folders: mbox.win
Only in Mail-Box-2.063-ssl/tests: msg-8247-1.txt

--------------000806040507060503000306--