forked from mantrajs/meteor-mantra-kickstarter
-
Notifications
You must be signed in to change notification settings - Fork 4
/
mail.js
40 lines (32 loc) · 1.13 KB
/
mail.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
var nodemailer = require('nodemailer');
var mg = require('nodemailer-mailgun-transport');
import _lgr from '/lib/logging/server/serverLogger';
const Lgr = new _lgr( __filename, 'info' );
var auth = {
/* eslint-disable camelcase */
auth: {
api_key: process.env.MAILGUN_KEY || Meteor.settings.MAILGUN_KEY,
domain: Meteor.settings.MAILGUN_DOMAIN
}
/* eslint-enable camelcase */
};
let mailer = nodemailer.createTransport(mg(auth));
mailer.resetPassword = function resetPassword(_email, _id, _validator) {
Lgr.a = 'mailer.resetPassword';
const cfg = Meteor.settings.public.PASSWORD_RESET;
const host = process.env.HOST_SERVER_NAME || Meteor.settings.public.HOST_SERVER_NAME;
mailer.sendMail({
from: cfg.From,
to: _email,
subject: cfg.Subject,
html: cfg.Html_1 + host + cfg.Route + _id + '-' + _validator + cfg.Html_2,
text: cfg.Text_1 + host + cfg.Route + _id + '-' + _validator + cfg.Text_2,
}, function (err, info) {
if (err) {
Lgr.error( '\n Mail send error : ' + err + '\n' );
} else {
Lgr.info( '\n Mail host response: ' + info.message + '\n' );
}
});
};
export default mailer;