Subject: | login() doesn't report success when IMAP server returns more than one line response |
Some implementations of IMAP return the capabilities on a separate line from the OK status. The login() method of Net::IMAP::Simple will only take one line. If it doesn't say "OK" then login will return an empty value, which indicates failure.
Here's a patch for login() that will handle multiple lines of response.
*** Net/IMAP/Simple.pm.orig Sun Sep 15 20:34:59 2002
--- Net/IMAP/Simple.pm Sun Sep 15 20:39:25 2002
***************
*** 116,125 ****
$id = $self->_nextid();
print $sh "$id LOGIN $user $pass\r\n";
- $resp = $sh->getline();
! if ( $resp =~ /^$id\s+OK/i ) {
! return $self->select( 'INBOX' );
}
return;
--- 116,127 ----
$id = $self->_nextid();
print $sh "$id LOGIN $user $pass\r\n";
! while ( $resp = $sh->getline() ) {
! if ( $resp =~ /^$id\s+OK/i ) {
! return $self->select( 'INBOX' );
! }
! last if ($resp =~ /^$id\s+(NO|BAD)/i);
}
return;