Hi there, This bug is still present and it's annoying that we can't use the plugin with tls connections because of it. There hasn't been any movement upstream for 8 years now unfortunately.
But, thanks to Jan's input, I've tried a simple workaround of just commenting out all of the calls to the problematic $smtp->message() calls and it made the script work again. I'm attaching the patch that I used for the workaround.
--- /usr/lib/nagios/plugins/check_smtp_send.orig 2020-09-25 15:36:59.291283004 -0400 +++ /usr/lib/nagios/plugins/check_smtp_send 2020-09-25 15:37:38.739800192 -0400 @@ -149,26 +149,26 @@ if( $tls and $auth_method ) { $smtp_port = $default_smtp_tls_port unless $smtp_port; $smtp = TLS_auth->new($smtp_server, Timeout=>$timeout, Port=>$smtp_port, User=>$username, Password=>$password, Auth_Method=>$auth_method); - if( $smtp ) { - my $message = oneline($smtp->message()); - die "cannot connect with TLS/$auth_method: $message" if $smtp->code() =~ m/53\d/; - } + #if( $smtp ) { + # my $message = oneline($smtp->message()); + # die "cannot connect with TLS/$auth_method: $message" if $smtp->code() =~ m/53\d/; + #} } elsif( $tls ) { $smtp_port = $default_smtp_tls_port unless $smtp_port; $smtp = Net::SMTP::TLS->new($smtp_server, Timeout=>$timeout, Port=>$smtp_port, User=>$username, Password=>$password); - if( $smtp ) { - my $message = oneline($smtp->message()); - die "cannot connect with TLS: $message" if $smtp->code() =~ m/53\d/; - } + #if( $smtp ) { + # my $message = oneline($smtp->message()); + # die "cannot connect with TLS: $message" if $smtp->code() =~ m/53\d/; + #} } elsif( $ssl ) { $smtp_port = $default_smtp_ssl_port unless $smtp_port; $smtp = Net::SMTP::SSL->new($smtp_server, Port => $smtp_port, Timeout=>$timeout,Debug=>$smtp_debug); if( $smtp && $username ) { $smtp->auth($username, $password); - my $message = oneline($smtp->message()); - die "cannot connect with SSL/password: $message" if $smtp->code() =~ m/53\d/; + #my $message = oneline($smtp->message()); + #die "cannot connect with SSL/password: $message" if $smtp->code() =~ m/53\d/; } } elsif( $auth_method ) { @@ -176,8 +176,8 @@ $smtp = Net::SMTP_auth->new($smtp_server, Port=>$smtp_port, Timeout=>$timeout,Debug=>$smtp_debug); if( $smtp ) { $smtp->auth($auth_method, $username, $password); - my $message = oneline($smtp->message()); - die "cannot connect with SSL/$auth_method: $message" if $smtp->code() =~ m/53\d/; + #my $message = oneline($smtp->message()); + #die "cannot connect with SSL/$auth_method: $message" if $smtp->code() =~ m/53\d/; } } else { @@ -185,8 +185,8 @@ $smtp = Net::SMTP->new($smtp_server, Port=>$smtp_port, Timeout=>$timeout,Debug=>$smtp_debug); if( $smtp && $username ) { $smtp->auth($username, $password); - my $message = oneline($smtp->message()); - die "cannot connect with password: $message" if $smtp->code() =~ m/53\d/; + #my $message = oneline($smtp->message()); + #die "cannot connect with password: $message" if $smtp->code() =~ m/53\d/; } } };
signature.asc
Description: OpenPGP digital signature