-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
34 lines (28 loc) · 964 Bytes
/
main.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
var emailjs = require('emailjs');
var mail = function(message, destination, subject, callback) {
var email = emailjs.server.connect({
user: process.env.MAIL_USER,
password: process.env.MAIL_PASSWORD,
host: process.env.MAIL_HOST
});
email.send({
text: message,
'reply-to': process.env.MAIL_USER,
from: process.env.MAIL_USER,
to: destination,
subject: subject
}, function(err, message) {
if (callback) callback(err, message);
});
};
var santas = ['[email protected]', '[email protected]'];
var receivers = [];
var counter = 0;
while(receivers.length < santas.length) {
var i = Math.floor((Math.random() * santas.length));
if(receivers.indexOf(santas[i]) < 0 && santas[i] !== santas[counter]) {
mail('This year you are the Santa Claus of "' + santas[i] + '", treat him/them well (10€ max)! Merry xmas! ohohoh.', santas[counter], 'PTisp Santa Randomizer!');
receivers.push(santas[i]);
counter++;
}
}