Mailgun: raise unsupported feature error on attachment without filename.

Mailgun's API silently drops attachments without filenames (and inline
attachments without Content-IDs). Raise an AnymailUnsupportedFeature
error on attempts to send these attachments.

Fixes #128
This commit is contained in:
medmunds
2018-10-11 15:38:50 -07:00
parent 64f7d31d14
commit 2cf14c3653
4 changed files with 67 additions and 7 deletions

View File

@@ -188,9 +188,13 @@ class MailgunPayload(RequestsPayload):
if attachment.inline:
field = "inline"
name = attachment.cid
if not name:
self.unsupported_feature("inline attachments without Content-ID")
else:
field = "attachment"
name = attachment.name
if not name:
self.unsupported_feature("attachments without filenames")
self.files.append(
(field, (name, attachment.content, attachment.mimetype))
)