lib/email/index.js
function sendAlertEmail(alertEmailData, cb) {
  var mongoAlert = alertEmailData.alert;
  var eventDetails = alertEmailData.eventDetails;
  var emailConfig = config.getConfig().email;
  var from = emailConfig ? emailConfig.alert_email_from : 'noreply@feedhenry.com';

  fs.readFile(ALERT_EMAIL_TEMPLATE, function(err, data) {
    if (err) {
      return cb({
        'error': 'Could not load email template from "' + ALERT_EMAIL_TEMPLATE + '": ' + err
      });
    }
    var emailBody = data.toString();
    emailBody = emailBody.replace(/%appName%/g, eventDetails.appName || "");
    emailBody = emailBody.replace(/%appGuid%/g, eventDetails.uid);
    emailBody = emailBody.replace(/%appUrl%/g, ' ');
    emailBody = emailBody.replace(/%alertName%/g, mongoAlert.alertName);
    emailBody = emailBody.replace(/%eventTimestamp%/g, eventDetails.timestamp);
    emailBody = emailBody.replace(/%updatedBy%/g, eventDetails.updatedBy);
    emailBody = emailBody.replace(/%eventMessage%/g, eventDetails.details.message);
    emailBody = emailBody.replace(/%eventCategory%/g, eventDetails.eventClass);
    emailBody = emailBody.replace(/%eventName%/g, eventDetails.eventType);
    emailBody = emailBody.replace(/%eventSeverity%/g, eventDetails.eventLevel);
    emailBody = emailBody.replace(/%eventDetails%/g, JSON.stringify(eventDetails.details));
    emailBody = emailBody.replace(/%providerName%/g, from);

    getTransport(emailConfig).sendMail({
      from: from,
      to: mongoAlert.emails,
      subject: 'Alert Name: ' + mongoAlert.alertName + ' - Cloud App (' + mongoAlert.uid + ')',
      html: emailBody
    }, cb);
  });
}
function sendAlertEmail(alertEmailData, cb) {
  var mongoAlert = alertEmailData.alert;
  var eventDetails = alertEmailData.eventDetails;
  var emailConfig = config.getConfig().email;
  var from = emailConfig ? emailConfig.alert_email_from : 'noreply@feedhenry.com';

  fs.readFile(ALERT_EMAIL_TEMPLATE, function(err, data) {
    if (err) {
      return cb({
        'error': 'Could not load email template from "' + ALERT_EMAIL_TEMPLATE + '": ' + err
      });
    }
    var emailBody = data.toString();
    emailBody = emailBody.replace(/%appName%/g, eventDetails.appName || "");
    emailBody = emailBody.replace(/%appGuid%/g, eventDetails.uid);
    emailBody = emailBody.replace(/%appUrl%/g, ' ');
    emailBody = emailBody.replace(/%alertName%/g, mongoAlert.alertName);
    emailBody = emailBody.replace(/%eventTimestamp%/g, eventDetails.timestamp);
    emailBody = emailBody.replace(/%updatedBy%/g, eventDetails.updatedBy);
    emailBody = emailBody.replace(/%eventMessage%/g, eventDetails.details.message);
    emailBody = emailBody.replace(/%eventCategory%/g, eventDetails.eventClass);
    emailBody = emailBody.replace(/%eventName%/g, eventDetails.eventType);
    emailBody = emailBody.replace(/%eventSeverity%/g, eventDetails.eventLevel);
    emailBody = emailBody.replace(/%eventDetails%/g, JSON.stringify(eventDetails.details));
    emailBody = emailBody.replace(/%providerName%/g, from);

    getTransport(emailConfig).sendMail({
      from: from,
      to: mongoAlert.emails,
      subject: 'Alert Name: ' + mongoAlert.alertName + ' - Cloud App (' + mongoAlert.uid + ')',
      html: emailBody
    }, cb);
  });
}
function sendAlertEmail ( alertEmailData , cb ) { var mongoAlert = alertEmailData . alert ; var eventDetails = alertEmailData . eventDetails ; var emailConfig = config . getConfig ( ) . email ; var from = emailConfig ? emailConfig . alert_email_from : 'noreply@feedhenry.com' ; fs . readFile ( ALERT_EMAIL_TEMPLATE , function ( err , data ) { if ( err ) { return cb ( { 'error' : 'Could not load email template from "' + ALERT_EMAIL_TEMPLATE + '": ' + err } ) ; } var emailBody = data . toString ( ) ; emailBody = emailBody . replace ( / %appName% / g , eventDetails . appName || "" ) ; emailBody = emailBody . replace ( / %appGuid% / g , eventDetails . uid ) ; emailBody = emailBody . replace ( / %appUrl% / g , ' ' ) ; emailBody = emailBody . replace ( / %alertName% / g , mongoAlert . alertName ) ; emailBody = emailBody . replace ( / %eventTimestamp% / g , eventDetails . timestamp ) ; emailBody = emailBody . replace ( / %updatedBy% / g , eventDetails . updatedBy ) ; emailBody = emailBody . replace ( / %eventMessage% / g , eventDetails . details . message ) ; emailBody = emailBody . replace ( / %eventCategory% / g , eventDetails . eventClass ) ; emailBody = emailBody . replace ( / %eventName% / g , eventDetails . eventType ) ; emailBody = emailBody . replace ( / %eventSeverity% / g , eventDetails . eventLevel ) ; emailBody = emailBody . replace ( / %eventDetails% / g , JSON . stringify ( eventDetails . details ) ) ; emailBody = emailBody . replace ( / %providerName% / g , from ) ; getTransport ( emailConfig ) . sendMail ( { from : from , to : mongoAlert . emails , subject : 'Alert Name: ' + mongoAlert . alertName + ' - Cloud App (' + mongoAlert . uid + ')' , html : emailBody } , cb ) ; } ) ; }
Send an Alert email to recipients for given Event
@param alertEmailData
@param cb
Send an Alert email to recipients for given Event