Skip to content

Instantly share code, notes, and snippets.

@zachary-russell
Created October 4, 2017 17:13
Show Gist options
  • Save zachary-russell/93dcc482b38d1c527adeddcd2ddb5ed9 to your computer and use it in GitHub Desktop.
Save zachary-russell/93dcc482b38d1c527adeddcd2ddb5ed9 to your computer and use it in GitHub Desktop.
Google Cloud Form Processing Script
var api_key = 'YOUR-KEY-HERE';
var sending_domain = 'sandbox3d603fef70dc4a3db61d4f9de9854c46.mailgun.org';
var mailgun = require('mailgun-js')({apiKey: api_key, domain: sending_domain});
exports.processForm = function processForm(req, res) {
query = req.query;
var data = {
from: query.fname + ' ' + query.lname + ' <' + decodeURIComponent(query.email) + '>',
to: '[email protected]',
subject: 'New Submission From ' + query['fname'] + ' ' + query['lname'] ,
text: decodeURIComponent(query.message)
}
console.log(query);
mailgun.messages().send(data, function (error, body) {
res.send(body);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment