mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 03:41:05 -05:00
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:
@@ -59,6 +59,10 @@ def attach_inline_image_file(message, path, subtype=None, idstring="img", domain
|
||||
|
||||
def attach_inline_image(message, content, filename=None, subtype=None, idstring="img", domain=None):
|
||||
"""Add inline image to an EmailMessage, and return its content id"""
|
||||
if domain is None:
|
||||
# Avoid defaulting to hostname that might end in '.com', because some ESPs
|
||||
# use Content-ID as filename, and Gmail blocks filenames ending in '.com'.
|
||||
domain = 'inline' # valid domain for a msgid; will never be a real TLD
|
||||
content_id = make_msgid(idstring, domain) # Content ID per RFC 2045 section 7 (with <...>)
|
||||
image = MIMEImage(content, subtype)
|
||||
image.add_header('Content-Disposition', 'inline', filename=filename)
|
||||
|
||||
Reference in New Issue
Block a user