【发布时间】:2015-02-20 05:46:22
【问题描述】:
我想在用户注册网站后向他们发送 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()
但我不想将 HTML 直接放在主代码中,而是希望有一个单独的 HTML 文件用作正文。 我尝试这样做:
message.html = 'emailHTML.html'
但徒劳无功。如何使用 HTML 文件代替 HTML 代码?
【问题讨论】:
-
您是否尝试过使用
open()和.readlines() or .read()命令?
标签: python html google-app-engine