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 6ce98ec..0a8a0a9 100644
--- a/lib/sendgrid.js
+++ b/lib/sendgrid.js
@@ -42,8 +42,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, boundary);
var length = 0;
@@ -74,9 +75,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();
}