简体   繁体   中英

Warning: stream_socket_enable_crypto(): this stream does not support SSL/crypto in C:\xampp\htdocs\12work\class.smtp.php on line 197

I am using XAMPP and when trying to send email through localhost I get the following warning:

Warning: stream_socket_enable_crypto() : this stream does not support SSL/crypto in C:\\xampp\\htdocs\\12work\\class.smtp.php on line 197

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 = "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";

}

Alright, we need to enable Open SSL module. Here is how to do it:

  1. Locate and open your php.ini file
  2. Search for the line: ;extension=php_openssl.dll
  3. Enable the module by removing ; char.
  4. Save the file and restart Apache.

Hint: If you are not familiar with php.ini file, 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.

If you are using LAMP stacks such as wamp, it should be possible to enable modules via graphic interface.

More about php.ini :https://secure.php.net/manual/en/configuration.file.php

在我的本地系统中,avast mail shield 开启后,一旦我禁用它,我就不允许 smtp gmail 发送任何邮件,邮件通过 smtp 在本地系统中发送

Just a quick note,
you use $mail->Port = 25;

 $mail->SMTPSecure = "tls";

Port should be 587 for gmail /tls
See https://support.google.com/mail/answer/78775?hl=el

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

I solved this

Hust close selinux

 #setenforce 0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM