kootenpv / yagmail

Send email in Python conveniently for gmail using yagmail
MIT License
2.66k stars 265 forks source link

Inline Images In Incorrect MIME Block #62

Closed doughoyt closed 7 years ago

doughoyt commented 7 years ago

In the _prepare_message method, inline images are being correctly referenced using Content-ID (CID tag in HTML img, etc.).

However, the image itself is then attached to the "top-level" msg object (which would be correct for a regular attachment), but should be attached to the msg_related MIME part in order for clients to properly embed the image inline. Some clients handle this more gracefully than others (Thurnderbird shows a "broken image" icon, for example).

Also, order of attachments matter ... so the msg_related.attach() of the htmlstr must happen before the msg_related.attach() of the content_object.

kootenpv commented 7 years ago

@doughoyt Thanks a lot for taking the time to post the issue! I'd really encourage you to make a pull request :) It would be a fantastic addition to making it a more correct package, and itt seems you have a solution in mind.

I currently do not really have time to pursue this, so please let me know if you're interested in picking it up.