diff options
author | Kyle Partridge <partkyle@gmail.com> | 2012-01-13 15:48:14 -0800 |
---|---|---|
committer | Kyle Partridge <partkyle@gmail.com> | 2012-01-13 15:48:14 -0800 |
commit | 0826f2d88ceaaffd16568bb21e8340f2f3537170 (patch) | |
tree | 89358633d48f65f3016547a22ef336f82d65071a | |
parent | b9168937ea838657969943e1a3737668e51d5a4a (diff) | |
download | sendgrid-nodejs-0826f2d88ceaaffd16568bb21e8340f2f3537170.zip sendgrid-nodejs-0826f2d88ceaaffd16568bb21e8340f2f3537170.tar.gz sendgrid-nodejs-0826f2d88ceaaffd16568bb21e8340f2f3537170.tar.bz2 |
boundary should reset each time
-rw-r--r-- | lib/sendgrid.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/sendgrid.js b/lib/sendgrid.js index fba001b..1ad92a6 100644 --- a/lib/sendgrid.js +++ b/lib/sendgrid.js @@ -14,8 +14,6 @@ function SendGrid(credentials) { this.api_key = credentials.api_key; } -var boundary = Math.random(); - /* * Sends an email and returns true if the * message was sent successfully. @@ -25,6 +23,8 @@ var boundary = Math.random(); SendGrid.prototype.send = function(email, callback) { var self = this; + var boundary = Math.random(); + if (email.constructor !== Email) { email = new Email(email); } @@ -37,7 +37,7 @@ SendGrid.prototype.send = function(email, callback) { method: 'POST', }; if (email.hasFiles()) { - post_data = self.getMultipartData(email); + post_data = self.getMultipartData(email, boundary); var length = 0; for (var buf in post_data) { length += post_data[buf].length; @@ -127,7 +127,7 @@ SendGrid.prototype.getPostData = function(email) { return querystring.stringify(data); }; -SendGrid.prototype.getMultipartData = function(email) { +SendGrid.prototype.getMultipartData = function(email, boundary) { var data = []; data.push(new Buffer(encodeField(boundary, 'api_user', this.api_user))); data.push(new Buffer(encodeField(boundary, 'api_key', this.api_key))); |