无法找到套接字传输“ssl”——您是否在配置 PHP 时忘记启用它?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21962849/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?
提问by Hyman
I'm googling for how to this error a lot of hours. I've tried all solutions from thistopic 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?
我在谷歌上搜索了很多小时如何解决这个错误。我已经尝试了这个主题的所有解决方案,但没有运气。<? phpinfo(); ?>(我使用 Appserver 而不是 IIS 的唯一区别)它没有显示任何与 SSL 相关的内容。我还应该尝试什么?
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 "ssl" - 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= "[email protected]";
$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 = "[email protected]"; // GMAIL username
$mail->Password = "*********"; // GMAIL password
$mail->AddReplyTo("[email protected]","AAAA"); // Reply email address
$mail->From = "[email protected]";
$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';
?>
回答by PatomaS
Check your php.ini file, on it, if you have this:
检查你的 php.ini 文件,如果你有这个:
;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.
之后,请记住使用 Appserver 提供的任何控制面板或使用系统控制面板上的服务窗口重新启动 Apache。
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.
还要确保php_openssl.dll在系统可以访问的文件夹中,很多人通过将它们复制到C:\windows或C:\windows\system32来解决dll位置问题的问题。虽然这不应该是必要的。
After that, execute a file with phpinfo and check that it's enabled.
之后,使用 phpinfo 执行一个文件并检查它是否已启用。
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?
我在某处读到过,无法确定,这种wamps的某些安装有不止一个php.ini,但只有一个是真正活跃的,难道你编辑错了?
回答by Dawson
The proper answer is to replace the line
正确答案是换行
;extension=php_openssl.dll
in the php.inifile with
在php.ini文件中
extension=php_openssl.dll
If you cant find extension=php_openssl.dllin the php.inifile, then just simply append the following line to the file:
如果您extension=php_openssl.dll在php.ini文件中找不到,那么只需将以下行附加到文件中:
extension=php_openssl.dll
This should work!
这应该有效!
回答by Daniel
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.
对我来说,解决方案是:将 dll libeay32.dll 和 ssleay32.dll 复制到服务器的 bin 目录 - apache。
The solution suggest in a comment in: http://php.net/manual/fa/openssl.installation.php
解决方案在评论中建议: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.
当我查看错误日志时,我了解到问题在于加载 dll 并将它们放入服务器目录是唯一的方法。
回答by emanresu
I had a similar error with ssl for hours.
我有几个小时的 ssl 类似错误。
What worked for me was copying php\libeay32.dll, php\ssleay32.dlland php\ext\php_openssl.dllfrom the php directory to the Apache2.2\bindirectory. Then restart apache.
对我有用的是将php\libeay32.dll,php\ssleay32.dll和php\ext\php_openssl.dll从 php 目录复制到Apache2.2\bin目录。然后重启apache。

