我已经尝试安装PHPMailer脚本,但我无法让它与谷歌的SMTP服务器一起使用。 它给了我这些错误
SMTP - >错误:无法连接到服务器:php_network_getaddresses:getaddrinfo失败:名称解析暂时失败(0) SMTP错误:无法连接到SMTP主机。邮件错误 - > SMTP错误:无法连接到SMTP主机。
我也尝试将地址更改为ssl://smtp.gmail.com或这些行中的某些内容。我已经尝试将端口从SSL更改为TLS并返回。
目前我没有想法并寻求帮助!
提前致谢!
<?php
require_once('phpmailer/class.phpmailer.php');
$mail = new PHPMailer();
$mail->CharSet = "utf-8";
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPDebug = "2";
$mail->Username = "lesrobotpws@gmail.com";
$mail->Password = "**********";
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = "465";
$mail->setFrom('lesrobotpws@gmail.com', 'Lesrobot');
$mail->AddAddress('Lastmark@gmail.com', 'Mark');
$mail->Subject = 'using PHPMailer';
$mail->IsHTML(true);
$mail->Body = 'Hi there ,
<br />
this mail was sent using PHPMailer...
<br />
cheers... :)';
if($mail->Send())
{
echo "Message was Successfully Send :)";
}
else
{
echo "Mail Error - >".$mail->ErrorInfo;
}
?>