forked from premithk/parse-server-genericemail-adapter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
43 lines (32 loc) · 1.05 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
36
37
38
39
40
41
42
var nodemailer = require('nodemailer');
module.exports = function (options) {
var transporter = nodemailer.createTransport({
service: options.service,
auth: {
user: options.email, // Your email id
pass: options.password // Your password }
}
});
var sendMail = function (mail) {
return new Promise(function (resolve, reject) {
var mailOptions = {
from: options.from, // sender address
to: [mail.to], // list of receivers
subject: mail.subject, // Subject line
text: mail.text //, // plaintext body
};
transporter.sendMail(mailOptions, function (error, info) {
if (error) {
console.log(error);
reject(error);
} else {
console.log('Message sent: ' + info.response);
resolve(info);
};
});
});
};
return {
sendMail: sendMail
}
};