26

I'm googling for how to this error a lot of hours. I've tried all solutions from this topic without luck. <? phpinfo(); ?> (the only difference I'm using Appserver instead of IIS) it doesn't show anything realated to SSL. What else should I try?

The full error message:

<b>Warning</b>:  fsockopen() [<a href='function.fsockopen'>function.fsockopen</a>]: unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport &quot;ssl&quot; - did you forget to enable it when you configured PHP?) in <b>C:\AppServ\www\webgitz\test\class.smtp.php</b> on line <b>122</b><br />
SMTP -> ERROR: Failed to connect to server: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? (27010016)

and code:

<?php 

require_once "validation.php";

require_once "PHPMailer.php";


require_once "class.smtp.php";

$email= "foo@gmamcil.com";

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth   = true; // enable SMTP authentication
$mail->Port       =465;                    // set the SMTP server port
$mail->Host = "smtp.gmail.com"; // GMAIL's SMTP server
$mail->SMTPDebug = 2;
$mail->SMTPSecure = 'ssl';
$mail->Username   = "xxxxxx@gmail.com"; // GMAIL username
$mail->Password   = "*********"; // GMAIL password
$mail->AddReplyTo("XXXXX@gmail.com","AAAA"); // Reply email address
$mail->From = "XXXX@gmail.com";
$mail->FromName = "...."; // Name to appear once the email is sent
$mail->Subject = "...."; // Email's subject
$mail->Body = "Hello World,<br />This is the HTML BODY<br />"; //HTML Body
$mail->AltBody = "..."; // optional, commentA out and test
$mail->WordWrap = 50; // set word wrap
$mail->MsgHTML($msg); // [optional] Send body email as HTML
$mail->AddAddress("$email", "fooo");  // email address of recipient
$mail->IsHTML(true); // [optional] send as HTML

if(!$mail->Send()) echo 'ok'; else echo 'error';    
?>
Community
  • 1
  • 1
Jack
  • 16,276
  • 55
  • 159
  • 284

4 Answers4

46

Check your php.ini file, on it, if you have this:

;extension=php_openssl.dll

change it to

extension=php_openssl.dll

After that, remember to restart Apache, either using any control panel that Appserver offers, or using the services windows on the control panel of the system.

Also be sure that php_openssl.dll is on a folder that the system can reach, many people use to solve the problem of dll location problems by copying them to C:\windows or C:\windows\system32. Although that shouldn't be necessary.

After that, execute a file with phpinfo and check that it's enabled.

I have read somewhere, can't pinpoint it, that some installation of that kind of wamps have more that one php.ini, but only one is really active, could it be that you have edited the wrong one?

PatomaS
  • 1,603
  • 18
  • 25
  • I uncommented that line, copyed the dlls and restarted the server and still get same error. There's really more than one php.ini files in there. I'm editing the one that `phpinfo()` show that's `C:\Windows\php.ini` – Jack Feb 23 '14 at 15:52
  • @Jack You accepted this answer, but it looks like you were still having trouble. Did you get this worked out? I am having the same problem, even though I uncommented `extension=php_openssl.dll`. – elixenide Jul 01 '14 at 02:38
  • @EdCottrell: I did switch to XAMPP server – Jack Jul 01 '14 at 02:44
  • 1
    Hmmm... I'm running XAMPP, but having the same problem when trying to install a package with `pecl`. Did you have to do anything to get it working? – elixenide Jul 01 '14 at 02:46
  • 2
    I have same problem in arch linux please help me.. Any solution for linux? – Ankur Loriya Nov 04 '14 at 06:07
2

The proper answer is to replace the line

;extension=php_openssl.dll

in the php.ini file with

extension=php_openssl.dll

If you cant find extension=php_openssl.dll in the php.ini file, then just simply append the following line to the file:

extension=php_openssl.dll

This should work!

ndm13
  • 1,189
  • 13
  • 19
Dawson
  • 39
  • 1
  • the first line "extension=php_openssl.dll" should be ";extension=php_openssl.dll" – Kuldeep Singh Apr 27 '17 at 02:23
  • ok this worked to solve the issue... but another issue raises immediatley after: OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed - Found this answer/solution , https://stackoverflow.com/questions/34515120/php-verify-failed-with-letsencrypt , but still not working (which file should i actually download?) – jumpjack Feb 21 '19 at 18:11
1

I had a similar error with ssl for hours.

What worked for me was copying php\libeay32.dll, php\ssleay32.dll and php\ext\php_openssl.dll from the php directory to the Apache2.2\bin directory. Then restart apache.

Johan
  • 8,068
  • 1
  • 33
  • 46
emanresu
  • 141
  • 2
  • 5
1

For some people, those solutions don't work.

For me the solution was this: copy dll libeay32.dll and ssleay32.dll to the bin directory of the server - apache.

The solution suggest in a comment in: http://php.net/manual/fa/openssl.installation.php

When I look in the error log, I understood that the problem was in loading the dll's and putting them to the server directory was the only way.

Daniel
  • 11
  • 1