alseambusher
8 years ago
4 changed files with 56 additions and 54 deletions
@ -1,36 +1,19 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var defaults = require("../config/mailconfig.js"); |
||||
|
||||
var crontab = require("../crontab.js"); |
||||
var nodemailer = require('nodemailer'); |
||||
|
||||
// create reusable transporter object using the default SMTP transport
|
||||
var transporter = nodemailer.createTransport(defaults.transporterStr); |
||||
var mailOptions = defaults.mailOptions; |
||||
|
||||
var stdin = process.stdin, |
||||
stdout = process.stdout, |
||||
inputChunks = []; |
||||
crontab.get_crontab(process.argv[process.argv.length -1 -2], function(job){ |
||||
var transporter = nodemailer.createTransport(job.mailing.transporterStr); |
||||
var mailOptions = job.mailing.mailOptions; |
||||
|
||||
stdin.resume(); |
||||
stdin.setEncoding('utf8'); |
||||
|
||||
stdin.on('data', function (chunk) { |
||||
inputChunks.push(chunk); |
||||
}); |
||||
|
||||
stdin.on('end', function () { |
||||
var inputJSON = inputChunks.join(), |
||||
mailOptions = JSON.parse(inputJSON); |
||||
|
||||
// outputJSON = JSON.stringify(parsedData, null, ' ');
|
||||
// stdout.write(outputJSON);
|
||||
// stdout.write('\n');
|
||||
}); |
||||
mailOptions.attachments = [{filename: "stdout.txt", path: process.argv[process.argv.length -1 -1]}, {filename: "stderr.txt", path: process.argv[process.argv.length -1]}]; |
||||
|
||||
transporter.sendMail(mailOptions, function(error, info){ |
||||
transporter.sendMail(mailOptions, function(error, info){ |
||||
if(error){ |
||||
return console.log(error); |
||||
} |
||||
console.log('Message sent: ' + info.response); |
||||
}); |
||||
}); |
||||
|
Loading…
Reference in new issue