gpt4 book ai didi

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

转载 作者:IT老高 更新时间:2023-10-28 22:20:30 25 4
gpt4 key购买 nike

您能给我一个使用 App Engine 发送 HTML 电子邮件的简单直接的 Python 示例吗?纯文本很简单,但我在使用 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()

关于python - 在 App Engine/Python 中发送 HTML 电子邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2860614/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com