是否可以将 Sengrid 的替换标签与 nodemailer 一起使用?

Is it possible to use Sengrid's Substitution tags with nodemailer?

我将 nodemailer 与 Sendgrid (https://github.com/nodemailer/nodemailer-smtp-transport) 一起使用,我想一次向 2000 个用户发送电子邮件,每个用户的内容不同。目前我创建了一个 SMTP 传输并一次发送一封邮件,但我遇到了问题,我认为最好只发出一个请求来发送所有邮件。
使用 Sengrid SMTP API,可以通过使用替换标签向许多用户发送具有自定义内容的邮件。使用 nodemailer,是否可以在单个请求中使用它们将自定义邮件发送给每个人?例如,可以使用带有 setSubstitutions 的 sendgrid 节点包 (https://github.com/sendgrid/smtpapi-nodejs),但我想继续使用 nodemailer。

类似于:

 smtp.sendMail({  
      from: "Me",  
      to: [ "you@example.com", "him@example.com" ],  
      subs: { "-name-": [ "you", "him" ] },  
      subject: "Your name",  
      html: "<h1>Your name is -name-</h1>"  
    })

不胜感激:)

您应该能够通过显式设置必要的 X-SMTPAPI header 来做到这一点。

smtp.sendMail({
  headers: {
    'X-SMTPAPI': '{"sub": { "-name-": ["you","him"] } }'
  },
  from: "Me",  
  to: [ "you@example.com", "him@example.com" ],    
  subject: "Your name",  
  html: "<h1>Your name is -name-</h1>"  
})