File tree Expand file tree Collapse file tree 3 files changed +30
-6
lines changed Expand file tree Collapse file tree 3 files changed +30
-6
lines changed Original file line number Diff line number Diff line change 7
7
"body-parser" : " ~1.2.2" ,
8
8
"express" : " ~4.3.1" ,
9
9
"interval" : " ~0.0.8" ,
10
- "morgan" : " ~1.1.1" ,
11
- "nodemailer" : " ~0.6.5"
10
+ "morgan" : " ~1.1.1"
12
11
},
13
12
"bin" : " ./cli.js" ,
14
13
"devDependencies" : {},
Original file line number Diff line number Diff line change
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
+ } ;
Original file line number Diff line number Diff line change 2
2
var express = require ( 'express' ) ;
3
3
var morgan = require ( 'morgan' ) ;
4
4
var bodyParser = require ( 'body-parser' ) ;
5
- var nodemailer = require ( 'nodemailer' ) ;
6
5
var interval = require ( 'interval' ) ;
6
+ var send = require ( './send' ) ;
7
7
module . exports = function ( config , inport ) {
8
8
var timeouts = { } ;
9
- var mandrill = nodemailer . createTransport ( 'SMTP' , config . smtp ) ;
9
+ var mandrill = send ( config . smtp . auth . pass ) ;
10
10
var app = express ( ) ;
11
11
app . use ( morgan ( 'dev' ) ) ;
12
12
app . use ( bodyParser ( ) ) ;
13
13
var port = inport || process . env . PORT || 3000 ;
14
14
function sendEmail ( opts ) {
15
- mandrill . sendMail ( opts , function ( err , resp ) {
15
+ mandrill ( opts , function ( err , resp ) {
16
16
if ( err ) {
17
17
console . log ( err ) ;
18
18
} else {
19
- console . log ( 'email sent' ) ;
19
+ console . log ( resp ) ;
20
20
}
21
21
} ) ;
22
22
}
You can’t perform that action at this time.
0 commit comments