在检查连接的phpmailer时是否捕获了EOF

问题描述 投票:0回答:1
    require 'PHPMailerAutoload.php';

    $mail = new PHPMailer;
    $mail->SMTPDebug = 3;                               // Enable verbose debug output
    $mail->isSMTP();                                      // Set mailer to use SMTP
    $mail->Host = 'myhost';  // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;                               // Enable SMTP authentication
    $mail->Username = 'myusername';                 // SMTP username
    $mail->Password = 'mypassword';                           // SMTP password
    $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
    $mail->Port = 1060;                                    // TCP port to connect to
    $mail->setFrom('[email protected]', 'test');
    $mail->isHTML(true); // Set email format to HTML


    $mail->addAddress('[email protected]');    // Add a recipient  

    for($i=0;$i<1;$i++){
      $mail->Subject    = "test bulk email ".$i;
      $mail->Body       = "this is email ".$i;


      if(!$mail->Send()) 
      {
          $error_message = "Mailer Error: " . $mail->ErrorInfo;
      }
}

echo $error_message;

当我运行此代码时,我收到此错误:

连接:打开2018-03-05 09:24:25服务器 - >客户端:2018-03-05 09:24:25 SMTP注意:检查EOF是否连接2018-03-05 09:24:25连接:关闭2018-03-05 09:24:25 SMTP错误:无法连接到SMTP主机。

我该如何解决?

php smtp phpmailer starttls
1个回答
2
投票

您正在使用不常见的端口号进行SMTP提交,因此请检查您是否拥有适合您主机的端口号。使用SMTPSecure = 'tls'时通常为587。

您在通过其他主机发送时从地址设置gmail;这会导致您的SPF检查失败,您的邮件将被阻止或被垃圾邮件过滤。

如果要发送到列表,请关注the mailing list example provided with PHPMailer - 您的代码包含一些可能导致重复消息的错误。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.