From 5d07cb0d705bc5abcf64a671c0fe354672110960 Mon Sep 17 00:00:00 2001 From: qgarnier Date: Mon, 28 Nov 2022 10:05:47 +0000 Subject: [PATCH] (plugin) apps::protocols::imap - fix port (#4081) --- .../apps/protocols/imap/custom/imapclient.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/centreon-plugins/apps/protocols/imap/custom/imapclient.pm b/centreon-plugins/apps/protocols/imap/custom/imapclient.pm index 9f20e6444..3cdf9a295 100644 --- a/centreon-plugins/apps/protocols/imap/custom/imapclient.pm +++ b/centreon-plugins/apps/protocols/imap/custom/imapclient.pm @@ -113,7 +113,7 @@ sub connect { $self->{imap} = Mail::IMAPClient->new(); $self->{imap}->Server($self->{hostname}); $self->{imap}->Ssl(1) if ($self->{use_ssl} == 1); - $self->{imap}->port($self->{port}) if ($self->{port} ne ''); + $self->{imap}->Port($self->{port}) if ($self->{port} ne ''); $self->{imap}->Timeout($self->{timeout}) if ($self->{timeout} ne ''); if ($self->{output}->is_debug()) { $self->{imap}->Debug(1); @@ -125,7 +125,12 @@ sub connect { push @$sslargs, $_, $self->{ssl_context}->{$_}; } } - my $rv = $self->{imap}->connect(Ssl => $sslargs); + my $rv; + if (scalar(@$sslargs) > 0) { + $rv = $self->{imap}->connect(Ssl => $sslargs); + } else { + $rv = $self->{imap}->connect(); + } if (!defined($rv)) { $self->{output}->output_add( severity => $connection_exit,