def send_activation_change_email(request, user, new_email):
subject = _('Change email')
from_email = settings.DEFAULT_FROM_EMAIL
current_site = get_current_site(request)
domain = current_site.domain
code = get_random_string(20)
context = {
'domain': domain,
'code': code,
}
act = Activation()
act.code = code
act.user = user
act.email = new_email
act.save()
html_content = render_to_string('email/change_email.html', context=context, request=request)
text_content = strip_tags(html_content)
msg = EmailMultiAlternatives(subject, text_content, from_email, [user.email])
msg.attach_alternative(html_content, 'text/html')
msg.send()
utils.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录