diff --git a/modules/imap/functions.php b/modules/imap/functions.php index de88d0652..7dbfdab6e 100644 --- a/modules/imap/functions.php +++ b/modules/imap/functions.php @@ -1523,9 +1523,13 @@ function parse_sieve_config_host($host) { $url = parse_url($host); if(!isset($url['host'])) { $host = $url['path']; + } else { + $host = $url['host']; } $port = $url['port'] ?? '4190'; - return [$host, $port]; + $scheme = $url['scheme'] ?? 'tcp://'; + $tls = $scheme === 'tls'; + return [$host, $port, $tls]; }} if (!hm_exists('connect_to_imap_server')) { diff --git a/modules/sievefilters/hm-sieve.php b/modules/sievefilters/hm-sieve.php index 21bbd578a..63677ab0e 100644 --- a/modules/sievefilters/hm-sieve.php +++ b/modules/sievefilters/hm-sieve.php @@ -5,7 +5,10 @@ class Hm_Sieve_Client_Factory { public function init($user_config = null, $imap_account = null) { if ($imap_account && ! empty($imap_account['sieve_config_host'])) { - list($sieve_host, $sieve_port) = parse_sieve_config_host($imap_account['sieve_config_host']); + list($sieve_host, $sieve_port, $sieve_tls) = parse_sieve_config_host($imap_account['sieve_config_host']); + if (!isset($imap_account['sieve_tls'])) { + $imap_account['sieve_tls'] = $sieve_tls; + } $client = new PhpSieveManager\ManageSieve\Client($sieve_host, $sieve_port); $client->connect($imap_account['user'], $imap_account['pass'], $imap_account['sieve_tls'], "", "PLAIN"); return $client; diff --git a/modules/sievefilters/modules.php b/modules/sievefilters/modules.php index 8949e994d..90a06c459 100644 --- a/modules/sievefilters/modules.php +++ b/modules/sievefilters/modules.php @@ -482,6 +482,7 @@ public function process() { $factory = get_sieve_client_factory($this->config); try { + $client = $factory->init($this->user_config, $imap_account); $scripts = $client->listScripts(); @@ -1292,7 +1293,6 @@ function sieve_enabled_callback($val) { return $val; } class Hm_Output_enable_sieve_filter_setting extends Hm_Output_Module { protected function output() { $settings = $this->get('user_settings'); - // exit(var_dump($settings['enable_sieve_filter'])); if ((array_key_exists('enable_sieve_filter', $settings) && $settings['enable_sieve_filter']) || DEFAULT_ENABLE_SIEVE_FILTER) { $checked = ' checked="checked"'; $reset = '';