diff options
author | Leigh Martell <leigh@goinstant.com> | 2013-09-19 00:11:12 -0300 |
---|---|---|
committer | scottmotte <scott@scottmotte.com> | 2013-10-29 15:36:14 -0700 |
commit | f464b5ebb3eeacaf0141999f490ca3c535566117 (patch) | |
tree | af162e7d0383f9daca0dd9d7f6e7650d1eb84293 /lib/sendgrid.js | |
parent | 60ebb668a797dfd1e34c7777aa936ff351d2f4cc (diff) | |
download | sendgrid-nodejs-f464b5ebb3eeacaf0141999f490ca3c535566117.zip sendgrid-nodejs-f464b5ebb3eeacaf0141999f490ca3c535566117.tar.gz sendgrid-nodejs-f464b5ebb3eeacaf0141999f490ca3c535566117.tar.bz2 |
Fixed tests and options
Diffstat (limited to 'lib/sendgrid.js')
-rw-r--r-- | lib/sendgrid.js | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/sendgrid.js b/lib/sendgrid.js index 5f1260b..d0b3375 100644 --- a/lib/sendgrid.js +++ b/lib/sendgrid.js @@ -2,7 +2,7 @@ var package_json = require('./../package.json'); var nodemailer = require('nodemailer'); -var _ = require('underscore'); +var _ = require('lodash'); var request = require('request'); var Email = require('./email'); var SmtpapiHeaders = require('./smtpapi_headers'); @@ -14,6 +14,7 @@ var Sendgrid = function(api_user, api_key, options) { var _this = this; this.options = options || {}; + this.options.web = this.options.web || {}; this.options.port = this.options.port || 587; var send = function() { @@ -40,8 +41,8 @@ var Sendgrid = function(api_user, api_key, options) { email = new Email(email); } - _sendWeb(email, callback); - }; + _sendWeb.bind(this)(email, callback); + }.bind(this); /* * Sends an email via SMTP and returns true if the @@ -75,10 +76,14 @@ var Sendgrid = function(api_user, api_key, options) { * Psuedo-private methods */ var _sendWeb = function(email, callback) { - var req = request({ + var postOptions = { method : 'POST', uri : "https://sendgrid.com/api/mail.send.json" - }, function(err, resp, body) { + }; + + var options = _.merge(this.options.web, postOptions); + + var req = request(options, function(err, resp, body) { var json; if(err) return callback(err, null); @@ -122,7 +127,7 @@ var Sendgrid = function(api_user, api_key, options) { } catch(err) {} } } - } + }; var _sendSmtp = function(email, nodeMailerOptions, callback) { // SMTP settings |