警告:stream_socket_enable_crypto():此流不支持第197行的C:\ xampp \ htdocs \ 12work \ class.smtp.php中的SSL /加密

时间:2013-02-20 11:13:51

标签: php

我正在使用XAMPP,在尝试通过localhost发送电子邮件时,我收到以下警告:

  

警告: stream_socket_enable_crypto():此流不支持C:\xampp\htdocs\12work\class.smtp.php在线的SSL /加密   197

这是我的代码:

$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 = "sheikh.abm@gmail.com"; // SMTP username

$mail->Password = "mypassword"; // SMTP password

$mail->From = "sheikh.abm@gmail.com"; //do NOT fake header.

$mail->FromName = "MailMan";

$mail->AddAddress("sheikh.abm@gmail.com"); // 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";

}

5 个答案:

答案 0 :(得分:46)

好的,我们需要启用 Open SSL 模块。以下是如何做到这一点:

  1. 找到并打开您的php.ini文件
  2. 搜索专栏:;extension=php_openssl.dll
  3. 删除 ; char。
  4. 启用该模块
  5. 保存文件并重新启动Apache。

  6. <强>提示: 如果您不熟悉php.ini文件,建议在修改前创建备份。 Ini是一个配置文件,错误配置或损坏ini可能导致Web服务器无法启动。

    如果您正在使用诸如wamp之类的LAMP堆栈,则应该可以通过图形界面启用模块。

    有关php.ini的更多信息: https://secure.php.net/manual/en/configuration.file.php

答案 1 :(得分:2)

快速说明,
你使用$mail->Port = 25;

 $mail->SMTPSecure = "tls";

gmail / tls的端口应为587 见https://support.google.com/mail/answer/78775?hl=el

答案 2 :(得分:2)

在我的本地系统中,avast mail shield处于打开状态,一旦我禁用它,我就不允许smtp gmail发送任何邮件,这些邮件是通过smtp在本地系统中发送的

答案 3 :(得分:0)

在我的本地系统中,我的计算机上装有avast防病毒软件,一旦禁用,我就不允许SMTP Gmail发送任何邮件,而是通过SMTP在本地系统中发送电子邮件

答案 4 :(得分:-2)

我解决了这个问题

Hust close selinux

 #setenforce 0