6

我有一个脚本,它处理一个共享邮箱并在不同的电子邮件上转发(基于诸如原始的“收件人:”标头之类的东西给不同的人。几个月来它一直运行良好,作为一个更灵活(并且,到目前为止,可靠)的替代品用于 gmail 过滤器。

逻辑基本上是

  1. 阅读收件箱中每条未处理的邮件
  2. 查找发送给谁“收件人:”(例如 support@domain.com),这是此 gmail 收件箱的别名
  3. 获取预期收件人的列表(在我们的组织内)
  4. 对于其中的每一个,将消息转发到
  5. 将该消息标记为已处理,以便下次不会重新转发

我们最近收到一封电子邮件,似乎在转发邮件时触发了一个奇怪的错误。错误是:

无效的 MIME 类型。(第 123 行,文件“代码”)。

脚本的第 123 行内容如下:

// subject: removes the 'Fwd:' prefix which we don't need, and adds the original target email in square brackets, and sets the replyTo for easy processing
really && msg.forward(rcvr, {subject: msg.getSubject() + " [" + thisTo + "]", replyTo: msg.getFrom()});

以下是有趣的部分的摘要:

  • really只是一个布尔值,因此我们可以进行“试运行”进行测试
  • msg设置为当前正在处理的消息,并且是类型GmailMessage
  • rcvr是一个带有收件人电子邮件地址的字符串
  • thisTo是一个包含原始 'To:' 标头的字符串

有问题的消息是包含纯文本和 html 的多部分 mime 电子邮件。它在 gmail 中显示得很好,我可以毫无问题地从那里转发它。那么,任何人都可以阐明脚本引擎在抱怨什么吗?原始电子邮件看起来像这样(为了保护隐私而删除了一些部分),以防有助于确定它:

Delivered-To: XXXX@YYYY.com
Received: by 10.182.155.73 with SMTP id vj5sqase239pbc;
        Wed, 26 Jun 2013 08:50:48 -0700 (PDT)
X-Received: by 10.68.166.5 with SMTP id zc5m425et238pbb.16.1372261847795;
        Wed, 26 Jun 2013 08:50:47 -0700 (PDT)
Return-Path: <support@ZZZZ.com>
Received: from mail.ZZZZ.com (mail.ZZZZ.com. [64.78.193.232])
        by mx.google.com with ESMTP id vj5sqwefwe239pbc.316.2013.06.26.08.50.47
        for <multiple recipients>;
        Wed, 26 Jun 2013 08:50:47 -0700 (PDT)
Received-SPF: pass (google.com: domain of support@ZZZZ.com designates aa.bb.cc.dd as permitted sender) client-ip=aa.bb.cc.dd;
Authentication-Results: mx.google.com;
       spf=pass (google.com: domain of support@ZZZZ.com designates aa.bb.cc.dd as permitted sender) smtp.mail=support@ZZZZ.com
Date: Wed, 26 Jun 2013 09:50:46 -0600
To: AAAA@YYYY.com, XXXX@YYYY.com
From: ZZZZ <support@ZZZZ.com>
Reply-to: ZZZZ <support@ZZZZ.com>
Subject: ZZZZ (Order #00412744)
Message-ID: <805b426783f23fec38ddafb002ce40b@admin.ZZZZ.com>
X-Priority: 3
X-Mailer: PHPMailer 5.1 (phpmailer.sourceforge.net)
MIME-Version: 1.0
Content-Type: multipart/alternative;
    boundary="b1_805b426783ff4601fbe72afb002ce40b"


--b1_805b426783ff4601fbe72afb002ce40b
Content-Type: text/plain; charset = "utf-8"
Content-Transfer-Encoding: 7bit

Hello Andy,

[SNIP]

and destroy all copies of the original message. Thank You


--b1_805b426783ff4601fbe72afb002ce40b
Content-Type: text/html; charset = "utf-8"
Content-Transfer-Encoding: 7bit

<html>
<head>
</head>

[SNIP]

and destroy all copies of the original message. Thank You</span></font></p></td></tr></tbody></table></body>
</html>



--b1_805b426783ff4601fbe72afb002ce40b--
4

0 回答 0