Hello there, welcome to my random question post.
I was facing small issue to add multiple address to bcc to the sendgrid nodejs example :
What I was tried to do ( which was wrong in accepting as sendgrid bcc parameters value)
let testAccount = {
emailSubject: subjectMsg,
emailFrom: `Application <${process.env.CESEmailFrom}>`,
emailTo: email || process.env.OWNER_TO_EMAIL_ADDRESS,
emailBcc: process.env.OWNER_EMAIL_ADDRESS //note here
};
(this is just a payload I am preparing to pass to seng-grid function), process.env.OWNER_EMAIL_ADDRESS was holding values like : email1@testdomain.com, email2@testdomain.com so which is incorrect to pass a comma separated string value.
Instead, we just need to tweak a little at the same bcc, line to pass it as Javascript Array value. Here is the example of working code (note the bcc line in the code below):
let testAccount = {
//user: process.env.CESUsername,
//pass: process.env.CESPassword,
emailSubject: subjectMsg,
emailFrom: `Kitchen Anak <${process.env.CESEmailFrom}>`,
emailTo: email || process.env.OWNER_TO_EMAIL_ADDRESS,
emailBcc: process.env.OWNER_EMAIL_ADDRESS && process.env.OWNER_EMAIL_ADDRESS.split(',') || '',
};
Using javascript split function, I was able pass it as a array, isn’t that simple? 🙂
Along this, I have also then faced error after fixing above, still on my Vercel deployment code, then which was related to sendGrid bcc parameter for multiple email address.
According to sendGrid documentation we should have unique email address for ‘to’, ‘cc’ and ‘bcc’ options while sending email, in my case I was having ‘bcc’ email address set in at ‘to’ option.
Hence, so creating a duplicate error log at API level of code. (attaching screenshot of error occurred) and then fixed it by removing or keeping all the ‘to’ and ‘bcc’ parameters unique! Volia, that simple 🙂
Result after correcting email address successful.
Thanks for visiting & Happy Learning!
Break! I didn’t plan it. One day I just didn’t feel like opening Instagram—and then…
AI tools Let’s be real—AI sounds like either a robot apocalypse or something only tech…
Summer vacation is a great time for kids to explore, have fun, and learn new…
Goal: Understand transformers, large language models, and the architecture behind ChatGPT. Tutorial Suggestions: ✅ “Transformers…
Goal: Build apps or tools with ChatGPT or GPT-4 API. Tutorial Suggestions: ✅ OpenAI API…
Goal: Learn how to prompt better, write content, brainstorm, code, etc. Tutorial Suggestions: ✅ OpenAI's…