VOOZH about

URL: https://www.nuget.org/packages/jcamp.FluentEmail.Core/

⇱ NuGet Gallery | jcamp.FluentEmail.Core 4.0.0




👁 Image
jcamp.FluentEmail.Core 4.0.0

Prefix Reserved
dotnet add package jcamp.FluentEmail.Core --version 4.0.0
 
 
NuGet\Install-Package jcamp.FluentEmail.Core -Version 4.0.0
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="jcamp.FluentEmail.Core" Version="4.0.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="jcamp.FluentEmail.Core" Version="4.0.0" />
 
Directory.Packages.props
<PackageReference Include="jcamp.FluentEmail.Core" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add jcamp.FluentEmail.Core --version 4.0.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: jcamp.FluentEmail.Core, 4.0.0"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package jcamp.FluentEmail.Core@4.0.0
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=jcamp.FluentEmail.Core&version=4.0.0
 
Install as a Cake Addin
#tool nuget:?package=jcamp.FluentEmail.Core&version=4.0.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

👁 FluentEmail

FluentEmail - All in one email sender for .NET and .NET Core

Now for .NET 8.0, 9.0 and 10.0.

The easiest way to send email from .NET and .NET Core. Use Razor or Liquid for email templates and send using SendGrid, MailGun, MailKit, SMTP and more.

Forked from original by @lukencode

My packages are the same names, but prefixed with jcamp. to differentiate them.

The original repo has not been updated in almost a year and I needed some updates to the package that were provided by various PRs. I've tried to give all credit where due.

Original blog post here for a detailed guide A complete guide to send email in .NET

Nuget Packages

Core Library

  • - Just the domain model. Includes very basic defaults, but is also included with every other package here.
  • - Send email via SMTP server.

Renderers

  • - Generate emails using Razor templates. Anything you can do in ASP.NET is possible here. Uses the RazorLight project under the hood.
  • - Generate emails using Liquid templates. Uses the Fluid project under the hood.
  • - Processes email templates after rendering through UnDotNet.BootstrapEmail to allow simpler templates to generate perfect emails.

Mail Provider Integrations

  • - Send emails via Azure Email Communication Services API
  • - Send emails via Postmark's REST API. Original Source/Credit
  • - Send emails via MailGun's REST API.
  • - Send email via the SendGrid API.
  • - Send emails to Mailtrap. Uses for delivery.
  • - Send emails using the MailKit email library.
  • - Send emails via the MailPace REST API.
  • FluentEmail.MailerSend - Send email via MailerSend's API.

Basic Usage

var email = await Email
 .From("john@email.com")
 .To("bob@email.com", "bob")
 .Subject("hows it going bob")
 .Body("yo bob, long time no see!")
 .SendAsync();

Dependency Injection

Configure FluentEmail in startup.cs with these helper methods. This will inject IFluentEmail (send a single email) and IFluentEmailFactory (used to send multiple emails in a single context) with the ISender and ITemplateRenderer configured using AddRazorRenderer(), AddSmtpSender() or other packages.

public void ConfigureServices(IServiceCollection services)
{
 services
 .AddFluentEmail("fromemail@test.test")
 .AddRazorRenderer()
 .AddSmtpSender("localhost", 25);
}

Example to take a dependency on IFluentEmail:

public class EmailService {

 private IFluentEmail _fluentEmail;

 public EmailService(IFluentEmail fluentEmail) {
 _fluentEmail = fluentEmail;
 }

 public async Task Send() {
 await _fluentEmail.To("hellO@gmail.com")
 .Body("The body").SendAsync();
 }
}

Using a Razor template

// Using Razor templating package (or set using AddRazorRenderer in services)
Email.DefaultRenderer = new RazorRenderer();

var template = "Dear @Model.Name, You are totally @Model.Compliment.";

var email = Email
 .From("bob@hotmail.com")
 .To("somedude@gmail.com")
 .Subject("woo nuget")
 .UsingTemplate(template, new { Name = "Luke", Compliment = "Awesome" });

Using a Liquid template

Liquid templates are a more secure option for Razor templates as they run in more restricted environment. While Razor templates have access to whole power of CLR functionality like file access, they also are more insecure if templates come from untrusted source. Liquid templates also have the benefit of being faster to parse initially as they don't need heavy compilation step like Razor templates do.

Model properties are exposed directly as properties in Liquid templates so they also become more compact.

See Fluid samples for more examples.

