Comparing version 0.1.6 to 0.1.7
{ | ||
"name": "emailjs", | ||
"description": "send text/html emails and attachments from node.js to any smtp server", | ||
"version": "0.1.6", | ||
"author": "eleith", | ||
"contributors" : [ | ||
], | ||
"repository": { | ||
"name": "emailjs", | ||
"description": "send text/html emails and attachments from node.js to any smtp server", | ||
"version": "0.1.7", | ||
"author": "eleith", | ||
"contributors": ["izuzak"], | ||
"repository": | ||
{ | ||
"type": "git", | ||
"url": "http://github.com/eleith/emailjs.git" | ||
}, | ||
"dependencies": { | ||
}, | ||
"engine": [ "node >= 0.3.8" ], | ||
"main": "email" | ||
"dependencies": {}, | ||
"engine": ["node >= 0.3.8"], | ||
"main": "email" | ||
} |
@@ -1,2 +0,2 @@ | ||
#v0.1.6 | ||
#v0.1.7 | ||
@@ -3,0 +3,0 @@ ### emailjs |
@@ -144,6 +144,14 @@ var stream = require('stream'); | ||
if(index == -1 && self.message.html) | ||
if(index < 0) | ||
{ | ||
self.emit('data', ["--", boundary, CRLF].join("")); | ||
output_process(function() { output_alternatives(next); }); | ||
if(self.message.html) | ||
{ | ||
output_process(function() { output_alternatives(next); }); | ||
} | ||
else | ||
{ | ||
output_text(next); | ||
} | ||
} | ||
@@ -157,3 +165,3 @@ else if(index < self.message.attachments.length) | ||
{ | ||
self.emit('data', [CRLF, CRLF, "--", boundary, "--", CRLF, CRLF].join("")); | ||
self.emit('data', ["--", boundary, "--", CRLF, CRLF].join("")); | ||
self.emit('end'); | ||
@@ -166,13 +174,13 @@ } | ||
var boundary = generate_boundary(); | ||
var data = ["Content-Type: multipart/alternative; boundary=\"", boundary, "\"", CRLF, CRLF]; | ||
data = data.concat(["--", boundary, CRLF]); | ||
data = data.concat(["Content-Type:", self.message.content, CRLF, "Content-Transfer-Encoding: 7bit", CRLF, "Content-Disposition: inline", CRLF, CRLF]); | ||
data = data.concat([self.message.text, CRLF, CRLF]); | ||
self.emit('data', ["Content-Type: multipart/alternative; boundary=\"", boundary, "\"", CRLF, CRLF].join("")); | ||
self.emit('data', ["--", boundary, CRLF].join("")); | ||
data = data.concat(["--", boundary, CRLF]); | ||
output_text(function(){}); | ||
var data = ["--", boundary, CRLF]; | ||
data = data.concat(["Content-Type:text/html; charset=", self.message.html.charset, CRLF, "Content-Transfer-Encoding: base64", CRLF]); | ||
data = data.concat(["Content-Disposition: inline", CRLF, CRLF]); | ||
data = data.concat([(new Buffer(self.message.html.message)).toString("base64"), CRLF, CRLF]); | ||
data = data.concat(["--", boundary, "--", CRLF, CRLF]); | ||
@@ -217,3 +225,4 @@ | ||
self.emit('data', buffer.slice(0, bytes).toString("base64")); | ||
fs.close(fd, function() { self.emit('end') }); | ||
self.emit('data', [CRLF, CRLF].join("")); // important! | ||
fs.close(fd, next); | ||
} | ||
@@ -237,2 +246,12 @@ } | ||
var output_text = function(next) | ||
{ | ||
var data = ["Content-Type:", self.message.content, CRLF, "Content-Transfer-Encoding: 7bit", CRLF]; | ||
data = data.concat(["Content-Disposition: inline", CRLF, CRLF]); | ||
data = data.concat([self.message.text || "", CRLF, CRLF]); | ||
self.emit('data', data.join("")); | ||
next(); | ||
}; | ||
var output_data = function() | ||
@@ -250,5 +269,3 @@ { | ||
{ | ||
self.emit("Content-Type:" + self.content + CRLF); | ||
self.emit('data', CRLF + self.message.text); | ||
self.emit('end'); | ||
output_text(function() { self.emit('end') }); | ||
} | ||
@@ -255,0 +272,0 @@ }; |
42918
1389