【问题标题】:Python Google App Engine : Send Mail ErrorPython Google App Engine:发送邮件错误
【发布时间】:2012-07-08 12:50:52
【问题描述】:

我正在编写一个简单的测试应用程序来使用 Python GAE 发送电子邮件。我在日志中收到以下错误。我尝试过空体和其他更改,但似乎没有任何效果。我需要进行任何配置更改吗?

Traceback(最近一次调用最后一次):

   文件“/base/data/home/apps/s~xxxx/1.360190002979488583/email.py”,第 5 行,在
从 google.appengine.api 导入邮件
中的文件“/base/python27_runtime/python27_lib/versions/1/google/appengine/api/mail.py”,第 37 行 从电子邮件导入 MIMEBase
ImportError: 无法导入名称 MIMEBase

下面是我的 app.yaml 文件

application: mailer
version: 1
runtime: python27
api_version: 1
threadsafe: no

handlers:
- url: /email
  script: email.py

libraries:
- name: webapp2
  version: "2.5.1"

下面是我的 email.py (本质上它与 https://developers.google.com/appengine/docs/python/mail/sendingmail 中提到的代码相同。我刚刚更改了一个有效的电子邮件地址)

from google.appengine.api import mail
import sys

message = mail.EmailMessage(sender="Example.com Support <valid-from-address@gmail.com>",
                            subject="Your account has been approved")

message.to = "Valid User <valid.user@gmail.com>"
message.body = """
Dear Albert:

Your example.com account has been approved.  

The example.com Team
"""

message.send()

【问题讨论】:

    标签: python google-app-engine email sendmail


    【解决方案1】:

    不要将你的脚本命名为email.py;这就是阻止您从标准库的 email 模块导入的原因。

    【讨论】:

      猜你喜欢
      • 2015-02-25
      • 1970-01-01
      • 2014-10-15
      • 2016-12-04
      • 1970-01-01
      • 2010-10-27
      • 1970-01-01
      • 1970-01-01
      • 2011-10-22
      相关资源
      最近更新 更多