OpenSSL connection Error called stream_socket_enable_crypto()

28,100

I had the same error.

stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number

It was caused by incorrect SMTP settings. I had:

$transport = Swift_SmtpTransport::newInstance('mail.myserver.com', 465, 'tls');

and as soon as I corrected it to

$transport = Swift_SmtpTransport::newInstance('mail.myserver.com', 465, 'ssl');

it worked normally. Quite a non-intuitive error message but I got there in the end.

Share:
28,100

Related videos on Youtube

mahen3d
Author by

mahen3d

Me doesn't exists

Updated on September 18, 2022

Comments

  • mahen3d
    mahen3d over 1 year

    in my php coding i have following line which uses by SWIFT MAILER Class

    if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
    
      return false;
    
    }
    

    however rarely (not always) i get following php error

    stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
    error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number
    

    i am not sure where the problem is or should i ignore this as this happens only once in a while

    • Citricguy
      Citricguy about 10 years
      I'm using PHP Version 5.3.6-8ubuntu0ppa5~lucid1 with the PHPMailer class and I see the same error.
  • matasoy
    matasoy over 2 years
    i change SMTPSecure tls to ssl, and Port 586 to 465, and working now.