--- a/controllers/emailer.js
+++ b/controllers/emailer.js
@@ -1,6 +1,6 @@
/*made by Miguel Rodrigues @ KBZ miguel.rodrigues@knowledgebiz.pt*/
-//Emailer to sendEmail
+//Emailer to to send Notification by Email
var email = require('nodemailer');
var emailconfig = require('../config/email');
@@ -25,9 +25,10 @@
emailTo: String Array of email destinations ex: ["destination1@email.com","destination2@email.com"]
notification: String with the email body
-*/
-module.exports.sendEmail = function (emailTo,notification) {
+ */
+ module.exports.sendEmail = function (emailTo,notification) {
//var destinations = "'";
+ /*
var destinations ="";
for(i=0;i<emailTo.length;i++){
destinations += emailTo[i];
@@ -35,6 +36,7 @@
destinations += ", "
}
}
+ */
/*
if(emailTo.length != 1){
destinations += "'";
@@ -42,7 +44,8 @@
*/
var mailOptions={
from: emailconfig.userEmail,
- bcc: destinations,
+ //bcc: destinations,
+ bcc: emailTo,
subject: 'New notification!',
html: '<h4>'+notification+'</h4>'+emailbody.signature
};
@@ -57,12 +60,12 @@
}
-module.exports.sendEmailToken = function (emailTo,Token) {
+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
+ html: '<h4>vApp Token for Notification Enabler: <br><br>'+token+'</h4>'+emailbody.signature
};
transporter.sendMail(mailOptions, function(error,info){
@@ -75,3 +78,20 @@
}
});
}
+
+module.exports.sendEmailNewRule = function (emailTo,newRule) {
+ var mailOptions={
+ from: emailconfig.userEmail,
+ to: emailTo,
+ subject: 'Intelligent creation of a new Rule!',
+ html: '<h4>'+newRule+'<br><br></h4>'+emailbody.signature
+ };
+
+ transporter.sendMail(mailOptions, function(error,info){
+ if(error){
+ logger.error(handler, error);
+ } else {
+ logger.info(handler, info.response);
+ }
+ });
+}