Change attach_inline_image default domain from hostname to "inline".

This avoids problems with ESPs that don't distinguish *Content-ID*
from attachment filename, where a local hostname ending in ".com" could
cause Gmail to block messages sent with inline attachments.
(Mailgun, Mailjet, Mandrill and SparkPost have APIs affected by this.)

Fixes #112.
This commit is contained in:
medmunds
2018-07-06 16:30:27 -07:00
parent 3f2c6d6917
commit e6431a62f0
4 changed files with 54 additions and 2 deletions

View File

@@ -398,9 +398,15 @@ classes.)
`idstring` and `domain` are optional, and are passed to Python's
:func:`~email.utils.make_msgid` to generate the :mailheader:`Content-ID`.
Generally the defaults should be fine.
(But be aware the default `domain` can leak your server's local hostname
in the resulting email.)
.. versionchanged:: 4.0
If you don't supply a `domain`, Anymail will use the simple string "inline"
rather than :func:`~email.utils.make_msgid`'s default local hostname. This
avoids a problem with ESPs that confuse :mailheader:`Content-ID` and attachment
filename: if your local server's hostname ends in ".com", Gmail could block
messages with inline attachments generated by earlier Anymail versions and sent
through these ESPs.
.. function:: attach_inline_image(message, content, filename=None, subtype=None, idstring="img", domain=None)