1var nodemailer = require('nodemailer');
2var transporter = nodemailer.createTransport({
3 service: 'gmail',
4 auth: {
5 user: 'youremail@address.com',
6 pass: 'yourpassword'
7 }
8});
9const mailOptions = {
10 from: 'sender@email.com', // sender address
11 to: 'to@email.com', // list of receivers
12 subject: 'Subject of your email', // Subject line
13 html: '<p>Your html here</p>'// plain text body
14};
15transporter.sendMail(mailOptions, function (err, info) {
16 if(err)
17 console.log(err)
18 else
19 console.log(info);
20});
1var nodemailer = require('nodemailer');
2
3var transporter = nodemailer.createTransport({
4 service: 'gmail',
5 auth: {
6 user: 'youremail@gmail.com',
7 pass: 'yourpassword'
8 }
9});
10
11var mailOptions = {
12 from: 'youremail@gmail.com',
13 to: 'myfriend@yahoo.com',
14 subject: 'Sending Email using Node.js',
15 text: 'That was easy!'
16};
17
18transporter.sendMail(mailOptions, function(error, info){
19 if (error) {
20 console.log(error);
21 } else {
22 console.log('Email sent: ' + info.response);
23 }
24});