What mail service errors can AppEngine produce?

☆樱花仙子☆ 提交于 2020-01-07 01:39:11

问题


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.

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?


回答1:


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


来源:https://stackoverflow.com/questions/10283352/what-mail-service-errors-can-appengine-produce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!