Created
October 11, 2017 18:21
-
-
Save rbren/0692c2fc0623751b0235789f4ad5b751 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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