diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 452ae74d614..d8a79164e6f 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -395,9 +395,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $connectstringtarget = ''; // Note: $object->host has been loaded by the fetch - $usessl = 1; - - $connectstringserver = $object->getConnectStringIMAP($usessl); + $connectstringserver = $object->getConnectStringIMAP(); if ($action == 'scan') { if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 78e19dbca1c..13341b880ec 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -131,6 +131,8 @@ class EmailCollector extends CommonObject 'host' => array('type'=>'varchar(255)', 'label'=>'EMailHost', 'visible'=>1, 'enabled'=>1, 'position'=>90, 'notnull'=>1, 'searchall'=>1, 'comment'=>"IMAP server", 'help'=>'Example: imap.gmail.com', 'csslist'=>'tdoverflowmax125'), 'port' => array('type'=>'varchar(10)', 'label'=>'EMailHostPort', 'visible'=>1, 'enabled'=>1, 'position'=>91, 'notnull'=>1, 'searchall'=>0, 'comment'=>"IMAP server port", 'help'=>'Example: 993', 'csslist'=>'tdoverflowmax50', 'default'=>'993'), 'hostcharset' => array('type'=>'varchar(16)', 'label'=>'HostCharset', 'visible'=>-1, 'enabled'=>1, 'position'=>92, 'notnull'=>0, 'searchall'=>0, 'comment'=>"IMAP server charset", 'help'=>'Example: "UTF-8" (May be "US-ASCII" with some Office365)', 'default'=>'UTF-8'), + 'imap_encryption' => array('type'=>'varchar(16)', 'label'=>'ImapEncryption', 'visible'=>1, 'enabled'=>1, 'position'=>93, 'searchall'=>0, 'comment'=>"IMAP encryption", 'help'=>'ImapEncryptionHelp', 'arrayofkeyval'=> array('ssl'=>'SSL', 'tls' => 'TLS', 'notls' => 'NOTLS'), 'default'=>'ssl'), + 'norsh' => array('type'=>'integer', 'label'=>'NoRSH', 'visible'=>1, 'enabled'=>"!getDolGlobalInt('MAIN_IMAP_USE_PHPIMAP')", 'position'=>94, 'searchall'=>0, 'help'=>'NoRSHHelp', 'arrayofkeyval'=> array(0 =>'No', 1 => 'Yes'), 'default'=> 0), 'acces_type' => array('type'=>'integer', 'label'=>'accessType', 'visible'=>-1, 'enabled'=>"getDolGlobalInt('MAIN_IMAP_USE_PHPIMAP')", 'position'=>101, 'notnull'=>1, 'index'=>1, 'comment'=>"IMAP login type", 'arrayofkeyval'=>array('0'=>'loginPassword', '1'=>'oauthToken'), 'default'=>'0', 'help'=>''), 'login' => array('type'=>'varchar(128)', 'label'=>'Login', 'visible'=>-1, 'enabled'=>1, 'position'=>102, 'notnull'=>-1, 'index'=>1, 'comment'=>"IMAP login", 'help'=>'Example: myaccount@gmail.com'), 'password' => array('type'=>'password', 'label'=>'Password', 'visible'=>-1, 'enabled'=>"1", 'position'=>103, 'notnull'=>-1, 'comment'=>"IMAP password", 'help'=>'WithGMailYouCanCreateADedicatedPassword'), @@ -775,11 +777,9 @@ class EmailCollector extends CommonObject /** * Return the connectstring to use with IMAP connection function * - * @param int $ssl Add /ssl tag - * @param int $norsh Add /norsh to connectstring * @return string */ - public function getConnectStringIMAP($ssl = 1, $norsh = 0) + public function getConnectStringIMAP() { global $conf; @@ -787,15 +787,16 @@ class EmailCollector extends CommonObject $flags = '/service=imap'; // IMAP if (!empty($conf->global->IMAP_FORCE_TLS)) { $flags .= '/tls'; - } elseif (empty($conf->global->IMAP_FORCE_NOSSL)) { - if ($ssl) { - $flags .= '/ssl'; - } + } elseif (empty($this->imap_encryption) || ($this->imap_encryption == 'ssl' && !empty($conf->global->IMAP_FORCE_NOSSL))) { + $flags .= ''; + } else { + $flags .= '/' . $this->imap_encryption; } + $flags .= '/novalidate-cert'; //$flags.='/readonly'; //$flags.='/debug'; - if ($norsh || !empty($conf->global->IMAP_FORCE_NORSH)) { + if (!empty($this->norsh) || !empty($conf->global->IMAP_FORCE_NORSH)) { $flags .= '/norsh'; } //Used in shared mailbox from Office365 @@ -1191,7 +1192,7 @@ class EmailCollector extends CommonObject $client = $cm->make([ 'host' => $this->host, 'port' => $this->port, - 'encryption' => 'ssl', + 'encryption' => !empty($this->imap_encryption) ? $this->imap_encryption : false, 'validate_cert' => true, 'protocol' => 'imap', 'username' => $this->login, @@ -1204,7 +1205,7 @@ class EmailCollector extends CommonObject $client = $cm->make([ 'host' => $this->host, 'port' => $this->port, - 'encryption' => 'ssl', + 'encryption' => !empty($this->imap_encryption) ? $this->imap_encryption : false, 'validate_cert' => true, 'protocol' => 'imap', 'username' => $this->login, diff --git a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql index 5d72775f1b2..f7a513f788a 100644 --- a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql +++ b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql @@ -428,3 +428,8 @@ ALTER TABLE llx_c_stcomm ADD COLUMN sortorder smallint DEFAULT 0; ALTER TABLE llx_element_time ADD COLUMN ref_ext varchar(32); ALTER TABLE llx_c_ziptown ADD COLUMN town_up varchar(180); + + +-- Email Collector +ALTER TABLE llx_emailcollector_emailcollector ADD COLUMN imap_encryption varchar(16) DEFAULT "ssl" AFTER hostcharset; +ALTER TABLE llx_emailcollector_emailcollector ADD COLUMN norsh integer DEFAULT 0 AFTER imap_encryption; diff --git a/htdocs/install/mysql/tables/llx_emailcollector_emailcollector.sql b/htdocs/install/mysql/tables/llx_emailcollector_emailcollector.sql index 4119e7aac08..080e9cd0533 100644 --- a/htdocs/install/mysql/tables/llx_emailcollector_emailcollector.sql +++ b/htdocs/install/mysql/tables/llx_emailcollector_emailcollector.sql @@ -24,6 +24,8 @@ CREATE TABLE llx_emailcollector_emailcollector( host varchar(255), port varchar(10) DEFAULT '993', hostcharset varchar(16) DEFAULT 'UTF-8', + imap_encryption varchar(16) DEFAULT 'ssl', + norsh integer DEFAULT 0, login varchar(128), acces_type integer DEFAULT 0, oauth_service varchar(128), diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 4fc55bfd30b..ba5184458f6 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -2108,6 +2108,10 @@ oauthToken=Jeton Oauth2 accessType=Type d'accès oauthService=Service Oauth TokenMustHaveBeenCreated=Le module OAuth2 doit être activé et un token oauth2 doit avoir été créé avec les bonnes permissions (par exemple scope "gmail_full" avec OAuth pour Gmail). +ImapEncryption = Méthode de chiffrement IMAP +ImapEncryptionHelp = Exemple: none, ssl, tls, notls +NoRSH = Utiliser la configuration NoRSH +NoRSHHelp = Ne pas utiliser les protocole RSH ou SSH pour établir une session de pré identification IMAP MailboxSourceDirectory=Répertoire source de la boîte aux lettres MailboxTargetDirectory=Répertoire cible de la boîte aux lettres EmailcollectorOperations=Opérations à effectuer par le collecteur