我正在使用XAMPP,当我尝试发送电子邮件时,localhost我收到以下警告:
警告::
stream_socket_enable_crypto()此流C:\xampp\htdocs\12work\class.smtp.php在第197行不支持SSL /加密
这是我的代码:
$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";
}
Run Code Online (Sandbox Code Playgroud)
vik*_*ter 47
好的,我们需要启用Open SSL模块.这是怎么做的:
php.ini文件;extension=php_openssl.dll;char来启用模块.提示:
如果您不熟悉php.ini文件,建议在修改前创建备份.Ini是一个配置文件,错误配置或损坏ini可能导致Web服务器无法启动.
如果您使用的是LAMP堆栈,例如wamp,则应该可以通过图形界面启用模块.
更多关于php.ini:https://secure.php.net/manual/en/configuration.file.php