PHP Mailer无法连接到服务器 [英] PHP Mailer Fails To Connect To Server
本文介绍了PHP Mailer无法连接到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这里是我的php代码:
here is my php code:
require_once('class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->CharSet="UTF-8";
$mail->SMTPSecure = 'ssl';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = 'clubbedinapp@gmail.com';
$mail->Password = 'pw';
$mail->SMTPAuth = true;
$mail->From = 'clubbedinapp@gmail.com';
$mail->FromName = 'Clubbed In';
$mail->AddAddress('nishil.shah17@gmail.com');
$mail->AddReplyTo('clubbedinapp@gmail.com', 'Information');
$mail->IsHTML(true);
$mail->Subject = "PHPMailer Test Subject via Sendmail, basic";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->Body = "Hello";
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message sent!";
}
我跟着一个Gmail PHPMailer教程,我不知道什么是错的?有人可以帮忙吗?
I followed a Gmail PHPMailer tutorial, I have no idea what is wrong? Can someone please help?
推荐答案
您是否在您的php.ini中启用了openssl?
Did you enable openssl on your php.ini?
转到PHP.ini并找到一行名为
Go to PHP.ini and find a line called
;extension=php_openssl.dll
并删除行首的分号。
停止Apache服务器和所有服务器,再次启动它们,
并再次尝试。
Stop the Apache server and all servers, start them again, and try it again.
这篇关于PHP Mailer无法连接到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文