Django html电子邮件
我正在工作的项目需要发送html电子邮件。url需要插入html内容,如Django html电子邮件,django,Django,我正在工作的项目需要发送html电子邮件。url需要插入html内容,如 <p><a href="http://dealerfunnel.com/passwordchange">Password Change Link</a></p> 这是你能做的 def send_notification_email(template, **kwargs): subject = "Your subject here" context = You
<p><a href="http://dealerfunnel.com/passwordchange">Password Change Link</a></p>
这是你能做的
def send_notification_email(template, **kwargs):
subject = "Your subject here"
context = Your_Context
email = Your_Email
body = render_to_string(template, {'context':context})
return send_mail(subject, body, settings.EMAIL_HOST_USER, [email], fail_silently=True)
这是指您正在从视图调用此函数。。
若并没有,那个么你们可以在send_-mail方法中明确地使用模板
现在,在模板中,你可以写任何你想要的东西,邮件应该发送为什么不使用django表单?显示你的设置。py和你的url,你不应该硬编码页面链接,你应该使用url模板标记
def send_notification_email(template, **kwargs):
subject = "Your subject here"
context = Your_Context
email = Your_Email
body = render_to_string(template, {'context':context})
return send_mail(subject, body, settings.EMAIL_HOST_USER, [email], fail_silently=True)