Skip to content
Open
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
10 changes: 9 additions & 1 deletion lib/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we do this at the place where stream is defined/used? It seems awkward to work with streams here. THis method should receive a string.

$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));
}
Expand Down
32 changes: 26 additions & 6 deletions modules/smtp/hm-smtp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

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

This seems to be part of another PR (which I already merged). Can you push one change at a time to a PR? Thanks.

$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(
Expand Down
Loading