APIv3-nodejs-library icon indicating copy to clipboard operation
APIv3-nodejs-library copied to clipboard

How to add `X-SMTPAPI` header to avoid email delivery delays?

Open chengtie opened this issue 2 years ago • 0 comments

When a user signs up on our website, we send them a verification email. We would like to ensure the delivery time of this email.

We have been using sendgrid to send these emails. By following this notice, we add X-SMTPAPI header to the emails as follows

class EmailService {
  sendMail (options) {
    return sgMail.send({ 
      to: options.to,
      from: '[email protected]',
      subject: options.subject,
      text: options.text,
      html: options.html,
      headers: {
        'X-SMTPAPI': JSON.stringify({
        category: options.category,
        unique_args: options.unique_args,
        }),
      },
    }, (error, response) => {
      if (error) {
        console.log(error)
      } else {
        console.log('send mail successfully')
      }
    })
  }
}

Now we plan to use sendinblue to send these emails. We first want to use official libraries of sendinblue such as https://github.com/sendinblue/APIv3-nodejs-library. Then, I did not find how to add such a X-SMTPAPI header. Could anyone help?

chengtie avatar Apr 07 '23 13:04 chengtie