Google Apps脚本突然开始抛出"无效的mime类型"错误

dsl*_*101 6 google-apps-script

我有一个脚本处理共享邮箱并转发不同的电子邮件(基于诸如原始的'To:'标题之类的东西给各个人.它已经好几个月工作,因为它更灵活(以及迄今为止,可靠)更换用于gmail过滤器.

逻辑是基本的

  1. 阅读收件箱中的每个未处理邮件
  2. 查看它发送给"To:"的人(例如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()});
Run Code Online (Sandbox Code Playgroud)

以下是有趣位的摘要:

  • really 只是一个布尔值,所以我们可以做'干运行'进行测试
  • msg 设置为当前正在处理的邮件,其类型为GmailMessage
  • rcvr 是带有收件人电子邮件地址的字符串
  • thisTo 是一个包含原始"To:"标题的字符串

有问题的消息是一个多部分的mime电子邮件,其中包含纯文本和html.它在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--
Run Code Online (Sandbox Code Playgroud)

非常感谢,

戴夫.