summaryrefslogtreecommitdiffstats
path: root/lib/sendgrid.js
diff options
context:
space:
mode:
authorKyle Partridge <partkyle@gmail.com>2012-01-10 15:49:31 -0800
committerKyle Partridge <partkyle@gmail.com>2012-01-10 15:49:31 -0800
commitbf067afe35ff5ad04fb136a06757e2353694ebb6 (patch)
tree400ac141930f27ebf5d83f483f44b3b038266200 /lib/sendgrid.js
parentc994e66bf37c30980a3d78b3a218e861880b4a12 (diff)
downloadsendgrid-nodejs-bf067afe35ff5ad04fb136a06757e2353694ebb6.zip
sendgrid-nodejs-bf067afe35ff5ad04fb136a06757e2353694ebb6.tar.gz
sendgrid-nodejs-bf067afe35ff5ad04fb136a06757e2353694ebb6.tar.bz2
added basic smtp sending capability
Diffstat (limited to 'lib/sendgrid.js')
-rw-r--r--lib/sendgrid.js26
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,