Har*_*rdu 2 javascript visual-studio node.js sendgrid express
下面的代码 目前是我的 sendgrid 辅助函数,这就是来自 infogmail.com 的发件人名称“info”。。我想添加一个自定义名称。我已阅读文档,但没有看到解决我的问题的方法。我看到的所有解决方案都是针对Python的
const msg = {
to: email,
from: `${SENDER_EMAIL}`,
fromname: FROM_NAME,
subject: "Thanks for the Gift",
html: `${html(name, SENDER_EMAIL, SENDER_NAME)}`,
};
sgMail
.send(msg)
.then(() => {
console.log("Email sent");
})
.catch((error) => {
console.error(error);
});
};```
Run Code Online (Sandbox Code Playgroud)
您可以通过以下方式:
sendgrid.send({
to: 'you@yourdomain.com',
from: {
email: 'example@example.com',
name: 'Sender Name'
},
subject: 'Hello World',
text: 'My first email through SendGrid'
});
Run Code Online (Sandbox Code Playgroud)