Merge pull request #1302 from garnier-quentin/bug-smtp-error
+ Fix smtp bug (#1172)
This commit is contained in:
commit
36c3b57a38
|
@ -95,14 +95,14 @@ sub connect {
|
||||||
$smtp_options{-$1} = $2;
|
$smtp_options{-$1} = $2;
|
||||||
}
|
}
|
||||||
|
|
||||||
my ($stdout);
|
my ($stdout, $error_msg);
|
||||||
{
|
{
|
||||||
eval {
|
eval {
|
||||||
local $SIG{ALRM} = sub { die 'timeout' };
|
local $SIG{ALRM} = sub { die 'timeout' };
|
||||||
local *STDOUT;
|
local *STDOUT;
|
||||||
open STDOUT, '>', \$stdout;
|
open STDOUT, '>', \$stdout;
|
||||||
alarm($self->{option_results}->{timeout});
|
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);
|
%smtp_options);
|
||||||
alarm(0);
|
alarm(0);
|
||||||
};
|
};
|
||||||
|
@ -114,10 +114,10 @@ sub connect {
|
||||||
$self->{output}->display();
|
$self->{output}->display();
|
||||||
$self->{output}->exit();
|
$self->{output}->exit();
|
||||||
}
|
}
|
||||||
if (defined($stdout) && $smtp_handle == -1) {
|
if ($smtp_handle == -1) {
|
||||||
chomp $stdout;
|
chomp $stdout;
|
||||||
$self->{output}->output_add(severity => $connection_exit,
|
$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}->display();
|
||||||
$self->{output}->exit();
|
$self->{output}->exit();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue