1 let router
= require("express").Router();
2 const mailer
= require(__dirname
.replace("/routes", "/utils/mailer"));
4 // Send a message through contact form
5 router
.post("/messages", (req
,res
,next
) => {
7 return res
.json({errmsg: "Unauthorized access"});
8 const from = req
.body
["email"];
9 const subject
= req
.body
["subject"];
10 const body
= req
.body
["body"];
12 mailer
.send(from, mailer
.contact
, subject
, body
, err
=> {
14 return res
.json({errmsg:err
});
15 // OK, everything fine
16 res
.json({}); //ignored
20 module
.exports
= router
;