在App Engine/Python中发送HTML邮件?
你能给我一个简单明了的Python示例,教我如何在App Engine上发送HTML格式的电子邮件吗?发送纯文本邮件很简单,但我在处理HTML标签时遇到了一些困难。
3 个回答
0
这里讲了一些在App Engine上发送HTML邮件时遇到的问题:http://code.google.com/p/googleappengine/issues/detail?id=965
4
看看这个文档。这就是你想要的内容。
html 是电子邮件内容的一个字段。这是给那些喜欢用HTML格式查看邮件的收件人准备的内容。
attachments 是用来放电子邮件附件的字段。
54
我还没有测试过这个,所以如果有小问题请多包涵。这是基于谷歌文档中的一个例子:
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()