// Using Liquid templating package (or set using AddLiquidRenderer in services)

// file provider is used to resolve layout files if they are in use
var fileProvider = new PhysicalFileProvider(Path.Combine(someRootPath, "EmailTemplates"));
var options = new LiquidRendererOptions
{
 FileProvider = fileProvider
};

Email.DefaultRenderer = new LiquidRenderer(Options.Create(options));

// template which utilizes layout
var template = @"
{% layout '_layout.liquid' %}
Dear {{ Name }}, You are totally {{ Compliment }}.";

var email = Email
 .From("bob@hotmail.com")
 .To("somedude@gmail.com")
 .Subject("woo nuget")
 .UsingTemplate(template, new ViewModel { Name = "Luke", Compliment = "Awesome" });

Embedded Templates

There is a set of extensions in EmbeddedTemplates that allows for use of embedded templates without specifying the assembly and the path every time.

EmbeddedTemplates.Configure(Assembly.GetCallingAssembly(), "FluentEmail.Core.Tests");
var email = Email
 .From(fromEmail)
 .To(toEmail)
 .Subject(subject)
 .UsingTemplateFromEmbedded("templatename.liquid", new ViewModel { Name = "Luke", Compliment = "Awesome" });

Embedded Templates with Liquid Renderer

Because the Liquid templates can also be configured with an embedded provider, there are builder extensions that will configure both the embedded file provider for layouts and the EmbeddedTemplates extensions.

There is a default of the executing assembly with Templates in EmailTemplates

builder.Services.AddFluentEmail("defaultfrom@email.com")
 .AddLiquidRendererWithEmbedded(Assembly.GetCallingAssembly(), "AssemblyName.EmailTemplates")

// These are the same 
builder.Services.AddFluentEmail("defaultfrom@email.com")
 .AddLiquidRendererWithEmbedded()

How to set all templates as embedded in the csproj file

If you want all templates in a folder to automatically be embedded, use the following in your csproj file.

 <ItemGroup>
 <EmbeddedResource Include="EmailTemplates/**/*.liquid" />
 </ItemGroup>

Sending Emails

// Using Smtp Sender package (or set using AddSmtpSender in services)
Email.DefaultSender = new SmtpSender();

//send normally
email.Send();

//send asynchronously
await email.SendAsync();

Template File from Disk

var email = Email
 .From("bob@hotmail.com")
 .To("somedude@gmail.com")
 .Subject("woo nuget")
 .UsingTemplateFromFile($"{Directory.GetCurrentDirectory()}/Mytemplate.cshtml", new { Name = "Rad Dude" });

Embedded Template File

Note for .NET Core 2 users: You'll need to add the following line to the project containing any embedded razor views. See this issue for more details.

<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
var email = new Email("bob@hotmail.com")
	.To("benwholikesbeer@twitter.com")
	.Subject("Hey cool name!")
	.UsingTemplateFromEmbedded("Example.Project.Namespace.template-name.cshtml",
		new { Name = "Bob" },
		TypeFromYourEmbeddedAssembly.GetType().GetTypeInfo().Assembly);
Product Versions Compatible and additional computed target framework versions.
.NET net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 is compatible.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (20)

Showing the top 5 NuGet packages that depend on jcamp.FluentEmail.Core:

Package Downloads
jcamp.FluentEmail.MailKit

Send emails via MailKit. The SmtpClient has been deprecated and Microsoft recommends using MailKit instead.

jcamp.FluentEmail.Razor

Generate emails using Razor templates. Anything you can do in ASP.NET is possible here. Uses the RazorLight project under the hood.

jcamp.FluentEmail.SendGrid

Send emails via SendGrid using their REST API

jcamp.FluentEmail.Smtp

Now we're talking. Send emails via SMTP.

jcamp.FluentEmail.Liquid

Generate emails using Liquid templates. Uses the Fluid project under the hood.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.0 78,971 10/26/2025
3.8.0 190,538 9/9/2024
3.7.0 103,635 11/29/2023
3.6.1 1,921 11/26/2023
3.6.0 1,990 11/23/2023
3.5.1 1,702 11/21/2023
3.5.0 1,669 11/21/2023
3.4.0 5,893 11/20/2023
3.3.1 3,590 11/20/2023
3.3.0 1,803 11/19/2023
3.2.0 28,620 2/5/2023
3.1.0 5,410 1/30/2023
3.0.3.1 2,352 1/30/2023
3.0.3 1,805 1/30/2023