saasgear
saasgear copied to clipboard
Fix send email
export default function generateEmailTemplate({ fileName, data }) {
const templatePath = `${path.resolve()}/email-template/${fileName}`;
const template = execSync(`mjml ${templatePath}`).toString();
return handlebars.compile(template)(data).toString();
}
- please use mjml npm package to compile email
- never use NodeJS sync method. It hurts app performance. Use async/await or Promise instead.