-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmail.js
41 lines (37 loc) · 1.23 KB
/
mail.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
const nodemailer = require('nodemailer');
const sendMail = async () => {
console.log('sendMail');
try{
// let testAccount = await nodemailer.createTestAccount();
// 1) Create a transporter
const transporter = nodemailer.createTransport({
host: 'smtp.google.com',
port: 587,
secure: true,
service:"gmail",
auth: {
user: '[email protected]',
pass: '9919004378'
}
});
// 2) Define the email options
const mailOptions = {
from: 'Node Mailer <[email protected]>',
to: '[email protected], [email protected]',
subject: 'Node Cron Test Mail',
text: 'Hole popat ho gaa re',
html: '<h1>Node Cron Test Every Hour</h1>'
};
// 3) Actually send the email
await transporter.sendMail(mailOptions, (err, data) => {
if (err) {
throw err;
} else {
console.log('Email sent!!! :'+data.response);
}
});
}catch(err){
console.log(err.message);
}
};
module.exports = {sendMail};