-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmailer.js
32 lines (26 loc) · 1.18 KB
/
mailer.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
const nodemailer = require("nodemailer");
// async..await is not allowed in global scope, must use a wrapper
async function sendNotif(to,result,job) {
// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
service: 'gmail',
host: "smtp.gmail.com",
port: 465,
secure: true, // true for 465, false for other ports
auth: {
user: `[email protected]`, // generated ethereal user
pass: `coding17` // generated ethereal password
}
});
// send mail with defined transport object
let info = await transporter.sendMail({
from: '"Dis-Tri-Buted 👻" <[email protected]>', // sender address
to: to, // list of receivers
subject: `Notif Regarding Job ${job}`, // Subject line
text: `Notif Regarding Job ${job}`, // plain text body
html: `Hey there,<br> Your Job <b>${job}</b> has been completed <br> You can access the result <a href="${result}"> here</a> <br><br> Regards,<br> Team Distributed` // html body
});
console.log("Message sent: %s", info.messageId);
}
//sendNotif("[email protected]","xyz.com", "12dee334f").catch(console.error);
module.exports = sendNotif;