mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 03:41:05 -05:00
Fix: treat first text/plain alternative as plaintext body
Improve handling of alternative parts and `content_subtype` to match how Django's SMTP backend handles some unusual cases. Change Test backend to support (and record) text/* alternative parts. (But still reject other types of alternatives.) Fixes #252
This commit is contained in:
@@ -107,7 +107,12 @@ class TestPayload(BasePayload):
|
||||
self.params['html_body'] = body
|
||||
|
||||
def add_alternative(self, content, mimetype):
|
||||
self.unsupported_feature("alternative part with type '%s'" % mimetype)
|
||||
# For testing purposes, we allow all "text/*" alternatives,
|
||||
# but not any other mimetypes.
|
||||
if mimetype.startswith('text'):
|
||||
self.params.setdefault('alternatives', []).append((content, mimetype))
|
||||
else:
|
||||
self.unsupported_feature("alternative part with type '%s'" % mimetype)
|
||||
|
||||
def add_attachment(self, attachment):
|
||||
self.params.setdefault('attachments', []).append(attachment)
|
||||
|
||||
Reference in New Issue
Block a user