Search code examples
laravelamazon-web-servicesemailsslamazon-ses

Laravel mail send Amazon SES no longer supports TLS 1.0 and TLS 1.1 connections


I'm using Laravel 5.1 with PHP 5.6.40 on Ubuntu EC2. I have a very large project that cannot be updated in few hours or days. My server version OpenSSL 1.1.1 and I've done a test from my PC to my website using curl --tlsv1.2 mywebsite.com and I got a successful response with the HTML page. I also checked the version of OpenSSL on my Ubuntu using

openssl s_client -connect mywebsite.com:443 -tls1_2

I got 'CONNECTED' response. Also I checked Swift Mailer version 5.4.12 supporting tls1.2.

But mail::send in Laravel is crashing with error exception Swift_TransportException with message Expected response code 250 but got code "554", with message "554 Access denied: Amazon SES no longer supports TLS 1.0 and TLS 1.1 connections. You must update your client to use TLS version 1.2 or above.

I don't know what's causing the problem if all the versions I checked are supporting tls 1.2. PHP: 5.6.40, Openssl: 1.1.11


Solution

  • Solved: If you have a correct version of open ssl, php and tls1.2 enabled in your server but still facing this issue in swiftmailer

    Go to laravel root then vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport

    open streambuffer.php find startTLS() function

    replace it with

    public function startTLS() { return stream_socket_enable_crypto($this->_stream, true, STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT); }

    now swift will use only tls 1.2

    This is a solution using php 5.6 and laravel 5.1