So this is my first time asking a question on StackOverflow..
I am using Nodemailer to email me when someone has filled a form. I am using ExpressJS to handle the POST request.
All seems good now except when I tried to inject HTML tags on the form. I could play with the mail html as I wish!
This is my code for the sendMail
transport.sendMail({
from: `Form Submittion <${myEmailAddress}>`,
to: myOtherEmailAddress,
subject: "New Form Submitted",
text:
`Hi, \nNew Form Submitted!\n${req.body.request}`,
html:
`<h1>Hi, <br />New Form Submitted!</h1>
<h2>${req.body.request}</h2>`,
});
When the req.body.request has HTML tags, it can affect how my email looks, which I don't like..
Is there a way to sanatize the req.body.request from the nodemailer or express or should I relay on other tools? If so, could you please suggest some tools to do the job?