【发布时间】:2011-02-21 01:58:59
【问题描述】:
您能否给我一个使用 App Engine 发送 HTML 电子邮件的简单直接的 Python 示例?纯文本很简单,但我在使用 HTML 标记时遇到了困难。
【问题讨论】:
标签: python google-app-engine email
您能否给我一个使用 App Engine 发送 HTML 电子邮件的简单直接的 Python 示例?纯文本很简单,但我在使用 HTML 标记时遇到了困难。
【问题讨论】:
标签: python google-app-engine email
这详细说明了在 App Engine 上发送 HTML 电子邮件的一些问题:http://code.google.com/p/googleappengine/issues/detail?id=965
【讨论】:
我还没有测试过,所以请原谅任何小错误。它基于 Google 文档中的一个示例: http://code.google.com/appengine/docs/python/mail/sendingmail.html
from google.appengine.api import mail
message = mail.EmailMessage(sender="Example.com Support <support@example.com>",
subject="Your account has been approved")
message.to = "Albert Johnson <Albert.Johnson@example.com>"
message.body = """
Dear Albert:
Your example.com account has been approved. You can now visit
http://www.example.com/ and sign in using your Google Account to
access new features.
Please let us know if you have any questions.
The example.com Team
"""
message.html = """
<html><head></head><body>
Dear Albert:
Your example.com account has been approved. You can now visit
http://www.example.com/ and sign in using your Google Account to
access new features.
Please let us know if you have any questions.
The example.com Team
</body></html>
"""
message.send()
【讨论】:
请参阅此文档。这就是你想要的。 http://code.google.com/appengine/docs/python/mail/emailmessagefields.html
电子邮件消息的html 字段。 正文内容的 HTML 版本,适用于喜欢 HTML 电子邮件的收件人。
电子邮件附件的附件字段。
【讨论】: