From 6df6286688d8e680453f078ba90fa6e2011d8c1c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Feb 2021 19:21:32 +0100 Subject: [PATCH] Fix IMAP_FORCE_NORSH and option for imap without ssl --- htdocs/admin/emailcollector_card.php | 5 ++++- htdocs/emailcollector/class/emailcollector.class.php | 9 ++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 5b037e70a73..9c73199abea 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -415,7 +415,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (function_exists('imap_open')) { - $connectstringserver = $object->getConnectStringIMAP(); + // Note: $object->host has been loaded by the fetch + $usessl = 1; + + $connectstringserver = $object->getConnectStringIMAP($usessl); try { if ($sourcedir) { diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 1a05017c1d3..b01f1883d53 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -202,7 +202,6 @@ class EmailCollector extends CommonObject public $debuginfo; - const STATUS_DISABLED = 0; const STATUS_ENABLED = 1; @@ -716,11 +715,15 @@ class EmailCollector extends CommonObject // Connect to IMAP $flags = '/service=imap'; // IMAP - if ($ssl) $flags .= '/ssl'; // '/tls' + if (!empty($conf->global->IMAP_FORCE_TLS)) { + $flags .= '/tls'; + } elseif (empty($conf->global->IMAP_FORCE_NOSSL)) { + if ($ssl) $flags .= '/ssl'; + } $flags .= '/novalidate-cert'; //$flags.='/readonly'; //$flags.='/debug'; - if ($norsh || !empty($conf->global->IMPA_FORCE_NORSH)) $flags .= '/norsh'; + if ($norsh || !empty($conf->global->IMAP_FORCE_NORSH)) $flags .= '/norsh'; $connectstringserver = '{'.$this->host.':993'.$flags.'}';