-
Notifications
You must be signed in to change notification settings - Fork 5
/
mail.js
71 lines (56 loc) · 1.86 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const nodemailer = require('nodemailer');
const emails = require('./emails');
let userEmail = '';
let subject = '';
let text = '';
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
readline.question('TO:', emailInput => {
userEmail = emailInput;
readline.question('Subject:', subjectInput => {
subject = subjectInput;
readline.question('Body:', bodyInput => {
text = bodyInput;
readline.close();
init();
});
})
})
const init = () => {
for (let i = 0; i < emails.length; i++) {
const item = emails[i];
const email = item.split(':')[0];
const password = item.split(':')[1];
const transporter = nodemailer.createTransport({
host: 'smtp.office365.com', // GMAIL: smtp.gmail.com HOTMAIL: smtp.office365.com
port: 587, //GMAIL & HOTMAIL: 587
secure: false,
auth: {
user: email,
pass: password
}
});
try {
async function sendEmail() {
let random = Math.floor(Math.random() * 100000000)
let info = await transporter.sendMail({
from: email,
to: userEmail,
subject: subject,
text: text + ' ' + random
}).catch(() => {
console.log('Error but who asked')
})
console.log(info?.messageId || 'Failed to get messageId')
console.log(`sending? ${email}`)
}
sendEmail()
} catch (err) {
console.log(err)
}
//Infinitly loop through the email list
if (i === emails.length - 1) i = 0;
}
}