-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode.js
49 lines (48 loc) · 1.33 KB
/
node.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
43
44
45
46
47
48
49
var nodemailer = require('nodemailer');
var fs = require('fs')
const email = ""; //whoops these values were accidentally removed from the PUSH, what a shame.
const emailpass = "";
var transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: email,
pass: emailpass
}
});
function createMailOptions(recipient){
var mailOptions = {
from: me,
to: recipient,
subject: 'Midterms are Coming Soon!',
html: htmlstream,
text: txt
};
return mailOptions;
}
htmlstream = fs.createReadStream('main.html');
txt = fs.createReadStream('text.txt');
function sendMail(name){
transporter.sendMail(createMailOptions(name), function(error, info){
if (error) {
console.log(error);
console.log("**Message wasn't sent to:" + name);
} else {
console.log('Email sent to: ' + name);
}
});
}
function delay(){
return new Promise(resolve => setTimeout(resolve, 300));
}
async function delayedLog(item){
await delay();
sendMail(item)
}
var recipients = [] //I know I'm irresponsible, but even I'd erase this list. #GOTTEM
async function processArray(array){
for(const item of array){
await delayedLog(item);
}
console.log('Done!')
}
processArray(recipients)