Comparing version 0.1.17 to 0.1.18
{ | ||
"name": "emailjs", | ||
"description": "send text/html emails and attachments from node.js to any smtp server", | ||
"version": "0.1.17", | ||
"version": "0.1.18", | ||
"author": "eleith", | ||
"contributors":["izuzak"], | ||
"contributors":["izuzak", "Hiverness"], | ||
"repository": | ||
@@ -8,0 +8,0 @@ { |
@@ -1,2 +0,2 @@ | ||
#v0.1.17 | ||
#v0.1.18 | ||
@@ -3,0 +3,0 @@ ### emailjs |
@@ -1,8 +0,9 @@ | ||
var stream = require('stream'); | ||
var util = require('util'); | ||
var fs = require('fs'); | ||
var os = require('os'); | ||
var path = require('path'); | ||
var CRLF = "\r\n"; | ||
var counter = 0; | ||
var stream = require('stream'); | ||
var util = require('util'); | ||
var fs = require('fs'); | ||
var os = require('os'); | ||
var path = require('path'); | ||
var CRLF = "\r\n"; | ||
var MIMECHUNK = 76; // MIME standard wants 76 char chunks when sending out. | ||
var counter = 0; | ||
@@ -207,6 +208,8 @@ var generate_boundary = function() | ||
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]); | ||
self.emit('data', data.join("")); | ||
output_chunk(new Buffer(self.message.html.message).toString("base64")); | ||
self.emit('data', [CRLF, "--", boundary, "--", CRLF, CRLF].join("")); | ||
next(); | ||
@@ -218,10 +221,9 @@ }; | ||
var data = ["Content-Type: ", attachment.type, CRLF, "Content-Transfer-Encoding: base64", CRLF]; | ||
data = data.concat(["Content-Disposition: attachment; filename=\"", attachment.name, "\"", CRLF, CRLF]); | ||
data = data.concat(["Content-Disposition: attachment; filename=\"", attachment.name, "\"", CRLF, CRLF]); | ||
self.emit('data', data.join("")); | ||
var mimechunk = 76; // MIME standard wants 76 char chunks when sending out | ||
var chunk = mimechunk*25*3; // 5700 | ||
var buffer = new Buffer(chunk); | ||
var opened = function(err, fd) | ||
var chunk = MIMECHUNK*25*3; // 5700 | ||
var buffer = new Buffer(chunk); | ||
var opened = function(err, fd) | ||
{ | ||
@@ -242,11 +244,4 @@ if(!err) | ||
{ | ||
var info = buffer.toString("base64", 0, bytes); | ||
var leftover= info.length % mimechunk; | ||
var loops = Math.round(info.length / mimechunk); | ||
output_chunk(buffer.toString("base64", 0, bytes)); | ||
for(var step = 0; step < loops; step++) | ||
{ | ||
self.emit('data', info.substring(step*mimechunk, mimechunk*(step + 1)) + CRLF); | ||
} | ||
if(bytes == chunk) // gauranteed no leftovers | ||
@@ -258,3 +253,2 @@ { | ||
{ | ||
self.emit('data', leftover ? info.substr(-leftover) + CRLF + CRLF : CRLF); // important! | ||
fs.close(fd, next); | ||
@@ -279,2 +273,16 @@ } | ||
var output_chunk = function(data) | ||
{ | ||
var leftover= data.length % MIMECHUNK; | ||
var loops = Math.round(data.length / MIMECHUNK); | ||
for(var step = 0; step < loops; step++) | ||
{ | ||
self.emit('data', data.substring(step*MIMECHUNK, MIMECHUNK*(step + 1)) + CRLF); | ||
} | ||
if(leftover) | ||
self.emit('data', leftover ? data.substr(-leftover) + CRLF + CRLF : CRLF); // important! | ||
}; | ||
var output_text = function(next) | ||
@@ -281,0 +289,0 @@ { |
@@ -21,2 +21,4 @@ var tests = | ||
{ | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var message = email.message.create( | ||
@@ -27,7 +29,8 @@ { | ||
to: config.email, | ||
text: "hello friend, i hope this message finds you well." | ||
text: "hello friend if you are seeing this, you can not view html emails. it is attached inline." | ||
}); | ||
// attach an alternative html email for those with advanced email clients | ||
message.attach_alternative("<html><body> hello <i>friend</i> i hope <b>this</b> <a href='http://github.com/eleith/emailjs'>message</a> finds <b>you</b> well.</body></html>"); | ||
//message.attach_alternative("<html><body> hello <i>friend</i> i hope <b>this</b> <a href='http://github.com/eleith/emailjs'>message</a> finds <b>you</b> well.</body></html>"); | ||
message.attach_alternative(fs.readFileSync(path.join(__dirname, "attachments/smtp.html"), "utf-8")); | ||
@@ -61,3 +64,3 @@ server.send(message, function(err, message) | ||
for(test in tests) | ||
for(var test in tests) | ||
exports[test] = tests[test]; |
1248247
1547
3