收到错误讯息:
Connection failed. Error #2: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: The requested name is valid, but no data of the requested type was found
我的代码:
require_once("PHPMailer/PHPMailerAutoload.php");
require_once("PHPMailer/class.phpmailer.php");
require_once("PHPMailer/class.smtp.php");
header('HTTP/1.1 420 Enhance Your Calm');
$mail = new PHPMailer;
$to = "x@gmail.com"
$uname="rex";
$body="Some valid Text /r/n some valid text";
$mail->SMTPDebug = 3;
$mail->isSMTP();
$mail->Host = 'smtp.google.com';
$mail->SMTPAuth = true;
$mail->Username = 'me@gmail.com';
$mail->Password = '*******';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->setFrom('me@gmail.com', 'username');
$mail->addAddress($to, $uname);
$mail->isHTML(true);
$mail->Subject = 'Forgot Password';
$mail->Body = $body;
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
答案 0 :(得分:0)
听起来您的服务器上的DNS配置已损坏。 This is covered in the troubleshooting guide,但您可能需要咨询您的ISP。
我还建议upgrading your PHPMailer;你使用的是旧版本。