Closed sumitpatel93 closed 1 year ago
Your code at https://gist.github.com/sumitpatel93/4560cb3760e99e0f2a63497dc51d04bf is mixing usage of async/await with callbacks, which is not supported and is bad code practice (it's an anti-pattern). It looks like we need to update our example on our side to support better code practice.
Also, you have a bug in your code at https://gist.github.com/sumitpatel93/4560cb3760e99e0f2a63497dc51d04bf#file-sendemail-js-L27-L31. You can see that you do not resolve
for the case when there is !template
found.
I am rendering the template from DB ( MongoDB )
Node.js version: 16
OS version: MacOS
Description: I want to send dynamic templates after fetching it from the database, but they are not being sent to the corresponding email. I think I am missing something on the syntax for rendering dynamic emails from DB
Actual behaviour
It should fetch the template from DB with its respective name and should be sent to the corresponding email The code works fine when the msg stored in DB is plain text, but with ejs/pug it's failing to send mail.
Template Db schema
{ _id : 23123, templateName : hello templateBody : <Template in Ejs format> }
Expected behaviour
Code to reproduce
Gist - https://gist.github.com/sumitpatel93/4560cb3760e99e0f2a63497dc51d04bf
Checklist