вы должны указать полный путь изображения к шаблону e js при отправке на электронную почту
// common function used for send different emails
async sendMail(to:string, template:string, subject:string) {
//create transport to send mail
var transporter = nodemailer.createTransport({
service: config.get('SMTP_CONSTANTS.SERVICE'),
auth: {
user: config.get('SMTP_CONSTANTS.USERNAME'),
pass: config.get('SMTP_CONSTANTS.PASSWORD')
}
});
//define mail options
var mailOptions = {
from: 'Your Domain <support@domain.com>',
to: to, // receiver
subject: subject, // Subject line
html: template
};
// send mail with defined transport object
let response = await transporter.sendMail(mailOptions);
return response;
}
app.get('/test',(req,res)=>{
let image_path = path.join(__dirname+'public/','logo.png');
console.log('image_path==',image_path);
let subject = 'Welcome To Website';
let to = 'to send mail';
let parameters = {
name: 'James',
image_path:image_path
};
let html = ejs.render(fs.readFileSync(__dirname+`/../views/auth/welcome.ejs`).toString(), parameters);
let response:any = await this.sendMail(to, html, subject).then((data:any)=>{return data}).catch(error => { return error });
return response;
});