Skip to content

Commit

Permalink
Changed inline to attachment
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Jan 21, 2011
1 parent 1ab4ba6 commit 5b10839
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
11 changes: 11 additions & 0 deletions README.md
Expand Up @@ -78,6 +78,17 @@ The following are the possible fields of an e-mail message:
- **html** - The HTML version of the message
- **attachments** - An array of attachment objects. Attachment object consists of two properties - `filename` and `contents`. Property `contents` can either be a String or a Buffer (for binary data). `filename` is the name of the attachment.

There's an optional extra field **headers** which holds custom header values in the form of `{key: value}`. These values will not overwrite any existing header but will be appended to the list.

mail_data = {
sender:"me@example.com",
....
headers: {
'X-My-Custom-Header-Value': 'Visit www.example.com for more info!'
}
}


Using Embedded Images
--------------------

Expand Down
9 changes: 4 additions & 5 deletions lib/mail.js
Expand Up @@ -5,7 +5,7 @@ var SMTPClient = require("./smtp").SMTPClient,
* Version constants
*/
var X_MAILER_NAME = "Nodemailer",
X_MAILER_VERSION = "0.1";
X_MAILER_VERSION = "0.1.1; +http://www.nodemailer.org";

/**
* mail
Expand Down Expand Up @@ -293,7 +293,7 @@ EmailMessage.prototype.generateBody = function(){
contents: this.attachments[i].contents instanceof Buffer?
this.attachments[i].contents:
new Buffer(this.attachments[i].contents, "utf-8"),
disposition: this.attachments[i].cid?"inline":"attachment"
disposition: "attachment"
};

rows.push("--"+this.content_boundary);
Expand All @@ -305,9 +305,8 @@ EmailMessage.prototype.generateBody = function(){
rows.push("Content-Transfer-Encoding: base64");
rows.push("");

rows.push(current.contents.toString("base64").replace(/.{78}/g,function(o){
return o+"\n";
}));
// rows can't be too long, so base64 string will be cut to 78 char lines
rows.push(current.contents.toString("base64").replace(/(.{78})/g,"$1\r\n"));

}

Expand Down

0 comments on commit 5b10839

Please sign in to comment.