2017-03-01 47 views
0

在我的本地服务器上,我尝试发送邮件“NoneType”对象的AppEngine邮件不是可迭代发送

INFO 2017-03-01 16:54:06,819 mail_stub.py:143] MailService.Send
From: None "[email protected]"
To: v*****@d******.com
Subject: Du contenu arrive à expiration ([email protected])
Body:
Content-type: text/plain
Data length: 50
INFO 2017-03-01 16:54:06,819 mail_stub.py:306] You are not currently sending out real email. If you have sendmail installed you can use it by using the server with --enable_sendmail

ERROR 2017-03-01 16:48:43,630 wsgi.py:279] Traceback (most recent call last):
File "/home/*****/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 268, in Handle
for chunk in result:
TypeError: 'NoneType' object is not iterable

我的代码时出现此错误是:

def send(recipient, subject, body): 
    message = mail.EmailMessage(
     sender=u'{} <[email protected]{}.appspotmail.com>'.format(app_identity.get_application_id(), 
                  app_identity.get_application_id()), 
     subject=subject, 
     body=body, 
     to=recipient 
    ) 
    message.check_initialized() 
    message.send() 

而且我有没有线索发生什么错误。你有什么可以解决这个问题或者我可以尝试调试的一些东西?

感谢您的帮助

+1

你可以显示调用'send()'的代码吗?这个错误信息是来自'mail_stub.py'的信息msg *,意思是**'send()'完成后它可能实际上是由其他的**造成的。也许在'send()'之后添加一个调试打印来检查这个理论? –

回答

0

在你的日志,这是发送电子邮件地址:

From: None "[email protected]"

我从来没有用过app_identity.get_application_id()但它不为你工作,因为它返回“无” 。而不是深入研究,为什么不硬编码应用程序ID,看看是否可以解决问题,即:

sender=u'[email protected]' 
+0

实际上,根据代码它会是'sender = u'myapp <[email protected]>',如果邮件服务不支持这种格式,那么*可能实际上是问题。两种变体的测试应该澄清。 –

+0

我必须在“”和不是< >之间编写[email protected],因为Stackoverflow没有显示它(所以在我的控制台中记录它在< >之间) –

1

好吧,我的坏。它与邮件无关,我只是在路由处理器的末尾没有返回任何东西。错误来自那里。谢谢您的帮助。

相关问题