php SMTP:无法连接套接字:无法找到套接字传输“ssl”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16642346/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 11:30:08  来源:igfitidea点击:

SMTP: Failed to connect socket: Unable to find the socket transport "ssl"

phpsslpear

提问by Jacob Larson

I've been trying to get to be able to send emails with Pear on WAMP through GMail, and after spending hours setting it all up and figuring out all the errors I was getting, I thought I was so close, until I started getting this error:

我一直试图通过 GMail在 WAMP 上使用 Pear 发送电子邮件,在花了数小时设置所有内容并弄清楚我遇到的所有错误之后,我以为我已经很接近了,直到我开始得到这个错误:

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

Using this code:

使用此代码:

<?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>");
}
?>

I've gone through and uncommented extension=php_openssl.dllin the (correct) php.ini, and made sure that the extension_dirwas pointing to the DLLs. I've used phpinfo();and I've seen multiple mentions of SSL:

我已经extension=php_openssl.dll在(正确的)php.ini 中检查并取消注释,并确保它extension_dir指向 DLL。我已经使用过phpinfo();并且看到多次提到 SSL:

I see mod_sslin Loaded Modules.

mod_sslLoaded Modules.

Under the mysqlndheading it has an entry SSL: supported.

mysqlnd标题下有一个条目SSL: supported

And under the Pharheading there's the entry Native OpenSSL support: enabled.

Phar标题下有条目Native OpenSSL support: enabled

I've also turned off my firewall, just to check, I've restarted my computer, and I've checked practically every question like mine on this site, and I still haven't found a solution.

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

I'm at a loss of what to do next. What do I need to enable/check to get it working?

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

回答by Abraham K

Open up the Port 465 open to smtp.gmail.com in your firewall :)

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

This will help

这将有助于

Then there may be problem with your host or else,

那么你的主机可能有问题,否则,

Try This- this is working for me

试试这个- 这对我有用

Did you allow SMTP in your Gmail

您是否允许在 Gmail 中使用 SMTP

Check that 'Settings' is active for the SMTP server in your Gmail Settings.

在 Gmail 设置中检查 SMTP 服务器的“设置”是否处于活动状态。

回答by Tanmay Patel

Uncoment php_openssl.dllin php.ini

php_openssl.dll在 php.ini 中取消注释

回答by admin ifas

The answer was simple; The first thing you should do:

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

  1. Open the file php.inithen try to search the key extension. Then if you cannot find this extension=php_openssl.dlland please write it but make sure you remove ;before the word extension.

  2. Once you save it, please restart again your Xampp server. After that, everything is good.

  1. 打开文件php.ini然后尝试搜索密钥extension。然后,如果你找不到这个extension=php_openssl.dll,请写下来,但一定要删除;这个词之前extension

  2. 保存后,请再次重新启动您的 Xampp 服务器。在那之后,一切都很好。