https://grokonez.com/node-js/nodejs-send-email-by-nodemailer-example
NodeJS – Send email by Nodemailer
In the tutorial, we show you how to send email from Node.js applications by Nodemailer module.
Nodemailer Module
Nodemailer is licensed under MIT license. It provides an easy way to send email.
To download and install it, we use below commandline:
$npm install nodemailer --save
Nodemailer Send Mail
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
// example with google mail service
host: 'smtp.gmail.com',
port: 587,
secure: false, // true for 465, false for other ports
auth: {
user: 'send-email@gmail.com', // replace by your email to practice
pass: '*****' // replace by your-password
}
});
var mailOptions = {
from: 'send-mail@gmail.com',
to: 'to-email-1@gmail.com, to-email-2@gmail.com',
subject: 'Sending Email using Nodemailer',
/*
for plain text body
-> text: 'Just Testing!'
*/
// html body
html: 'Hello world!
The mail has been sent from Node.js application!
'
};
transporter.sendMail(mailOptions, (error, info) => {
if (error)
return console.log(error);
console.log('Email sent: ' + info.response);
});
More at:
https://grokonez.com/node-js/nodejs-send-email-by-nodemailer-example
NodeJS – Send email by Nodemailer
Top comments (1)
Thanks for sharing ! Here a package which can help with email sending in node.js environment. One library for many providers.
konfer-be / cliam
Agnostic transactional email sending in Node.js environment
Transactional emails with a kick
Agnostic transactional email sending in Node.js environment💥 💪 💊
> Why ?
To improve and facilitate the implementation, flexibility and maintenance of transactional emailing tasks.
> Features
> Table of contents
> Requirements
> Getting started
Install
> npm i cliam --save
Configure
Create a .cliamrc.json file on the root of your project.
> touch .cliamrc.json
Define a minimalist configuration in .cliamrc.json newly created: