Skip to content
Go to file


alt text

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

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

Nuget Packages

FluentEmail.Core - Just the domain model. Includes very basic defaults, but is also included with every other package here.

FluentEmail.Smtp - Send email via SMTP server.

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

FluentEmail.Mailgun - Send emails via MailGun's REST API.

FluentEmail.SendGrid - Send email via the SendGrid API.

FluentEmail.Mailtrap - Send emails to Mailtrap. Uses FluentEmail.Smtp for delivery.

FluentEmail.MailKit - Send emails using the MailKit email library.

Basic Usage

var email = await Email
    	.To("", "bob")
    	.Subject("hows it going bob")
    	.Body("yo bob, long time no see!")

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)
		.AddSmtpSender("localhost", 25);

Using a 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
    .Subject("woo nuget")
    .UsingTemplate(template, new { Name = "Luke", Compliment = "Awesome" });

Sending Emails

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

//send normally

//send asynchronously
await email.SendAsync();

Template File from Disk

var email = Email
    .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.

var email = new Email("")
	.Subject("Hey cool name!")
		new { Name = "Bob" }, 

More Info

Sending email in .NET Core with FluentEmail

The future of FluentEmail Looking for collaborators, discussion and hoping to keep improving the library!

You can’t perform that action at this time.