Skip to content

Instantly share code, notes, and snippets.

@pepesenaris
Created July 19, 2018 18:23
Show Gist options
  • Save pepesenaris/f15f808c0581db091aefc250935fdfe1 to your computer and use it in GitHub Desktop.
Save pepesenaris/f15f808c0581db091aefc250935fdfe1 to your computer and use it in GitHub Desktop.
Send email route handler
// server/index.js
const mailer = require("./mailer"); // In the top of the file
/* ... */
app.get("/api/send_email", function(req, res) {
res.set("Content-Type", "application/json");
const locals = { userName: req.body.userName };
const messageInfo = {
email: req.body.email, fromEmail: "info@ingsw.com",
fromName: "Star Wars", subject: "Checkout this awesome droids"
};
mailer.sendOne("droids", messageInfo, locals);
res.send('{"message":"Email sent."}');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment