AppEngine可以产生哪些邮件服务错误? [英] What mail service errors can AppEngine produce?

查看:138
本文介绍了AppEngine可以产生哪些邮件服务错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在try / except中控制并嵌入我的 send()调用,但我不确定它会产生哪些错误。

I would like to control and embed my send() calls in a try/except, but I'm not sure of what errors it can produce.

环顾SDK,看起来好像是MailServiceError,但不确定,因为我不知道如何测试这样的错误。

Looking around the SDK, it seems like MailServiceError is the one, but not sure since I don't know how to test an error like that.

任何人都可以证实这一点吗?

Can anyone confirm this?

推荐答案

以下是可通过调用发送的异常(): https://developers.google.com/appengine/docs/python/邮件/例外

Here are the exceptions that can be thrown by a call to send(): https://developers.google.com/appengine/docs/python/mail/exceptions

下面是一个如何捕捉这些信息的例子:

Here's an example of how you could catch these:

from google3.apphosting.api import mail

# other code to create 'message' here
try:
  message.send()
except mail.InvalidSender, e:
  # Do something special for an invalid sender error
  pass
except mail.Error, e:
  # This will catch all the other exceptions in the doc above.
  pass

这篇关于AppEngine可以产生哪些邮件服务错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