sabuhish / fastapi-mail

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

fix jinja2 templates #63

Closed kucera-lukas closed 3 years ago

kucera-lukas commented 3 years ago

Hi,

I've been using this library for a few weeks and ran into some issues with the jinja2 integration.

1) if ConnectionConfig is not instantiated in project parent directory the template validator silently fails and returns None. This results in very confusing error messages because user is not notified about it.

This has been improved so there is proper directory validation and template engine creation is done separately via a method.

2) There are 3 ways to send data with MessageSchema - via body (no jinja2), html or body (with jinja2). The combination of this with the subtype argument is pretty confusing because it is not very well documented so sometimes emails end up looking very differently from what we would expect.

Created a separate jinja2 argument (template_body) so user knows which argument to use whether they're using jinja2 or not.

kucera-lukas commented 3 years ago

Take a look at this improvement, is it sufficient?

I have also removed some of the os checks because that is already done by pydantic DirectoryPath.

sabuhish commented 3 years ago

Yes, you are right at first it gets a bit complicated, to have field html and body. But if you properly set it up, this won't be a big problem. Your workaround also seems to be meaningful. thank you for your additional changes. Thanks for your work.Highly appreciated your work!

sabuhish commented 3 years ago

@kucera-lukas Thank you a lot again for your work! it is released available in 0.4.0.