您可以使用@sendgrid/mail 库:
const sgMail = require("@sendgrid/mail");
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const msg = {
to: "recipientmail",
from: "verifiedsendermail",
subject: "Email Subject",
template_id: "your sendgrid email dynamic template id",
personalizations: [
{
dynamic_template_data: {
fullName: "John Doe",
},
},
],
};
sgMail
.send(msg)
.then((response: any) => {
})
.catch((error: any) => {
});
Run Code Online (Sandbox Code Playgroud)
在这里,您的模板将如下所示,其中 {{fullName}} 是您的动态变量:

| 归档时间: |
|
| 查看次数: |
6899 次 |
| 最近记录: |