Skip to content

Commit

Permalink
Allow TLS 1.2, fixes PHPMailer#696
Browse files Browse the repository at this point in the history
  • Loading branch information
Synchro committed Apr 28, 2016
1 parent b04ab34 commit 703410e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion class.smtp.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,22 @@ public function startTLS()
if (!$this->sendCommand('STARTTLS', 'STARTTLS', 220)) {
return false;
}

//Allow the best TLS version(s) we can
$crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT;

//PHP 5.6.7 dropped inclusion of TLS 1.1 and 1.2 in STREAM_CRYPTO_METHOD_TLS_CLIENT
//so add them back in manually if we can
if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) {
$crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
$crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
}

// Begin encrypted connection
if (!stream_socket_enable_crypto(
$this->smtp_conn,
true,
STREAM_CRYPTO_METHOD_TLS_CLIENT
$crypto_method
)) {
return false;
}
Expand Down

0 comments on commit 703410e

Please sign in to comment.