SMTP错误:无法连接到服务器:php_network_getaddresses:getaddrinfo failed:名称或服务未知(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的新手,任何详细的解释都将受到高度赞赏。谢谢
答案 0 :(得分:0)
主机hosting.secureserver.net
不存在。您需要为出站SMTP服务器设置正确的服务器和凭据。这些信息应由托管您电子邮件服务的人提供 - 可能是您的网络托管服务商。