Oh Snap!

Please turnoff your ad blocking mode for viewing your site content

Hit enter after type your search item

Node.js Send Email Through Gmail Using NodeMailer Library Full Project


Welcome folks today in this blog post we will talk about how to send email through gmail server in node.js with the help of nodemailer library full project. You can see the step by step detailed video of this approach as follows





npm init -y


npm i nodemailer


The first command will initialize the package.json file for your node.js project.

READ  Generate Custom Social Share Buttons With jQuery C Share Plugin

And the second command will install the nodemailer library to send emails with the help of node.js.

And now if you open your editor your directory will contain a file called as package.json which will contain information about your node.js project and the dependencies of your project



So now just make the app.js file which will be the starting point of the application and copy paste the below code

READ  Smoke.js - Javascript Library for Making Alert Boxes


var nodemailer = require('nodemailer');

var transporter = nodemailer.createTransport({
  service: 'gmail',
  auth: {
    user: '####youremail####',
    pass: '#####yourpassword####'

var mailOptions = {
  from: '####youremail#####',
  to: '###targetemail#####',
  subject: 'Sending Email using Node.js',
  text: 'That was easy!'

transporter.sendMail(mailOptions, function(error, info){
  if (error) {
  } else {
    console.log('Email sent: ' + info.response);


So In this block of code we are first of all importing the nodemailer library and then we are initializing some options such as our email and password you need to replace with your email and password and then with the help of sendemail method we send the email

READ  React File Uploader With Express (Using React Hooks)




Before executing this script you need to turn on the less secure app access in your gmail account like this. Follow the given steps


Now execute the script with the following command


node app.js


Leave a Comment

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

This div height required for enabling the sticky sidebar
Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views :