From 2ea2ce413058695b3b1581685a27df4976f9e9fa Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 20 Dec 2018 14:57:04 +0100 Subject: [PATCH] + Fix smtp bug (#1172) --- apps/protocols/smtp/lib/smtp.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/protocols/smtp/lib/smtp.pm b/apps/protocols/smtp/lib/smtp.pm index c72a1dfd8..503beed79 100644 --- a/apps/protocols/smtp/lib/smtp.pm +++ b/apps/protocols/smtp/lib/smtp.pm @@ -95,14 +95,14 @@ sub connect { $smtp_options{-$1} = $2; } - my ($stdout); + my ($stdout, $error_msg); { eval { local $SIG{ALRM} = sub { die 'timeout' }; local *STDOUT; open STDOUT, '>', \$stdout; alarm($self->{option_results}->{timeout}); - $smtp_handle = Email::Send::SMTP::Gmail->new(-smtp=> $self->{option_results}->{hostname}, + ($smtp_handle, $error_msg) = Email::Send::SMTP::Gmail->new(-smtp=> $self->{option_results}->{hostname}, %smtp_options); alarm(0); }; @@ -114,10 +114,10 @@ sub connect { $self->{output}->display(); $self->{output}->exit(); } - if (defined($stdout) && $smtp_handle == -1) { + if ($smtp_handle == -1) { chomp $stdout; $self->{output}->output_add(severity => $connection_exit, - short_msg => 'Unable to connect to SMTP: ' . $stdout); + short_msg => 'Unable to connect to SMTP: ' . (defined($stdout) ? $stdout : $error_msg)); $self->{output}->display(); $self->{output}->exit(); }