Skip to content

Commit d1221b9

Browse files
xrobaulcharette
authored andcommitted
Resolves Issue #986 - Turn off opportunistic TLS when disabled. (#987)
This ensures that when you have disabled 'secure' in your mail config no TLS attempts are ... attempted.
1 parent 4739a54 commit d1221b9

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

app/sprinkles/core/config/default.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211
'host' => getenv('SMTP_HOST') ?: null,
212212
'port' => 587,
213213
'auth' => true,
214-
'secure' => 'tls',
214+
'secure' => 'tls', // Enable TLS encryption. Set to `tls`, `ssl` or `false` (to disabled)
215215
'username' => getenv('SMTP_USER') ?: null,
216216
'password' => getenv('SMTP_PASSWORD') ?: null,
217217
'smtp_debug' => 4,

app/sprinkles/core/src/Mail/Mailer.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ public function __construct($logger, $config = [])
6767
$this->phpMailer->Password = $config['password'];
6868
$this->phpMailer->SMTPDebug = $config['smtp_debug'];
6969

70+
// Disable opportunistic encryption if secure is unset. This is
71+
// required if you have an incorrect or invalid SSL Certificate on
72+
// your SMTP host, but the server offers STARTTLS.
73+
if (!$config['secure']) {
74+
$this->phpMailer->SMTPAutoTLS = false;
75+
}
76+
7077
if (isset($config['smtp_options'])) {
7178
$this->phpMailer->SMTPOptions = $config['smtp_options'];
7279
}

0 commit comments

Comments
 (0)