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

attach images in email #2784

Merged
merged 2 commits into from
Oct 19, 2022
Merged

Conversation

stefan0xC
Copy link
Contributor

@stefan0xC stefan0xC commented Oct 2, 2022

Since many email clients don't load external images I was wondering if we should include the images as attachment instead.

Some drawbacks to this change:

  • Embedding the images as attachments makes the mails around ~5kb bigger.
  • If you change the templates vaultwarden would still attach the images to the mail.

Copy link
Collaborator

@BlackDex BlackDex left a comment

Choose a reason for hiding this comment

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

It might be an option to add a new config option, SMTP_EMBED_IMAGES or something like that and have it dynamically embed or provide the external link.

The only thing is that the images are fully internal. So, if someone wants to change them it will not be easy besides for them to compile them selfs with a changed image file.

But in those cases someone probably wants to do more changes, so I'm not too worried about that.

src/mail.rs Outdated Show resolved Hide resolved
@stefan0xC stefan0xC marked this pull request as draft October 2, 2022 07:26
@stefan0xC
Copy link
Contributor Author

It might be an option to add a new config option, SMTP_EMBED_IMAGES or something like that and have it dynamically embed or provide the external link.

Okay, I will look into that.

@stefan0xC stefan0xC marked this pull request as ready for review October 2, 2022 08:16
@stefan0xC stefan0xC requested a review from BlackDex October 2, 2022 08:19
@stefan0xC stefan0xC force-pushed the email-attach-images branch 2 times, most recently from 7aaa41c to 8666adc Compare October 4, 2022 01:24
src/api/web.rs Outdated Show resolved Hide resolved
@mikepattyn
Copy link

mikepattyn commented Oct 5, 2022 via email

@BlackDex
Copy link
Collaborator

BlackDex commented Oct 5, 2022

Put the images inthere as true svgs if possible, they are code so will render in email even without a request from the user

That probably isn't working for all clients, and probably suffers from the same issues as using a base64 image src, that some client's just block that by default without a way to show it at all.

CID is old, but still works.

@stefan0xC stefan0xC force-pushed the email-attach-images branch 4 times, most recently from 25c74e2 to e5c3ac7 Compare October 6, 2022 10:26
src/config.rs Outdated Show resolved Hide resolved
src/mail.rs Outdated Show resolved Hide resolved
@stefan0xC stefan0xC force-pushed the email-attach-images branch from 67e0cb5 to ea37934 Compare October 11, 2022 13:27
stefan0xC and others added 2 commits October 15, 2022 04:59
Set SMTP_EMBED_IMAGES option to false if you don't want to attach images
to the mail.

NOTE: If you have customized the template files `email_header.hbs` and
`email_footer.hbs` you can replace `{url}/vw_static/` to `{img_url}`
to support both URL schemes
Apply suggestions from code review

Co-authored-by: Mathijs van Veluw <black.dex@gmail.com>
Copy link
Collaborator

@BlackDex BlackDex left a comment

Choose a reason for hiding this comment

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

Tested it and looks good to me.
It just needs an other re-base :)

@stefan0xC stefan0xC force-pushed the email-attach-images branch from ea37934 to 4289663 Compare October 15, 2022 14:19
@dani-garcia dani-garcia merged commit 4289663 into dani-garcia:main Oct 19, 2022
@stefan0xC stefan0xC deleted the email-attach-images branch October 19, 2022 20:22
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.

4 participants