File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44from mimetypes import guess_type
55
66import jsonpickle
7+ import django
78from django .conf import settings
89from django .contrib .sites .models import Site
910from django .core .files import File
1415
1516from herald .utils import get_sent_notification_model
1617
18+ use_legacy_mixed_subtype : bool = False
19+ if django .VERSION < (5 , 0 ):
20+ use_legacy_mixed_subtype : bool = True
21+
1722
1823class NotificationBase :
1924 """
@@ -451,7 +456,8 @@ def _send(
451456 # All mimebase attachments must have a Content-ID or Content-Disposition header
452457 # or they will show up as unnamed attachments"
453458 if isinstance (attachment , MIMEBase ):
454- if attachment .get ("Content-ID" , False ):
459+ # `mixed_subtype` was removed from Django 5+
460+ if use_legacy_mixed_subtype and attachment .get ("Content-ID" , False ):
455461 # if you are sending attachment with content id,
456462 # subtype must be 'related'.
457463 mail .mixed_subtype = "related"
You can’t perform that action at this time.
0 commit comments