diff --git a/src/Postal.AspNetCore/EmailService.cs b/src/Postal.AspNetCore/EmailService.cs index de522e1..5c3e0b8 100644 --- a/src/Postal.AspNetCore/EmailService.cs +++ b/src/Postal.AspNetCore/EmailService.cs @@ -104,7 +104,7 @@ public async Task CreateMailMessageAsync(Email email) var rawEmailString = await emailViewRenderer.RenderAsync(email); emailParser = new EmailParser(emailViewRenderer); var mailMessage = await emailParser.ParseAsync(rawEmailString, email); - if (mailMessage.From == null || mailMessage.From.Address == null) + if ((mailMessage.From == null || mailMessage.From.Address == null) && this.options.FromAddress != null) { mailMessage.From = new MailAddress(this.options.FromAddress); } diff --git a/src/Postal.AspNetCore/TemplateServices/TemplateService.cs b/src/Postal.AspNetCore/TemplateServices/TemplateService.cs index 08cd208..dbf0882 100644 --- a/src/Postal.AspNetCore/TemplateServices/TemplateService.cs +++ b/src/Postal.AspNetCore/TemplateServices/TemplateService.cs @@ -60,8 +60,11 @@ public async Task RenderTemplateAsync(HttpContextData httpCo { RequestServices = _serviceProvider, }; - httpContext.Features.Set(new EndpointFeature(httpContextData.Endpoint)); - httpContext.Features.Set(new RouteValuesFeature() { RouteValues = httpContextData.RouteValues }); + if (httpContextData != null) + { + httpContext.Features.Set(new EndpointFeature(httpContextData.Endpoint)); + httpContext.Features.Set(new RouteValuesFeature() { RouteValues = httpContextData.RouteValues }); + } if (viewModel.RequestPath != null) { diff --git a/src/Postal.Tests/EmailViewRenderTests.cs b/src/Postal.Tests/EmailViewRenderTests.cs index 40c41f3..f109e4b 100644 --- a/src/Postal.Tests/EmailViewRenderTests.cs +++ b/src/Postal.Tests/EmailViewRenderTests.cs @@ -100,7 +100,7 @@ public FakeView(Func templateString) TemplateString = templateString; } - public string Path => throw new NotImplementedException(); + public string Path => "FakePathUnitTest"; public Func TemplateString { get; private set; } diff --git a/src/Postal.Tests/Postal.Tests.csproj b/src/Postal.Tests/Postal.Tests.csproj index 40002f6..51e5db3 100644 --- a/src/Postal.Tests/Postal.Tests.csproj +++ b/src/Postal.Tests/Postal.Tests.csproj @@ -31,4 +31,5 @@ Always - + +