bal*_*man 6 php email dns smtp phpmailer
我正在使用 Phpmailer 发送电子邮件。最初,当我通过用户名和密码使用 SMTP 时,它工作正常。如果我尝试不进行 SMTP 身份验证,则会返回连接超时错误。这是我的代码
<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
$mail->Host = "relay-hosting.secureserver.net";
$mail->Port = 25;
$mail->SMTPAuth = false;
$mail->SMTPSecure = false;
$mail->setFrom('xxxx@domainname.com', 'First Last');
$mail->addAddress("xxxx@domainname.com", "Recepient Name");
$mail->addReplyTo("xxxx@domainname.com", "Reply");
$mail->isHTML(true);
$mail->Subject = "Subject Text";
$mail->Body = "<i>Mail body in HTML</i>";
$mail->AltBody = "This is the plain text version of the email content";
if(!$mail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent successfully";
}
?>
Run Code Online (Sandbox Code Playgroud)
返回的错误是
SMTP 错误:无法连接到服务器:连接超时 (110)
mail.log 文件包含
host smtp.secureserver.net[68.178.213.203] refused to talk to
me: 554 p3plibsmtp03-06.prod.phx3.secureserver.net bizsmtp
IB105. Connection refused. <ip address> is listed on the
Exploits Block List (XBL)<http://www.spamhaus.org/query/ip/ip
address> Please visit http://www.spamhaus.org/xbl/ for
more information.
Run Code Online (Sandbox Code Playgroud)
检查您的 IP 是否列在 spamhaus 黑名单删除中心上。
https://www.spamhaus.org/query/ip/your-ip-address
如果已列出,则按照其程序取消列出它们。这需要一些时间。从代码中删除 SMTP 配置。
<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->setFrom('xxxx@domainname.com', 'First Last');
$mail->addAddress("xxxx@domainname.com", "Recepient Name");
$mail->addReplyTo("xxxx@domainname.com", "Reply");
$mail->isHTML(true);
$mail->Subject = "Subject Text";
$mail->Body = "<i>Mail body in HTML</i>";
$mail->AltBody = "This is the plain text version of the email content";
if(!$mail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent successfully";
}
?>
Run Code Online (Sandbox Code Playgroud)
这个对我有用。