I have a html/css e-mail template that I want to use to send users e-mails for things like welcoming after signing up, send secret codes, and general purpose e-mails.
I need to "inject" this html template it with custom text instead of the lorem ipsum it currently contains.
I want to make a javascript function that inserts given text into my html template, this way my e-mail service can send custom e-mail to users based on their e-mail and custom messages throughout my node app as certain events are triggered.
I have a html/css e-mail in the file generalContact.html
I am unsure of 1 how "export" it so that makeEmail.js has access to the template and 2 how to format the html email so it can accept custom input text.
Do I have to assign the template to a variable first somehow?
Any help/guidance would be appreciated, thank you.
makeEmail.js
const htmlTemplate = require("generalContact.html")
const makeEmail = (bodyText) => {
// How can I access the HTML file and insert the above input into it?
return emailWithTextInserted
}
module.exports = makeEmail
generalContact.html
<!DOCTYPE html PUBLIC "-//W3C/...." "http://www.w3.org/.....">
<html xmlns="http://www.w3.org......">
<head>
<title></title>
</head>
<body>
<center>
<tr>
<td>
This is Photoshop's version of Lorem Ipsum. Proin gravida nibh vel
velit auctor aliquet. Aenean sollicitudin, lorem quis bibendum auctor,
nisi elit consequat ipsum, nec sagittis sem nibh id elit. Duis
<a>
sit amet nibh vulputate cursus a sit amet mauris.<br /><br />
Mauris in erat justo. Nullam ac urna eu felis dapibus condimentum sit
amet a augue. Sed non neque elit. Sed ut imperdiet nisi. Proin
condimentum fermentum nunc. Etiam
<a>
erat sed fermentum feugiat, velit mauris egestas quam, ut aliquam
massa nisl quis neque. Suspendisse in orci enim.
</td>
</tr>
</center>
</body>
</html>