Skip to content

Commit 6880528

Browse files
authored
Merge pull request #1771 from affinitytechworks/fix-starttls-default
fix(module/smtp): honor starttls mode instead of implicit tls
2 parents 7f83159 + db26e7e commit 6880528

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

modules/smtp/hm-smtp.php

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,33 @@ function __construct($conf) {
111111
else {
112112
$this->port = 25;
113113
}
114-
if (isset($conf['tls']) && $conf['tls']) {
115-
$this->tls = true;
116-
}
117-
else {
118-
$this->tls = false;
114+
$this->tls = false;
115+
$this->starttls = false;
116+
if (isset($conf['tls'])) {
117+
$tls_val = $conf['tls'];
118+
if (is_string($tls_val)) {
119+
$normalized = mb_strtolower(trim($tls_val));
120+
if ($normalized === 'starttls') {
121+
$this->starttls = true;
122+
}
123+
elseif ($normalized === 'tls' || $normalized === 'ssl' || $normalized === 'true' || $normalized === '1') {
124+
$this->tls = true;
125+
}
126+
elseif ($normalized === 'false' || $normalized === '0' || $normalized === '') {
127+
// leave both false
128+
}
129+
elseif ($tls_val) {
130+
$this->tls = true;
131+
}
132+
}
133+
elseif ($tls_val === true || $tls_val === 1) {
134+
$this->tls = true;
135+
}
136+
elseif ($tls_val) {
137+
$this->tls = true;
138+
}
119139
}
120-
if (!$this->tls) {
140+
if (!$this->tls && !$this->starttls) {
121141
$this->starttls = true;
122142
}
123143
$this->request_auths = array(

0 commit comments

Comments
 (0)