Hello guys,

In this blog, we will discuss how to send email in sails.js using sails-email-hook and SendGrid service.

first of all, install sails-hook-email in your project directory-

$ npm install sails-hook-email

and then create an account on SendGrid.

SendGrid provides email delivery service for email sending we use SendGrid email service after creating an account on SendGrid it will give username and password for authentication account for using email service.

Create a file in named email.js inside project directory config/ folder.

Create a file named EmailService inside service folder in a project directory.

After that create email template which is view on email inside api/emailTemplates/welcomeEmail.

call email service create an action inside api/controllers

In the above code EmailService.sendWelcomeMail(user) function user argument contain email and other data.

On the call, this function sends function is called using sails-hook-email which is send an email template to create inside api/emailTeamplates/welcomeEmail folder to the email.