@caps = $self->capabilities();
}
- $self->fail("Logins are disabled.") if grep {$_ eq 'LOGINDISABLED'} @caps;
- my @mechs = grep defined, map { /^AUTH=(.+)/ ? $1 : undef } @caps;
+ my @mechs = ('LOGIN', grep defined, map { /^AUTH=(.+)/ ? $1 : undef } @caps);
my $mech = (grep defined, map {my $m = $_; (grep {$m eq $_} @mechs) ? $m : undef}
split(/ /, $self->{auth}))[0];
$self->fail("Failed to choose an authentication mechanism") unless defined $mech;
+ $self->fail("Logins are disabled.") if ($mech eq 'LOGIN' or $mech eq 'PLAIN') and
+ grep {$_ eq 'LOGINDISABLED'} @caps;
my ($command, $callback);
my ($username, $password) = @$self{qw/username password/};