Closed rozsival closed 6 years ago
The solution is to set images: false
inside juiceResources.webResources
config. This should definitely be part of docs as it's handled by https://github.com/jrit/web-resource-inliner
. Then the images are not inlined and attachment embedding works.
For those joining us now, note that #303 fixed this in v4.0.2:
niftylettuce commented on Jul 31, 2018
I've released v4.0.2 which sets
images: false
in the built-in configuration ofemail-templates
. I also added a note to the README regarding this here https://github.com/niftylettuce/email-templates#plugins.
I am still failing to display my embedded images using cid. This is my current implementation.
const email = new Email({
transport: smtpTransport,
juice: true,
juiceResources: {
preserveImportant: true,
webResources: {
images: true,
relativeTo: path.join(__dirname, '../emails/assets'),
},
},
});
const sendMail = async (template, receiver, options) => {
await email.send({
template,
message: {
to: receiver,
},
locals: {
...options,
},
attachments: [
{
filename: 'cube.png',
path: path.join(__dirname, '../assets/cube.png'),
cid: 'sbil',
},
],
});
};
and my img
tag in pug
img(src='cid:sbil', alt='SBIL', style='display:block;width:29px;height:auto;margin-left:auto;margin-right:auto;margin-bottom:10px', height='auto')
According to https://nodemailer.com/message/embedded-images/ it should be possible to embed images from attachments. However, when using
email-templates
my attachment does not get embed.At first I thought it might be caused by custom render I implemented, but when I tried using it with
email-templates
default render without any customization, it did not work too.Any suggestions on what should I do to make it work?
mails/index.js
mails/render.js
mails/templates/layout.hbs
I need to get this to work as
base64
encoding is a no-go for us. Everything else works without any issues.