Nodejs Tutorial-- Sending Email using NodeMailer
Hello Everyone
In this post, we will learn how to send Emails to any Email address using node.js. By following the steps at the end of this tutorial you will able to send any message through Email address. We are going to use Gmail to send Emails to other Gmail addresses. So without wasting time le's begin.
- Make sure you have Node.js installed. If you don't have it. go to the node.js site and download it or read the previous post in which I have installed the node.js.
- Open vs code and download the node-modular from NPM(Node package Module).
open terminal and typenpm install node-mailer.
Now copy-paste the whole code.
const nodemailer = require('nodemailer');
const config = require('./config.json');
let transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: config.from,
pass: config.pass
}
});
let mailOptions = {
from: config.from,
to: config.to,
subject: 'Hive Post',
text: 'This is mail sent by Noed-Mailer '
};
transporter.sendMail(mailOptions, function(error, info) {
if (error) {
console.log(error);
} else {
console.log('Email sent to the given adress');
}
});
Create a new file name it index.js and paste the whole code int it.
create another file and name it confog.json.
{
"from": "YOUR-GMAIL",
"to": "WHERE-YOU-WANT-SEND",
"pass": "YOUR-PASSWORD"
}
copy the above code into it and change its values.
- Now we are ready to send our Email. Let's run our code.
- we got no error let's check the Gmail.
- Let's send another Mail.
I think this much is enough for today. Now if you like the post please upvote and comment if you want to give me some advise
Leave Nodejs Tutorial-- Sending Email using NodeMailer to:
Read more #hive-148441 posts
Best Posts From ProGrammer
We have not curated any of pakgamer's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From ProGrammer
- What do you think your Password is Secure?
- Nodejs Tutorial-- Sending Email using NodeMailer
- Node.js Tutorial --Reading and Writing files
- How to install Nodemon-- Express.js Tutorials
- How to use Range Element in a simple voting tool
- Learning Express.js-- installation and Hello World Example
- How to Compile your C/C++ code on the Visual Studio Code.
- How to check Voting Power And Resource Credit of Hive Account Through dhive
- How To Send Message TO WhatsApp Using JavaScript/Node.js-- Twilio
- How to add Custom prefix to your Discord Bot. Discordjs Tutorial
- HiveJs Tutorials --Learning how to transfer HIVE/HBD thorugh HiveJs
- Fetching API -- JavaScript Tutorial
- Learning Local Storage in JavaScript..
- Hivejs Tutorials-- #3
- Learn jQuery. Learning Events/Methods
- Learn jQuery --- Learning Selectors
- Learning JQuery-- Understanding the basics
- TypeScript for beginners -- A quick start
- How to Stream Hive Blockchain Transactions.-- HIVED
- Grand Theft Auto V (GTA 5) is now free on Epic Games Store.