summaryrefslogtreecommitdiffstats
path: root/lib/sendgrid.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sendgrid.js')
-rw-r--r--lib/sendgrid.js14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/sendgrid.js b/lib/sendgrid.js
index 4d039a3..cc1d98d 100644
--- a/lib/sendgrid.js
+++ b/lib/sendgrid.js
@@ -35,8 +35,9 @@ SendGrid.prototype.send = function(email, callback) {
var options = {
host: 'sendgrid.com',
path: '/api/mail.send.json',
- method: 'POST',
+ method: 'POST'
};
+
if (email.hasFiles()) {
post_data = self.getMultipartData(email);
var length = 0;
@@ -63,9 +64,16 @@ SendGrid.prototype.send = function(email, callback) {
});
});
- for (var key in post_data) {
- request.write(post_data[key]);
+ // If the email has files, it will be a multipart request.
+ // TODO: make this feel less dirty.
+ if (email.hasFiles()) {
+ for (var key in post_data) {
+ request.write(post_data[key]);
+ }
+ } else {
+ request.write(post_data);
}
+
request.end();
}