我正在使用node.js中的nodemailer发送html电子邮件,我正在使用电子邮件模板npm包的模板概念发送[ https://www.npmjs.com/package/email-templates]。
此处,电子邮件已成功发送,但收到时,HTML 中的图像未显示在电子邮件上。
这是发送邮件的主文件:
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", …Run Code Online (Sandbox Code Playgroud)