I have a script that processes a shared mailbox and forwards it to a different email (based on things like the original βTo:β header for different people. It has been working fine for several months as being more flexible (and right now, reliable) replacing gmail filters.
Logic is basically
- Read each raw message in your inbox
- See to whom it was sent to: (for example, support@domain.com ), which is an alias for this gmail mailbox.
- Get a list of prospective recipients (as part of our site)
- For each of them send a message to
- Mark this message as processed, so it will not be redirected next time
We recently received an email that seems to be causing a strange error the moment the message is being forwarded. Error: "Invalid mime type. (Line 123, file" Code "). Line 123 script reads:
Here's a summary of the interesting bits:
really is just logical, so we can run dry runs for testingmsg set to the currently processed message and is of type GmailMessagercvr is a string with the recipient's email address.thisTo is a string containing the original To: header
This post is a multi-user plaintext and html mime post. It displays fine in gmail, and I can send it there without a problem. So, can anyone shed some light on what the script engine is complaining about? Raw email looks like this (with some bits extracted to ensure confidentiality), in case this helps to disable it:
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
Thank you very much,
Dave
source share