mailcomposer
Advanced tools
Comparing version 0.1.12 to 0.1.13
@@ -6,2 +6,3 @@ var Stream = require("stream").Stream, | ||
DKIMSign = require("./dkim").DKIMSign, | ||
urlFetch = require("./urlfetch"), | ||
fs = require("fs"); | ||
@@ -945,3 +946,7 @@ | ||
if(element.filePath){ | ||
this._serveFile(element.filePath, callback); | ||
if(element.filePath.match(/^https?:\/\//)){ | ||
this._serveStream(urlFetch(element.filePath, {userAgent: element.userAgent}), callback); | ||
}else{ | ||
this._serveFile(element.filePath, callback); | ||
} | ||
return; | ||
@@ -948,0 +953,0 @@ }else if(element.streamSource){ |
{ | ||
"name": "mailcomposer", | ||
"description": "Compose E-Mail messages", | ||
"version": "0.1.12", | ||
"version": "0.1.13", | ||
"author" : "Andris Reinman", | ||
@@ -6,0 +6,0 @@ "maintainers":[ |
@@ -22,2 +22,6 @@ # mailcomposer | ||
## Support mailcomposer development | ||
[![Donate to author](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DB26KWR2BQX5W) | ||
## Installation | ||
@@ -211,6 +215,7 @@ | ||
* **contents** - String or a Buffer contents for the attachment | ||
* **filePath** - path to a file if you want to stream the file instead of including it (better for larger attachments) | ||
* **filePath** - path to a file or an URL if you want to stream the file instead of including it (better for larger attachments) | ||
* **streamSource** - Stream object for arbitrary binary streams if you want to stream the contents (needs to support *pause*/*resume*) | ||
* **contentType** - content type for the attachment, if not set will be derived from the `fileName` property | ||
* **contentDisposition** - content disposition type for the attachment, defaults to "attachment" | ||
* **userAgent** - User-Agent string to be used if the fileName points to an URL | ||
@@ -217,0 +222,0 @@ One of `contents`, `filePath` or `streamSource` must be specified, if none is |
@@ -5,4 +5,8 @@ var testCase = require('nodeunit').testCase, | ||
MailParser = require("mailparser").MailParser, | ||
fs = require("fs"); | ||
fs = require("fs"), | ||
http = require("http"); | ||
var HTTP_PORT = 9437; | ||
exports["General tests"] = { | ||
@@ -754,2 +758,61 @@ | ||
}, | ||
"Attachment source url": function(test){ | ||
var server = http.createServer(function (req, res) { | ||
if(req.url=="/textfile.txt"){ | ||
fs.createReadStream(__dirname+"/textfile.txt") | ||
fs.createReadStream(__dirname+"/textfile.txt").pipe(res); | ||
}else{ | ||
res.writeHead(404, {'Content-Type': 'text/plain'}); | ||
res.end('Not found!\n'); | ||
} | ||
}); | ||
server.listen(HTTP_PORT, '127.0.0.1'); | ||
var mc = new MailComposer(); | ||
mc.setMessageOption(); | ||
mc.addAttachment({ | ||
fileName: "file.txt", | ||
filePath: "http://localhost:"+HTTP_PORT+"/textfile.txt" | ||
}); | ||
mc.streamMessage(); | ||
var mp = new MailParser(); | ||
mc.pipe(mp); | ||
mp.on("end", function(mail){ | ||
test.equal(mail.attachments[0].checksum, "59fbcbcaf18cb9232f7da6663f374eb9"); | ||
server.close(); | ||
test.done(); | ||
}); | ||
}, | ||
"Attachment source invalid url": function(test){ | ||
var server = http.createServer(function (req, res) { | ||
res.writeHead(404, {'Content-Type': 'text/plain'}); | ||
res.end('Not found!\n'); | ||
}) | ||
server.listen(HTTP_PORT, '127.0.0.1'); | ||
var mc = new MailComposer(); | ||
mc.setMessageOption(); | ||
mc.addAttachment({ | ||
fileName: "file.txt", | ||
filePath: "http://localhost:"+HTTP_PORT+"/textfile.txt" | ||
}); | ||
mc.streamMessage(); | ||
var mp = new MailParser(); | ||
mc.pipe(mp); | ||
mp.on("end", function(mail){ | ||
test.equal(mail.attachments[0].checksum, "3995d423c7453e472ce0d54e475bae3e"); | ||
server.close(); | ||
test.done(); | ||
}); | ||
}, | ||
"escape SMTP": function(test){ | ||
@@ -756,0 +819,0 @@ var mc = new MailComposer({escapeSMTP: true}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
168620
14
2428
317
3