-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.js
52 lines (50 loc) · 1.62 KB
/
config.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
43
44
45
46
47
48
49
50
51
52
const nodeMailer = require('nodemailer');
const emailTemplates = require('email-templates');
const fs = require('fs');
const ejs = require('ejs');
//mail configurations
const transporter = nodeMailer.createTransport({
host: 'smtp.gmail.com',
port: 465,
secure: true, // true for 465, false for other ports
auth: {
user: '[email protected]',
pass: 'hashakgec18'
}
});
let readHTMLFile = function(path, callback) {
fs.readFile(path, {encoding: 'utf-8'}, function(err, html) {
if(err) {
callback(err);
} else {
callback(null, html);
}
})
}
module.exports = {
secret: "Qdhyi59BhPZsjRkg",
connection: 'mongodb://scrolls-admin:[email protected]:33762/scrolls18',
captchaKey: '6Led_G0UAAAAAOFOdrJyTYIk3A6mjsXDlE_4aOjz',
captchaKeyv2: '6LeVY3EUAAAAAFVVVDsQZuf6hCTasmifzEU71-7c',
sendYourMail: function(templatePath, from, to, subject, templateVar, callback) {
readHTMLFile(templatePath, function(err, html) {
if (err) throw err;
let template = ejs.compile(html);
let htmlToSend = template(templateVar);
let mailOptions = {
from: from,
to: to,
subject: subject,
html: htmlToSend
}
transporter.sendMail(mailOptions, function(error, response) {
if (error) {
console.log(error);
callback(error);
} else {
callback(null, response);
}
})
});
}
}