Last active
May 30, 2019 23:40
-
-
Save rbren/ceb9a16e30391bb1aeea83439bc724ef 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
let app = require('express')(); | |
app.use(require('body-parser').urlencoded()); | |
const CONTACT_ADDRESS = '[email protected]'; | |
var mailer = require('nodemailer').createTransport({ | |
service: 'Gmail', | |
auth: { | |
user: process.env.GMAIL_ADDRESS, | |
pass: process.env.GMAIL_PASSWORD, | |
} | |
}); | |
app.post('/contact', function(req, res) { | |
mailer.sendMail({ | |
from: req.body.from, | |
to: [CONTACT_ADDRESS], | |
subject: req.body.subject || '[No subject]', | |
html: req.body.message || '[No message]', | |
}, function(err, info) { | |
if (err) return res.status(500).send(err); | |
res.json({success: true}); | |
}) | |
}); | |
app.listen(3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment