13
rated 0 times
[
14]
[
1]
/ answers: 1 / hits: 7171
/ 4 Years ago, wed, june 3, 2020, 12:00:00
I am sending an html email using nodemailer in node.js, I am sending using the templates concept of the email-templates npm package [https://www.npmjs.com/package/email-templates].
Here, the email is sending successfully but the image in the HTML is not displaying on the email when received.
this is the main file which sends the mail :
const nodemailer = require(nodemailer);
var Email = require('email-templates');
const path = require('path');
var transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: '[email protected]',
pass: 'password'
}
});
const email = new Email({
transport: transporter,
send: true,
preview: false,
views: {
options: {
extension: 'ejs'
}
},
juice: true,
juiceResources: {
preserveImportant: true,
webResources: {
relativeTo: path.join(__dirname,'./templates/emailCampaign/images')
}
}
});
email.send({
template:path.join(__dirname,'./templates/emailCampaign'),
message: {
from: '[email protected]',
to: '[email protected]',
},
locals: {
tournament_name:tournament_name,
date:date,
time:time,
fee:4,
sections:sections,
description:description
},
}).then(() => console.log('email has been sent!'));
This is the HTML part where I want my image to show
<img style=width: 100%;
height: auto;
src=./images/background.jpg
alt=game>
More From » node.js