【发布时间】:2018-04-28 17:44:58
【问题描述】:
SMTP 错误:无法连接到服务器:php_network_getaddresses:getaddrinfo 失败:名称或服务未知 (0) 2017-11-15 13:11:07 SMTP connect() 失败。
<?php
require 'PHPMailerAutoload.php';
//echo !extension_loaded('openssl')?"Not Available":"Available <br/>";
$email = $_POST['email'];
$number = $_POST['phone'];
$client = $_POST['client'];
$to = 'myemailid@gmail.com';
$subject = 'user registration';
$phone = "phone number:".$number;
$message = "client details:"."\n"."email:".$email."\n"."phone number:".$number."\n"."client:".$client;
$headers = "From:".$email;
$mail = new PHPMailer;
$mail->SMTPDebug = 0; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'hosting.secureserver.net'; // ssl://smtp.gmail.com // Specify main and backup SMTP servers
$mail->SMTPAuth = false; // Enable SMTP authentication
$mail->Username = ''; // SMTP username
$mail->Password = ''; // SMTP password
$mail->From = 'myemailid@gmail.com';
$mail->SMTPSecure = 'none'; //TLS // Enable TLS encryption, `ssl` also accepted
$mail->Port = 25; //587 // TCP port to connect to
$mail->setFrom($email);
$mail->addAddress($to);
$mail->Subject = $subject;
$mail->Body = $message;
if($mail->send()) {
header("Location: ../../thankyou.html");
}
else {
echo $mail->ErrorInfo;
//header("Location: ../../error.html");
}
?>
这是我收到的错误,因为我是这个 php 的新手,任何详细的解释将不胜感激。谢谢
【问题讨论】:
-
发帖前先搜索。 GoDaddy 对出站电子邮件有非常严格的规定;它们在这里出现过很多次,并且在错误消息链接的 PHPMailer 故障排除指南中有所提及。
标签: email server phpmailer shared-hosting fault