您能否给我一个简单,直接的python示例,使用App Engine发送HTML电子邮件?明文很简单,但我对HTML标签有困难。
答案 0 :(得分:53)
我没有测试过这个,所以请原谅任何小错误。它基于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()
答案 1 :(得分:4)
请参阅此文档。这就是你想要的。 http://code.google.com/appengine/docs/python/mail/emailmessagefields.html
html 电子邮件的字段。 正文内容的HTML版本,适用于喜欢HTML电子邮件的收件人。
电子邮件附件的附件字段。
答案 2 :(得分:0)
详细介绍了在App Engine上发送HTML电子邮件的一些问题:http://code.google.com/p/googleappengine/issues/detail?id=965