From 5fe11eaf0b7f76bb2a5479ab79cc6f4bc47dd44f Mon Sep 17 00:00:00 2001 From: typpo Date: Fri, 6 Apr 2012 15:44:51 -0400 Subject: [PATCH] work on it --- app.js | 23 ++++++++++++++++++----- package.json | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app.js b/app.js index bd153f8..dc21fb3 100644 --- a/app.js +++ b/app.js @@ -26,30 +26,43 @@ app.get('/', function(req, res) { }); }); +app.post('/text', function(req, res) { + if (true) { + sendText(req.body.number, req.body.msg, function(err) { + if (err) + res.send({success:false}); + else + res.send({success:true}); + }); + } +}); + +function sendText(phone, msg, cb) { var transport = nodemailer.createTransport("SES", { AWSAccessKeyID: config.aws.access, - AWSSecretKey: config.aws.secret, + AWSSecretKey: config.aws.secret, }); - var mailOptions = { transport: transport, // transport method to use - from: "testing@airtext.com", // sender address + from: "txt@textbelt.com", // sender address to: '9147727429@vtext.com', subject: '', // Subject line - text: 'testtingg', // plaintext body + text: msg, } nodemailer.sendMail(mailOptions, function(error){ if (error) { console.log(error); + cb(true); } else { console.log("Message sent!"); - cb(); + cb(false); } transport.close(function(){}); // shut down the connection pool }); +} var port = process.env.PORT || 8080; app.listen(port, function() { diff --git a/package.json b/package.json index 46e7f01..11796e0 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "AirText" + "name": "TextBelt" , "dependencies": { "express": "2.5.2" , "jade": "0.14.2"