【发布时间】:2019-06-20 17:47:17
【问题描述】:
发送.js
我测试了邮件,但它是一个硬内容。我想附加一个动态内容
const msg = {
to: email,
from: 'no-reply@mail.com',
subject: 'subject',
html: '<strong>and easy to do anywhere, even with Node.js</strong>',
};
sgMail
.send(msg)
.then(() => {
console.log('sended');
})
.catch(error => {
console.log('error', error);
});
模板.js
module.exports = (data)=> {
return `
<html>
<body>
<div style="text-align: center;">
<h3>I'd like your input!</h3>
<p>Please answer the following question:</p>
<p>${data.body}</p>
</div>
</body>
</html>
`;
};
有没有办法附加html模板 请帮帮我
【问题讨论】:
标签: javascript node.js email sendgrid