-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotifier.js
More file actions
29 lines (26 loc) · 742 Bytes
/
notifier.js
File metadata and controls
29 lines (26 loc) · 742 Bytes
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
const nodemailer = require('nodemailer');
async function sendEmail(recipients, subject, content) {
console.log(`user: ${process.env.GMAIL_USER}`);
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: process.env.GMAIL_USER,
pass: process.env.GMAIL_PASSWORD,
},
});
try {
for (const recipient of recipients) {
const mailOptions = {
from: process.env.GMAIL_USER,
to: recipient,
subject: subject,
html: content,
};
await transporter.sendMail(mailOptions);
console.log(`Email sent successfully to ${recipient}`);
}
} catch (error) {
console.error('Error sending email:', error);
}
}
module.exports = sendEmail;