freeCodeCamp/controllers/contact.js

27 lines
742 B
JavaScript
Raw Normal View History

var config = require('../config/config.json');
var sendgrid = require('sendgrid')(config.sendgrid.user, config.sendgrid.password);
exports.getContact = function(req, res) {
2013-11-20 04:19:53 +00:00
res.render('contact', {
title: 'Contact',
2013-11-20 13:03:10 +00:00
user: req.user,
messages: req.flash('messages')
2013-11-20 04:19:53 +00:00
});
};
exports.postContact = function(req, res) {
var firstName = req.body.firstName;
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);
});
};