diff -ruN e-smith-email-5.4.0.old/root/usr/local/sbin/smtp-auth-proxy.pl e-smith-email-5.4.0/root/usr/local/sbin/smtp-auth-proxy.pl --- e-smith-email-5.4.0.old/root/usr/local/sbin/smtp-auth-proxy.pl 2013-02-06 13:56:01.000000000 -0800 +++ e-smith-email-5.4.0/root/usr/local/sbin/smtp-auth-proxy.pl 2013-12-14 12:27:33.000000000 -0800 @@ -114,13 +114,29 @@ if ($smtp->supports("AUTH")) { - foreach (split (/ /, $self->get_property('Blacklist'))) - {${*$smtp}{'net_smtp_esmtp'}->{"AUTH"} =~ s/$_//;} - - unless ($smtp->auth($name, $pass)) + my $authenticated = 0; + my $blacklist = $self->get_property('Blacklist') || "";; + foreach my $method (split (/ /, ${*$smtp}{'net_smtp_esmtp'}->{"AUTH"})) + { + # Skip $method if in the blacklist + next unless ($blacklist !~ /$method/); + # Only present one auth method at a time to NET::SMTP + {${*$smtp}{'net_smtp_esmtp'}->{"AUTH"} = $method;} + + if ($smtp->auth($name, $pass)) + { + $authenticated++; + last; + } + else + { + warn "SMTP authentication (with $method) with ISP server failed\n"; + } + } + unless ($authenticated) { print "451 Could not auth to mail server\n"; - warn "SMTP authentication with ISP server failed\n"; + warn "all SMTP authentication methods failed\n"; $smtp->quit; exit; } @@ -133,19 +149,19 @@ my $discard = ; # Swallow EHLO while (my $msg = shift @ehlo) { - my $sep = (@ehlo ? "-" : " "); - print "250$sep$msg"; + my $sep = (@ehlo ? "-" : " "); + print "250$sep$msg"; } die "can't fork: $!" unless defined ($kidpid = fork()); if ($kidpid) { - print $smtp $_ while ; + print $smtp $_ while ; kill ("TERM" => $kidpid); } else { - print while <$smtp>; + print while <$smtp>; kill ("TERM" => getppid()); } }