{"id":962,"date":"2022-05-31T11:51:24","date_gmt":"2022-05-31T11:51:24","guid":{"rendered":"https:\/\/www.workfall.com\/learning\/blog\/?p=962"},"modified":"2025-10-06T07:15:29","modified_gmt":"2025-10-06T07:15:29","slug":"how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application","status":"publish","type":"post","link":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/","title":{"rendered":"How to send customized emails by integrating SendGrid with a Node.js application?"},"content":{"rendered":"<span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">10<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span>\n<p><img src=\"https:\/\/lh3.googleusercontent.com\/lSsHd2VH_LFrA98etOthHrYcM8B9_rVNYust-4mEIBSiTxk_AOhwaJbt62eBG22-m3TygCwRAMpg2q8SaYATeb_TEs_0S8KdyujhbbGeZHUSPnnh8hbBY-c1MKeBSHTnswZFbQuWEV6C7xR4-A\" style=\"width: 1600px;\"><\/p>\n\n\n\n<p class=\"has-text-align-justify\">Email is still one of the most popular forms of textual communication, particularly among corporations for notifications, outreach, etc. through their business product. SendGrid is one of the most widely used email APIs to integrate email services into business products. SendGrid makes it simple to send welcome emails, password reset emails, communication updates, and other types of emails, as well as new product feature announcements. In the transactional email space, SendGrid is probably the industry leader. In this blog, we will do a small implementation on how to integrate and configure SendGrid API with a <a href=\"https:\/\/www.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/\">Node.js<\/a> application.<\/p>\n\n\n\n<p>In this blog we will cover:<\/p>\n\n\n\n<ul><li>What is SendGrid API?<\/li><li>Benefits of using SendGrid API<\/li><li>Why choose SendGrid over other solutions to send emails&nbsp;<\/li><li>Popularity of SendGrid API<\/li><li>Hands-on<\/li><li>Conclusion<\/li><\/ul>\n\n\n\n<h2>What is SendGrid API?&nbsp;<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/0mlSrawG_w7i5TC360RbM_PS6kMe6_-9lQQJSKAKrx1PBgv9CVj6wtneSaWHohtg7dxnQFJ5gfdmsgrYyaK3QreuCSROHU1mtTBxj0H7apOEuJOYMyg0jzQasfrHtcGFaaQNSIRLqw3tKFrDOQ\" alt=\"What is SendGrid API?\u00a0\"\/><\/figure>\n\n\n\n<p><strong><em>The Email API by developers, for developers!<\/em><\/strong><\/p>\n\n\n\n<p class=\"has-text-align-justify\">SendGrid is a service that allows businesses to send transactional and marketing emails to their consumers. It offers scalability, dependability, and deliverability, all of which are critical for any business.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">In the transactional email space, SendGrid is arguably the industry leader. It is a cloud-based email service provider. A popular email service provider that provides services for sending, receiving, tracking, and storing emails. Many developers use SendGrid to send emails from their Node.js applications.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">The SendGrid platform enables businesses to scale their infrastructure and provide high performance at a low cost, allowing them to scale their email delivery to clients through the cloud.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">Over 30 million businesses throughout the world have been assisted by SendGrid in enhancing their customer relationships by offering tools that include transactional emails, SMS messages, and marketing automation.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">SendGrid provides over 700 open-source projects and over 100 Fortune 500 companies with web, mobile, API, integration, and services.<\/p>\n\n\n\n<p>Benefits of using SendGrid API<\/p>\n\n\n\n<ul><li>You can only send a specific number of emails per day if you use Nodemailer with Gmail.<\/li><li>You also don&#8217;t have to set up your own SMTP server.<\/li><li>SMTP does not guarantee delivery, which means that emails may or may not be sent.<\/li><\/ul>\n\n\n\n<h2>Why choose SendGrid over other solutions to send emails?<\/h2>\n\n\n\n<p>Any programming language, including Node.js, may send emails in a variety of ways. For example, we could use software like Nodemailer, which supports several means of transport such as SMTP, Sendmail, and even Amazon SES.<\/p>\n\n\n\n<p>The issue with using an arbitrary SMTP or Sendmail server is that the emails would almost certainly be categorized as spam and end up in our clients&#8217; rubbish folders. This is not something we want to happen.<br><br>Here are a few benefits that you get by using SendGrid:<\/p>\n\n\n\n<ul><li>Send mass emails with excellent deliverability rates using this powerful email service.<\/li><li>Provides built-in email templates that are interactive and eye-catching, as well as the ability to change them.<\/li><li>You can track the real-time performance of emails with SendGrid by looking at metrics such as bounce rates, unsubscribers, delivered emails rate, unique reads\/opens\/clicks, and more.<\/li><li>Excellent client service<\/li><li>Sendgrid has so many technologies integrated that it allows you to centralize your marketing activities. The integration of the API with the various tools is really powerful.<\/li><\/ul>\n\n\n\n<h2>Popularity of SendGrid API<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/76SnlFuakcUJpLKAYRoQcGKBCIIouzoWVSpCsJLDD11wNh-H-zg2upHeyztzgAGNk6kJSvhZ6Z5akQS-UnnCAb0wto_iwtNEsS99SJmRikSQc_0SDPrdmt7Hx1Ap4AwuWopC7ZQwljAXFRB9wQ\" alt=\"Popularity of SendGrid API\"\/><\/figure>\n\n\n\n<h2>Hands-on<\/h2>\n\n\n\n<h3><strong>Required Installations<\/strong><\/h3>\n\n\n\n<ul><li><strong>Node.js: <\/strong>It is an open-source server environment that acts as a backend allowing us to run JavaScript on the server to execute the JavaScript code outside the web browser.<\/li><\/ul>\n\n\n\n<ul><li><strong>Express.js: <\/strong>It is also known as Express and plays the role of being a backend web application framework for Node.js for building web applications and APIs.<\/li><\/ul>\n\n\n\n<ul><li><strong>Git Bash: <\/strong>It is a Linux-based version source control management system for Windows that provides us with the flexibility to type in different git commands.<\/li><\/ul>\n\n\n\n<ul><li><strong>SendGrid: <\/strong>It is a customer communication platform that can be easily integrated with different web applications for sending out bulk transactional and marketing emails to the target audiences.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/EcOG4_IVkxujE-jRXlpSuUhAtV1WBoyb66BdJwketQ4RCRKRmfdBo_WvAGjNweUWBepCBJuc0H-yFWtTDtpQgGYht1Vd6cbIK7pOktd_yB-52Ijbk7dry_BHXRQwMWo6DHov1ytNKQ2-wZCsdw\" alt=\"SendGrid API\"\/><\/figure>\n\n\n\n<h3><strong>Now let\u2019s begin with a small implementation\u2026<\/strong><\/h3>\n\n\n\n<ul><li>Considering a use case wherein the team of Workfall is currently facing challenges to use the most trustworthy, cost-effective, flexible, smooth, and efficient API to send the Partner emails to the required target audiences. To eliminate the process of sending the partner emails manually, they wish to automate the process making it easy for the team to focus on other important tasks. The team finally decides to proceed with the SendGrid API and build a Node.js application to send emails on hitting the URL to automate the mail-sending process.<\/li><\/ul>\n\n\n\n<ul><li>To do the same, we will create a SendGrid account followed by creating a sender&#8217;s identity and an API key to integrate it within the application. We will then set up the code base building a node.js application integrating the SendGrid account to the application using the Access Key. To test out the connection, we will send a test email and on success, we will make the required changes in the code base followed by triggering the application on hitting the URL via the postman application to automate the process of sending the partner emails to the target audiences.<\/li><\/ul>\n\n\n\n<p>Navigate to the official site of SendGrid. Click on Start for Free.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/bNV2YmnyshExZtDTasX1VE_gQGhiA5gQqJP6vINVekgzOJyGMYiOouN39yItVJ0wNCJ1Q16EwSx7q8TeG4BNd-0V5IWQMK3wGJ2sYCMjYH_Kwz7DElVjXbH_mODrViFTFk7BAFpE1Avh4-9Seg\" alt=\"How to send customized emails by integrating SendGrid with a Node.js application?\"\/><\/figure>\n\n\n\n<p>Entire an email address and a password for the account and click on Create Account.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/7xZRaNGEvpK12hEEN5RVr4QbUt3zDX3OusoPS3eKXXXZ3CRq-90cEY3FVwcb-xVRR5MUSkm9PovO-1HkDiD9gnHcIhvl2Vo0-QfG19Y3t9eBFC8DnMhcO5BOvLlny5KLNlY9eeCCpGGRjeYTVw\" alt=\"How to send customized emails by integrating SendGrid with a Node.js application?\"\/><\/figure>\n\n\n\n<p>Before proceeding, you will have to fill in the details and click on Create Account.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/eJwDMgAdG8w89Hkz5Ql3E_iHnG2VvoWxZI0UPtMH27xrTZHnJSKncXbsmMWWQYCuPh1E5RPy4kqWEUrEhu4EFPZlu_q1pIBR43GGVzLmfDCrhr7fpGu4FsvWvml7FlC_ar4-7QUIj8hbSb267Q\" alt=\"\"\/><\/figure>\n\n\n\n<p>On the main Dashboard, click on the Setup Guide.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/TeSP2S74NewX5FXs5HCCbK4ZopeuZCs5QWBwmpLAfiumTwrxilHy1Qwi9I3_raMQ6HeAveUsyEGPba83o3KFe--RHWh4wUDnV4L91Nq5kKzJAELIbXlFUKniHa1qlxGEU1CYbvj2q4uv28v9aQ\" alt=\"How to send customized emails by integrating SendGrid with a Node.js application?\"\/><\/figure>\n\n\n\n<p>Expand the create a sender identity. Click on sender authentication.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/t0uwT_6eCVEH4jLls2HVXszblU4skrHJc12zoqlCb9n86YjAdh5xJQosZsmjS1YaJRkG8dPf-31hNhJ7oo5bfoAjoSf8VeS9MCcOXHB8qdeaKZQ7Et8FJMdkhOXHoANPL9YFz647S0PsaoD-Ug\" alt=\"\"\/><\/figure>\n\n\n\n<p>Create a new Sender to create a newly verified identity. Click on create and verify the identity.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/o2Rburbq56Ur8RGyqNP2OmtYj0opFgS-eIKpQ2ib8rAq-q26vQkvRZ9LHGXt4m6VnyKMSMtEaqAhHS0ywU4nXxsnPlp8Bqgtvhv4ih5XY36UpTrpf9B5m8XezFkieOmiAH78U-Wqu8I1mV3M7g\" alt=\"How to send customized emails by integrating SendGrid with a Node.js application?\"\/><\/figure>\n\n\n\n<p>On the web page, click on choose below Web API.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/KGspf6t_u4cXSDswqEo7dQhe7cfbAZbXr6qYsSsHh_N920CQyUxkf7BUh3i3mA-iS0XblATZRm1by4HsxOOv6iLTyxIx9hLz-gVi7UVYGWCkD53if24YrNuAWKY7LvvvYEIQzOCbMjgAqmvDyg\" alt=\"How to send customized emails by integrating SendGrid with a Node.js application?\"\/><\/figure>\n\n\n\n<p>Click on choose besides Node.js.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/hIK-IlJQqXmXKxfivFD4YeceBHx2gaJmNuARxkuxgm6g8Bp549tUy8unJGhiUdZRQHdVx2YjYKZ8bSVnI0y9fqTcXvYMT_Bj1QxGfn_iw10xIMy6b4cxNA5ERw2S-GbEnRAgU7-urEm_VX9ktA\" alt=\"How to send customized emails by integrating SendGrid with a Node.js application?\"\/><\/figure>\n\n\n\n<p>Enter a name for the API key Workfall-Email-Sender-Key. Click on Create Key.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/p9Ga4_0ucLifNNbrP4Io_5yRbZsEXgf2TbqG2Gc-vQQsniuRoaWM7dUvNlfaJtva2eeb7gkUCzmvM9KyLEablddaln4YdbcooX7NSqf3Kr2t9nb9wDzlE0DHaY9pfVDWsipS2NkRNPatvb5QKg\" alt=\"\"\/><\/figure>\n\n\n\n<p>On success, you will see the screen as shown below with the newly created API key.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/PzwBBz8zmsjALKAJu-roofzPcGTzhlcGpBe_20iCzmtNCs9lgCu8OGAwPzYfBDJLtm0D7B1eaBaBpVcz-zSMCpjbtekVA_PGegGWFzAnLqt2A-IEaewWAuLZeQdFZE3FrV-PwyRPbUyCaGNHrg\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">You can note the further steps to create a simple mail sender API and the steps to install the same.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/8F9S7En9jDvd0AqFA9ipUazW9wwNQX-hab1fx1kga9aQk4yiKwQGhDbPlQqmKvRY-WmHG4nC9uzg_UAXCjvzwG8uCpIeSEI-yQ_f4to5Izlb_9SpbiROE8yXcP-YUCfWZibGzKbz3EWIpb2KOA\" alt=\"How to send customized emails by integrating SendGrid with a Node.js application?\"\/><\/figure>\n\n\n\n<p>Lastly, once integrated, we can test the integration.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/GpwhyOfYpb7yE77R_zHx_Vy-nq7sgGozW1ZYloPscQXbh5eXho44vDlwF-PJrff0GN_0ScOSGP0w6JB9QSdyt-WoJ3UEj0MDoE8-_F8smmlMeHMFi7gzVqoKNXS-zE0ahjNobs0cpDn2l9yr7w\" alt=\"\"\/><\/figure>\n\n\n\n<p>Create a new folder on your local machine.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/EjpCdi-UAl8pKyHcTo7cuw2g2hy-ZhoKu7TEhyVU3-G6R-4IOHwXfeeeA467lfiDimfn86ONyyG8eWEXnIiJPyltzxJvpt9uf3DMyHMs6s3PjqgjudTMvQQYDKehxhtLI30-dBDCQoBmyjfGdg\" alt=\"\"\/><\/figure>\n\n\n\n<p>Right-click and select Git Bash Here.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/xD5nE8JIZTLlBx1LQ_507aGGjFojdfrzN1uVXEvypihae6_ouZAhDR3tYf1Kr3Hlth8Vjq-46vpFCO1SoL7dOdLJhRllqJj-nS8hYCULDmr2UBiCzN2MaInUnjL6GXvEb5NOEJfK3vfNUgDh9w\" alt=\"How to send customized emails by integrating SendGrid with a Node.js application?\"\/><\/figure>\n\n\n\n<p>Run the below command to initiate a directory.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/gXZoVVfhCaIf7rY2qxgLWDED31IO_qw8fZRBmTCiB_iUGP-f9icvSuLyxmvt3z_pOcjE1FG1Hzn0RNy7XICQ64wSLLd-98WLQ5xk-gQHJB7p0rZqrZI0ZAgwZu7L2fTAAgINAOxrDXCDDudApw\" alt=\"\"\/><\/figure>\n\n\n\n<p>A new package.json file will be created.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/RYZe9VdQwAmxhPpWPGLOT9Jw8PFD7umpREMIvfiXcTaAxHllUDJFurNjYAcRLkWk6fzMqmld-lcSQ_mp3SPMDlW6oZYbf9x64yAHS6Kedu0W_zKmTI30HkqCNNSIILU7SM5RiaB0go_yl4HKzw\" alt=\"\"\/><\/figure>\n\n\n\n<p>Use the below command to install express and SendGrid mailer packages.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/_AGY6ze1mSdq7AbGIp3R_e8rr_8B-tMoWlzeH9uCZtlpJHEsdbbHM4NO2eICu_MrtsbO28dP-g1dPonawnxPfooxLOvd0V1hBXpLUIhs804zX-CHA6smR-5qR4WZGgw7-lmNVDmDTvuLxH5XaQ\" alt=\"\"\/><\/figure>\n\n\n\n<p>On success, you will see the screen as shown below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/R1MObscVrgiBNlckIBSG8ACIAaIpntUUajPcvZ5vrIOvwPPoGxkyMsAry-xLaBBYgbH2PjrHuW5vCur26sT5hltv9UHjU_pc-Hk5MJsS3JGQsW9pzamkzqfhgPQJyZA6SlxyjaoxRvLhdlv4DA\" alt=\"How to send customized emails by integrating SendGrid with a Node.js application?\"\/><\/figure>\n\n\n\n<p>The new files will be created as required with the node_modules directory installed.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/1fC8csJirldZf1OJcYc6_xCHLX_-F-jLAa2W3rcI91KYD4haaJ6PO_HJiUJ5xaWW4QfXY4VQJi4q50msNRF2mOwVpTeWYuDa7w9zgXUAT4B6zxQ-z0XzuJlQdf658ULa17_7Kp1nJzn84ImPyQ\" alt=\"\"\/><\/figure>\n\n\n\n<p>Open the directory in a code editor.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/An1q_J8pei_Ksd4oS6JRa9KyW9OvIYSc63aXEFmPQh4LcFLiiZplcBFmesu2GH0udAfs2haXol3PfIeWUiGGYzYNeYq38fP_-Eu9VVWmM8dsF-ECdHGJQ9LA752Rp-vXXPvi1VMzCYZOKN2r0A\" alt=\"\"\/><\/figure>\n\n\n\n<p>Check the package.json file to verify the package installations.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/6IoMhl-_I0Ws5-0ALfSfkyNw_LVh0-VVxg2XXdCv_XFHi47hfZg4CFTKD0O8eaeOuW9bufAo5USjK2A_OmEkoqxmlxkPrZhTgLXDPPSzTSrUydtzZ9MlQW0841vEpmKEF_xPdu_sko8EbDuwxA\" alt=\"\"\/><\/figure>\n\n\n\n<p>Create a new file with the name app.js in the folder structure.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/S6mSOxYxKmiAnlJsRCU8v3sLfRL83dgkVtmahsYtav31XE3eWgbAsuiPnSq3uXWlE08XDf5EEYHCz-mLSX4_7DVgrCwpXyHb18eJbbirl_Ob7W0OOHVvm5S27uYBvDXxJ79_pJeyctswLbBryw\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">Paste the below code into the app.js file. This is the server file that imports express and starts the server on port 3000.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/_9r240QRJK1pfgO23Dhv-PkAmHlx1FMtRZDQXzjx_m-F2UshEeEjopzF8cbcoF6_rZXr4EXlHXqlJe7kkHbEONCPHU4N5KCH2DIoBO7ZF-mzDfbMXFxK0mo_kdedBWRHMzxohyDh0XffI6B2VQ\" alt=\"\"\/><\/figure>\n\n\n\n<p>Run the following command to start the node.js app.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/7ymAKgkswS7HGm4M8ffGKgYRGEBW8K8RtNUao4aOQnflnUc8OD5AAVB-pZF6ULqRjtNlEuoqYdhXpWdv7HlPzzG3-p2EGkAK_ZlGCRPST1xKpiTN-rexnrzi4O3hNEP_ss_5ib-T4CkjdMhJyg\" alt=\"\"\/><\/figure>\n\n\n\n<p>Verify if the server is up and running on port 3000.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/vGMl2VIn3sEQrYGrqR66ThsFA2lmW9KS5tvzAZkWDBYs0fJhXW3N8JcLFMqy-oMgYGGwLfG-K_a_tBYiegigpD00Cptw1B02eDC4VY3-ziTygK3VpdutcWKBz1cfdPJep-WRvdwKoUurKsm-2g\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">Create a new folder with the name templates that will contain the template of the email to be sent. Create a new file emailTemplate.js with the code of the body and the subject of the email.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/cNRL2V9MadkHsTCS_Oybg5TX9nm0VSphRAY-ICe3M7bzXjsUX6kM_7DlLeAFks17tnJdQuVmr-ha5EJ8idNIgXGqU0q_nLoGZxadXOA3eosS5wuLuJ4Cou_rGXdxMVQlml-7lF03P7weeMEwkA\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">The below code will import the SendGrid package using the Access Key that we created above. It will contain a function to send an email as per required and will export the same function to the file that will give it a call. In place of ACCESS_KEY, enter the key that we created above. In place of receivers&#8217; and senders&#8217; email addresses, enter in the email of the verified identities. You can then replace the subject and the body of the email as required.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/SThc7wsPSeWaNuOo8wQdxCZRlpdrVIgst0BSn0awxK1FHrzXzwKHL2UdsSS0T8MziySJJWA0-1heP1qZxyLrUvP-8uiqqXz5lSAjMkbkkSPxQKW4xRYzQf0NxlG-JxNOyjFiyDQ64XGq0pTfJg\" alt=\"How to send customized emails by integrating SendGrid with a Node.js application?\"\/><\/figure>\n\n\n\n<p>Now, we will create a route file sendAnEmail.js that will trigger the function sendMail in the emailTemplate.js file.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/Z_vLDavJu27Lae6ROqt4rTBI0QHMej0Rk0OC0sXtK7sXCJsupGwBTSBF4hRDsKAgz3bwLrh6vDDuYhHhI0epUzKq41YCV0LlkkA7fAI5g7Q-DXX1vt7wt7PHRzC9CKs0F_2b7svhGFaj49EWkA\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">The below code will import the express library, and create a new route to hit the URL on sendAnEmail thereby calling the sendMail function. The user variable will take input of the email and name of the user. On success, it will print the message on the console and if there&#8217;s an error, it will catch the error and print it.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/EWI5LsNVe5TwfDtLBO6h_Nj-LxF1jSbDsfmW-jmqaVXIiuzKpsytu7G0qa4DqsUWHVPiLqzz6pXAnG9QdE8DvRYbxOarflFCrtCtHWYS4S2JjsARGcwkZwc665yo9XkQ7ezlFRsPGxmW-DCvVg\" alt=\"How to send customized emails by integrating SendGrid with a Node.js application?\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">Now, navigate to the app.js file and import the route that we created above. We will use that route so that when the server is started, hitting the URL will trigger the route to call the sendMail function.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/m8EjufPj8P986LVvCq0u3lexpJRV71MysASWgyzd0C63gXLNrO219RI5ddVCH6M_61jF-jAVS9qdjrCB9PaPQlBfVvqLFoCnjGJKzWDrlAND-2qKF-r_tn_d4xgzgNhonoYJCNS06pdqrjPVOg\" alt=\"\"\/><\/figure>\n\n\n\n<p>Now initiate the below command to trigger the node application.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/XuTMrjPd0_mkux4TRsyHIw46aFlwikxjYxPeCVXUDW0y2Xb7tJISCeUv-awVNuGOv46wTNI_Zr8DI__cb9VzcQ8mhhqleUaXiDx1hpG2FXvNFDQYy7FlcdYWcGHI0POeUZ0s_maidEc1mlVOXQ\" alt=\"\"\/><\/figure>\n\n\n\n<p>On success, the server will be up and running on port 3000.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/F0r63KgHRmcx2m5yqEEN6hiHmWf4gtZ1-5406FddkI1R4niKDXEfjLPITl2Qrqt6lz_mlPgyVX65vzwFJKFVOQFk1MUWhcs_0pH7vHg1ua24NK94Te_Y6m9OdYZ4IGzJlBhjl-n_kIPCqvzFEA\" alt=\"\"\/><\/figure>\n\n\n\n<p>Hit the URL on the API sendAnEmail using the below URL to trigger the mailer application.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/DuI5eOOiMQ1lEF3GxPNLdre45ALDMTE0iuznfQimBoTdVNnFakoSqmMSbrlhsu72RFb8feJCW2vQaVzSwuuRIKAngcnxszbedPGPWo4Fo3W_HTHbKGdnvWxAOLELGlEMnqZGSA21M5Ea2t2yew\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">On success, you will see the Email successfully sent the message as shown in the image below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/aMTv1mCCZ5wM2MvbacDOiw_YzAHu6j7lwE4xdxLOAPXvIciGpSEBmcuoziJ7dITUE6JtUJn8zuJBBkQ88AK7xrCVdrBQ5XRxEXLzTRYIFB5YFEP2x9lGzFBDS3CFOGuIn63oxlEYr3SQNsR81w\" alt=\"\"\/><\/figure>\n\n\n\n<p>You can then navigate to your mail account and check the received email. This will be the subject of the mailer.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/lIwZON-ys4fGAC7EVvjHI7Shwv1FfItffAh-kNdJx0tZwbX6BNFN1P2RBszCCZuF1zLDIWMbvDj01UkZg0Mf3r7FfQzsVlKtlcnkNciqkkUzgBdut1ZzF7lWMpufzYsJXxowVumtoYom25xkvQ\" alt=\"\"\/><\/figure>\n\n\n\n<p>The following will be the body of the mail.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/aA0pYaTFqHMosgFLsb_VpG2bcjf0qjSeyQ-m2BVqQKSsnrvnQJdq8UuqGkDmfrk2dXuxQzUOc_mjrMZBzWrJODtiaKi3NRR88DxaSQU9SAM0W0csY9Jecys9o3KTyh5SIhcS0oMGsRWT_JwSpw\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">Now we&#8217;ll see how we can integrate and send an HTML email body rather than a normal text body. To do so, make the following changes as shown in the image below for the sendMail function.<\/p>\n\n\n\n<p><img loading=\"lazy\" src=\"https:\/\/lh6.googleusercontent.com\/W_0CG1Ck0xoY-5itSbIuIrS17P7Ptkq9VS7MljIjo9owjfQVLOFxNu5IjL03gv9kpSpQ6REQ85CBcicsgv6hK61mY_uS1pMPzx5kd0gMQblgr2Y8_9ygwxcldJkmCXexAevMgw6tZUf85K3xfA\" width=\"1920\" height=\"1080\"><\/p>\n\n\n\n<p>Open the sendAnEmail.js router file and make the required changes for success and error messages.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/_vDH4Y9_BxLOrNjlhFhHlTsg8LcRU-IkkxQlfdwxIyDRfp5cDKtHGAdebbXhZfRS4eTe1UY-6XbQwAfLDKtTTbJsUNxyQcrDDOnslBjRDJaP80DqNdlQti-cJKqQt96YmlOQpX9-EjsHBzX1Og\" alt=\"How to send customized emails by integrating SendGrid with a Node.js application?\"\/><\/figure>\n\n\n\n<p>Run the below command to start the server.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/FctH2J3qz4li6vJZv3_d-t0pbvwC8ycT6MyEWLNWoz9BYARH4RDieg1jw81V1DWimTZTck3Q16i8w_wL-rJkLmO775ec0ByHERNCWXUMOIqq2BeSZwvxsyVhRJZMft03oJ-SD3NN2ANl-8whBQ\" alt=\"\"\/><\/figure>\n\n\n\n<p>On success, the server will be running on port 3000 successfully.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/fNwhTjNomUulFOll5LbqIU89abF9l_r8iZAgjajPtzzqbmw6CsKrIFBYO44ZGZ2nxlJukGQQzZFZ9nLnZYiNi76orFh-sg4SmCfR6C3Jff49nbK55lL_ccWkt1CdQrOfkC4KZmyD_GdosImIHQ\" alt=\"\"\/><\/figure>\n\n\n\n<p>Now, open the Postman application. To send API request. Click on the plus icon.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/wd05AXc-xr5CLx_V42O1naOPoDglpyfYt7tuDdbhQUe6Uy9coc8mlNyqPSd68HqrBalqdL1mHhJKIOGa01OW1S2O_XT4xGlpH4Qz2_e-_H5NQvMkbvN8cDzRT8QIyT3QRz50MgzmyxXkncD4vQ\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">Enter the URL as <a href=\"http:\/\/localhost:3000\/sendAnEmail\">http:\/\/localhost:3000\/sendAnEmail<\/a> to trigger the API to send an email. Now click on the Body section below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh3.googleusercontent.com\/A0E7qlsSwvKaRr233wXMimoRjCVqergqYeLGWBAAB5e70PMPmCXJQexHlcLgW23vzx1jG01EQGT1IsaRzKLE8fk6RtNpzYQ-6oytsf5TcqVfAkuTm72ZQg4N-FlkK_s1hu_lznBYOWPmbt04ZQ\" alt=\"How to send customized emails by integrating SendGrid with a Node.js application?\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-justify\">In the editor area, click key-value pairs for name and email. Configure the email that is a verified identity in your SendGrid account and the name as required.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/hXAZ3bjkTWQ288_M6nVGTS6w9DEa0ttaDHh-gulEZe8Thbxv_3R7MDOVPlaCkxnk_8kvVJR7NWsu8_V2NbtR1O5sCO0z3u3xLwUrtLKv3pTrPyAaYGsddhQpCjrEn6oJnB2zKqd-18sfW7AGgg\" alt=\"\"\/><\/figure>\n\n\n\n<p>Click on the type and change the type to JSON. Once done, hit Send.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh4.googleusercontent.com\/MSqkKMFqnsL_3KJE1cfpywBJQras1tOXuTmr7EbskEyfyS9wxVJ44r7FhPrt3yi5LleseMYHgT_zl7Kn0Qaz163gMxw4NFtfg8izSsz-NNH25muBZEy6UtpP5GqoLITfNEV9rpWgBktT5dOJjw\" alt=\"\"\/><\/figure>\n\n\n\n<p>On success, you will see the success message as shown in the image below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh5.googleusercontent.com\/tOFQeB46o6zLqtrj5IltofuVx2EtAf_95UsTmZDUAuXyKPcc0OFB_p2rVYjWzp-mXgL6zLwYqzKyg4_ivJrejoVvwIHqfbDhY92P1KuF73QA_S5CfAHFTM8ye6mXDgfMbwk_R9Q5TSFeBMDbag\" alt=\"\"\/><\/figure>\n\n\n\n<p>On success, you will see the email received in your mailbox as per the designed template.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/lh6.googleusercontent.com\/sTLuJohMU41sOiGVLYejhpET4lye_Z05m6F8S1pq1P4rEOqniw05o3xtATeASpW-itMZqvxFIumLvF5yDL8mWkDUbInCP306k1PqfVycfRQ106dEJtMcBaDSxnsijhOe4NauBLTN-vqGgYH-jQ\" alt=\"How to send customized emails by integrating SendGrid with a Node.js application?\"\/><\/figure>\n\n\n\n<p>To clone the code repository, use the link with the git clone command in a directory on your local machine: <a href=\"https:\/\/github.com\/workfall\/SendGrid-Code.git\">https:\/\/github.com\/workfall\/SendGrid-Code.git<\/a><\/p>\n\n\n\n<h2>Conclusion<\/h2>\n\n\n\n<p class=\"has-text-align-justify\">In this blog, we have integrated and configured SendGrid API with the Node.js application. In hands-on, we implemented a solution to resolve a use case for automating the process of sending out emails to the target audiences of Workfall.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">To do the same, we created a SendGrid account followed by creating a sender&#8217;s identity and an API key to integrate it within the application. We then created a setup for the code base building a Node.js application integrating the SendGrid account to the application using the Access Key.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">To test out the connection, we sent out a test email, and with success, we made the required changes in the code base followed by triggering the application on hitting the URL via the Postman application to automate the process of sending out the partner emails to the target audiences.<\/p>\n\n\n\n<p class=\"has-text-align-justify\">We will come up with more such use cases in our upcoming blogs. Stay tuned to keep getting all updates about our upcoming new blogs on different technologies.<\/p>\n\n\n\n<p>Meanwhile\u2026<\/p>\n\n\n\n<p><strong>Keep Exploring -&gt; Keep Learning -&gt; Keep Mastering<\/strong><\/p>\n\n\n\n<p class=\"has-text-align-justify\">This blog is part of our effort towards building a knowledgeable and kick-ass tech community. At <a href=\"https:\/\/www.workfall.com\/\">Workfall<\/a>, we strive to provide the best tech and pay opportunities to AWS-certified talents. If you\u2019re looking to work with global clients, build kick-ass products while making big bucks doing so, give it a shot at <a href=\"https:\/\/www.workfall.com\/partner\/\">workfall.com\/partner<\/a> today.<\/p>\n\n\n\n<p><\/p>\n\n\n<style type=\"text\/css\"><\/style><section id='' \n                class='helpie-faq accordions faq-toggle open-first groupSettings-542__enabled' \n                data-collection='' \n                data-pagination='0' \n                data-search='0' \n                data-pagination-enabled='0'\n                role='region'\n                aria-label='FAQ Section'\n                aria-live='polite'><h3 class=\"collection-title\">Frequently Asked Questions:<\/h3><article class=\"accordion \"><div class='helpie-faq-row'><div class='helpie-faq-col helpie-faq-col-12' ><ul><li class=\"accordion__item \"><div class=\"accordion__header \" \r\n                id=\"accordion-header-post-3125\"\r\n                role=\"button\"\r\n                aria-expanded=\"false\"\r\n                aria-controls=\"accordion-content-post-3125\"\r\n                data-id=\"post-3125\" \r\n                data-item=\"hfaq-post-3125\" \r\n                style=\"background:transparent;\" \r\n                data-tags=\"\"\r\n                tabindex=\"0\"><div class=\"accordion__title\">Q. What is SendGrid and why is it used?<\/div><\/div><div id=\"accordion-content-post-3125\" \r\n                class=\"accordion__body\" \r\n                role=\"region\"\r\n                aria-labelledby=\"accordion-header-post-3125\"\r\n                style=\"background:transparent;\"><p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">10<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span><span style=\"font-weight: 400\">\u00a0SendGrid is a cloud-based email delivery service used for sending transactional, marketing, and customized emails reliably via APIs or SMTP.<\/span><\/p>\n<\/div><\/li><li class=\"accordion__item \"><div class=\"accordion__header \" \r\n                id=\"accordion-header-post-3126\"\r\n                role=\"button\"\r\n                aria-expanded=\"false\"\r\n                aria-controls=\"accordion-content-post-3126\"\r\n                data-id=\"post-3126\" \r\n                data-item=\"hfaq-post-3126\" \r\n                style=\"background:transparent;\" \r\n                data-tags=\"\"\r\n                tabindex=\"0\"><div class=\"accordion__title\">Q. How do you integrate SendGrid with Node.js?<\/div><\/div><div id=\"accordion-content-post-3126\" \r\n                class=\"accordion__body\" \r\n                role=\"region\"\r\n                aria-labelledby=\"accordion-header-post-3126\"\r\n                style=\"background:transparent;\"><p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">10<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span><span style=\"font-weight: 400\">\u00a0Install the <\/span><span style=\"font-weight: 400\">@sendgrid\/mail<\/span><span style=\"font-weight: 400\"> package and configure it using your API key. Then, use the <\/span><span style=\"font-weight: 400\">send()<\/span><span style=\"font-weight: 400\"> method to send customized emails with HTML templates or attachments.<\/span><\/p>\n<\/div><\/li><li class=\"accordion__item \"><div class=\"accordion__header \" \r\n                id=\"accordion-header-post-3127\"\r\n                role=\"button\"\r\n                aria-expanded=\"false\"\r\n                aria-controls=\"accordion-content-post-3127\"\r\n                data-id=\"post-3127\" \r\n                data-item=\"hfaq-post-3127\" \r\n                style=\"background:transparent;\" \r\n                data-tags=\"\"\r\n                tabindex=\"0\"><div class=\"accordion__title\">Q. How do you secure SendGrid API keys in a Node.js app?<\/div><\/div><div id=\"accordion-content-post-3127\" \r\n                class=\"accordion__body\" \r\n                role=\"region\"\r\n                aria-labelledby=\"accordion-header-post-3127\"\r\n                style=\"background:transparent;\"><p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">10<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span><span style=\"font-weight: 400\">\u00a0Store API keys in environment variables (<\/span><span style=\"font-weight: 400\">process.env.SENDGRID_API_KEY<\/span><span style=\"font-weight: 400\">) and load them using <\/span><span style=\"font-weight: 400\">dotenv<\/span><span style=\"font-weight: 400\"> to prevent exposure in version control.<\/span><\/p>\n<\/div><\/li><li class=\"accordion__item \"><div class=\"accordion__header \" \r\n                id=\"accordion-header-post-3128\"\r\n                role=\"button\"\r\n                aria-expanded=\"false\"\r\n                aria-controls=\"accordion-content-post-3128\"\r\n                data-id=\"post-3128\" \r\n                data-item=\"hfaq-post-3128\" \r\n                style=\"background:transparent;\" \r\n                data-tags=\"\"\r\n                tabindex=\"0\"><div class=\"accordion__title\">Q. Can you send HTML templates using SendGrid in Node.js?<\/div><\/div><div id=\"accordion-content-post-3128\" \r\n                class=\"accordion__body\" \r\n                role=\"region\"\r\n                aria-labelledby=\"accordion-header-post-3128\"\r\n                style=\"background:transparent;\"><p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">10<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span><span style=\"font-weight: 400\">\u00a0Yes, you can include rich HTML content or even pre-designed SendGrid templates by specifying the <\/span><span style=\"font-weight: 400\">html<\/span><span style=\"font-weight: 400\"> property in the email object.<\/span><\/p>\n<\/div><\/li><li class=\"accordion__item \"><div class=\"accordion__header \" \r\n                id=\"accordion-header-post-3129\"\r\n                role=\"button\"\r\n                aria-expanded=\"false\"\r\n                aria-controls=\"accordion-content-post-3129\"\r\n                data-id=\"post-3129\" \r\n                data-item=\"hfaq-post-3129\" \r\n                style=\"background:transparent;\" \r\n                data-tags=\"\"\r\n                tabindex=\"0\"><div class=\"accordion__title\">Q. What are the common errors while sending emails via SendGrid?<\/div><\/div><div id=\"accordion-content-post-3129\" \r\n                class=\"accordion__body\" \r\n                role=\"region\"\r\n                aria-labelledby=\"accordion-header-post-3129\"\r\n                style=\"background:transparent;\"><p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">10<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span><span style=\"font-weight: 400\">\u00a0Common issues include incorrect API key permissions, exceeding rate limits, or invalid recipient addresses.<\/span><\/p>\n<\/div><\/li><\/ul><\/div><\/div><\/article><\/section>\n","protected":false},"excerpt":{"rendered":"<p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">10<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span> Email is still one of the most popular forms of textual communication, particularly among corporations for notifications, outreach, etc. through their business product. SendGrid is one of the most widely used email APIs to integrate email services into business products. SendGrid makes it simple to send welcome emails, password reset emails, communication updates, and other [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":963,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[288],"tags":[85,300,301,265,299,298,6],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to send customized emails by integrating SendGrid with a Node.js application? - The Workfall Blog<\/title>\n<meta name=\"description\" content=\"SendGrid is one of the most widely used email APIs to integrate email services into business products, &amp; is probably the industry leader.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to send customized emails by integrating SendGrid with a Node.js application? - The Workfall Blog\" \/>\n<meta property=\"og:description\" content=\"SendGrid is one of the most widely used email APIs to integrate email services into business products, &amp; is probably the industry leader.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/\" \/>\n<meta property=\"og:site_name\" content=\"The Workfall Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/workfall\" \/>\n<meta property=\"article:published_time\" content=\"2022-05-31T11:51:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-10-06T07:15:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/18-141-20-153.plesk.page\/learning\/blog\/wp-content\/uploads\/2022\/05\/Cover-Images_Part2-4.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@workfall\" \/>\n<meta name=\"twitter:site\" content=\"@workfall\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Workfall\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"19 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#organization\",\"name\":\"Workfall - Hire #Kickass Coders On Demand\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/\",\"sameAs\":[\"https:\/\/www.instagram.com\/workfall\/\",\"https:\/\/www.linkedin.com\/company\/workfall\/\",\"https:\/\/facebook.com\/workfall\",\"https:\/\/twitter.com\/workfall\"],\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400\",\"contentUrl\":\"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400\",\"width\":400,\"height\":400,\"caption\":\"Workfall - Hire #Kickass Coders On Demand\"},\"image\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#website\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/\",\"name\":\"The Workfall Blog\",\"description\":\"#Tech #Remote #Jobs\",\"publisher\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/learning.workfall.com\/learning\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/#primaryimage\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/05\/Cover-Images_Part2-4.png\",\"contentUrl\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/05\/Cover-Images_Part2-4.png\",\"width\":1200,\"height\":628,\"caption\":\"Send Customized emails by SendGrid\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/#webpage\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/\",\"name\":\"How to send customized emails by integrating SendGrid with a Node.js application? - The Workfall Blog\",\"isPartOf\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/#primaryimage\"},\"datePublished\":\"2022-05-31T11:51:24+00:00\",\"dateModified\":\"2025-10-06T07:15:29+00:00\",\"description\":\"SendGrid is one of the most widely used email APIs to integrate email services into business products, & is probably the industry leader.\",\"breadcrumb\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/learning.workfall.com\/learning\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to send customized emails by integrating SendGrid with a Node.js application?\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/#webpage\"},\"author\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a\"},\"headline\":\"How to send customized emails by integrating SendGrid with a Node.js application?\",\"datePublished\":\"2022-05-31T11:51:24+00:00\",\"dateModified\":\"2025-10-06T07:15:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/#webpage\"},\"wordCount\":1903,\"publisher\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/05\/Cover-Images_Part2-4.png\",\"keywords\":[\"api\",\"email\",\"expressjs\",\"node\",\"node.js\",\"sendgrid\",\"workfall\"],\"articleSection\":[\"Backend Development\"],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a\",\"name\":\"Workfall\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png\",\"contentUrl\":\"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png\",\"caption\":\"Workfall\"},\"sameAs\":[\"https:\/\/www.workfall.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to send customized emails by integrating SendGrid with a Node.js application? - The Workfall Blog","description":"SendGrid is one of the most widely used email APIs to integrate email services into business products, & is probably the industry leader.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/","og_locale":"en_US","og_type":"article","og_title":"How to send customized emails by integrating SendGrid with a Node.js application? - The Workfall Blog","og_description":"SendGrid is one of the most widely used email APIs to integrate email services into business products, & is probably the industry leader.","og_url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/","og_site_name":"The Workfall Blog","article_publisher":"https:\/\/facebook.com\/workfall","article_published_time":"2022-05-31T11:51:24+00:00","article_modified_time":"2025-10-06T07:15:29+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/18-141-20-153.plesk.page\/learning\/blog\/wp-content\/uploads\/2022\/05\/Cover-Images_Part2-4.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_creator":"@workfall","twitter_site":"@workfall","twitter_misc":{"Written by":"Workfall","Est. reading time":"19 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Organization","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#organization","name":"Workfall - Hire #Kickass Coders On Demand","url":"https:\/\/learning.workfall.com\/learning\/blog\/","sameAs":["https:\/\/www.instagram.com\/workfall\/","https:\/\/www.linkedin.com\/company\/workfall\/","https:\/\/facebook.com\/workfall","https:\/\/twitter.com\/workfall"],"logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400","contentUrl":"https:\/\/i1.wp.com\/18.141.20.153\/learning\/blog\/wp-content\/uploads\/2021\/10\/cropped-WF_logo.png?fit=400%2C400","width":400,"height":400,"caption":"Workfall - Hire #Kickass Coders On Demand"},"image":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/logo\/image\/"}},{"@type":"WebSite","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#website","url":"https:\/\/learning.workfall.com\/learning\/blog\/","name":"The Workfall Blog","description":"#Tech #Remote #Jobs","publisher":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/learning.workfall.com\/learning\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/#primaryimage","url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/05\/Cover-Images_Part2-4.png","contentUrl":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/05\/Cover-Images_Part2-4.png","width":1200,"height":628,"caption":"Send Customized emails by SendGrid"},{"@type":"WebPage","@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/#webpage","url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/","name":"How to send customized emails by integrating SendGrid with a Node.js application? - The Workfall Blog","isPartOf":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/#primaryimage"},"datePublished":"2022-05-31T11:51:24+00:00","dateModified":"2025-10-06T07:15:29+00:00","description":"SendGrid is one of the most widely used email APIs to integrate email services into business products, & is probably the industry leader.","breadcrumb":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/learning.workfall.com\/learning\/blog\/"},{"@type":"ListItem","position":2,"name":"How to send customized emails by integrating SendGrid with a Node.js application?"}]},{"@type":"Article","@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/#article","isPartOf":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/#webpage"},"author":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a"},"headline":"How to send customized emails by integrating SendGrid with a Node.js application?","datePublished":"2022-05-31T11:51:24+00:00","dateModified":"2025-10-06T07:15:29+00:00","mainEntityOfPage":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/#webpage"},"wordCount":1903,"publisher":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/#organization"},"image":{"@id":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-send-customized-emails-by-integrating-sendgrid-with-a-node-js-application\/#primaryimage"},"thumbnailUrl":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/05\/Cover-Images_Part2-4.png","keywords":["api","email","expressjs","node","node.js","sendgrid","workfall"],"articleSection":["Backend Development"],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/cab8236044692bc5b27606b13167794a","name":"Workfall","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/learning.workfall.com\/learning\/blog\/#\/schema\/person\/image\/","url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png","contentUrl":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2023\/09\/avatar_user_1_1693914404-96x96.png","caption":"Workfall"},"sameAs":["https:\/\/www.workfall.com"]}]}},"jetpack_featured_media_url":"https:\/\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/05\/Cover-Images_Part2-4.png","jetpack-related-posts":[{"id":1187,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-upload-single-or-multiple-images-to-a-local-directory-with-multer-in-node-js\/","url_meta":{"origin":962,"position":0},"title":"How to upload single or multiple images to a local directory with Multer in Node.js?","date":"August 30, 2022","format":false,"excerpt":"The most fundamental operation of any application is a file upload. While images can be uploaded on the front end, they must be received via an API and database on the backend. You can set up file and image uploads in one place using Multer and Express, a Node.js framework.\u2026","rel":"","context":"In &quot;Backend Development&quot;","img":{"alt_text":"Multer in Node.js","src":"https:\/\/i2.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/08\/Cover-Images_Part2-1-4.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1121,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-show-flash-messages-in-node-js-using-the-connect-flash-package\/","url_meta":{"origin":962,"position":1},"title":"How to Show Flash Messages in Node.js using the Connect-flash Package?","date":"August 9, 2022","format":false,"excerpt":"The Node.js Connect-flash module is extremely useful for developers whenever a flash message needs to be sent. When a user is redirected to a specific webpage, the connect-flash module in Node.js allows developers to display a pop-up message. For example, in your Node.js demo application, you might want to notify\u2026","rel":"","context":"In &quot;Backend Development&quot;","img":{"alt_text":"Flash messages in Node.js","src":"https:\/\/i2.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/08\/Cover-Images_Part2.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":884,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-create-and-delete-email-templates-on-amazon-ses-using-node-js-and-postman-api\/","url_meta":{"origin":962,"position":2},"title":"How to create and delete Email Templates on Amazon SES using Node.js and Postman API?","date":"February 28, 2022","format":false,"excerpt":"If you are developing an application that needs to send bulk emails to larger communities for trigger-based messages such as email verification or password resets, announcements like festival discounts, newsletters, or general notifications in a cost-effective, flexible, and scalable manner, then Amazon SES is the answer. Amazon SES can be\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"Send and Delete Emails Templates with Amazon SES","src":"https:\/\/i0.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/02\/Cover-Images_Part2-9.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1397,"url":"https:\/\/learning.workfall.com\/learning\/blog\/pm2-daemon-process-manager-for-a-node-js-application\/","url_meta":{"origin":962,"position":3},"title":"How to set up a PM2 daemon process manager for a Node.js application?","date":"October 4, 2022","format":false,"excerpt":"Process management encompasses a wide range of activities centered on the creation, termination, and monitoring of processes. A process manager is a program that ensures that your applications remain operational after they have been launched. Process managers can prevent production downtime by restarting your application automatically after a crash or\u2026","rel":"","context":"In &quot;Backend Development&quot;","img":{"alt_text":"How to set up a PM2 daemon process manager for a Node.js application?","src":"https:\/\/i1.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/10\/Cover-Images_Part2-1.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1508,"url":"https:\/\/learning.workfall.com\/learning\/blog\/how-to-perform-encryption-and-decryption-of-messages-using-crypto-in-node-js\/","url_meta":{"origin":962,"position":4},"title":"How to perform encryption and decryption of messages using Crypto in Node.js?","date":"November 8, 2022","format":false,"excerpt":"Web applications have access to massive amounts of data belonging to individuals, organizations, and governments. The more data that is accessed, the greater the risk to data security. Cryptography and encryption techniques are used by software developers to protect sensitive data from malicious parties. Cryptography is used to protect data\u2026","rel":"","context":"In &quot;Backend Development&quot;","img":{"alt_text":"How to perform encryption and decryption of messages using Crypto in Node.js?","src":"https:\/\/i1.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2022\/11\/Cover-Images_Part2-1.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":611,"url":"https:\/\/learning.workfall.com\/learning\/blog\/trigger-lambda-function-using-amazon-cloudwatch-events-and-configure-cloudwatch-alarm-to-get-email-notifications-using-amazon-sns-part-1\/","url_meta":{"origin":962,"position":5},"title":"How to trigger Lambda function using Amazon CloudWatch events and configure CloudWatch alarm to get email notifications using Amazon SNS (Part 1)?","date":"November 11, 2021","format":false,"excerpt":"Whether you're considering a cloud migration or have already made the switch to AWS, you'll want to know how to manage your digital environment. With Amazon CloudWatch, AWS makes monitoring simple. CloudWatch is the cornerstone of your AWS infrastructure management. It has a robust framework for capturing and storing metrics\u2026","rel":"","context":"In &quot;AWS Cloud Computing&quot;","img":{"alt_text":"Amazon CloudWatch - Workfall","src":"https:\/\/i2.wp.com\/learning.workfall.com\/learning\/blog\/wp-content\/uploads\/2021\/11\/cloudwatch1.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts\/962"}],"collection":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/comments?post=962"}],"version-history":[{"count":8,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts\/962\/revisions"}],"predecessor-version":[{"id":3131,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/posts\/962\/revisions\/3131"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/media\/963"}],"wp:attachment":[{"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/media?parent=962"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/categories?post=962"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learning.workfall.com\/learning\/blog\/wp-json\/wp\/v2\/tags?post=962"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}