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

Add non-inline images as attachments #226

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

skoobasteeve
Copy link

@skoobasteeve skoobasteeve commented Feb 19, 2022

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
Copy link
Owner

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

Copy link

@drocpdp drocpdp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am actually looking to solve this exact problem and thank you for adding this. (TLDR. For non-tldr, scroll down). [EDIT: I am actually needing to attach an .html file, but not have it rendered, but show in the attachments section]

Small, but important feedback on this PR:

  • Can you add a way to wrap this bit of code? I think this functionality should only be enabled with an optional flag passed into the prepare_message() fn.
  • All for the sake of backwards-compatibility.

Email formatting is important, depending on the use of this library.
Just to think ahead, those in the opposite camp may have a need for the functionality as it is now. Especially if it is a company footer or such. I can imagine they may depend on the "broken" functionality to maintain their email appearance. etc.
Some people simply prefer having images within their email, esp. if it is important to their branding. Making their customers open an attachment may be a less-desirable business move.

@drocpdp
Copy link

drocpdp commented Oct 27, 2022

@kootenpv

if type(content_string) == inline:

Probably need to ensure it will acceptably pass under this umbrella.

@drocpdp
Copy link

drocpdp commented Oct 28, 2022

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.

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

Successfully merging this pull request may close these issues.

None yet

3 participants