Sendgrid now uses a more sophisticated Email object rather than plain object (more flexible for sending complex email message)
This commit is contained in:
@ -11,20 +11,20 @@ exports.getContact = function(req, res) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.postContact = function(req, res) {
|
exports.postContact = function(req, res) {
|
||||||
var firstName = req.body.firstName;
|
var from = req.body.email;
|
||||||
var lastName = req.body.lastName;
|
|
||||||
var email = req.body.email;
|
|
||||||
var body = req.body.contactBody;
|
var body = req.body.contactBody;
|
||||||
|
|
||||||
var sendTo = 'sakhat@gmail.com';
|
var sendTo = 'sakhat@gmail.com';
|
||||||
var subject = 'API Example | Contact Form';
|
var subject = 'API Example | Contact Form';
|
||||||
|
|
||||||
sendgrid.send({
|
var email = new sendgrid.Email({
|
||||||
to: sendTo,
|
to: sendTo,
|
||||||
from: email,
|
from: from,
|
||||||
subject: subject,
|
subject: subject,
|
||||||
text: body
|
text: body
|
||||||
}, function(err, json) {
|
});
|
||||||
|
|
||||||
|
sendgrid.send(email, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
req.flash('error', err.message);
|
req.flash('error', err.message);
|
||||||
return res.redirect('/contact');
|
return res.redirect('/contact');
|
||||||
|
Reference in New Issue
Block a user