Sendio 1.1.0
dotnet add package Sendio --version 1.1.0
NuGet\Install-Package Sendio -Version 1.1.0
<PackageReference Include="Sendio" Version="1.1.0" />
<PackageVersion Include="Sendio" Version="1.1.0" />
<PackageReference Include="Sendio" />
paket add Sendio --version 1.1.0
#r "nuget: Sendio, 1.1.0"
#:package Sendio@1.1.0
#addin nuget:?package=Sendio&version=1.1.0
#tool nuget:?package=Sendio&version=1.1.0
send.io .NET SDK
The official .NET library for the send.io email API. Targets .NET 8 and .NET 10 (apps on .NET 9 use the .NET 8 build).
Full API reference: https://developer.send.io/docs/api
Install
dotnet add package Sendio
Optional companion packages:
Sendio.Webhooks: ASP.NET helpers to receive and verify send.io webhook eventsSendio.FluentEmail: a FluentEmail sender
Quick start
Create an API key in the send.io dashboard (keys start with mx_).
Without dependency injection:
using Sendio;
ISendio sendio = SendioClient.Create( "mx_123" ); // or SendioClient.Create() to read SENDIO_API_KEY
var resp = await sendio.EmailSendAsync( new EmailMessage()
{
From = "Acme <onboarding@yourdomain.com>",
To = "delivered@send.io",
Subject = "Hello from .NET",
HtmlBody = "<strong>It works!</strong>",
} );
Console.WriteLine( resp.Content ); // email id
With dependency injection (ASP.NET Core and generic host):
using Sendio;
builder.Services.AddSendio( o =>
{
o.ApiToken = builder.Configuration["Sendio:ApiKey"]!; // omit to use SENDIO_API_KEY
} );
// or simply:
builder.Services.AddSendio( "mx_123" );
Then inject ISendio:
public class Signup( ISendio sendio )
{
public Task Welcome( string to ) => sendio.EmailSendAsync( new EmailMessage()
{
From = "Acme <onboarding@yourdomain.com>",
To = to,
Subject = "Welcome",
TextBody = "Thanks for signing up!",
} );
}
Send a batch
Up to 100 emails in one request:
var resp = await sendio.EmailBatchAsync( new[]
{
new EmailMessage() { From = "Acme <onboarding@yourdomain.com>", To = "delivered@send.io", Subject = "First", TextBody = "one" },
new EmailMessage() { From = "Acme <onboarding@yourdomain.com>", To = "delivered@send.io", Subject = "Second", TextBody = "two" },
} );
foreach ( var id in resp.Content )
Console.WriteLine( id );
Retrieve an email
var email = await sendio.EmailRetrieveAsync( emailId );
Console.WriteLine( $"{email.Content.Subject} {email.Content.LastEvent}" );
Domains
var added = await sendio.DomainAddAsync( "yourdomain.com" );
await sendio.DomainVerifyAsync( added.Content.Id );
var domains = await sendio.DomainListAsync();
foreach ( var d in domains.Content )
Console.WriteLine( $"{d.Name} {d.Status}" );
Transactional emails
A transactional email (a sign-in code, a password reset, a receipt) is a saved send of a
published template: it keeps the sender, subject, reply-to and tracking (off by default),
and its content is always the template's published version. Create it once, then send it
by id with only the recipient and the variables. Its id is a string (tx_...).
var tx = await sendio.TransactionalEmailCreateAsync( new TransactionalEmailData()
{
Name = "Sign-in code",
TemplateId = "signin-code", // a published template, by id or alias
From = "Acme <security@yourdomain.com>",
Subject = "Your code is {{CODE}}",
} );
await sendio.EmailSendAsync( new EmailMessage()
{
TransactionalId = tx.Content.Id,
To = "ada@example.com",
Variables = new Dictionary<string, object?>() { { "CODE", "123456" } },
} );
ISendio also has TransactionalEmailListAsync (search, template), TransactionalEmailRetrieveAsync,
TransactionalEmailUpdateAsync (set ExpectedUpdatedAt to get a 409 instead of overwriting
someone else's change), TransactionalEmailDeleteAsync, TransactionalEmailTestAsync and
TransactionalEmailStatsAsync. A republish of the template, or an update, reaches every send
within 10 seconds.
Broadcasts can be made from a published template too: BroadcastData.TemplateId (and
TemplateVersionId) copies its published version, and BroadcastUpdateData.DetachTemplate
keeps the content but drops the link. Broadcast.UnfillableVariables lists the template
variables a broadcast cannot fill; while it is not empty, sending is refused with 422.
Mailboxes
Mailboxes are real email accounts with an IMAP/SMTP login. The login is only returned on creation (when IMAP/SMTP is ready) and on a password reset; the password is also an API key for that mailbox.
// The domain must be verified.
var mailbox = await sendio.MailboxCreateAsync( new MailboxData() { Address = "sales@yourdomain.com" } );
if ( mailbox.Content.Credentials != null )
Console.WriteLine( $"{mailbox.Content.Credentials.Smtp.Host} {mailbox.Content.Credentials.Password}" );
await sendio.MailboxUpdateAsync( mailbox.Content.Id, new MailboxUpdateData() { WarmupEnabled = false } );
// The old password stops working.
var reset = await sendio.MailboxResetPasswordAsync( mailbox.Content.Id );
var mailboxes = await sendio.MailboxListAsync();
foreach ( var m in mailboxes.Content )
Console.WriteLine( $"{m.Address} {m.Health}" );
// Removes the email account, and the agent inbox on it, if any.
await sendio.MailboxDeleteAsync( mailbox.Content.Id );
ISendio also covers emails (schedule, cancel, list, attachments), receiving (inbound),
API keys, audiences, contacts, contact properties, segments, topics, broadcasts, templates,
transactional emails, webhooks, events, automations, suppressions, logs, metrics and usage.
Configuration
| Setting | In code (SendioClientOptions) |
Environment variable | Default |
|---|---|---|---|
| API key | ApiToken |
SENDIO_API_KEY |
none (required) |
| Base URL | ApiUrl |
SENDIO_BASE_URL |
https://api.send.io |
Values set in code win over the environment. To point at another environment (for example a local test server):
var sendio = SendioClient.Create( new SendioClientOptions()
{
ApiToken = "mx_123",
ApiUrl = "http://localhost:8080",
} );
Every request carries the User-Agent: sendio-dotnet:<version> header.
Error handling
By default a failed call throws SendioException, which carries the HTTP status code,
the API error type and the rate limit headers:
try
{
await sendio.EmailSendAsync( message );
}
catch ( SendioException ex )
{
Console.WriteLine( $"{ex.StatusCode} {ex.ErrorType}: {ex.Message}" );
}
Set ThrowExceptions = false in SendioClientOptions to get a SendioResponse with
Success == false and an Exception property instead.
License
| 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 is compatible. 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. |
-
net10.0
- Microsoft.AspNetCore.WebUtilities (>= 10.0.15)
- Microsoft.Extensions.Http (>= 10.0.12)
- Microsoft.Extensions.Options (>= 10.0.12)
-
net8.0
- Microsoft.AspNetCore.WebUtilities (>= 8.0.34)
- Microsoft.Extensions.Http (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Sendio:
| Package | Downloads |
|---|---|
|
Sendio.Webhooks
ASP.NET utilities for send.io webhook events |
|
|
Sendio.FluentEmail
FluentEmail sender for the send.io email API |
GitHub repositories
This package is not used by any popular GitHub repositories.