CakePHP SwiftMailer SMTP TLS OpenSSL Error SSL3_GET_RECORD: Invalid Version Number

I am trying to send an email using the CakePHP SwiftMailer component that I found here: http://bakery.cakephp.org/articles/sky_l3ppard/2009/11/07/updated-swiftmailer-4-xx-component-with-attachments- and-plugins

The server I'm sending to uses SMTP with TLS on port 25. Here is the error I get when I try to send mail:

Notice (8): Trying to get property of non-object [APP/views/helpers/hdl_session.php, line 14] Warning (2): stream_socket_client() [function.stream-socket-client]: SSL operation failed with code 1. OpenSSL Error messages: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number [CORE/vendors/classes/Swift/Transport/StreamBuffer.php, line 271] Warning (2): stream_socket_client() [function.stream-socket-client]: Failed to enable crypto [CORE/vendors/classes/Swift/Transport/StreamBuffer.php, line 271] Warning (2): stream_socket_client() [function.stream-socket-client]: unable to connect to tls://mail.aedisit.com:25 (Unknown error) [CORE/vendors/classes/Swift/Transport/StreamBuffer.php, line 271] Warning (2): Illegal offset type in isset or empty [CORE/cake/libs/i18n.php, line 177] Warning (2): Cannot modify header information - headers already sent by (output started at /srv/www/stage/hypercool/cake/libs/debugger.php:673) [CORE/cake/libs/controller/controller.php, line 742] 

Here is the OpenSSL info from my phpinfo:

 openssl OpenSSL support enabled OpenSSL Library Version OpenSSL 0.9.8o 01 Jun 2010 OpenSSL Header Version OpenSSL 0.9.8o 01 Jun 2010 

And more info about my phpinfo:

 PHP Version 5.3.5-1ubuntu7.2 Registered Stream Socket Transports tcp, udp, unix, udg, ssl, sslv3, sslv2, tls 

Any help here is appreciated :-)

EDIT:

Failed to perform SSL operation with code 1. OpenSSL error messages: Error: 1408F10B: SSL routines: SSL3_GET_RECORD: invalid version number

This seems to be the root of the problem. Does anyone know what exactly this means?

+6
source share
2 answers

We have solved this problem. The problem was our version of SSL and the SwiftMailer connection method. The SwiftMailer component tried to connect using TLS, when instead it first needed to connect in clear text and then initiate a TLS connection. Hope this helps someone else with this issue.

+2
source

Update your SwiftMailer libraries. I recently ran into this exact issue with SwiftMailer 4.0.6 and upgraded to 4.1.6 - now it works like a charm :)

+1
source

Source: https://habr.com/ru/post/896502/


All Articles