Do not silently drop nameless attachments over HTTP API
We're currently switching our email sending from SMTP to the HTTP API and noticed that some attachments were being silently dropped.
The main problem seems to be twofold:
1) the HTTP API requires non-ASCII filenames to be encoded using the "newish" RFC 7578 and simply ignores filenames encoded using the older RFC 2231.
2) attachments sent without filenames (or whose filenames were ignored because of #1) are simply dropped without warning, causing broken content to be sent.
Some more technical info can be found in this github issue: https://github.com/anymail/django-anymail/issues/125 (including examples of how to replicate)
Ideally, we'd expect mailgun to be able to accept filenames in either of the RFC formats, to enable usage with a broader range of client libraries. If that's not feasible, other options include (in decreasing order of usefulness):
- generating a filename on-the-fly for the cases where the filename cannot be parsed but also cannot be empty.
- throwing an error during submission, so that client systems are at least aware that something went wrong (attachment was submitted, but dropped).
- at the very, very least, logging a warning that the attachment was dropped.