Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

content id for attachments #91

Open
matthewlent opened this issue Oct 25, 2014 · 7 comments
Open

content id for attachments #91

matthewlent opened this issue Oct 25, 2014 · 7 comments

Comments

@matthewlent
Copy link

need to set content id for attachments to be able to embed images using cid method

also the line 373 should be changed to:
for key, value in attachment.headers.items():

need the .items():

@warmspringwinds
Copy link

Is there a workarond to add contend-id header for attachment?

@pachay
Copy link
Contributor

pachay commented Mar 9, 2015

msg = Message(.....)
msg.attach(image_name, "image/png", image_data, headers={'Content-ID': '<%s>' % image_name})

but you should use my bug fix from master branch e195fca

@lavr
Copy link

lavr commented Mar 9, 2015

One who don't have bugfix e195fca can pass headers as a list I guess:

msg.attach(..., headers=[['Content-ID', '<filename.ext>'],])

@eLvErDe
Copy link

eLvErDe commented Sep 14, 2016

Confirmed, simply adding .items() fixes it

@cklos
Copy link

cklos commented Jun 18, 2019

Looks like the workaround makes some problems when opening the Mail with (at least) Thunderbird. The CID image is well attached but Thunderbird has problems displaying it in the html corpus. When the message is a multipart/mixed message, thunderbird shows the images simply as attachments. When the Content-Type is multipart/related instead, it is working. I think there might be some problems with real attachments. I found no official way to modify the Content-Type, so it would be nice if the enhancement suggested in this issue takes that into account.

@ilosuna
Copy link

ilosuna commented Oct 13, 2020

Same problem with Thunderbird here. I edited the following in flask_mail.py (line 321):
[-] msg = MIMEMultipart()
[+] msg = MIMEMultipart('related')
Now it seems to work at least in Thunderbird and Outlook.

@KaiRo-at
Copy link

Same problem with Thunderbird here. I edited the following in flask_mail.py (line 321): [-] msg = MIMEMultipart() [+] msg = MIMEMultipart('related') Now it seems to work at least in Thunderbird and Outlook.

I think it also would work if the images would be attached to the alternative object inside the msg object, which probably would be the correct nice and clean way to do it, but there is no possibility right now to specify that when attaching the images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

10 participants