Sending bulk emails in Node.js using SendGrid API Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report What is SendGrid API? SendGrid is a platform for sending transactional and marketing emails to the customers. It provides scalability, reliability, and deliverability which is an important issue for an organization.Benefits of using SendGrid API: If you are using Nodemailer with Gmail then you can send only certain amount of emails per day.Also, there is no need to set up your own SMTP server.SMTP doesn't provide the deliverability, i.e. email may or may not be sent. Steps to send emails using SendGrid API: Setting up an API key: Go to sendgrid dashboard and click on create api key button. Name the API-key as you want, for this tutorial we'll name it node-mail Copy the API-key as for security reasons you may not be able to see it again. Setting up a node.js app:Create an empty NPM package using the command. (The -y flag which is passed is used to use the defaults in the generator instead of asking questions) npm init -y Create a file named index.js and add a boiler plate code. index.js // Importing http library const http = require("http"); const PORT = 3000; // Defining PORT http.createServer((req, res) => { // Output Hello World on HTML page res.write("<h1>Hello World!</h1>"); res.end(); }) // Initializing server .listen(PORT,() => console.log(`Server running on PORT : ${PORT}`)); Now run the code by using node index command and go to 127.0.0.1:3000 link. You will see the output. And in console  Installing SendGrid library: Install the SendGrid library by running the below command npm i @sendgrid/mail Sending emails by using library: javascript const http = require("http"); const PORT = 3000; http.createServer((req, res) => { // Initializing sendgrid object const mailer = require("@sendgrid/mail"); // Insert your API key here mailer.setApiKey("<your-api-key>"); // Setting configurations const msg = { to: ["[email protected]", "[email protected]"], from: "[email protected]", subject: "Message sent for demo purpose", html: "<h1>New message from Geeksforgeeks</h1> <p>Some demo text from geeksforgeeks.</p> " }; // Sending mail mailer.send(msg, function(err, json) { if (err) { console.log(err); // Writing error message res.write("Can't send message sent"); } else { // Writing success message res.write("Message sent"); } }); res.end(); }) .listen(PORT, () => console.log(`Server running on PORT : ${PORT}`)); Now run the app again by using node index and go to 127.0.0.1:3000 in the browser and check both of your emails, you'll see an output like below. Comment More infoAdvertise with us Next Article Sending bulk emails in Node.js using SendGrid API F frikishaan Follow Improve Article Tags : Technical Scripter Web Technologies Node.js Node.js-Misc Similar Reads How to Send Email using Mailgun API in Node.js ? Sending an email is an essential part of any project and it can be achieved by using Mailgun API. It is very popular for sending emails. Features of Mailgun: . It is easy to get started and easy to use.It is a widely used and popular module for sending emails.Mails can also be scheduled. Installati 2 min read Sending bulk SMS in Node.js using Twilio SMS is a common method of sending short messages between cell phones, but these SMS can be sent to multiple users at a time using Twilio notify service. Sending bulk SMS to users at a time is possible using Twilio. Introduction: It's easy to get started and easy to use. It is widely used for sending 2 min read How to send Attachments and Email using nodemailer in Node.js ? For this purpose, we will use a package called nodemailer. It is a module that makes email sending pretty easy. For using it, you will need to install by using the following command: $ npm install nodemailer Features of nodemailer module: It has zero dependencies and heavy security.You can use it 2 min read How to Send Email using NodeJS? Sending emails programmatically is a common requirement in many applications, especially for user notifications, order confirmations, password resets, and newsletters. In this article, we will learn how to build a simple email-sending system using NodeJS. We will use Nodemailer, a popular module for 5 min read Node.js Server Side Rendering (SSR) using EJS Server-side rendering (SSR) is a popular technique for rendering a normally client-side-only single-page app (SPA) on the server and then sending a fully rendered page to the client. The client's JavaScript bundle can then take over and the SPA can operate as normal. SSR technique is helpful in situ 3 min read Like