谷歌邮箱无法与服务器建立连接失败,GMAIL SMTP错误:无法连接到服务器

我正在使用PHP中的Gmail SMTP发送电子邮件 . 我还在php.ini中启用了OPENSSL . 但是我收到了这个错误 .

SMTP - >错误:无法连接到服务器:连接尝试失败,因为连接方在一段时间后没有正确响应,或者由于连接主机无法响应而 Build 连接失败 . (10060)以下发件人地址失败:mhtkumar46@gmail.com:未连接时调用Mail()发送邮件失败 .

这是我的代码 .

error_reporting(E_ALL);

require("PHPMailer_5.2.4/class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP(); // set mailer to use SMTP

$mail->SMTPDebug = 2;

$mail->Debugoutput = 'html';

$mail->From = "mhtkumar46@gmail.com";

$mail->FromName = "Mohit";

$mail->Host = "smtp.gmail.com"; // specif smtp server

$mail->SMTPSecure= "tls"; // Used instead of TLS when only POP mail is selected

$mail->Port = 587; // Used instead of 587 when only POP mail is selected

$mail->SMTPAuth = true;

$mail->Username = "mhtkumar46@gmail.com"; // SMTP username

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

$mail->AddAddress("mohitkumarsingla60@gmail.com", "Singla"); //replace myname and mypassword to yours

$mail->AddReplyTo("mhtkumar46@gmail.com", "Mohit");

$mail->WordWrap = 50; // set word wrap

//$mail->AddAttachment("c:\\temp\\js-bak.sql"); // add attachments

//$mail->AddAttachment("c:/temp/11-10-00.zip");

$mail->IsHTML(true); // set email format to HTML

$mail->Subject = 'test';

$mail->Body = 'test';

if($mail->Send()) {echo "Send mail successfully";}

else {echo "Send mail fail";}

?>

我无法找到解决方案 . 请帮我 .

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值