sabuhish / fastapi-mail

Fastapi mail system sending mails(individual, bulk) attachments(individual, bulk)
https://sabuhish.github.io/fastapi-mail/
MIT License
681 stars 82 forks source link

Fetching template from database instead of file #110

Closed nsankar90 closed 2 years ago

nsankar90 commented 2 years ago

Thanks for the wonderful package team,

Quick question Is it possible to fetch the template from a database to send mail to the user Every customers have a different level of access permissions so instead of keeping it in folder I thought of saving it in database.

I even write it as a HTML file and used it in the code it worked well for me, Is there any other better way you could suggest.

Many thanks in advance

sabuhish commented 2 years ago

Hi thanks for your nice words, they mean a lot. Actually what I was thinking is you could store them as a string then with the help of jinja you can map values, is that solve your case?

maestro-1 commented 2 years ago

So typically jinja works with both strings and template files, and fastapi mail is such that you have access to both, so storing it as a text in the database would work, just remember that the css has to be embedded in the string text for it to be styled properly.

sabuhish commented 2 years ago

Thanks for your help @maestro-1. I think we both answered questions, closing the issue.