nette / mail

A handy library for creating and sending emails in PHP
https://doc.nette.org/mailing
Other
463 stars 70 forks source link

Support for TLS 1.2 SMTP #57

Closed radabo closed 5 years ago

radabo commented 5 years ago

Version: 2.4

Bug Description

If SMTP server support only TLS 1.2 isn't possible connect it.

Expected Behavior

In SmtpMailer is now this: stream_socket_enable_crypto($this->connection, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)

i found solution on php.net

$cryptoMethod = STREAM_CRYPTO_METHOD_TLS_CLIENT;

if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) { $cryptoMethod |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; $cryptoMethod |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT; }

if (!stream_socket_enable_crypto($this->connection, true, $cryptoMethod)) { throw new SmtpException('Unable to connect via TLS.'); }

What do you think?

dg commented 5 years ago

In PHP 5.6 there should be STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT & STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT, so test via defined() is not imho needed. Can you send PR?