In this tutorial, we will learn “How to send Emails in Node.js using Nodemailer“.

How to send Emails using NodeMailer?

Sending an email in the node is very easy thanks to NodeMailer. Let me show you the process of sending an email using it.

I assume that you have already running your node.js application or you can learn how to start with the node.js application from my previous tutorial here.

First, install NodeMailer to your node application

After installing in your js file require it

Now, create transporter object using the default SMTP transport which can send emails. In this example, I am using ZOHO mail.

In auth object specify your email address and password.

Now, we need to configure our email details.

Now the last thing is actually sending the email using ‘sendMail()’ method provided by the transporter object we created.

‘sendMail()’ method takes two argument mailOptions and a callback function which will be called when the mail is sent. The callback function will be called when either email sent successfully or an error occurred.

Putting everything together,

And that’s how we send emails using NodeMailer.

Github link:

Here are more tutorials:

  1. An easy way to build node.js RESTful APIs
  2. File upload in Node.js

Any doubts, feel free to comment.

Happy Coding!!


What Others Are Reading

File Upload in Node.js Server
Deval Kasundra Jul 13, 2018
Easy way to Build Node JS RESTful APIs
Deval Kasundra Jun 08, 2018

Leave a Reply

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