forwardemail / email-templates

Create, preview (browser/iOS Simulator), and send custom email templates for Node.js. Made for @forwardemail, @ladjs, @cabinjs, @spamscanner, and @breejs.
https://forwardemail.net/docs/send-emails-with-node-js-javascript
MIT License
3.67k stars 337 forks source link

Do not embed images in Base64 #303

Closed ibc closed 6 years ago

ibc commented 6 years ago

AFAIS, if the html.ejs template includes a <img src="https://foo.com/image.png">, it happens that email-templates converts it to Base64 within the email HTML body.

Thanks.

niftylettuce commented 6 years ago

I will add in https://github.com/ladjs/nodemailer-base64-to-s3/ soon as built-in - but if you want to use this manually in meanwhile that would be nice.

ibc commented 6 years ago

Finally it was possible to disable Base64 image encoding by setting some configuration options in juice.

niftylettuce commented 6 years ago

@ibc please share your documentation and options? 👍

ibc commented 6 years ago

Actually you can add data-inline-ignore attribute within the corresponding <img> tag, or you can disable it globally by setting:

{
  juice: {
    webResources: {
      images : false
    } 
 }
}

Check https://www.npmjs.com/package/juice API, specifically the webResources setting which points to https://www.npmjs.com/package/web-resource-inliner

macpatel commented 6 years ago

Finally thanks @ibc

niftylettuce commented 6 years ago

@macpatel @ibc I've released v4.0.2 which sets images: false in the built-in configuration of email-templates. I also added a note to the README regarding this here https://github.com/niftylettuce/email-templates#plugins.

niftylettuce commented 6 years ago

I also released a deprecation notice to NPM versions <4.0.2:

npm deprecate email-templates@"<4.0.2" "If you are using <4.0.2, you may have an issue in production with <img> tags 'src' attribute being converted to an inlined base64 data-uri, as of v4.0.2+ we have specifically set 'images: false' in the options we pass to 'juice' so that images will not get converted this way.  See <https://github.com/niftylettuce/email-templates/issues/303> for more information and consider using 'nodemailer-base64-to-s3' as documented here <https://github.com/niftylettuce/email-templates\#plugins>"
ibc commented 6 years ago

Great! thanks a lot.

PS: This issue can be closed :)

niftylettuce commented 6 years ago

Done @ibc!