2021年3月22日星期一

Sending autogenerated emails using handlebarsjs, email-templates or nodemailer-express-handlebars

In both email-templates and nodemailer-express-handlebars npm packages, it appears that the way to load the templates is from file path.

For instance:

const options = {    viewEngine: {      partialsDir: __dirname + "/views/partials",      layoutsDir: __dirname + "/views/layouts",      extname: ".hbs"    },    extName: ".hbs",    viewPath: "views"  };  

However, I have a use case where the template is returned as html string from a database.

Example

<h1>Hi , ........<h1> // could be anything at any given time  

Is there a way to pass the returned html string as template on either email-templates or nodemailer-express-handlebars without having to create and delete files on the node system?

I am also open to any other solution.

https://stackoverflow.com/questions/66756300/sending-autogenerated-emails-using-handlebarsjs-email-templates-or-nodemailer-e March 23, 2021 at 10:08AM

没有评论:

发表评论