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