Download this file

emailer.js    57 lines (47 with data), 1.2 kB

 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
53
54
55
/*made by Miguel Rodrigues @ KBZ miguel.rodrigues@knowledgebiz.pt*/
//Emailer to sendEmail
var email=require('nodemailer');
var emailconfig = require('../config/email');
var emailbody = require('../signature');
var transporter= email.createTransport({
service: 'hotmail',
port: 465,
auth: {
type: 'OAuth2',
user: emailconfig.userEmail,
pass: emailconfig.userPwd
},
tls: {
ciphers:'SSLv3'
}
});
module.exports.sendEmail = function (emailTo,notification) {
var mailOptions={
from: emailconfig.userEmail,
to: emailTo,
subject: 'New notification!',
html: '<h4>'+notification+'</h4>'+emailbody.signature
};
transporter.sendMail(mailOptions, function(error,info){
if(error){
console.log(error);
} else {
console.log('Email sent: '+ info.response);
}
});
}
module.exports.sendEmailToken = function (emailTo,Token) {
var mailOptions={
from: emailconfig.userEmail,
to: emailTo,
subject: 'New Token!',
html: '<h4>vApp Token for Notification Enabler: <br><br>'+Token+'</h4>'+emailbody.signature
};
transporter.sendMail(mailOptions, function(error,info){
if(error){
console.log(error);
} else {
console.log('Email sent: '+ info.response);
}
});
}