dj-rest-auth
dj-rest-auth copied to clipboard
Password reset HTML email not sending
Using custom serializer to pass HTML template name as the context
class CustomPasswordResetSerializer(PasswordResetSerializer):
def get_email_options(self):
return {
'subject_template_name': 'account/email/password_reset_key_subject.txt',
'email_template_name': 'account/email/password_reset_key_message.txt',
'html_email_template_name': 'account/email/password_reset_key_message.html',
}
But the email delivered is not containing HTML version.
I checked with the library's source and the dj_rest_auth/forms.py
, the PasswordResetForm
's save()
method has the following code
context = {
'current_site': current_site,
'user': user,
'password_reset_url': url,
'request': request,
}
if app_settings.AUTHENTICATION_METHOD != app_settings.AuthenticationMethod.EMAIL:
context['username'] = user_username(user)
get_adapter(request).send_mail(
'account/email/password_reset_key', email, context
)
The passed kwargs
are not being used in the context passed to the send_mail
method, which the django.contrib.auth.forms.PasswordResetForm
accepts the following
def send_mail(self, subject_template_name, email_template_name,
context, from_email, to_email, html_email_template_name=None):
What is the use of setting extra parameters in the serializer's get_email_options
method?
Hi @anuj9196! I am currently having the same issue. We're you able to figure out a solution?
Hi @tarricsookdeo Not yet. Please update if you get any solution.
Hi @anuj9196 @tarricsookdeo . Facing the same issue. In case any you guys get any resolution. Please share.
Found multiple issues that seems related. I've given my solution in this comment that might help.