【问题标题】:Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?找不到套接字传输“ssl” - 您在配置 PHP 时是否忘记启用它?
【发布时间】:2014-03-24 15:28:58
【问题描述】:

我花了很多时间在谷歌上搜索如何解决这个错误。我已经尝试了来自this 主题的所有解决方案,但没有运气。 <? phpinfo(); ?>(我使用 Appserver 而不是 IIS 的唯一区别)它没有显示与 SSL 相关的任何内容。我还应该尝试什么?

完整的错误信息:

<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)

和代码:

<?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';    
?>

【问题讨论】:

标签: php windows apache sockets ssl


【解决方案1】:

正确的答案是换行

;extension=php_openssl.dll

php.ini 文件中

extension=php_openssl.dll

如果您在php.ini 文件中找不到extension=php_openssl.dll,则只需将以下行附加到文件中:

extension=php_openssl.dll

这应该可行!

【讨论】:

  • 第一行“extension=php_openssl.dll”应该是“;extension=php_openssl.dll”
  • 好的,这解决了这个问题......但另一个问题在之后立即引发:OpenSSL 错误消息:错误:14090086:SSL 例程:ssl3_get_server_certificate:certificate verify failed - 找到这个答案/解决方案,@987654321 @ ,但仍然无法正常工作(我应该实际下载哪个文件?)
【解决方案2】:

对于某些人来说,这些解决方案不起作用。

对我来说,解决方案是:将 dll libeay32.dll 和 ssleay32.dll 复制到服务器的 bin 目录 - apache。

解决方案在评论中建议: http://php.net/manual/fa/openssl.installation.php

当我查看错误日志时,我了解到问题在于加载 dll 并将它们放入服务器目录是唯一的方法。

【讨论】:

    【解决方案3】:

    我在使用 ssl 时遇到了类似的错误数小时。

    对我有用的是将php\libeay32.dllphp\ssleay32.dllphp\ext\php_openssl.dll 从php 目录复制到Apache2.2\bin 目录。然后重启apache。

    【讨论】:

      【解决方案4】:

      检查你的 php.ini 文件,如果你有这个:

      ;extension=php_openssl.dll
      

      改成

      extension=php_openssl.dll
      

      之后,记得使用 Appserver 提供的任何控制面板或使用系统控制面板上的服务窗口重新启动 Apache。

      还要确保php_openssl.dll在系统可以访问的文件夹中,很多人使用复制到C:\windows或C:\windows\system32来解决dll位置问题。虽然这不应该是必要的。

      之后,使用 phpinfo 执行一个文件并检查它是否已启用。

      我在某处读过,无法确定,某些安装的那种 wamps 有不止一个 php.ini,但只有一个是真正活跃的,会不会是你编辑错了?

      【讨论】:

      • 我取消了该行的注释,复制了 dll 并重新启动了服务器,但仍然出现相同的错误。里面真的不止一个 php.ini 文件。我正在编辑phpinfo() 显示的C:\Windows\php.ini
      • @Jack 您接受了这个答案,但看起来您仍然遇到问题。你解决了吗?我遇到了同样的问题,即使我取消了 extension=php_openssl.dll 的注释。
      • @EdCottrell:我确实切换到 XAMPP 服务器
      • 嗯...我正在运行 XAMPP,但在尝试使用 pecl 安装软件包时遇到了同样的问题。你必须做些什么才能让它工作吗?
      • 我在 Arch linux 中遇到了同样的问题,请帮帮我.. linux 有什么解决方案吗?
      猜你喜欢
      • 2011-01-13
      • 2015-12-21
      • 2016-03-14
      • 2011-07-23
      • 1970-01-01
      • 2018-11-27
      相关资源
      最近更新 更多