Текст письма приходящего на почту:
{% load i18n %}
<html>
<title>Company - {% trans 'Activation by email' %}</title>
<body>
<p>{% trans 'Hello' %}, {{ user }}</p>
<p>{% trans 'Your account in Company name has been successfully created. Please click link below to activate your account.'%}</p>
<p><a href="{{ activate_url }}">{% trans 'Activate your account' %}</a></p>
</body>
</html>
Таск с отправкой письма:
def mail_send(scheme, host, user_id):
user = User.objects.get(pk=user_id)
text_content = 'Account Activation Email'
subject = 'Email Activation'
template_name = "activation.html"
from_email = settings.DEFAULT_FROM_EMAIL
recipients = [user.email]
# receive url with encoded data
context = encoder(scheme, host, user)
html_content = render_to_string(template_name, context)
email = EmailMultiAlternatives(subject, text_content, from_email, recipients)
email.attach_alternative(html_content, "text/html")
mail_sent = email.send()
return mail_sent