Fusonic.Extensions.Email
9.5.4
Prefix Reserved
See the version list below for details.
dotnet add package Fusonic.Extensions.Email --version 9.5.4
NuGet\Install-Package Fusonic.Extensions.Email -Version 9.5.4
<PackageReference Include="Fusonic.Extensions.Email" Version="9.5.4" />
<PackageVersion Include="Fusonic.Extensions.Email" Version="9.5.4" />
<PackageReference Include="Fusonic.Extensions.Email" />
paket add Fusonic.Extensions.Email --version 9.5.4
#r "nuget: Fusonic.Extensions.Email, 9.5.4"
#:package Fusonic.Extensions.Email@9.5.4
#addin nuget:?package=Fusonic.Extensions.Email&version=9.5.4
#tool nuget:?package=Fusonic.Extensions.Email&version=9.5.4
Setup
The following sample binds settings from the configuration located in the section "Email" using SimpleInjector.
The settings contain sender Email and name, SMTP settings, Debug settings, PostProcessor settings and CSS settings. Check the EmailSettings class for details.
container.RegisterEmail(options => Configuration.GetSection("Email").Bind(options));
Razor Views (MVC)
Create and send an email
To add new emails, following steps need to be done:
- Add a new View (
.cshtml) in the directoryViews/Emails/. - Add a new ViewModel in the same namespace as the business logic that needs to send the mail.
- Add the
EmailViewattribute to the ViewModel. The constructor argument is path to the view, relative to theViewsdirectory without the.cshtmlextension. Example:[EmailView("Emails/Registration")]points toViews/Emails/Registration.cshtml. - Extend the
EmailControllerwith a new method to render the view file and return the contents. - To send the mail in the business logic use the Mediator-command
SendEmailand supply it with the view model. SendEmail renders the mail based on the view model and theEmailViewAttribute.
To check the visuals of the view file, use the Swagger API to access the methods of the EmailController.
View locations
The views that are used for the emails are configured on the EmailViewAttribute. To find the view, the Razor view engine looks in the folder Views by default. A view path of Emails/FancyEmail matches to Views/Emails/FancyEmail.cshtml.
If you want to place the Views in other folders, for example /Emails, you can simply configure this in the Razor options as follows:
services.Configure<RazorViewEngineOptions>(options => options.ViewLocationFormats.Add("/Emails/{0}" + RazorViewEngine.ViewExtension));
Set a Subject
Per default the SubjectKey is "Subject" and it is being tried to resolve from the corresponding resource file. If you want to use a different key, you can set it in the EmailViewAttribute like this: [EmailView("Emails/Registration", SubjectKey = "RegistrationSubject")]. If no value could be found it will fallback to the the SubjectKey.
Razor Components (Blazor)
Create and send an email
To add new emails, following steps need to be done:
- Add a new Component (
.razor) in the directoryComponents/Emails/. - Add a new ComponentModel in the same namespace as the business logic that needs to send the mail.
- Implement the
IComponentModel<T>interface in the ComponentModel, whereTis the type of the Component. - Extend the
EmailControllerwith a new method to render the razor file and return the contents. - To send the mail in the business logic use the Mediator-command
SendEmailand supply it with the view model. SendEmail renders the mail based on the component model and theIComponentModel<T>.
To check the visuals of the view file, use the Swagger API to access the methods of the EmailController.
Component locations
In contrast to the classic Razor Views, the Razor Components can be placed in any folder, even in a different assembly, as long as you can reference it in the IComponentModel<T>.
Set a Subject
Per default the SubjectKey is "Subject" and it is being tried to resolve from the corresponding resource file. If you want to use a different key, you can optionally implement the IProvideEmailSubject interface like this string IProvideEmailSubject.SubjectKey => "RegistrationSubject";. If no value could be found it will fallback to the the SubjectKey.
Attachments
By default, only attachments in file://-Uris are supported. To allow adding attachments from other sources (eg. AWS S3), implement IEmailAttachmentResolver and register it SimpleInjector with
container.Collections.Append<IEmailAttachmentResolver, YourResolver>()
Headers
No special Headers are sent per default, however with the Headers parameter on SendEmail, MimeKit.Headers can be added to the email (overrides all Headers defined in EmailOptions.DefaultHeaders). With EmailOptions.DefaultHeaders default headers can be set for all emails. Predefined sets of headers can be found in EmailHeaders:
DiscourageAutoRepliesincludesPrecedence:list,AutoSubmitted:generated, andX-Auto-Response-Suppress:All. They discourage email servers to sent auto replies.
Post Processor
On the EmailOptions email content post processors can be defined on the RazorContentPostProcessor (.cshtml) and the BlazorContentPostProcessor (.razor) property. Per default they both call the CssInliner to inline all styles into the tags themselves.
Providing null will instruct the renderer to not use a post processor.
Mjml Sample
Configuring the EmailOptions like seen in the sample below, all blazor emails will be processed by Mjml.Net before being sent.
container.RegisterSingleton<MjmlRenderer>();
container.RegisterEmail(o =>
{
// Other configurations...
o.BlazorContentPostProcessor = async ctx =>
{
var result = await container.GetInstance<MjmlRenderer>().RenderAsync(ctx.Html);
return result.Html;
};
});
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Fusonic.Extensions.AspNetCore (>= 9.5.4)
- Fusonic.Extensions.Mediator (>= 9.5.4)
- MailKit (>= 4.8.0)
- PreMailer.Net (>= 2.6.0)
- SimpleInjector (>= 5.5.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.0.0 | 275 | 11/25/2025 |
| 10.0.0-rc.2 | 151 | 11/24/2025 |
| 10.0.0-rc.1 | 128 | 9/12/2025 |
| 9.5.4 | 250 | 8/20/2025 |
| 9.5.3 | 293 | 3/28/2025 |
| 9.5.2 | 345 | 1/16/2025 |
| 9.5.0 | 342 | 10/4/2024 |
| 9.4.0 | 269 | 9/23/2024 |
| 9.3.1 | 326 | 9/11/2024 |
| 9.3.0 | 220 | 9/11/2024 |
| 9.2.0 | 251 | 8/8/2024 |
| 9.2.0-rc.3 | 90 | 8/7/2024 |
| 9.2.0-rc.2 | 75 | 8/5/2024 |
| 9.2.0-rc.1 | 92 | 8/1/2024 |
| 9.1.0 | 196 | 7/29/2024 |
| 9.0.0 | 844 | 7/17/2024 |
| 9.0.0-preview.2 | 140 | 6/13/2024 |
| 9.0.0-preview.1 | 108 | 4/5/2024 |
| 8.1.3 | 346 | 3/27/2024 |
| 8.1.2 | 230 | 3/27/2024 |
| 8.1.1 | 227 | 3/1/2024 |
| 8.1.0 | 1,301 | 1/26/2024 |
| 8.0.1 | 291 | 12/18/2023 |
| 8.0.1-rc.2 | 136 | 12/7/2023 |
| 8.0.1-rc.1 | 113 | 12/6/2023 |
| 8.0.0 | 315 | 11/21/2023 |
| 8.0.0-preview1 | 163 | 10/4/2023 |
| 7.4.0 | 249 | 1/25/2024 |
| 7.3.0 | 266 | 10/11/2023 |
| 7.2.1-rc.1 | 184 | 8/28/2023 |
| 7.2.0 | 475 | 6/28/2023 |
| 7.2.0-alpha.1 | 184 | 6/27/2023 |
| 7.1.2 | 612 | 5/25/2023 |
| 7.1.1 | 1,045 | 4/3/2023 |
| 7.1.1-rc.2 | 210 | 3/30/2023 |
| 7.1.1-rc.1 | 176 | 3/30/2023 |
| 7.1.0 | 973 | 2/28/2023 |
| 7.1.0-rc.1 | 190 | 2/20/2023 |
| 7.0.4-rc.5 | 195 | 2/23/2023 |
| 7.0.4-rc.4 | 218 | 2/23/2023 |
| 7.0.4-rc.3 | 190 | 2/23/2023 |
| 7.0.4-rc.2 | 188 | 2/22/2023 |
| 7.0.4-rc.1 | 193 | 2/16/2023 |
| 7.0.3 | 535 | 2/16/2023 |
| 7.0.2 | 396 | 2/9/2023 |
| 7.0.2-rc.1 | 231 | 2/2/2023 |
| 7.0.1 | 725 | 1/26/2023 |
| 7.0.0 | 620 | 1/24/2023 |
| 7.0.0-preview1 | 287 | 7/18/2022 |
| 7.0.0-beta.9 | 210 | 1/24/2023 |
| 7.0.0-beta.8 | 191 | 1/23/2023 |
| 7.0.0-beta.7 | 219 | 1/23/2023 |
| 7.0.0-beta.6 | 233 | 1/23/2023 |
| 7.0.0-beta.5 | 211 | 1/23/2023 |
| 7.0.0-beta.4 | 224 | 1/19/2023 |
| 7.0.0-beta.3 | 200 | 1/17/2023 |
| 7.0.0-beta.2 | 201 | 1/11/2023 |
| 7.0.0-beta.1 | 189 | 11/24/2022 |
| 6.2.2 | 1,407 | 9/20/2022 |
| 6.2.2-rc.1 | 222 | 9/19/2022 |
| 6.2.1 | 2,108 | 5/4/2022 |
| 6.2.0 | 610 | 4/21/2022 |
| 6.2.0-rc.2 | 276 | 4/21/2022 |
| 6.2.0-rc.1 | 274 | 4/20/2022 |
| 6.1.1 | 1,148 | 3/1/2022 |
| 6.1.0 | 812 | 2/10/2022 |
| 6.1.0-rc.3 | 253 | 2/10/2022 |
| 6.1.0-rc.2 | 242 | 2/10/2022 |
| 6.1.0-rc.1 | 244 | 2/9/2022 |
| 6.0.3 | 1,562 | 1/18/2022 |
| 6.0.2 | 928 | 1/10/2022 |
| 6.0.1 | 491 | 12/16/2021 |
| 6.0.0 | 839 | 12/13/2021 |
| 6.0.0-rc.6 | 309 | 12/6/2021 |
| 6.0.0-rc.5 | 470 | 12/6/2021 |
| 6.0.0-rc.4 | 634 | 12/6/2021 |
| 6.0.0-rc.3 | 490 | 12/6/2021 |
| 6.0.0-rc.2 | 469 | 12/6/2021 |
| 6.0.0-rc.1 | 769 | 11/15/2021 |
| 5.4.0 | 827 | 10/13/2021 |
| 5.3.0 | 509 | 9/23/2021 |
| 5.3.0-rc.1 | 468 | 9/17/2021 |
| 5.2.0 | 2,822 | 5/20/2021 |
| 5.2.0-rcjh.6 | 354 | 5/19/2021 |
| 5.2.0-rcjh.5 | 278 | 5/19/2021 |
| 5.2.0-rcjh.4 | 329 | 5/19/2021 |
| 5.2.0-rcjh.3 | 281 | 5/19/2021 |
| 5.2.0-rcjh.2 | 277 | 4/12/2021 |
| 5.2.0-rcjh.1 | 271 | 4/12/2021 |
| 5.1.3 | 543 | 5/19/2021 |
| 5.1.2 | 802 | 3/26/2021 |
| 5.1.1 | 1,161 | 1/13/2021 |
| 5.1.0 | 2,157 | 12/16/2020 |
| 5.0.0 | 895 | 11/17/2020 |
| 5.0.0-rc.1 | 436 | 10/15/2020 |
| 2.0.6 | 1,658 | 10/8/2020 |
| 2.0.5 | 1,381 | 8/19/2020 |
| 2.0.4 | 2,604 | 7/10/2020 |
| 2.0.3 | 700 | 7/10/2020 |
| 2.0.2 | 703 | 7/9/2020 |
| 2.0.1 | 702 | 7/9/2020 |
| 2.0.0 | 722 | 6/17/2020 |
| 1.0.0 | 749 | 6/15/2020 |