-
Notifications
You must be signed in to change notification settings - Fork 5
/
email.js
executable file
·49 lines (43 loc) · 1.27 KB
/
email.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
const mongoose = require('mongoose');
const CONFIG = require('./config.json');
const connection = mongoose.connect(CONFIG.MONGO_URL);
const volunteer = require('./model/volunteer');
const nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: '[email protected]',
pass: 'yourpassword'
}
});
var confirmationMail = {
from: '[email protected]',
to: '[email protected]',
subject: 'Confirm volunteer date and location',
text: 'That was easy!'
};
mongoose.connection.once('open', () => {
volunteer.find({}).then((volunteerData)=>{
for(var i = 0; i < volunteerData.length; i++)
{
var email = volunteerData[i].email;
var reminderMail = {
from: '[email protected]',
to: email,
subject: "Reminder for election",
text: "Dear " + volunteerData[i].firstName
+ " , this is a email to remind you that you are scheduled to volunteer "+
volunteerData[i].electionAvailable
};
console.log(reminderMail.text);
}
// transporter.sendMail(reminder, function(error, info){
// if (error) {
// console.log(error);
// }
// else {
// console.log('Email sent: ' + info.response);
// }
// });
});
});