2014-02-23 14 views
15

我在Google上搜索如何在很长时间内发生这个错误。我试过this主题的所有解决方案都没有运气。 <? phpinfo(); ?>(我使用Appserver而不是IIS的唯一区别)它没有显示与SSL相关的任何内容。我还应该尝试什么?无法找到套接字传输“ssl” - 您是否忘记在配置PHP时启用它?

完整的错误消息:

<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= "[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';  
?> 
+0

[未启用PHP中的套接字传输“ssl”的可能的重复](http://stackoverflow.com/questions/1705856/socket-transport-ssl-in-php-not-enabled) –

+1

@ShankarDamodaran:阅读话题我说我已经试过 – Jack

+0

你能发布一个链接到phpinfo()的结果吗? – PatomaS

回答

31

检查您的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,但只有一个是真正活跃的,难道是你编辑了错误的吗?

+0

我取消了该行的注释,将dll复制并重新启动服务器,仍然出现相同的错误。那里真的有不止一个php.ini文件。我在编辑一个'phpinfo()'显示'C:\ Windows \ php.ini' – Jack

+0

@Jack你已经接受了这个答案,但看起来你仍然遇到了麻烦。你有没有解决这个问题?我有同样的问题,即使我取消了注释'extension = php_openssl.dll'。 –

+0

@EdCottrell:我确实切换到XAMPP服务器 – Jack

0

我有一个类似的错误与ssl几个小时。

我的工作原理是将php\libeay32.dll,php\ssleay32.dllphp\ext\php_openssl.dll从php目录复制到Apache2.2\bin目录。然后重新启动apache。

0

正确的答案是更换线路

;extension=php_openssl.dll 

php.ini文件,

extension=php_openssl.dll 

如果你不能在php.ini文件中找到extension=php_openssl.dll,然后只是简单地将下面的行追加到文件:

extension=php_openssl.dll 

这应该w扫!

+2

用什么替换自己的东西?... – Mithredate

+0

第一行“extension = php_openssl.dll”应该是“; extension = php_openssl.dll” –

0

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

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

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

当我看到在错误日志中,我明白,这个问题是在载入DLL的,并把他们的服务器的目录是唯一的办法。

相关问题