v2 API Node.js Code Example
We recommend using v3 SendGrid Node.js, our client library, available on GitHub, with full documentation.
The library does not officially support the V2 API, but you can use V2 with an older version of the library. For more information, see Continue Using V2 in Node.js.
Using SendGrid's Node.js Library
// using SendGrid's Node.js Library // https://github.com/sendgrid/sendgrid-nodejs const sendgrid = require("sendgrid")("SENDGRID_APIKEY"); const email = new sendgrid.Email(); email.addTo("email@example.com"); email.setFrom("firstname.lastname@example.org"); email.setSubject("Sending an email with SendGrid is Fun"); email.setHtml("and easy to do anywhere, even with Node.js"); sendgrid.send(email);
Need some help?
We all do sometimes. Get help now from the Twilio SendGrid Support Team.
Running into a coding hurdle? Lean on the wisdom of the crowd by browsing the SendGrid tag on Stack Overflow or visiting Twilio's Stack Overflow Collective.