When I use a transactional template , this ignore the recipient
juanOlivasG opened this issue · 1 comments
Issue Summary
When using the @sendgrid/mail client for Node, when I try to use a transactional template it does not work, it sends the email to Sendgrid and response status 202 but I never receive the email, when I check the SendGrid console the email is there with status not delivered when I test the template with SendGrid portal it works I am able to send me test emails.
When I send an email without a transactional template it works well, the problem is when I try to use the template it ignores the recipient.
//template code
html>
head>
title></title>
/head>
body>
div data-role="module-unsubscribe" class="module" role="module" data-type="unsubscribe" style="color:#444444; font-size:12px; line-height:20px; padding:16px 16px 16px 16px; text-align:Center;" data-muid="4e838cf3-9892-4a6d-94d6-170e474d21e5">
You've been assigned to {{ticketType}} #{{ticketNumber}} on the {{projectName}} project.
/div>
/body>
/html>
//node code
const sgMail = require('@sendgrid/mail')
sgMail.setApiKey(process.env.SENDGRID_KEY)
sgMail.setSubstitutionWrappers('{{', '}}')
const dispatchEmail=async(email,sendgrid_from,templateId,substitutions)=>{
const projectName = 'Project Foo';
const ticketNumber = 1234;
const msg = {
personalizations: [{
to: [{
email: email,
name: 'myself',
}],
}],
from: {
email: sendgrid_from,
name: 'myself',
},
templateId:templateId,
dynamic_template_data: {
ticketNumber,
projectName,
ticketType: 'bar',
},
};
await sgMail.send(msg).then(([response, body]) => {
console.log(response);
console.log(body);
}).catch(err => console.log(err));
}
exports.dispatchEmail=dispatchEmail
Technical details:
sendgrid-nodejs version: 6.5.5 and 7.4.5
node version: v12.16.1
Thanks for submitting a GitHub issue! We are very sorry that you are running into this problem. In order to better serve you, as this does not present itself as a library specific issue, we would like to ask that you reach out to our support team at support.sendgrid.com.