我尝试使用django发送HTML模板邮件。邮件发送正确,但无法获取html模板
这是我的View.py文件
def Mail_Send(request):
name = "Shyam"
mydist = { 'name': name }
html_template = 'mail_template.html'
render_html = get_template(html_template).render(mydist)
email = EmailMessage('Welcome',
render_html,
settings.EMAIL_HOST_USER,
['itsupport@synergyhospital.co.in'],
)
email.content_subtype='html'
email.send(fail_silently=False)
tesddting = {
'mailsend':'mailsend'
}
return render(request,"index.html",tesddting)
这是我的Html文件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h2>Hello This is testing</h2>
<p>Hi {{name}}</p>
</body>
</html>
**the html file is in template folder**
1条答案
按热度按时间zmeyuzjn1#
在Django Docs中:
你的html_message应该是