Skip to content

Commit 7815ea0

Browse files
committed
change of directions
1 parent 54bab4b commit 7815ea0

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
"body-parser": "~1.2.2",
88
"express": "~4.3.1",
99
"interval": "~0.0.8",
10-
"morgan": "~1.1.1",
11-
"nodemailer": "~0.6.5"
10+
"morgan": "~1.1.1"
1211
},
1312
"bin": "./cli.js",
1413
"devDependencies": {},

send.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use strict';
2+
var https = require('https');
3+
var url = require('url');
4+
5+
module.exports = function (apiKey) {
6+
return function (opts, cb) {
7+
var wrapper = {};
8+
wrapper.message = opts;
9+
wrapper.key = apiKey;
10+
var buff = new Buffer(JSON.stringify(wrapper));
11+
var httpOptions = url.parse('https://mandrillapp.com/api/1.0/messages/send.json');
12+
httpOptions.method = 'post';
13+
var req = https.request(httpOptions, function (res) {
14+
var data = '';
15+
res.on('error',cb).on('data', function (d) {
16+
data += d.toString();
17+
}).on('end', function () {
18+
cb(null, data);
19+
});
20+
});
21+
req.on('error', cb);
22+
req.write(buff);
23+
req.end();
24+
};
25+
};

server.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
var express = require('express');
33
var morgan = require('morgan');
44
var bodyParser = require('body-parser');
5-
var nodemailer = require('nodemailer');
65
var interval = require('interval');
6+
var send = require('./send');
77
module.exports = function (config, inport) {
88
var timeouts = {};
9-
var mandrill = nodemailer.createTransport('SMTP', config.smtp);
9+
var mandrill = send(config.smtp.auth.pass);
1010
var app = express();
1111
app.use(morgan('dev'));
1212
app.use(bodyParser());
1313
var port = inport || process.env.PORT || 3000;
1414
function sendEmail(opts) {
15-
mandrill.sendMail(opts, function (err, resp) {
15+
mandrill(opts, function (err, resp) {
1616
if (err) {
1717
console.log(err);
1818
} else {
19-
console.log('email sent');
19+
console.log(resp);
2020
}
2121
});
2222
}

0 commit comments

Comments
 (0)