in reply to Net::SMTP_auth giving 421 errors with authentication

Hello philkime,

Recently I was struggling with similar problems and I found that quite a few things can go wrong around using the starttls command.

You can build in extra error checking like how I did it in my recent post in Cool Uses For Perl: here

The code that I took from there shows:

# HELLO # Reminder: hello is also send again after starttls $smtp->hello( $cs->{ clientID } ) or die "Error: " . $smtp->message() ; # STARTTLS if ( !$smtp->starttls() ) { if ( ref $smtp eq 'Net::SMTP' ) { die "NET::SMPT failed to upgrade connection after connection m +essage: " . $smtp->message() . "Possible reasons for this may be firewalls or antivirus prote +ction software (such as mail shields). You can activate debugging for + IO::Socket::SSL and \$dbgSMTP to search for other possible reasons\n +" ; } else { die "starttls failed with Error: " . $smtp->message() . "You can activate debugging for IO::Socket::SSL and \$dbgSMTP +to search for possible reasons\n" ; } } ; # AUTHENTICATE ... # Finish with this line, it may contain extra error info if($@) { print STDERR "Error sending mail: $@"; }

Let us know what you find,

Veltro

edit: In case your $smtp object is a 'Net::SMTP_auth', then you need to change the line: if ( ref $smtp eq 'Net::SMTP' ) { to if ( ref $smtp eq 'Net::SMTP_auth' ) {. But now I am thinking again about this, here may actually be your problem. The auth method is not the one you think you are calling! Because after starttls the $smpt object is a Net::SMTP::_SSL (unless this was solved differently for Net::SMTP_auth)

Replies are listed 'Best First'.
Re^2: Net::SMTP_auth giving 421 errors with authentication
by philkime (Beadle) on Jul 17, 2018 at 18:15 UTC
    Many thanks, debugging with IO::Socket::SSL as suggested showed that it was a broken CA cert bundle. This also allowed me to revert to Net::SMTP as the STARTTLS redoes the EHLO, as you said, and this then properly advertised the AUTH mechanism so everything now works. It appears that certain SSL/TLS errors dont' really manifest in obvious symptoms but setting IO::Socket::SSL debugging makes the issue immediately obvious.