簡體   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