From 27788480430948f158086cb175eae5b5714f08c7 Mon Sep 17 00:00:00 2001 From: Sahat Yalkabov Date: Sat, 30 Nov 2013 13:14:29 -0500 Subject: [PATCH] Added sendgrid package and user/pass to config --- controllers/contact.js | 13 +++++++++++++ package.json | 1 + 2 files changed, 14 insertions(+) diff --git a/controllers/contact.js b/controllers/contact.js index 70328a80a1..7a15240e46 100644 --- a/controllers/contact.js +++ b/controllers/contact.js @@ -1,3 +1,6 @@ +var config = require('../config/config.json'); +var sendgrid = require('sendgrid')(config.sendgrid.user, config.sendgrid.password); + exports.getContact = function(req, res) { res.render('contact', { title: 'Contact', @@ -11,4 +14,14 @@ exports.postContact = function(req, res) { var lastName = req.body.lastName; var email = req.body.email; var body = req.body.contactBody; + + sendgrid.send({ + to: 'example@example.com', + from: 'other@example.com', + subject: 'Hello World', + text: 'My first email through SendGrid.' + }, function(err, json) { + if (err) { return console.error(err); } + console.log(json); + }); }; \ No newline at end of file diff --git a/package.json b/package.json index 9c3980b3a3..9c2fb2b432 100755 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "passport-local": "*", "passport-facebook": "*", "passport-google-oauth": "*", + "sendgrid": "*", "tumblrwks": "*", "underscore": "*" }