/*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 logger = require('../config/logger.js');
var handler = "backend.controllers.emailer";
var transporter= email.createTransport({
host: "smtp-mail.outlook.com",
port: 587,
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){
logger.error(handler, error);
//console.log(error);
} else {
logger.info(handler, info.response);
//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){
logger.error(handler, error);
//console.log(error);
} else {
logger.info(handler, info.response);
//console.log('Email sent: '+ info.response);
}
});
}