PHPMailer的给出错误“数据结束命令失败”和“数据不接受”没有进一步解释错误(PHPMaile

2019-10-30 11:27发布

我试图用这个代码发送电子邮件(SMTP_HOST等在配置中定义的常量,它们都被定义,它使用端口587):

    $txt = strip_tags(str_replace(array("<br>","<br\>","<br \>"),"\n",$this->_params['message']));
    // some irrelevant code here (saves record)
    $mail = new PHPMailer;
    $mail->isSMTP();
    $mail->Host = SMTP_HOST;
    $mail->Port = SMTP_PORT;
    $mail->SMTPAuth = true;
    $mail->Username = $mail->From = SMTP_USER;
    $mail->Password = SMTP_PASS;
    $mail->addReplyTo($this->_params['email'], $this->_params['name']);
    $mail->From = MAIL_FROM;
    $mail->FromName = MAIL_FROM_NAME;
    $mail->addAddress(MAIL_TO);
    $mail->Body = str_replace("\n","<br/>\n",$this->_params['message']);
    $mail->AltBody = $txt;
    $mail->Subject = MAIL_SUBJECT.$this->_params['subject'];
    $mail->isHTML (true);
    $mail->SMTPDebug = 3;
    $ok = $mail->send();

随着PHPMailer的版本5.2.7。

我收到调试信息(我****任何私人数据):

2014-07-04 13:57:38 Connection: opening
2014-07-04 13:57:38 Connection: opened
2014-07-04 13:57:38 SERVER -> CLIENT: 220 **** ESMTP Exim 4.82 Fri, 04  Jul 2014 15:57:38 +0200
2014-07-04 13:57:38 CLIENT -> SERVER: EHLO ****
2014-07-04 13:57:38 SERVER -> CLIENT: 250-**** Hello **** [****]
250-SIZE 20971520
250-8BITMIME
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP
2014-07-04 13:57:38 CLIENT -> SERVER: AUTH LOGIN
2014-07-04 13:57:38 SERVER -> CLIENT: 334 ****
2014-07-04 13:57:38 CLIENT -> SERVER: ****
2014-07-04 13:57:38 SERVER -> CLIENT: 334 ****
2014-07-04 13:57:38 CLIENT -> SERVER: ****
2014-07-04 13:57:38 SERVER -> CLIENT: 235 Authentication succeeded
2014-07-04 13:57:38 CLIENT -> SERVER: MAIL FROM:<****>
2014-07-04 13:57:38 SERVER -> CLIENT: 250 OK
2014-07-04 13:57:38 CLIENT -> SERVER: RCPT TO:<****>
2014-07-04 13:57:38 SERVER -> CLIENT: 250 Accepted
2014-07-04 13:57:38 CLIENT -> SERVER: DATA
2014-07-04 13:57:38 SERVER -> CLIENT: 354 Enter message, ending with "." on a line by itself
2014-07-04 13:57:38 CLIENT -> SERVER: Date: Fri, 4 Jul 2014 15:57:38 +0200
2014-07-04 13:57:38 CLIENT -> SERVER: To: ****
2014-07-04 13:57:38 CLIENT -> SERVER: From: Automat SNC <****>
2014-07-04 13:57:38 CLIENT -> SERVER: Reply-To: **** <****@koszmail.pl>
2014-07-04 13:57:38 CLIENT -> SERVER: Subject: ****: Contact-form Test test test
2014-07-04 13:57:38 CLIENT -> SERVER: Message-ID: <ff1fbff844bf01ff24f5575e9e362ef1@****>
2014-07-04 13:57:38 CLIENT -> SERVER: X-Priority: 3
2014-07-04 13:57:38 CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.7(https://github.com/PHPMailer/PHPMailer/)
2014-07-04 13:57:38 CLIENT -> SERVER: MIME-Version: 1.0
2014-07-04 13:57:38 CLIENT -> SERVER: Content-Type: multipart/alternative;
2014-07-04 13:57:38 CLIENT -> SERVER:   boundary="b1_ff1fbff844bf01ff24f5575e9e362ef1"
2014-07-04 13:57:38 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
2014-07-04 13:57:38 CLIENT -> SERVER:
2014-07-04 13:57:38 CLIENT -> SERVER: --b1_ff1fbff844bf01ff24f5575e9e362ef1
2014-07-04 13:57:38 CLIENT -> SERVER: Content-Type: text/plain; charset=us-ascii
2014-07-04 13:57:38 CLIENT -> SERVER:
2014-07-04 13:57:38 CLIENT -> SERVER: Test test test
2014-07-04 13:57:38 CLIENT -> SERVER: test test test test
2014-07-04 13:57:38 CLIENT -> SERVER: test
2014-07-04 13:57:38 CLIENT -> SERVER:
2014-07-04 13:57:38 CLIENT -> SERVER:
2014-07-04 13:57:38 CLIENT -> SERVER: --b1_ff1fbff844bf01ff24f5575e9e362ef1
2014-07-04 13:57:38 CLIENT -> SERVER: Content-Type: text/html; charset=us-ascii
2014-07-04 13:57:38 CLIENT -> SERVER:
2014-07-04 13:57:38 CLIENT -> SERVER: Test test test
2014-07-04 13:57:38 CLIENT -> SERVER: <br/>
2014-07-04 13:57:38 CLIENT -> SERVER: test test test test
2014-07-04 13:57:38 CLIENT -> SERVER: <br/>
2014-07-04 13:57:38 CLIENT -> SERVER: test
2014-07-04 13:57:38 CLIENT -> SERVER:
2014-07-04 13:57:38 CLIENT -> SERVER:
2014-07-04 13:57:38 CLIENT -> SERVER:
2014-07-04 13:57:38 CLIENT -> SERVER: --b1_ff1fbff844bf01ff24f5575e9e362ef1--
2014-07-04 13:57:38 CLIENT -> SERVER:
2014-07-04 13:57:38 CLIENT -> SERVER: .
2014-07-04 13:57:48 SERVER -> CLIENT:
2014-07-04 13:57:48 SMTP ERROR: DATA END command failed:
SMTP Error: data not accepted.
2014-07-04 13:57:48 CLIENT -> SERVER: QUIT
2014-07-04 13:57:49 SERVER -> CLIENT: 250 OK id=1X33ze-0007GO-Nc
2014-07-04 13:57:49 SMTP ERROR: QUIT command failed: 250 OK id=1X33ze-0007GO-Nc
2014-07-04 13:57:49 Connection: closed

有人可以给我一个提示,什么都可以错在这里?

Answer 1:

这种奇特的SMTP服务器的行为在DNS和服务器配置错误引起的。

我们有几个VPS服务器,并在其中一人(接收机R)一个域的子域被委派到另一个(发件人S)。 由于失误,是在S上的“A”条目R(wchich真的是对其他DNS)的域名。 也有人错误地与S和S的IP已配置(通过直接联系)来处理的R的域的邮件设置。 它不能做到,因为是在本地DNS中没有相应的邮箱,也没有MX记录。

通过发送关闭电子邮件处理接收机域和删除错误的DNS条目和现在的作品。



文章来源: PHPMailer gives error “DATA END command failed” and “data not accepted” without further error explanation