2016-12-13 08:36:13 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
var defaults = require("../config/mailconfig.js");
|
2016-12-14 13:12:19 +00:00
|
|
|
var crontab = require("../crontab.js");
|
2016-12-13 08:36:13 +00:00
|
|
|
var nodemailer = require('nodemailer');
|
|
|
|
|
2016-12-14 13:12:19 +00:00
|
|
|
crontab.get_crontab(process.argv[process.argv.length -1 -2], function(job){
|
|
|
|
var transporter = nodemailer.createTransport(job.mailing.transporterStr);
|
|
|
|
var mailOptions = job.mailing.mailOptions;
|
2016-12-13 08:36:13 +00:00
|
|
|
|
2016-12-14 13:12:19 +00:00
|
|
|
mailOptions.attachments = [{filename: "stdout.txt", path: process.argv[process.argv.length -1 -1]}, {filename: "stderr.txt", path: process.argv[process.argv.length -1]}];
|
2016-12-13 08:36:13 +00:00
|
|
|
|
2016-12-14 13:12:19 +00:00
|
|
|
transporter.sendMail(mailOptions, function(error, info){
|
2016-12-13 08:36:13 +00:00
|
|
|
if(error){
|
2016-12-14 13:12:19 +00:00
|
|
|
return console.log(error);
|
2016-12-13 08:36:13 +00:00
|
|
|
}
|
|
|
|
console.log('Message sent: ' + info.response);
|
2016-12-14 13:12:19 +00:00
|
|
|
});
|
2016-12-13 08:36:13 +00:00
|
|
|
});
|