繁体   English   中英

在App Engine / Python中发送HTML电子邮件?

[英]Send HTML e-mail in App Engine / Python?

你能给我一个简单,直接的python示例,使用App Engine发送HTML电子邮件吗? 明文很简单,但我对HTML标签有困难。

我没有测试过这个,所以请原谅任何小错误。 它基于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电子邮件的收件人。

电子邮件附件的附件字段。

这详细介绍了在App Engine上发送HTML电子邮件的一些问题: http//code.google.com/p/googleappengine/issues/detail?id = 965

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM