-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathapp.js
42 lines (34 loc) · 862 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require('dotenv').config();
const nodemailer = require('nodemailer');
const hbs = require('nodemailer-express-handlebars');
//Step 1
let transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: process.env.EMAIL,
pass: process.env.PASSWORD
}
});
transporter.use('compile', hbs({
viewEngine: "express-handlebars",
viewPath: "./",
extName: ".handlebars"
}));
//Step 2
let mailOptions = {
from: '[email protected]',
to: '[email protected], [email protected]',
// cc: ''
// bcc: ''
subject: 'Testing and Testing',
text: 'IT works',
template: 'main'
};
//Step 3
transporter.sendMail(mailOptions)
.then(function(response) {
console.log('Email Sent !!');
})
.catch(function(error) {
console.log('Error: ' ,error);
});