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

时间:2013-06-28 15:17:22

标签: google-apps-script

我有一个脚本可以处理共享邮箱并在不同的电子邮件上转发(基于原始的“To:”标题给各个人。它已经好几个月工作得更灵活了(直到现在,可靠的)替换gmail过滤器。

逻辑基本上是

  1. 阅读收件箱中的每条未处理邮件
  2. 查找发送给“收件人:”的人(例如support@domain.com),这是此gmail收件箱的别名
  3. 获取目标收件人列表(在我们的组织内)
  4. 对于其中每一个,请转发
  5. 上的消息
  6. 将该邮件标记为已处理,以便下次不再重新转发
  7. 我们最近收到了一封电子邮件,似乎在邮件转发时触发了一个奇怪的错误。错误是'无效的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是一个包含原始“收件人:”标题
    • 的字符串

    有问题的邮件是一个多部分的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--
    

    非常感谢,

    戴夫。

0 个答案:

没有答案