-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
41 lines (31 loc) · 1.24 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
/**
* API mailer service
*/
const simpleTemplateMailer = require('simple-template-mailer');
const path = require('path');
module.exports = {
mailer: {},
options: {},
start: function (mainOptions, mainPath) {
// defaults
let opts = module.exports.options;
opts = mainOptions || {};
opts.translationsPath = mainOptions.translationsPath || path.join(mainPath + '/translations');
opts.templatesPath = mainOptions.templatesPath || path.join(mainPath + '/templates');
opts.inlineAttribute = (mainOptions.inlineAttribute || mainOptions.inlineAttribute === false) ? mainOptions.inlineAttribute : 'inline';
// create mailer instance
module.exports.mailer = simpleTemplateMailer(opts);
// give back all functions
return module.exports;
},
sendMail: function (template, options, callback) {
// defaults
options = options || {};
options.from = options.from || module.exports.options.from || module.exports.options.contactMail;
options.replyTo = options.replyTo || module.exports.options.contactMail;
module.exports.mailer.send(template, options, callback);
},
getTemplate: function () {
module.exports.mailer.getTemplate.apply(null, arguments);
}
};