Subject: | Logout not working if server answers with two separate lines |
Using example from the documentation:
$imap->logout or die "Logout error:", $imap->LastError, "\n";
Logout with Gmail:
Sending: 32 LOGOUT
Sent 11 bytes
Read: * BYE LOGOUT Requested
32 OK 73 good day (Success)
Works.
Logout with Dovecot:
Sending: 5 LOGOUT
Sent 10 bytes
Read: * BYE Logging out
Read: 5 OK Logout completed.
Application will always die with "Logout error: * BYE Logging out".
Possible solution:
--- IMAPClient.pm.orig Tue Aug 3 17:51:00 2010
+++ IMAPClient.pm Tue Aug 3 17:53:30 2010
@@ -1456,7 +1456,7 @@
$code = uc($1);
$self->LastError($data) unless ( $code eq 'OK' );
}
- elsif ( $data =~ /^\*\s+(BYE)\b/i ) {
+ elsif ( not exists $self->{IGNORE_BYE} and $data =~
/^\*\s+(BYE)\b/i ) {
$code = uc($1);
$byemsg = $data;
}
@@ -1922,7 +1922,9 @@
sub logout {
my $self = shift;
+ $self->{IGNORE_BYE} = 1;
my $rc = $self->_imap_command("LOGOUT");
+ delete $self->{IGNORE_BYE};
$self->_disconnect;
return $rc;
}