Skip to content

Commit 483983f

Browse files
committed
fix: use inline type for disposition
1 parent 513af07 commit 483983f

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

django_email_verification/confirm.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,18 @@ def has_decorator(k):
8282
if not validators.url(context['link']):
8383
logger.warning(f'{DJANGO_EMAIL_VERIFICATION_MALFORMED_URL} - {context["link"]}')
8484

85-
subject = Template(subject).render(Context(context))
86-
87-
text = render_to_string(mail_plain, context)
88-
89-
html = render_to_string(mail_html, context)
90-
9185
do_convert_base64_images = _get_validated_field(f'EMAIL_CONVERT_BASE64_IMAGES', default=False, use_default=True, default_type=bool)
9286

9387
attachments = []
9488
if do_convert_base64_images:
9589
# Look for inline base64 images and converts them to attachments for email providers that require them i.e. Gmail
96-
html, attachments = convert_base64_images(html, attachments)
90+
mail_html, attachments = convert_base64_images(mail_html, attachments)
91+
92+
subject = Template(subject).render(Context(context))
93+
94+
text = render_to_string(mail_plain, context)
95+
96+
html = render_to_string(mail_html, context)
9797

9898
msg = EmailMultiAlternatives(subject, text, sender, [user.email], attachments=attachments)
9999

django_email_verification/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def repl(match):
2121
"data": match.group("data"),
2222
"subtype": subtype,
2323
}
24-
return ' src="cid:image%s"' % key
24+
return ' src="cid:image-%s"' % key
2525

2626
# Compile pattern for base64 inline images
2727
RE_BASE64_SRC = re.compile(
@@ -44,8 +44,8 @@ def repl(match):
4444
)
4545
else:
4646
raise
47-
image.add_header('Content-ID', '<image%s>' % key)
48-
image.add_header('Content-Disposition', "attachment; filename=%s" % f'image_{random_string(length=6)}')
47+
image.add_header('Content-ID', '<image-%s>' % key)
48+
image.add_header('Content-Disposition', "inline; filename=%s" % f'image_{random_string(length=6)}')
4949
attachments.append(image)
5050

5151
return body, attachments

0 commit comments

Comments
 (0)