FusionAuth / fusionauth-issues

FusionAuth issue submission project
https://fusionauth.io
91 stars 12 forks source link

Allow adding images via Content-ID to email templates #804

Open sigalor opened 4 years ago

sigalor commented 4 years ago

Allow adding images via Content-ID to email templates

Problem

Currently, it is not possible to directly embed images into the email templates in the form of attachments, i.e. using the Content-ID field (see this Stack Overflow answer for a short explanation). Yet, using this field is the best option for maximum compatibility.

Solution

One option to solve this would be the following workflow:

  1. One could just upload any images into some sort of new "image/file dump" using the FusionAuth email API or the web interface. Each uploaded image would need a unique filename, e.g. logo.png.
  2. After having uploaded this image, one would simply add something like <img src="cid:logo.png"/> to any HTML email template.
  3. When sending out an email with this template, FusionAuth would first process the FreeMarker stuff like usual and then scan the resulting HTML for any mentions of an img tag with a src attribute starting with cid:. In the example, FusionAuth would thus find logo.png and, because it knows there already is a logo.png in the dump of possible email attachments, it would automatically attach this file to the sent out email.

Alternatives/workarounds

There are currently two major workarounds that both have their drawbacks:

Another option is to set up your own SMTP proxy. FusionAuth will then only send emails to this proxy, the proxy takes these emails and adds the required image attachments itself (essentially executing step 3 of the possible solution mentioned above) and then forwards them to the actual recipient.

How to vote

Please give us a thumbs up or thumbs down as a reaction to help us prioritize this feature. Feel free to comment if you have a particular need or comment on how this feature should work.

voidmain commented 4 years ago

As a side note, some email clients will show embedded images as attachments and some email servers will stripe them out completely. There isn't a great way to guarantee images are always displayed without problems. I do believe that externally hosted images is still the recommended solution for most clients. This is how most email platforms (i.e. Mailchimp and the like) serve images.