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: 'test@gmail.com',
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: 'test@gmail.com',
to: 'test@gmail.com',
},
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">