Comparing version 0.3.9 to 0.3.10
{ | ||
"name": "emailjs", | ||
"description": "send text/html emails and attachments (files, streams and strings) from node.js to any smtp server", | ||
"version": "0.3.9", | ||
"version": "0.3.10", | ||
"author": "eleith", | ||
@@ -29,3 +29,3 @@ "contributors":["izuzak", "Hiverness", "mscdex", "jimmybergman"], | ||
}, | ||
"engine": ["node >= 0.6"], | ||
"engine": ["node >= 0.10"], | ||
"main": "email", | ||
@@ -32,0 +32,0 @@ "scripts": |
@@ -5,51 +5,54 @@ var SMTPError = require('./error'); | ||
{ | ||
var buffer = '', | ||
notify = function() | ||
{ | ||
if(buffer.length) | ||
{ | ||
// parse buffer for response codes | ||
var line = buffer.replace("\r", ''); | ||
var match = line ? line.match(/(\d+)\s?(.*)/) : null; | ||
var buffer = '', | ||
stream.emit('response', null, match ? {code:match[1], message:match[2], data:line} : {code:-1, data:line}); | ||
buffer = ''; | ||
} | ||
}, | ||
notify = function() | ||
{ | ||
if(buffer.length) | ||
{ | ||
// parse buffer for response codes | ||
var line = buffer.replace("\r", ''); | ||
var match = line ? line.match(/(\d+)\s?(.*)/) : null; | ||
error = function(err) | ||
{ | ||
console.log("uh oh", err); | ||
stream.emit('response', SMTPError('connection encountered an error', SMTPError.ERROR, err)); | ||
}, | ||
stream.emit('response', null, match ? {code:match[1], message:match[2], data:line} : {code:-1, data:line}); | ||
buffer = ''; | ||
} | ||
}, | ||
error = function(err) | ||
{ | ||
stream.emit('response', SMTPError('connection encountered an error', SMTPError.ERROR, err)); | ||
}, | ||
timedout = function(err) | ||
{ | ||
stream.emit('response', SMTPError('timedout while connecting to smtp server', SMTPError.TIMEDOUT, err)); | ||
stream.emit('response', SMTPError('timedout while connecting to smtp server', SMTPError.TIMEDOUT, err)); | ||
}, | ||
watch = function(data) | ||
{ | ||
var decoded = data.toString(); | ||
var emit = false; | ||
var code = 0; | ||
watch = function() | ||
{ | ||
var data = stream.read(); | ||
buffer += decoded; | ||
notify(); | ||
}, | ||
if (data !== null) { | ||
var decoded = data.toString(); | ||
var emit = false; | ||
var code = 0; | ||
close = function(err) | ||
{ | ||
stream.emit('response', SMTPError('connection has closed', SMTPError.CONNECTIONCLOSED, err)); | ||
}, | ||
buffer += decoded; | ||
notify(); | ||
} | ||
}, | ||
end = function(err) | ||
{ | ||
stream.emit('response', SMTPError('connection has ended', SMTPError.CONNECTIONENDED, err)); | ||
}; | ||
close = function(err) | ||
{ | ||
stream.emit('response', SMTPError('connection has closed', SMTPError.CONNECTIONCLOSED, err)); | ||
}, | ||
end = function(err) | ||
{ | ||
stream.emit('response', SMTPError('connection has ended', SMTPError.CONNECTIONENDED, err)); | ||
}; | ||
this.stop = function(err) { | ||
stream.removeAllListeners('response'); | ||
stream.removeListener('data', watch); | ||
stream.removeListener('readable', watch); | ||
stream.removeListener('end', end); | ||
@@ -63,6 +66,6 @@ stream.removeListener('close', close); | ||
stream.on('data', watch); | ||
stream.on('end', end); | ||
stream.on('close', close); | ||
stream.on('error', error); | ||
stream.on('readable', watch); | ||
stream.on('end', end); | ||
stream.on('close', close); | ||
stream.on('error', error); | ||
stream.setTimeout(timeout, timedout); | ||
@@ -73,3 +76,3 @@ }; | ||
{ | ||
return new SMTPResponse(stream, timeout, onerror); | ||
return new SMTPResponse(stream, timeout, onerror); | ||
}; |
@@ -369,5 +369,5 @@ /* | ||
var attempt = function(err) { | ||
var attempt = function(err, data) { | ||
if (err) self.helo(response, domain); | ||
else caller(callback, err); | ||
else caller(callback, err, data); | ||
}; | ||
@@ -374,0 +374,0 @@ |
58849
1614