Unofficial .NET SDK for useSend — an open-source alternative to Resend, SendGrid, Mailgun, and Postmark.
| Package | NuGet | Description |
|---|---|---|
UseSend |
Core SDK — send emails, manage domains, contacts, campaigns, and analytics | |
UseSend.FluentEmail |
FluentEmail sender backed by useSend | |
UseSend.Identity |
ASP.NET Core Identity IEmailSender / IEmailSender<TUser> backed by useSend |
|
UseSend.OpenTelemetry |
Distributed tracing (ActivitySource) and metrics (request count + duration) | |
UseSend.Razor |
Razor (.cshtml) template rendering via RazorLight | |
UseSend.Fluid |
Liquid template rendering via Fluid | |
UseSend.Webhooks |
Webhook signature verification and typed event parsing |
dotnet add package UseSend// Program.cs
builder.Services.AddUseSend("us_your_api_token");
// Inject IUseSend or individual service interfaces (IEmailService, IDomainService, …)
public class WelcomeSender(IUseSend useSend)
{
public async Task SendAsync(string to)
{
var response = await useSend.Emails.SendAsync(new EmailMessage
{
From = "noreply@yourdomain.com",
To = to,
Subject = "Welcome!",
Html = "<h1>Welcome aboard!</h1>",
});
}
}Self-hosted useSend — point the SDK at your own instance:
builder.Services.AddUseSend(options =>
{
options.ApiToken = "us_your_api_token";
options.ApiUrl = "https://send.mycompany.com/api/";
});| Resource | Operations |
|---|---|
| Emails | Send, Batch send (with idempotency), Get, List, Cancel / Update schedule |
| Domains | List, Create, Get, Delete, Verify |
| Contacts | Create, Get, List, Update, Upsert, Delete, Bulk create / delete |
| Contact Books | List, Create, Get, Update, Delete |
| Campaigns | Create, Get, List, Delete, Schedule, Pause, Resume |
| Analytics | Email time series, Reputation metrics |
ASP.NET Core Identity IEmailSender / IEmailSender<TUser> — drop-in email sending for scaffolded Identity pages (confirm email, reset password, etc.).
dotnet add package UseSend
dotnet add package UseSend.Identity// Program.cs — typed (scaffolded Identity pages)
builder.Services.AddUseSend("us_your_api_token");
builder.Services.AddUseSendIdentityEmailSender<ApplicationUser>(
fromAddress: "noreply@yourdomain.com",
fromName: "My App"
);Default HTML templates are provided for confirmation links, password reset links, and reset codes. Override any method by subclassing UseSendEmailSender<TUser>.
Drop-in FluentEmail sender — use the FluentEmail API you already know, delivered by useSend.
dotnet add package UseSend
dotnet add package UseSend.FluentEmailbuilder.Services.AddUseSend("us_your_api_token");
builder.Services
.AddFluentEmail("noreply@yourdomain.com")
.AddUseSendSender();Verify webhook signatures and parse typed event payloads from useSend.
dotnet add package UseSend.Webhooksbuilder.Services.AddUseSendWebhooks(builder.Configuration["UseSend:WebhookSecret"]!);
app.MapPost("/webhooks/usesend", async (HttpRequest req, UseSendWebhooks webhooks) =>
{
var rawBody = await new StreamReader(req.Body).ReadToEndAsync();
var headers = req.Headers.ToDictionary(h => h.Key, h => h.Value.ToString());
var evt = webhooks.ConstructEvent(rawBody, headers); // throws WebhookException on bad/stale signature
if (evt.Type == WebhookEventType.EmailDelivered)
Console.WriteLine($"Delivered: {evt.GetData<EmailEventData>()?.Id}");
return Results.Ok();
});Signatures use HMAC-SHA256 with constant-time comparison and 5-minute replay protection.
| Group | Events |
|---|---|
queued, sent, delivered, delivery_delayed, bounced, rejected, rendering_failure, complained, failed, cancelled, suppressed, opened, clicked |
|
| Contact | created, updated, deleted |
| Domain | created, verified, updated, deleted |
Adds distributed tracing spans and metrics (request count + duration histogram) to every useSend API call.
dotnet add package UseSend.OpenTelemetrybuilder.Services.AddOpenTelemetry()
.WithTracing(tracing => tracing
.AddUseSendInstrumentation() // ActivitySource "UseSend"
.AddOtlpExporter())
.WithMetrics(metrics => metrics
.AddUseSendInstrumentation() // Meter "UseSend"
.AddOtlpExporter());Compile and render strongly-typed Razor (.cshtml) templates as email HTML bodies using RazorLight.
dotnet add package UseSend.Razorbuilder.Services.AddUseSendRazor("/path/to/email/templates");
// Inject IEmailTemplateRenderer and render before sending
var html = await renderer.RenderAsync("Emails/Welcome", new WelcomeModel { Name = "Alice" });Compile and render Liquid (.liquid) email templates using the Fluid engine — simpler syntax, safe for designers and marketers.
dotnet add package UseSend.Fluidbuilder.Services.AddUseSendFluid("/path/to/liquid/templates");
// Inject IEmailTemplateRenderer and render before sending
var html = await renderer.RenderAsync("Emails/Welcome", new { Name = "Alice" });Both UseSend.Razor and UseSend.Fluid implement the same IEmailTemplateRenderer interface — swap between them by changing only the registration call.
- .NET 8 or .NET 10
- A useSend account or self-hosted instance
| Example | Description |
|---|---|
| ConsoleNoDi | Standalone usage without dependency injection |
| WebMinimalApi | ASP.NET Core minimal API with DI |
| ConsoleSelfHosted | Custom host URL for self-hosted useSend |
| WebIdentity | ASP.NET Core Identity — email confirmation and password reset |
| WebHangfire | Background email jobs via Hangfire |
| WebMassTransit | Event-driven email via MassTransit SendEmailCommand consumer |
| WebTemporal | Durable email workflow with Temporal.io |
| WebFluid | Liquid (.liquid) email templates with UseSend.Fluid |
PRs and issues welcome. Run tests with:
dotnet testMIT