【问题标题】:What mail service errors can AppEngine produce?AppEngine 会产生哪些邮件服务错误?
【发布时间】:2012-04-23 15:18:37
【问题描述】:

我想控制我的 send() 调用并将其嵌入到 try/except 中,但我不确定它会产生什么错误。

环顾SDK,似乎是MailServiceError,但不确定,因为我不知道如何测试这样的错误。

谁能证实这一点?

【问题讨论】:

    标签: google-app-engine python-2.7


    【解决方案1】:

    以下是调用 send() 可能引发的异常:https://developers.google.com/appengine/docs/python/mail/exceptions

    这是一个如何捕捉这些的示例:

    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
    

    【讨论】:

    • 太好了,我不知道为什么我跳过了文档中的那个页面。感谢您的快速回答。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-02-10
    • 2012-01-12
    • 2020-05-03
    • 1970-01-01
    • 2021-12-21
    • 1970-01-01
    • 2014-10-10
    相关资源
    最近更新 更多