Node.js Send Email
Node.js Tutorial » Node.js Send Email
How to Send Emails with Node.js
To send emails we use Nodemailer Module
Nodemailer module it is an easy method to send emails from your computer.
Nodemailer module can be downloaded and installed on your server using npm:
After installing nodemailer module, you can check your version in command prompt
After downloaded Nodemailer module, include the module in any application:
Send an Email
After the steps above you are ready to make a web page in Node.js that lets the user send email from your server:
This chapter will show you how to use your Gmail account to send emails:
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'your_email@gmail.com',
pass: 'your_password'
}
});
var mailOptions = {
from: 'your_email@gmail.com',
to: 'my_friend_email@agernic.com',
subject: 'Sending Email using Node.js',
text: 'Hi, this is a text using nodejs send email '
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
Related subjects:
node.js http module
node.js upload files
global objects nodejs
Tags: node js send email with html template, through gmail, without authentification, with attachment, send email without smtp, node js send email smtp example, node js send email through gmail, send email with html template
CAN node JS send emails?
How do I trigger an email in node JS?
How do you use Nodemailer?
How do I send an email from Express?
Send Email to Multiple Receivers
To send email to multiple recipients at once, add them to the "to" property of the mailOptions object:
from: 'your_email@gmail.com',
to: 'my_friend1@agernic.com, my_friend2@agernic.com,
my_friend3@agernic.com, my_friend4@agernic.com,',
subject: 'Sending Email using Node.js',
text: 'Hi, this is a test of my nodejs program'
}
Send HTML Email
To send HTML formatted text in your email with nodemail module in node, use "html" property instead of the "text" property:
from: 'youremail@gmail.com',
to: 'my_friend1@agernic.com, my_friend2@agernic.com,
my_friend3@agernic.com, my_friend4@agernic.com,',
subject: 'Sending Email using Node.js',
html: '<h2>Welcome</h2>
<p>Hi, this is a test of my nodejs program</p>
<p>I will see you later</p>
<hr>
Regardes '
}
node js send email with html template, through gmail, without authentification, with attachment, send email without smtp, node js send email smtp example, node js send email through gmail, send email with html template
CAN node JS send emails?
How do I trigger an email in node JS?
How do you use Nodemailer?
How do I send an email from Express?
Node.js Send Email - nodejs
This tool makes it easy to create, adjust, and experiment with custom colors for the web.

Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.

Find here examples of creative and unique website layouts.

Find here examples of creative and unique website CSS HTML menu.