Commit | Line | Data |
---|---|---|
298c42e6 | 1 | let router = require("express").Router(); |
866842c3 | 2 | const access = require("../utils/access"); |
1ad88021 BA |
3 | const sendEmail = require("../utils/mailer"); |
4 | const params = require("../config/parameters"); | |
298c42e6 BA |
5 | |
6 | // Send a message through contact form | |
866842c3 | 7 | router.post("/messages", access.ajax, (req,res) => { |
603b8a8b | 8 | const from = req.body["email"]; |
99b7a14c BA |
9 | // Replace potential newline characters in subject |
10 | const subject = req.body["subject"].replace(/\r?\n|\r/g, " "); | |
c5c47010 | 11 | const body = req.body["content"]; |
603b8a8b | 12 | |
866842c3 BA |
13 | sendEmail(from, params.mail.contact, subject, body, err => { |
14 | res.json(err || {}); | |
dac39588 | 15 | }); |
298c42e6 BA |
16 | }); |
17 | ||
18 | module.exports = router; |