I am sending email using smtp in django but its showing its HTML code.
Here is my django view and template
view.py
current_site = get_current_site(request)
mail_subject = 'Activate Your Account'
mail_message = render_to_string('mail_body.html', {
'user' : user,
'domain' : current_site.domain,
'uid' : urlsafe_base64_encode(force_bytes(user.pk)),
'token' : default_token_generator.make_token(user)
})
mail_to = email,
email = EmailMessage( mail_subject, mail_message, to = mail_to )
email.send()
mail_body.html
<div>
{% autoescape off %}
<b class="text-center">Hello {{ user.username }}</b><br>
Please click on the link below to verify your email address and complete your registration.
<a class="btn btn-primary btn-block" href="http://{{ domain }}{% url 'auth' uidb64=uid token=token
%}" role="button" target="_blank">Verify</a>
<hr />
<br />
If you think, it's not you, then just ignore this email.
{% endautoescape %}
</div>