yads / nodemailer-express-handlebars

A plugin for nodemailer that uses express-handlebars view engine to generate emails
87 stars 30 forks source link

Load template from database instead of filepath #5

Closed lajpatshah closed 9 years ago

lajpatshah commented 9 years ago

Hi

I have an app which stores user-generated email template in DB & not as .hbs file. The template uses same delimiters as handlebar.

How can I render this template?

Say user has created an invoice email template (using CKEditor & exposed template variables) which I am supposed to send at the time of creating an invoice. I will be saving this template in DB TEXT. Now how do I initialize this template & send the mail.

Thanks

Lajpat

yads commented 9 years ago

I saw you posted this question in the express-handlebars project as well. Since this plugin uses express-handlebars under the hood, there is no way to do this unless they also support it.

lajpatshah commented 9 years ago

Hi Yads Thanks for looking into the request. However can you help me with my query http://stackoverflow.com/questions/33872486/freshbook-style-email-template-using-nodejs Thanks once again

yads commented 9 years ago

@lajpatshah you seem to be a bit confused in regards to nodejs and express. It's true that most express view engines need the views to be stored on the file system. However, nothing is inherently stopping you from writing raw html directly to the response or creating raw html emails with Nodemailer. For your use case you can use handlebars or another templating engine directly to generate your emails from any text.