mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 11:51:05 -05:00
Preserve filename of inline attachments
For ESPs that support both content-id and filename, don't drop the filename.
This commit is contained in:
@@ -111,9 +111,14 @@ class MailgunPayload(RequestsPayload):
|
||||
|
||||
def add_attachment(self, attachment):
|
||||
# http://docs.python-requests.org/en/v2.4.3/user/advanced/#post-multiple-multipart-encoded-files
|
||||
field = "inline" if attachment.inline else "attachment"
|
||||
if attachment.inline:
|
||||
field = "inline"
|
||||
name = attachment.cid
|
||||
else:
|
||||
field = "attachment"
|
||||
name = attachment.name
|
||||
self.files.append(
|
||||
(field, (attachment.name, attachment.content, attachment.mimetype))
|
||||
(field, (name, attachment.content, attachment.mimetype))
|
||||
)
|
||||
|
||||
def set_metadata(self, metadata):
|
||||
|
||||
@@ -118,10 +118,15 @@ class MandrillPayload(RequestsPayload):
|
||||
self.data["message"]["html"] = body
|
||||
|
||||
def add_attachment(self, attachment):
|
||||
key = "images" if attachment.inline else "attachments"
|
||||
self.data["message"].setdefault(key, []).append({
|
||||
if attachment.inline:
|
||||
field = "images"
|
||||
name = attachment.cid
|
||||
else:
|
||||
field = "attachments"
|
||||
name = attachment.name or ""
|
||||
self.data["message"].setdefault(field, []).append({
|
||||
"type": attachment.mimetype,
|
||||
"name": attachment.name or "",
|
||||
"name": name,
|
||||
"content": attachment.b64content
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user