Send Email through NodeJs

Sending email through Nodejs is one of the very important & basic feature to develop an application. To day I am showing how to send email through NodeJs.

We will use “nodemailer” to send email.

var nodemailer = require(‘nodemailer’);
var transporter = nodemailer.createTransport();
transporter.sendMail({ from: ‘sender@address’, to: ‘receiver@address’, subject: ‘hello’, text: ‘hello world!’});
Sending emails through SMTP is also possible (using Gmail, Hotmail):
var nodemailer = require(‘nodemailer’);
var transporter = nodemailer.createTransport({ service: ‘gmail’, auth: { user: ‘sender@gmail.com’, pass: ‘password’ }});
transporter.sendMail({ from: ‘sender@address’, to: ‘receiver@address’, subject: ‘hello’, text: ‘hello world!’});