Skip to content

About

Unofficial useSend .NET SDK, written in C#

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

useSend .NET SDK

Unofficial .NET SDK for useSend — an open-source alternative to Resend, SendGrid, Mailgun, and Postmark.

CI

Packages

Package NuGet Description
UseSend NuGet Core SDK — send emails, manage domains, contacts, campaigns, and analytics
UseSend.FluentEmail NuGet FluentEmail sender backed by useSend
UseSend.Identity NuGet ASP.NET Core Identity IEmailSender / IEmailSender<TUser> backed by useSend
UseSend.OpenTelemetry NuGet Distributed tracing (ActivitySource) and metrics (request count + duration)
UseSend.Razor NuGet Razor (.cshtml) template rendering via RazorLight
UseSend.Fluid NuGet Liquid template rendering via Fluid
UseSend.Webhooks NuGet Webhook signature verification and typed event parsing

UseSend — Core SDK

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

→ Full documentation


UseSend.Identity

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>.

→ Full documentation


UseSend.FluentEmail

Drop-in FluentEmail sender — use the FluentEmail API you already know, delivered by useSend.

dotnet add package UseSend
dotnet add package UseSend.FluentEmail
builder.Services.AddUseSend("us_your_api_token");
builder.Services
    .AddFluentEmail("noreply@yourdomain.com")
    .AddUseSendSender();

→ Full documentation


UseSend.Webhooks

Verify webhook signatures and parse typed event payloads from useSend.

dotnet add package UseSend.Webhooks
builder.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
Email queued, sent, delivered, delivery_delayed, bounced, rejected, rendering_failure, complained, failed, cancelled, suppressed, opened, clicked
Contact created, updated, deleted
Domain created, verified, updated, deleted

→ Full documentation


UseSend.OpenTelemetry

Adds distributed tracing spans and metrics (request count + duration histogram) to every useSend API call.

dotnet add package UseSend.OpenTelemetry
builder.Services.AddOpenTelemetry()
    .WithTracing(tracing => tracing
        .AddUseSendInstrumentation()   // ActivitySource "UseSend"
        .AddOtlpExporter())
    .WithMetrics(metrics => metrics
        .AddUseSendInstrumentation()   // Meter "UseSend"
        .AddOtlpExporter());

→ Full documentation


UseSend.Razor

Compile and render strongly-typed Razor (.cshtml) templates as email HTML bodies using RazorLight.

dotnet add package UseSend.Razor
builder.Services.AddUseSendRazor("/path/to/email/templates");

// Inject IEmailTemplateRenderer and render before sending
var html = await renderer.RenderAsync("Emails/Welcome", new WelcomeModel { Name = "Alice" });

→ Full documentation


UseSend.Fluid

Compile and render Liquid (.liquid) email templates using the Fluid engine — simpler syntax, safe for designers and marketers.

dotnet add package UseSend.Fluid
builder.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.

→ Full documentation


Requirements

  • .NET 8 or .NET 10
  • A useSend account or self-hosted instance

Examples

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

Contributing

PRs and issues welcome. Run tests with:

dotnet test

License

MIT

About

Unofficial useSend .NET SDK, written in C#

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages