0

我的应用引擎无法接收某些发件人的电子邮件,并返回以下消息:

*********************************************************************************
Delivery to the following recipient failed permanently:

     sometext@my-app-id.appspotmail.com

----- Original message -----

Received: by <recipient's ip> with SMTP id o5mr5102778igd.2.1346674874496;
        Mon, 03 Sep 2012 05:21:14 -0700 (PDT)
Return-Path: <sender-email@senderdomain.com>
Received: from mail-ie0-f177.senderdomain.com (mail-ie0-f177.senderdomain.com [<sender-ip>])
        by gmr-mx.senderdomain.com with ESMTPS id wo9si719480igc.1.2012.09.03.05.21.14
        (version=TLSv1/SSLv3 cipher=OTHER);
        Mon, 03 Sep 2012 05:21:14 -0700 (PDT)
Received-SPF: pass (senderdomain.com: domain of sender-email@senderdomain.com designates <sender-ip> as permitted sender) client-ip=<sender-ip>;
Authentication-Results: gmr-mx.senderdomain.com; spf=pass (senderdomain.com: domain of sender-email@senderdomain.com designates <sender-ip> as permitted sender) smtp.mail=sender-email@senderdomain.com; dkim=pass header.i=@senderdomain.com
Received: by ieje10 with SMTP id e10so4602552iej.22
        for <sometext@my-app-id.appspotmail.com>; Mon, 03 Sep 2012 05:21:14 -0700 (PDT)

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=senderdomain.com; s=20120113;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :content-type:x-system-of-record;
        bh=XiHGSzr6o8p0wD7eNTHFG0qcWyXJz75LsjP/5TXbwYc=;
        b=mL9J2xP7mLM5VVKGgc9dhBCV7RClZOtIqyhE22JQlNro8jiCB/nBZBmzmv2G3wsoMw
         I3lRTKUmJFXKI07IFEHKAISQn/QuIQloR6Cn5H8eAMQBlXUbmmvC2Uq6g7mjiD3KV4Hf
         4RgHfe2B2cNrGNPLNMQF/Ftcn5cmb/NfikgefjvcVoxrf5/Y15JgR609/k5fyLVYSjxb
         uYFW9fNiPl9Cf0r/Blm5aEWkrNACyF86tbSTpH48XrxXIRU/riUgjbKIfrX4EArbUmuk
         sqEAxDYwHPrzLhyV/r8q1dPuJzISGQ2xJ9tYtZnrN4ExtKkvgqGg4Yh9QS1nFpcWVfrP
         Uniw==

X-<sender-domain>-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=senderdomain.com; s=20120113;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :content-type:x-system-of-record:x-gm-message-state;
        bh=XiHGSzr6o8p0wD7eNTHFG0qcWyXJz75LsjP/5TXbwYc=;
        b=oMfU8AGDLjA77FgK3imDh6sQdT+Fl37x/3P7ZOh8Ac7oTB4HEkfWClpAU3Ui7y3d9T
         BnsKRTCx7H/xUSYdguCU5eRyUmuo4wwTIgAi/OT7Do1nTecJx5DB8u416bflfkonBeSD
         RTyjjfan1NIG/fC8yF26DCMSFKJnKQNbCHlxB+LlYWMBrl5HO1Fxc+nYHf9qtha8qedT
         5B3TUFrLm1QS5FfIPJGq8jtTONANWa1vBijMAJReU6qauuKoPsVgTgWZ9B+grgE0Nfn3
         w6rUCxzq90d4R+QWcMzWDfzYksIhBgv/6NECjbSFiX0fVw/3vM1z9mCNbUNkB9rbyE0I
         DVkg==
Received: by 10.50.181.136 with SMTP id dw8mr10648907igc.31.1346674874247;
        Mon, 03 Sep 2012 05:21:14 -0700 (PDT)
Received: by 10.50.181.136 with SMTP id dw8mr10648883igc.31.1346674873921;
 Mon, 03 Sep 2012 05:21:13 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.50.214.39 with HTTP; Mon, 3 Sep 2012 05:20:53 -0700 (PDT)
In-Reply-To: <20120829165751.F24167488531@new_msg2.rancardsolutions.com>
References: <20120829165751.F24167488531@new_msg2.rancardsolutions.com>
From: <Sender-name> <sender-email@senderdomain.com>
Date: Mon, 3 Sep 2012 13:20:53 +0100
Message-ID: <CAOS-8ONnuWfPRhDuKseTOhjG94pBMVKq8PDQJw_gPuWdmEySUA@mail.gmail.com>

Subject: Fwd: GMAIL-SMS Summary(Active Networks)
To: sometext@my-app-id.appspotmail.com
Content-Type: multipart/mixed; boundary=14dae93408a37cf2e404c8cb2d38
X-System-Of-Record: true
X-Gm-Message-State: ALoCoQmNK+HxrLzS52zrj9RKLG9C/MeBJ5NiXcp9/+zVSFRGJtWvI0xGeO2x/e1bOR/sFUDQNYJjNj3KJfmI5L58JnRqz5WCe8/qCEjIDWNInsL1v9qew06Z7OEesEKEBgJazox1pAuQE8+J9syvYJdNXmGMaFHNvZcyEd8WkAdY1Pdbk8pNu1WyVK3ogioHs1kmpR5OQfvYHfBUArF95Z+fmVQldDSfgA==

---------- Forwarded message ----------
*********************************************************************************

从上面的文字中,我无法找到错误原因。

注意:它适用于许多发件人。我没有为邮件服务启用登录:管理员。

这是我的代码片段:

应用程序.yaml

--------

application: my-app
version: 2
runtime: python
api_version: 1

handlers:
- url: /remote_api
  script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py
  login: admin

- url: /_ah/mail/sometext@my-app.appspotmail.com
  script: process_email.py

- url: .*
  script: main.py

inbound_services:
- mail

process_email.py 中的处理程序

  def receive(self, mail_message):
    if not hasattr(mail_message, 'attachments'):
      err = 'No attachment found.'
      self.status = 'ERROR'
      self.status_message.append(err)
      self.SendStatusMail(mail_message.sender)
      return
    for name, content in mail_message.attachments:
      report_time_period = self.GetReportTimePeriod(name)
      report_date = self.GetReportDate(name)
      if report_time_period and report_date and name.endswith('.csv'):
        records, product_prefix = self.ProcessCsv(content)
        if records and product_prefix:
          self.UpdateRecordsToDb(report_time_period, report_date, records,
                                 product_prefix)
      else:
        err = ('Invalid file name %s.' % (name))
        self.status = 'ERROR'
        self.status_message.append(err)


  self.SendStatusMail(mail_message.sender)

有什么建议可以找到反弹的原因吗?

4

1 回答 1

0

将代码放入 try-catch 并在处理附件时出错: “在未引用的字段中看到换行符 - 你需要以通用换行模式打开文件吗?” 使用 content.decode().splitlines() 解决了它。

虽然它不应该因为邮件仍然到达目的地而导致邮件传递失败。谢谢乔苏。

于 2012-09-06T05:12:17.650 回答