Skip to content

Instantly share code, notes, and snippets.

@tromboneamafone
Created October 25, 2012 16:52
Show Gist options
  • Save tromboneamafone/3953992 to your computer and use it in GitHub Desktop.
Save tromboneamafone/3953992 to your computer and use it in GitHub Desktop.
//email alert for nmt's
//need to determine if auctually connected to enrg sql db
//
//TO-DO: EMAIL http://howtonode.org/sending-e-mails-with-node-and-nodemailer
var Connection = require('tedious').Connection,
Request = require('tedious').Request, //sql monitering dependency
nodemailer = require('nodemailer'); //email dependency
var config = {
userName: 'baller',
password: 'Birdie2',
server: '506.enrgnmt.com',
};
var connection = new Connection(config);
console.log('before connection.on');
//connecting to the db
//http://pekim.github.com/tedious/getting-started.html
connection.on('connect', function(err) {
if(err) {
console.log(err);
}
else {
console.log('sucessful connection, now get some data');//why not printing
}
console.log('inception');//why not printing
printData();
});
console.log('after connection.on');
//sql statement execution?
//http://pekim.github.com/tedious/getting-started.html
function executeStatement() {
request = new Request("
}
/*emailing WORKS AS IS
var smtpTransport = nodemailer.createTransport("SMTP",{
service: "Gmail",
auth: {
user: "tromboneamafone@gmail.com",
pass: "124461rlb!?"
}
});
var mailOptions = {
from: "<robertbevly@gmail.com>",
to: "tromboneamafone@gmail.com, tromb_rob67@yahoo.com",
subject: "subject goes here",
text: "the system is down.",
html: "<b>html goes here</b>"
}
smtpTransport.sendMail(mailOptions, function(error, response) {
if(error) {
console.log(error);
}
else {
console.log("Message sent: " + response.message);
}
});
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment