Core.Email.Abstractions
1.1.0
dotnet add package Core.Email.Abstractions --version 1.1.0
NuGet\Install-Package Core.Email.Abstractions -Version 1.1.0
<PackageReference Include="Core.Email.Abstractions" Version="1.1.0" />
<PackageVersion Include="Core.Email.Abstractions" Version="1.1.0" />
<PackageReference Include="Core.Email.Abstractions" />
paket add Core.Email.Abstractions --version 1.1.0
#r "nuget: Core.Email.Abstractions, 1.1.0"
#:package Core.Email.Abstractions@1.1.0
#addin nuget:?package=Core.Email.Abstractions&version=1.1.0
#tool nuget:?package=Core.Email.Abstractions&version=1.1.0
.NET Transactional E-Mail Abstraction Layer
Send transactional e-mail through one ICoreEmail interface and switch providers by configuration.
Several providers - or several configurations of the same provider - can be registered side by side as keyed services.
Targets .NET 10.
Packages
| Package | Sends via |
|---|---|
| Core.Email | core service (ICoreEmail) - always needed |
| Core.Email.Abstractions | message, status and provider contracts |
| Core.Email.Provider.SMTP | any SMTP server (MailKit) |
| Core.Email.Provider.SES | Amazon SES, v2 API |
| Core.Email.Provider.Mailjet | Mailjet |
| Core.Email.Provider.SendGrid | SendGrid |
| Core.Email.Provider.Postmark | Postmark |
dotnet add package Core.Email
dotnet add package Core.Email.Provider.SES
Configuration
appsettings.json - only the providers you register need a section:
{
"Email": {
"Default": "Postmark",
"SMTP": {
"Host": "smtp.***.com",
"Port": 587,
"Username": "***",
"Password": "***",
"Tls": true
},
"SES": {
"AccessKey": "***",
"SecretAccessKey": "***",
"Region": "eu-central-1"
},
"Postmark": {
"ServerToken": "***",
"MessageStream": "outbound"
},
"Mailjet": {
"ApiKey": "***",
"ApiSecret": "***"
},
"SendGrid": {
"ApiKey": "***"
}
}
}
Email:Defaultis the key of the provider used for messages without aProviderKey.- Each provider reads its settings from
Email:{key}.
Registration
services.AddCoreEmail();
services.AddSmtpProvider("SMTP");
services.AddPostmarkProvider("Postmark");
services.AddSendGridProvider("SendGrid");
services.AddMailjetProvider("Mailjet");
services.AddSimpleEmailServiceProvider("SES");
The key is free to choose, so one provider can be registered several times:
services.AddPostmarkProvider("Postmark"); // reads Email:Postmark
services.AddPostmarkProvider("PostmarkBroadcast"); // reads Email:PostmarkBroadcast
Without a key (services.AddSmtpProvider()) the provider is registered unkeyed, reads Email:SMTP (or Email:SES, Email:Postmark, ...) and is used as default while Email:Default is not set.
Sending
var email = serviceProvider.GetRequiredService<ICoreEmail>();
var status = await email.SendAsync(new CoreEmailMessage
{
From = "noreply@example.com",
FromName = "Example Inc. · Reports", // optional display name
To = ["jane@example.com"],
Bcc = ["archive@example.com"],
ReplyTo = "support@example.com",
Subject = "Weekly report",
TextBody = "Your weekly report is attached.",
HtmlBody = "<p>Your weekly report is attached.</p>",
Attachments =
[
new CoreEmailAttachment
{
Name = "report.csv",
ContentType = "text/csv",
Content = csvBytes
}
]
});
if (!status.IsSuccess)
logger.LogWarning("Mail {Id} failed: {Error}", status.Id, status.Error);
- Choose a provider per message with
ProviderKey = "SES"; without it the default provider is used. - Batches:
SendAsync(List<CoreEmailMessage>)groups the messages byProviderKeyand hands each group to its provider as one batch. It returns oneCoreEmailStatusper message - match them byId. - Errors: an unknown
ProviderKeythrowsInvalidOperationExceptionbefore anything is sent. Rejected messages come back withIsSuccess = falseandError. SMTP, SES and SendGrid also report connection and API exceptions that way; Mailjet and Postmark send the whole batch in one API call, which can throw. ProviderMessageIdholds the provider's own message id where available (SES, Postmark).
Provider notes
| Provider | Size limit¹ | Notes |
|---|---|---|
| SMTP | set by the server | one connection per batch; login is skipped when Username is empty; Tls: true uses STARTTLS |
| SES | 40 MB | sent as raw MIME through the SES v2 API; Region defaults to eu-central-1 |
| Mailjet | 15 MB | whole batch in one API call |
| SendGrid | 30 MB | one API call per message; To and Cc recipients see each other |
| Postmark | 10 MB | whole batch in one API call; at most 50 recipients (To + Cc + Bcc) per message; MessageStream selects the stream |
¹ exposed as ICoreEmailProvider.MaxSize for information - not enforced by the library.
Development
dotnet build
dotnet test --filter "Category!=Integration"
EmailTest is an integration test that sends a real e-mail. It needs provider credentials plus TestSetup:From / TestSetup:To in Core.Email.Tests/appsettings.private.json (git-ignored).
License
Apache-2.0
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- No dependencies.
NuGet packages (6)
Showing the top 5 NuGet packages that depend on Core.Email.Abstractions:
| Package | Downloads |
|---|---|
|
Core.Email.Provider.SES
Amazon SES (v2 API) provider for Core.Email |
|
|
Core.Email
Transactional email abstraction layer for .NET - one ICoreEmail interface with interchangeable providers (SMTP, Amazon SES, Mailjet, SendGrid, Postmark) |
|
|
Core.Email.Provider.SMTP
SMTP provider (MailKit) for Core.Email |
|
|
Core.Email.Provider.Mailjet
Mailjet provider for Core.Email |
|
|
Core.Email.Provider.SendGrid
SendGrid provider for Core.Email |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.0 | 55 | 10/3/2026 |
| 1.0.2 | 223 | 8/11/2026 |
| 1.0.1 | 4,013 | 3/8/2026 |
| 1.0.0 | 415 | 1/14/2026 |
| 0.1.0 | 841 | 11/11/2025 |
| 0.0.12 | 228 | 10/21/2025 |
| 0.0.11 | 935 | 7/11/2025 |
| 0.0.10 | 880 | 4/29/2025 |
| 0.0.9 | 1,646 | 11/13/2024 |
| 0.0.8 | 1,085 | 8/1/2024 |
| 0.0.7 | 2,030 | 2/7/2024 |
| 0.0.6 | 327 | 2/4/2024 |
| 0.0.5 | 352 | 1/21/2024 |
| 0.0.4 | 373 | 1/18/2024 |
| 0.0.3 | 306 | 1/18/2024 |
| 0.0.2 | 327 | 1/18/2024 |
| 0.0.1 | 297 | 1/18/2024 |