sendgrid : add cc in email

Manish Sapkal picture Manish Sapkal · May 7, 2015 · Viewed 7.2k times · Source

I am sending email using sendgrid from my app. Now I want to add cc or bcc if user reply to my mail. How Do I do this. let me explain first. I am sending answer of user's feedback comes on my web application using my application let say I am sending email via '[email protected]', and user receive this mail in his/her inbox in gmail/yahoo or any other email service. In this case user may click reply to this mail. so now, yours 'To:' has contain '[email protected]' default reply address. it's fine. Now I want to add 'cc:' (carbon copy) as follows '[email protected]'. How to do this?

Answer

Jeff Sloyer picture Jeff Sloyer · May 7, 2015

You can pass the cc value when calling the sendgrid npm module. See below.

var sendgrid  = require('sendgrid')(api_user, api_key);
var email     = new sendgrid.Email({
  to:       '[email protected]',
  from:     '[email protected]',
  cc:       '[email protected]',
  subject:  'Subject goes here',
  text:     'Hello world'
});
sendgrid.send(email, function(err, json) {
  if (err) { return console.error(err); }
  console.log(json);
});