diff --git a/lib/config.php b/lib/config.php index 11441d7b0..7c9a33bdf 100644 --- a/lib/config.php +++ b/lib/config.php @@ -357,7 +357,15 @@ private function new_settings($username) { */ private function decrypt_settings($data, $key) { if (!$this->crypt) { - $data = $this->decode($data['settings']); + $settings = $data['settings']; + if (is_resource($settings)) { + $settings = stream_get_contents($settings); + } + if ($settings === false) { + $this->decrypt_failed = true; + return false; + } + $data = $this->decode($settings); } else { $data = $this->decode(Hm_Crypt::plaintext($data['settings'], $key)); } diff --git a/modules/smtp/hm-smtp.php b/modules/smtp/hm-smtp.php index 7a3342faf..a621397ef 100644 --- a/modules/smtp/hm-smtp.php +++ b/modules/smtp/hm-smtp.php @@ -111,13 +111,33 @@ function __construct($conf) { else { $this->port = 25; } - if (isset($conf['tls']) && $conf['tls']) { - $this->tls = true; - } - else { - $this->tls = false; + $this->tls = false; + $this->starttls = false; + if (isset($conf['tls'])) { + $tls_val = $conf['tls']; + if (is_string($tls_val)) { + $normalized = mb_strtolower(trim($tls_val)); + if ($normalized === 'starttls') { + $this->starttls = true; + } + elseif ($normalized === 'tls' || $normalized === 'ssl' || $normalized === 'true' || $normalized === '1') { + $this->tls = true; + } + elseif ($normalized === 'false' || $normalized === '0' || $normalized === '') { + // leave both false + } + elseif ($tls_val) { + $this->tls = true; + } + } + elseif ($tls_val === true || $tls_val === 1) { + $this->tls = true; + } + elseif ($tls_val) { + $this->tls = true; + } } - if (!$this->tls) { + if (!$this->tls && !$this->starttls) { $this->starttls = true; } $this->request_auths = array(