Skip to content

Instantly share code, notes, and snippets.

@rbren
Last active May 30, 2019 23:40
Show Gist options
  • Save rbren/ceb9a16e30391bb1aeea83439bc724ef to your computer and use it in GitHub Desktop.
Save rbren/ceb9a16e30391bb1aeea83439bc724ef to your computer and use it in GitHub Desktop.
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