Alongkorn Chetasumon Alongkorn Chetasumon - 9 months ago 100
Node.js Question

node.js sendgrid with multiple recipients get blank value when adding substitution

i found issue when sending email to multiple recipients using sendgrid.
i got blank value when adding substitution.


  • node.js

  • sendgrid (v2)

==== my sample code (node.js) ====

const sendgrid = require('sendgrid')(SENDGRID_API_KEY)

function sendEmailToSupport() {
const email = new sendgrid.Email({
from: '',
to: ['', '', '']
html: '<div>test = :test</div>',
subject: 'dummy'

email.addSubstitution(':test', 'ddddddddddddd')
sendgrid.send(email, (err, response) => {
if (err) {
} else {
console.log('Yay! Our templated email has been sent')

module.exports = {

====== result ======

  • gets email with correct content
    test = ddddddddddddd

  •, get email with blank value
    test =

it looks like the first email in the
array will get the correct content, others get blank data.

in the sendgrid web admin, there is no error, everying is fiine.

how to fix this issue?



after analyse the sendgrid lib, i found the solution now by editing this line

email.addSubstitution(':test', new Array('ddddddddddddd'))