Closed AmbroiseVuaridel closed 6 years ago
This is because juice
uses something called webResources
option, and it's not looking in the right folder. You would need to move the image to a different folder. See https://github.com/niftylettuce/email-templates/blob/master/src/index.js#L77. It's looking for a build
folder right now (assuming you're on the latest version of email-templates
). So the path it'll look at is /your-project/build/images/logo.png
, and it's in /your-project/emails/resetPassword/images/logo.png
.
I am trying to add images to email templates in an ejs file but get the following error:
Error: The file /Server/build/images/logo.png was not found!
(i removed the beggining of the path that initiate at the root of my drive)
here's html.ejs:
here's how i send the mail: 'use strict';
const nodeMailer = require("nodemailer"); const EmailTemplate = require('email-templates');
let smtpConfig = { host: CONFIG.email_host, port: CONFIG.email_port, secure: false, // upgrade later with STARTTLS auth: { user: CONFIG.email_user, pass: CONFIG.email_psw } };
var transporter = nodeMailer.createTransport(smtpConfig);
exports.sendPasswordReset = function (email, username, name, tokenUrl) { const email1 = new EmailTemplate({ message: { from: '"AMBROISE admin" ambroise@test.ch', // sender address to: email, }, send: true, preview: false, transport:transporter, views: { options: { extension: 'ejs' } } });
};
and here's my file organization:
I don't understand why the image path is changed to /Server/build/images/logo.png while I call it in email and should be /Server/emails/images/logo.png
Any obvious error I made and missed ?
Thanks