2013-05-20 107 views
2

我一直试图通过GMail在WAMP 上发送带梨的电子邮件,并花费数小时完成设置后,找出所有我得到的错误,我想我是如此接近,直到我开始收到此错误:SMTP:无法连接套接字:无法找到套接字传输“SSL”

Failed to connect to ssl://smtp.gmail.com:465 [SMTP: Failed to connect socket: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? (code: -1, response:)] 

使用此代码:

<?php require_once "info.php"; require_once "Mail.php"; // info.php contains the variable $password 
$from = "Me <[email protected]>"; 
$to = "Me <[email protected]>"; 
$subject = "Hi!"; 
$body = "Hi,\n\nHow are you?"; 

$host = "ssl://smtp.gmail.com"; 
$port = "465"; 
$username = "[email protected]"; 
$password = "$password"; 

$headers = array ('From' => $from, 
'To' => $to, 
'Subject' => $subject); 
$smtp = Mail::factory('smtp', 
array ('host' => $host, 
'port' => $port, 
'auth' => true, 
'username' => $username, 
'password' => $password)); 

$mail = $smtp->send($to, $headers, $body); 

if (PEAR::isError($mail)) { 
echo("<p>" . $mail->getMessage() . "</p>"); 
} else { 
echo("<p>Message successfully sent!</p>"); 
} 
?> 

我已经经历了,并取消注释extension=php_openssl.dll在(正确的)php.ini,a nd确保extension_dir指向DLL。我已经使用phpinfo();,我已经看到多次提到SSL:

我看mod_sslLoaded Modules

mysqlnd标题它有一个入口SSL: supported

而且Phar标题下有入门Native OpenSSL support: enabled

我也关闭了我的防火墙,只是为了检查,我重新启动我的电脑,我已经检查几乎像在这个网站矿的每一个问题,我还没有找到一个解决方案。

我不知道下一步该做什么。我需要启用/检查才能使其工作?

回答

3

在防火墙中打开端口465开放为smtp.gmail.com :)

This will help

那么有可能是您的主机,否则,

Try This问题 - 这是工作我

你有没有允许SMTP在Gmail

检查“设置”是用于SMTP的主动在您的Gmail设置中发挥作用。

+0

我附近,我有我的防火墙完全脱落到底说了。无论如何,我尝试过,但它没有奏效。 –

+0

我没有使用Ubuntu(尽管我拥有它),我使用的是Windows 7.我还检查了GMail中的所有设置,并且一切都很顺利。感谢您花时间,我希望我能弄明白这一点。:) –

+0

Niceeee,谢谢解决我的问题 – Flappy

2

Uncoment php_openssl.dll在php.ini

1

答案很简单;你应该做的第一件事:

  1. 打开文件php.ini然后尝试搜索键extension。那么如果你找不到这个extension=php_openssl.dll,请写下来,但要确保你删除;之前的单词extension

  2. 一旦你保存它,请再次重新启动XAMPP服务器。之后,一切都很好。

+0

正如我在问题中所述,我已经这样做了。无论如何,我最终还是做了其他事情,因为我从来没有这样做过,尽管我甚至不记得这是什么。 –