From fbb104acc03ac329fb51f0c1a7f81edea791bd25 Mon Sep 17 00:00:00 2001 From: Raymond Penners Date: Fri, 15 Dec 2023 23:26:37 +0100 Subject: [PATCH] fix(account/adapter): Use TEMPLATE_EXTENSION when sending mail --- allauth/account/adapter.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/allauth/account/adapter.py b/allauth/account/adapter.py index 68334566dc..8e55ccb89b 100644 --- a/allauth/account/adapter.py +++ b/allauth/account/adapter.py @@ -148,7 +148,8 @@ def render_mail(self, template_prefix, email, context, headers=None): from_email = self.get_from_email() bodies = {} - for ext in ["html", "txt"]: + html_ext = app_settings.TEMPLATE_EXTENSION + for ext in [html_ext, "txt"]: try: template_name = "{0}_message.{1}".format(template_prefix, ext) bodies[ext] = render_to_string( @@ -164,10 +165,12 @@ def render_mail(self, template_prefix, email, context, headers=None): msg = EmailMultiAlternatives( subject, bodies["txt"], from_email, to, headers=headers ) - if "html" in bodies: - msg.attach_alternative(bodies["html"], "text/html") + if html_ext in bodies: + msg.attach_alternative(bodies[html_ext], "text/html") else: - msg = EmailMessage(subject, bodies["html"], from_email, to, headers=headers) + msg = EmailMessage( + subject, bodies[html_ext], from_email, to, headers=headers + ) msg.content_subtype = "html" # Main content is now text/html return msg