-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmailer.js
More file actions
30 lines (25 loc) · 694 Bytes
/
Emailer.js
File metadata and controls
30 lines (25 loc) · 694 Bytes
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
var config = require('./config.json'),
nodemailer = require('nodemailer');
function Emailer () {
this._transporter = nodemailer.createTransport(config.emailConfig);
}
Emailer.prototype = {
send: function (listing) {
this._writeToLog();
this._transporter.sendMail({
from: config.emailConfig.from,
to: config.emails.join('; '),
subject: this._getMessage(listing),
text: listing.url
});
},
_writeToLog: function () {
console.log("Sending email to ", config.emails);
},
_getMessage: function (listing) {
return [
listing.title, listing.price, listing.location
].join(' | ');
}
};
module.exports = Emailer;