lukencode / FluentEmail

All in one email sender for .NET. Supports popular senders (SendGrid, MailGun, etc) and Razor templates.
https://lukelowrey.com/dotnet-email-guide-2021/
MIT License
3.04k stars 438 forks source link

UsingTemplateFromFile should use configured FileProvider for relative paths #293

Open hisuwh opened 3 years ago

hisuwh commented 3 years ago

We have just started out using FluentEmail. Our assumption was that this setup:

services
    .AddFluentEmail("test@example.com")
    .AddLiquidRenderer(options =>
    {
         options.FileProvider = new PhysicalFileProvider("C:\\email-templates");
    });

Combined with:

   .UsingTemplateFromFile("template.liquid", model)

Would result in the template C:\email-templates\template.liquid being used. Instead, it looks for a file called template.liquid in the current directory.

In reality we're reading that root path from config, it would be nice if this library worked as above so we do not need to use the config and absolute path everywhere we are trying to send an email.

hisuwh commented 3 years ago

In fact this would be even more of a problem with a different file provider - i.e. if we wanted to store and read email templates from Azure Blob storage or similar as we would then have to load our template outside of FluentEmail and pass in raw at this point.

VictorioBerra commented 2 years ago

I think I am running into this now, I have spent a ton of time trying to work out why my templates from file could never be found.

Svudec commented 2 years ago

+1 for this feature