-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (28 loc) · 1.09 KB
/
index.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
const nodemailer = require('nodemailer');
const fs = require('fs');
const csv = require('csvtojson');
const config = require('./config.json');
const csvFilePath = process.argv[2];
let transporter = nodemailer.createTransport(config);
// csv header format first, last, email, url
csv().fromFile(csvFilePath).on('json', (person) => {
fs.readFile('template.html', 'utf8', (err, content) => {
const link = 'http://interview.boilermake.org/interview' + person.url.substring(person.url.lastIndexOf('/'));
content = content.replace('#{name}', person.first);
content = content.replace('#{link}', link);
content = content.replace('#{link}', link);
let mailOptions = {
from: '"BoilerMake Team" <[email protected]>',
to: person.email,
subject: 'THIS IS A TEST: BoilerMake Exec Team Interview',
html: content
};
transporter.sendMail(mailOptions, (error, info) => {
if(error) return console.log(error);
console.log('Message sent to: ' + person.first + ' ' + person.last);
});
});
})
.on('done', (error) => {
if(error) console.log(error);
});