diff options
Diffstat (limited to 'lib/sendgrid.js')
-rw-r--r-- | lib/sendgrid.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/sendgrid.js b/lib/sendgrid.js index 821e6c1..122a1a9 100644 --- a/lib/sendgrid.js +++ b/lib/sendgrid.js @@ -2,6 +2,7 @@ var querystring = require('querystring'); var https = require('https'); +var nodemailer = require('nodemailer'); var _ = require('underscore'); function SendGrid(credentials) { @@ -39,6 +40,31 @@ SendGrid.prototype.send = function(email, callback) { request.end(); }; +SendGrid.prototype.smtp = function(email, callback) { + var self = this; + + nodemailer.SMTP = { + host: 'smtp.sendgrid.net', + use_authentication: true, + ssl: true, + user: this.api_user, + pass: this.api_key + }; + + email = email.params || email; + + nodemailer.send_mail({ + sender: email.from, + to: email.to, + subject: email.subject, + body: email.text, + html: email.html + }, function(error, success) { + callback.call(self, success, error); + }); + +} + SendGrid.prototype.getPostData = function(params) { var data = { api_user: this.api_user, |