2016-11-23 128 views
1

Mailer Error: SMTP Error: Could not connect to SMTP host.;PHPMailer:Godaddy上的SMTP主機連接錯誤

當我在godaddy中運行此代碼時,會生成此錯誤。

<?php 
require("PHPMailer_5.2.0/class.phpmailer.php"); 
$mail = new PHPMailer(); 
$mail->IsSMTP(); // set mailer to use SMTP 
$mail->Host  = "smtpout.secureserver.net"; // specify main and backup server 
$mail->SMTPAuth = true; // turn on SMTP authentication 
$mail->Username = "[email protected]"; // SMTP username 
$mail->Password = "******"; // SMTP password 
$mail->From  = "[email protected]"; 
$mail->FromName = "User"; 
$mail->AddAddress("[email protected]"); // name is optional 
$mail->WordWrap = 50; // set word wrap to 50 characters 
$mail->IsHTML(true); // set email format to HTML 
$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"; 
?> 
+0

我相信你有聯繫GoDaddy的支持。 –

+0

也許godaddy阻止tcp/25端口(SMTP)上的傳出流量。 –

+0

$ mail-> Port? 傳出端口 沒有SSL - 以下之一:25,80,3535,587 使用SSL - 465 –

回答

0

如果我理解正確,使用您使用的SMTP地址,您也需要指定端口(465)。

然而,根據GoDaddy的文檔,你應該使用以下SMTP服務器:

relay-hosting.secureserver.net 
0

此代碼可以幫助你。

$mail->Host  = "smtpout.secureserver.net"; 

您的主機名稱應該像mydomain.com

$mail->Port = 465; 
相關問題