Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sieve socket creation failed #1344

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion modules/imap/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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://';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this will work with stalwart too, try and ping me

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll get back to you after the test

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$tls = $scheme === 'tls';
return [$host, $port, $tls];
}}

if (!hm_exists('connect_to_imap_server')) {
Expand Down
5 changes: 4 additions & 1 deletion modules/sievefilters/hm-sieve.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion modules/sievefilters/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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 = '';
Expand Down