1 let router
= require("express").Router();
2 const access
= require("../utils/access");
3 const sendEmail
= require(__dirname
.replace("/routes", "/utils/mailer"));
4 const params
= require(__dirname
.replace("/routes", "/config/parameters"));
6 // Send a message through contact form
7 router
.post("/messages", access
.ajax
, (req
,res
) => {
8 const from = req
.body
["email"];
9 // Replace potential newline characters in subject
10 const subject
= req
.body
["subject"].replace(/\r?\n|\r/g, " ");
11 const body
= req
.body
["content"];
13 sendEmail(from, params
.mail
.contact
, subject
, body
, err
=> {
18 module
.exports
= router
;