Mailgun/SendGrid inbound: workaround Django filename issue

Workaround for Django multipart/form-data limitation
where certain attachment filenames cause fields to be dropped
or to end up in request.POST rather than request.FILES.

Handle the MultiValueDictKeyError in inbound webhooks when
this has occurred. Also update docs to recommend avoiding
the problem by using Mailgun and SendGrid's "raw MIME" options.

Also handle reported cases of empty, duplicate keys in Mailgun's
content-id-map.

Fixes #272
This commit is contained in:
medmunds
2022-05-10 11:47:57 -07:00
committed by Mike Edmunds
parent 6a2e30ba8f
commit 09f21a5c2d
9 changed files with 244 additions and 52 deletions

View File

@@ -30,6 +30,23 @@ vNext
*Unreleased changes in main branch*
Fixes
~~~~~
* **Mailgun and SendGrid inbound:** Work around a Django limitation that
drops attachments with certain filenames. The missing attachments
are now simply omitted from the resulting inbound message. (In earlier
releases, they would cause a MultiValueDictKeyError in Anymail's
inbound webhook.)
Anymail documentation now recommends using Mailgun's and SendGrid's "raw MIME"
inbound options, which avoid the problem and preserve all attachments.
See `Mailgun inbound <https://anymail.readthedocs.io/en/latest/esps/mailgun/#mailgun-inbound>`__
and `SendGrid inbound <https://anymail.readthedocs.io/en/latest/esps/sendgrid/#sendgrid-inbound>`__
for details. (Thanks to `@erikdrums`_ for reporting and helping investigate the problem.)
Other
~~~~~
@@ -1299,6 +1316,7 @@ Features
.. _@coupa-anya: https://github.com/coupa-anya
.. _@decibyte: https://github.com/decibyte
.. _@dominik-lekse: https://github.com/dominik-lekse
.. _@erikdrums: https://github.com/erikdrums
.. _@ewingrj: https://github.com/ewingrj
.. _@fdemmer: https://github.com/fdemmer
.. _@Flexonze: https://github.com/Flexonze