警告:stream_socket_enable_crypto():此流在 C:\xampp\htdocs\12work\class.smtp.php 中第 197 行不支持 SSL/crypto
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/14978459/
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
Warning: stream_socket_enable_crypto(): this stream does not support SSL/crypto in C:\xampp\htdocs\12work\class.smtp.php on line 197
提问by Arslan Sunny
I am using XAMPP and when trying to send email through localhostI get the following warning:
我正在使用 XAMPP,当我尝试通过发送电子邮件时localhost收到以下警告:
Warning:
stream_socket_enable_crypto(): this stream does not support SSL/crypto inC:\xampp\htdocs\12work\class.smtp.phpon line 197
警告::
stream_socket_enable_crypto()此流不支持C:\xampp\htdocs\12work\class.smtp.php第 197 行中的SSL/加密
Here is my code:
这是我的代码:
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "smtp.gmail.com"; // specify main and backup server
$mail->SMTPAuth = true;
$mail->Port = 25;
$mail->SMTPSecure = "tls";
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "[email protected]"; // SMTP username
$mail->Password = "mypassword"; // SMTP password
$mail->From = "[email protected]"; //do NOT fake header.
$mail->FromName = "MailMan";
$mail->AddAddress("[email protected]"); // Email on which you want to send mail
$mail->IsHTML(true);
$mail->Subject = "Just a Test";
$mail->Body = "Hello. I am testing <b>PHP Mailer.</b>";
if(!$mail->Send())
{
echo $mail->ErrorInfo;
}else{
echo "email was sent";
}
回答by vikingmaster
Alright, we need to enable Open SSLmodule. Here is how to do it:
好的,我们需要启用Open SSL模块。这是如何做到的:
- Locate and open your php.inifile
- Search for the line: ;extension=php_openssl.dll
- Enable the module by removing ;char.
- Save the file and restart Apache.
- 找到并打开您的php.ini文件
- 搜索行: ;extension=php_openssl.dll
- 通过删除;字符来启用模块。
- 保存文件并重新启动 Apache。
Hint:If you are not familiar with php.inifile, it is recommended to create a backup before modification. Ini is a configuration file and misconfigured or corrupted ini can result in that web server will not start.
提示:如果您对php.ini文件不熟悉,建议在修改前创建一个备份。Ini 是一个配置文件,错误配置或损坏的ini 会导致该Web 服务器无法启动。
If you are using LAMP stacks such as wamp, it should be possible to enable modules via graphic interface.
如果您使用的是 LAMP 堆栈,例如 wamp,则应该可以通过图形界面启用模块。
More about php.ini: https://secure.php.net/manual/en/configuration.file.php
更多关于php.ini:https: //secure.php.net/manual/en/configuration.file.php
回答by Konstantinos Chertouras
Just a quick note,
you use  $mail->Port = 25;
只是一个快速说明,
你使用  $mail->Port = 25;
 $mail->SMTPSecure = "tls";
Port should be 587 for gmail  /tls
See https://support.google.com/mail/answer/78775?hl=el
gmail /tls 的端口应为 587
请参阅https://support.google.com/mail/answer/78775?hl=el
回答by vikas etagi
In my local system avast mail shield was on I was not allowing any mail to be sent by smtp gmail once I disabled it, the mails were sending in local system via smtp
在我的本地系统中,avast mail shield 开启后,一旦我禁用它,我就不允许 smtp gmail 发送任何邮件,邮件通过 smtp 在本地系统中发送
回答by user3867473
I solved this
我解决了这个
Hust close selinux
关闭 selinux
 #setenforce 0

