from django.core.mail import EmailMultiAlternatives
subject, from_email, to = 'hello', '[email protected]', '[email protected]'
text_content = 'This is an important message.'
html_content = '<p>This is an <strong>important</strong> message.</p>'
msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
msg.attach_alternative(html_content, "text/html")
msg.send()
發送正規的郵件我希望能夠把已經設計得當,包括如果可能的圖像通訊或電子郵件。我想知道是否可以將這個通過Django的
html_content = '<p>This is an <strong>important</strong> message.</p>'
轉換成html模板文件。像這樣
html_content = 'newsletter/news.html'
如果沒有,那麼我怎麼去發送電子郵件一樣,Quora的和其他websites.`
可能使用[用Django創建電子郵件模板]的副本(http://stackoverflow.com/questions/2809547/creating-email-templates-with-django) – Sayse