Skip to content

Commit

Permalink
Added URL option for attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
Andris Reinman committed Apr 16, 2012
1 parent 903dc31 commit 02c57f0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
21 changes: 14 additions & 7 deletions README.md
Expand Up @@ -401,7 +401,7 @@ Attahcment object consists of the following properties:
* **fileName** - filename to be reported as the name of the attached file, use of unicode is allowed (except when using Amazon SES which doesn't like it)
* **cid** - optional content id for using inline images in HTML message source
* **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** - optional content type for the attachment, if not set will be derived from the `fileName` property
* **contentDisposition** - optional content disposition type for the attachment, defaults to "attachment"
Expand All @@ -414,26 +414,33 @@ Attachments can be added as many as you want.
var mailOptions = {
...
attachments: [
{
{ // utf-8 string as an attachment
fileName: "text1.txt",
contents: "hello world!
},
{
{ // binary buffer as an attachment
fileName: "text2.txt",
contents: new Buffer("hello world!,"utf-8")
},
{
{ // file on disk as an attachment
fileName: "text3.txt",
filePath: "/path/to/file.txt" // stream this file
},
{
{ // fileName and content type is derived from filePath
filePath: "/path/to/file.txt"
},
{ // stream as an attachment
fileName: "text4.txt",
streamSource: fs.createReadStream("file.txt")
},
{
fileName: "text",
{ // define custom content type for the attachment
fileName: "text.bin",
contents: "hello world!,
contentType: "text/plain"
},
{ // use URL as an attachment
fileName: "license.txt",
contents: "https://raw.github.com/andris9/Nodemailer/master/LICENSE"
}
]
}
Expand Down
1 change: 1 addition & 0 deletions lib/nodemailer.js
Expand Up @@ -275,6 +275,7 @@ Nodemailer.prototype.setAttachments = function(){
var attachment;
for(var i=0, len=this.options.attachments.length; i<len; i++){
attachment = this.options.attachments[i];
attachment.userAgent = attachment.userAgent || this.generateUserAgentString();
this.mailcomposer.addAttachment(attachment);
}
};
4 changes: 2 additions & 2 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "nodemailer",
"description": "Easy to use module to send e-mails, supports unicode and SSL/TLS",
"version": "0.3.17",
"version": "0.3.18",
"author" : "Andris Reinman",
"maintainers":[
{
Expand All @@ -25,7 +25,7 @@
}
],
"dependencies": {
"mailcomposer": ">= 0.1.11",
"mailcomposer": ">= 0.1.14",
"simplesmtp": ">= 0.1.15"
},
"devDependencies": {
Expand Down

0 comments on commit 02c57f0

Please sign in to comment.