Skip to content

Instantly share code, notes, and snippets.

@rbren
Created October 11, 2017 18:21
Show Gist options
  • Save rbren/0692c2fc0623751b0235789f4ad5b751 to your computer and use it in GitHub Desktop.
Save rbren/0692c2fc0623751b0235789f4ad5b751 to your computer and use it in GitHub Desktop.
var CONTACT_ADDRESS = '[email protected]';
var querystring = require('querystring');
var mailer = require('nodemailer').createTransport({
service: 'Gmail',
auth: {
user: process.env.GMAIL_ADDRESS,
pass: process.env.GMAIL_PASSWORD,
}
});
module.exports.contact = (event, context, callback) => {
var body = querystring.parse(event.body);
mailer.sendMail({
from: body.from,
to: [CONTACT_ADDRESS],
subject: body.subject || '[No subject]',
html: body.message || '[No message]',
}, function(err, info) {
if (err) return callback(err);
callback(null, {statusCode: 200, body: "Success!"});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment