【问题标题】:Phpmailer send mail without SMTP authenticationPhpmailer 发送邮件无需 SMTP 验证
【发布时间】:2017-05-26 00:46:32
【问题描述】:

我正在使用 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";
}

?>

返回的错误是

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.

【问题讨论】:

  • 您是否检查了您在 www.spamhaus.org 上的 IP 地址,因为错误消息表明它在阻止列表中。
  • 是的,我的 ip 列在 XBL 上。
  • 这显然是在 GoDaddy 上,但很奇怪,他们应该使用外部黑名单来阻止自己的内部 IP!我建议向 GoDady 询问这件事,以及查看 spamhaus 上的内容。
  • 现在我从 spamhaus 中取消了我的 ip。仍然连接超时错误。但是mail.log文件中没有日志

标签: php email dns smtp phpmailer


【解决方案1】:

//使用PHPMAILER发送邮件正常工作并正确配置服务器上的SMTP中继

require_once "vendor/autoload.php"; //PHPMailer Object 
use PHPMailer\PHPMailer\PHPMailer;

$mail = new PHPMailer;
$mail->SMTPDebug = 2;                           
$mail->isSMTP();        
$mail->Host = "smtp.xxxxxxx.com";
$mail->SMTPAuth = false;                      
$mail->Port = 25;                    
$mail->From = "xxx@xxxxx.com";
$mail->FromName = "xxxxxxxx";
$mail->addAddress("xxxxx@xxxxxxxx.com", "Recepient Name");
$mail->isHTML(true);
$mail->Subject = "Subject is here";
$mail->Body = "Hello, <br>test body ";
if(!$mail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent successfully";
}

【讨论】:

    【解决方案2】:

    检查您的 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";
    }
    
    ?>
    

    它对我有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-04
      • 1970-01-01
      • 1970-01-01
      • 2011-02-10
      • 2012-01-11
      • 2019-02-09
      • 2018-09-10
      • 2017-10-05
      相关资源
      最近更新 更多