elsif ($mech eq 'PLAIN') {
require 'MIME/Base64.pm';
$self->fail("Missing option $_") foreach grep {!defined $self->{$_}} qw/username password/;
- $command = "AUTHENTICATE $mech";
my $credentials = MIME::Base64::encode_base64("\x00".$username."\x00".$password, '');
- $callback = sub($) {return $credentials};
+ $command = "AUTHENTICATE $mech";
+ if ($self->_capable('SASL-IR')) { # RFC 4959 SASL-IR
+ $command .= " $credentials";
+ } else {
+ $callback = sub($) {return $credentials};
+ }
}
else {
$self->fail("Unsupported authentication mechanism: $mech");