kootenpv / yagmail

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

Add non-inline images as attachments #226

Open skoobasteeve opened 2 years ago

skoobasteeve commented 2 years ago

This PR addresses issue #224 by adding an attachment header to images in the attachments list. Images will still display inline if yagmail.inline() is used.

I tested this in the master branch and everything worked as expected, but let me know if this causes any other problems for you. Sample header:

--===============6820474337442594020==
Content-Type: image/jpeg; name*=utf-8''image.jpg
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename= image.jpg

Thank you for all your work!

kootenpv commented 2 years ago

Awesome, thanks a lot for your work! I'll soon give it a try!

drocpdp commented 2 years ago

@kootenpv https://github.com/kootenpv/yagmail/blob/53923432d75bca3048365f5ae3680656081dd137/yagmail/message.py#L118 Probably need to ensure it will acceptably pass under this umbrella.

drocpdp commented 2 years ago

or maybe needs decoupling to get access to message. https://github.com/kootenpv/yagmail/blob/master/yagmail/message.py#L70

I don't know. I'm trying to find a way to access the prepare_message() and it's too encapsulated. I'm getting sucked into this issue, but don't have the time to really break this apart.