PHPMailer给出错误" DATA END命令失败"和"数据不被接受"没有进一步的错误解释

时间:2014-07-04 14:24:21

标签: php email smtp phpmailer

我尝试使用此代码发送电子邮件(SMTP_HOST等是在config中定义的常量,它们都已定义,它使用端口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

有人可以给我一个提示,这里有什么不对吗?

1 个答案:

答案 0 :(得分:0)

SMTP服务器的这种奇怪行为是由DNS和服务器配置错误引起的。

我们有很少的VPS服务器,其中一个(接收方R)的一个域的子域被委托给另一个(发送方S)。错误的是,对于R的域,S上有一个“A”条目(wchich确实在其他DNS上)。它也被错误地设置为S的IP。并且(由直接管理员)配置S来处理该R域的电子邮件。由于本地DNS中没有合适的邮箱或MX记录,因此无法做到这一点。

关闭发件人对收件人域名的电子邮件处理并删除错误的DNS条目,现在可以正常工作。