A .NET client for the whole SMTP2GO v3 API: sending (JSON, MIME, batch, scheduled), webhooks, reporting and statistics, templates, suppressions, allowed senders and recipients, API keys, SMTP users, domains, subaccounts, email archiving and SMS. Targets netstandard2.0, net8.0 and net10.0, is trim- and AOT-compatible, sends the API key in a header rather than the body, surfaces the API's own error payloads as typed exceptions, and ships opt-in packages for Microsoft.Extensions.DependencyInjection and ASP.NET Core webhook endpoints.
- The whole v3 API, typed. 69 of 69 documented operations across 18 families, each with request and response records, reachable as
client.Email,client.Webhooks,client.Stats,client.Activity,client.Templates,client.Suppressions,client.Archive,client.ApiKeys,client.SmtpUsers,client.IpAuth,client.Domains,client.SingleSenders,client.AllowedSenders,client.AllowedRecipients,client.Subaccounts,client.DedicatedIpsandclient.Sms.client.Rawreaches anything the API adds before the library does, with the same authentication, routing, validation and error mapping. - Current sending features.
fastaccept,schedulewith scheduled-email search and removal,email/batch, URL-sourced attachments, templates without a subject,EnsureAccepted()to turn a 200 with failed recipients into an exception. - Authentication and routing. The key goes in the
X-Smtp2go-Api-Keyheader or asAuthorization: Bearer; never in the body.Region(US,EU,AU) selects the regional endpoint,SubaccountIdis merged into every call of an endpoint that documents it, and both can be overridden per call. - Errors you can act on.
Smtp2GoApiExceptioncarries the API'serror_code,error,request_idandfield_validation_errors;Smtp2GoRateLimitExceptionparsesRetry-After. Documented limits (50 MB underemail/*, 1 MB elsewhere, 100 recipients per field) fail client-side before a byte is sent. - Resilience that matches the docs. Retry only on idempotent endpoints (or when a call opts in), per-endpoint rate-limit classes for the limits SMTP2GO documents (60/min
activity/search, 5/minapi_keys/add, 50/hoursubaccount/add), circuit breaker and timeouts throughMicrosoft.Extensions.Http.Resilience. - Webhooks end to end. Managing webhooks, parsing JSON and form-encoded callbacks into typed events (unknown fields land in
Extra, custom headers inCustomHeaders), andMapSmtp2GoWebhookfor ASP.NET Core with bearer or basic authentication, a source-IP allow-list andIWebhookEventHandler<TEvent>dispatch from the concrete event up toWebhookEvent. - Paging and the archive.
IAsyncEnumerable<T>pagers over activity, templates, suppressions, subaccounts and the archive; downloading the original archived message. - Observability. An
ActivitySourcespan per call, aMeterwith request, duration and email-result instruments, and source-generated logging with stable event ids. - Built to last.
netstandard2.0,net8.0andnet10.0; trim- and AOT-compatible with source-generated JSON; the public API tracked withPublicAPI.*.txtand package validation against the previous release; the API reference harvested weekly intodocs/api-spec/, with contract tests that fail when the models and the documentation disagree.
dotnet package add Scott.Mail.Smtp2GoOptional: Scott.Mail.Smtp2Go.DependencyInjection (options, IHttpClientFactory, resilience) and Scott.Mail.Smtp2Go.AspNetCore (MapSmtp2GoWebhook).
using Scott.Mail.Smtp2Go;
var client = new Smtp2GoClient(apiKey: "api-...");
var response = await client.Email.SendAsync(new EmailSendRequest
{
Sender = "Alice <alice@example.com>",
To = ["bob@example.com"],
Subject = "Hello from Scott.Mail.Smtp2Go",
TextBody = "It works.",
});
Console.WriteLine($"Sent: {response.Data.Succeeded} succeeded, {response.Data.Failed} failed ({response.RequestId})");The quick start above is compiled by a unit test so it stays in sync with the API.
Start with Getting started, then pick what you need:
| Document | Covers |
|---|---|
| Sending email | JSON, MIME and batch sends, fastaccept, scheduling, attachments, templates, EnsureAccepted() |
| Webhooks | Managing webhooks, parsing callbacks, receiving them in ASP.NET Core |
| Reporting | Statistics, quota, activity search and paging |
| Archive | Searching archived email and downloading the original message |
| Account management and SMS | API keys, SMTP users, domains, senders, allowed lists, subaccounts, dedicated IPs, SMS |
| Configuration | Client options, regions, authentication, dependency injection, resilience |
| Observability | Logging, metrics and tracing |
| Errors | The exception types and how API responses map to them |
| API coverage | Every SMTP2GO endpoint and the client member that calls it |
| API notes | Where the live API and its documentation disagree |
| Contributing | Building, testing and releasing |
Runnable examples are in demo/: a send, archive search and download round trip, a generic host with dependency injection, and a webhook receiver. Release history is in the changelog.
See SECURITY.md for how to report a vulnerability.