You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
905 B
37 lines
905 B
8 years ago
|
#!/usr/bin/env node
|
||
|
|
||
|
var defaults = require("../config/mailconfig.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 = [];
|
||
|
|
||
|
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');
|
||
|
});
|
||
|
|
||
|
transporter.sendMail(mailOptions, function(error, info){
|
||
|
if(error){
|
||
|
return console.log(error);
|
||
|
}
|
||
|
console.log('Message sent: ' + info.response);
|
||
|
});
|