diff options
author | Steve Hay <steve.m.hay@googlemail.com> | 2014-06-03 09:09:44 +0100 |
---|---|---|
committer | Steve Hay <steve.m.hay@googlemail.com> | 2014-06-03 09:09:44 +0100 |
commit | 9155076257b16507c87f99829773b5d65fb71bba (patch) | |
tree | 3d9b51f349ab03b325ac804a51a196bf06256b27 | |
parent | 8dedae07612e77e4a46214334e83891dd3ce388b (diff) | |
parent | fdcacd730e5e9fabe084f343a2d58e036745610e (diff) | |
download | perl-libnet-9155076257b16507c87f99829773b5d65fb71bba.tar.gz |
Merge pull request #3 from apla/patch-2
Authen::SASL fixes
-rw-r--r-- | Net/SMTP.pm | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/Net/SMTP.pm b/Net/SMTP.pm index 52b5060..51e66d3 100644 --- a/Net/SMTP.pm +++ b/Net/SMTP.pm @@ -178,14 +178,29 @@ sub auth { user => $username, pass => $password, authname => $username, - } + }, + debug => $self->debug ); } - # We should probably allow the user to pass the host, but I don't - # currently know and SASL mechanisms that are used by smtp that need it - my $client = $sasl->client_new('smtp', ${*$self}{'net_smtp_host'}, 0); - my $str = $client->client_start; + my $client; + my $str; + do { + if ($client) { + # $client mechanism failed, so we need to exclude this mechanism from list + my $failed_mech = $client->mechanism; + $self->debug_text ("Auth mechanism failed: $failed_mech") + if $self->debug; + $mechanisms =~ s/(?:\s|^)$failed_mech(?:\s|$)//; + } + $sasl->mechanism ($mechanisms); + + # We should probably allow the user to pass the host, but I don't + # currently know and SASL mechanisms that are used by smtp that need it + + $client = $sasl->client_new('smtp', ${*$self}{'net_smtp_host'}, 0); + $str = $client->client_start; + } while (!defined $str); # We don't support sasl mechanisms that encrypt the socket traffic. # todo that we would really need to change the ISA hierarchy |