我目前正在尝试使用phpmailer通过smtp协议将邮件发送到gmail,但是我甚至在谷歌搜索后我都不明白我收到错误消息无法发送我目前在我的localhost上并且错误我得到了
SMTP -> ERROR: Failed to connect to server: A connection attempt failed
because the connected party did not properly respond after a period of time,
or established connection failed because connected host has failed to
respond. (10060)
SMTP Error: Could not connect to SMTP host. Message could not be sent.
Mailer Error: SMTP Error: Could not connect to SMTP host.
我写的php代码是
<?php
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->SMTPSecure = 'tls';
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->Username = "rammanoj.potla1608@gmail.com";
$mail->Password = "marjo741963";
$mail->port = 587;
$mail->From = "rammanoj.potla@gmail.com";
$mail->FromName = "rammanoj";
$mail->AddAddress("rammanojpotla1608@gmail.com", "ram");
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = "Here is the subject";
$mail->Body = "This is the HTML message body <b>in bold!</b>";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
三江源