Skip to content

Commit

Permalink
Resolves Issue #986 - Turn off opportunistic TLS when disabled. (#987)
Browse files Browse the repository at this point in the history
This ensures that when you have disabled 'secure' in your mail config no TLS attempts are ... attempted.
  • Loading branch information
xrobau authored and lcharette committed Jun 13, 2019
1 parent 4739a54 commit d1221b9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/sprinkles/core/config/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
'host' => getenv('SMTP_HOST') ?: null,
'port' => 587,
'auth' => true,
'secure' => 'tls',
'secure' => 'tls', // Enable TLS encryption. Set to `tls`, `ssl` or `false` (to disabled)
'username' => getenv('SMTP_USER') ?: null,
'password' => getenv('SMTP_PASSWORD') ?: null,
'smtp_debug' => 4,
Expand Down
7 changes: 7 additions & 0 deletions app/sprinkles/core/src/Mail/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ public function __construct($logger, $config = [])
$this->phpMailer->Password = $config['password'];
$this->phpMailer->SMTPDebug = $config['smtp_debug'];

// Disable opportunistic encryption if secure is unset. This is
// required if you have an incorrect or invalid SSL Certificate on
// your SMTP host, but the server offers STARTTLS.
if (!$config['secure']) {
$this->phpMailer->SMTPAutoTLS = false;
}

if (isset($config['smtp_options'])) {
$this->phpMailer->SMTPOptions = $config['smtp_options'];
}
Expand Down

0 comments on commit d1221b9

Please sign in to comment.