×


Sending email with SendGrid and Node.js – Using HTML templates:Step by step tutorial

SendGrid is a communication platform that helps you manage communications with your clients via e-mail.SendGrid helps you manage email sending,design templates using code editor/design editor,run marketing campaign etc.To use send grid with your Node.js application,you need to integrate @sendgrid/mail package to your application.Follow the steps below to integrate and configure mail sending in Node.js with SendGrid

 

STEP 1

Create a SendGrid account using your email,provide the necessary information and confirm your account by clicking the confirmation mail from sendgrid

 

STEP 2

Sign in to your SendGrid account and go to dashboard.In the left side settings you will find an option called Api keys. Click on Api keys and generate a new api key for your sendgrid account.

 

STEP 3 – Integrating #sendgrid/mail

To install sendgrid/mail for node run the following in the terminal.

In your node application,use the following code to import @sendgrid/mail

 

STEP – 3 Creating a template in sendgrid

To create aSendGrid template, go to the template section in the left side of your dashboard.Create a template  and then click the action button.

From the action button choose the option New Version which will give you the following screen with design editor and code editor.Choose the design editor to add your custom HTML.

Add the html in the following way.The  data in the {{ name }}  indicate the data  we send from our Nodejs code that will be substituted in the template.

STEP 4 – Using the templates and sending mail

 

The above code sends e-mail to ‘test.recipient@gmail.com’,the name and age will be substituted with ‘test name’ and ’22’ respectively.

https://sendgrid.com/docs/Integrate/Code_Examples/v3_Mail/nodejs.html

No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *