Acontplus.Notifications
1.5.2
dotnet add package Acontplus.Notifications --version 1.5.2
NuGet\Install-Package Acontplus.Notifications -Version 1.5.2
<PackageReference Include="Acontplus.Notifications" Version="1.5.2" />
<PackageVersion Include="Acontplus.Notifications" Version="1.5.2" />
<PackageReference Include="Acontplus.Notifications" />
paket add Acontplus.Notifications --version 1.5.2
#r "nuget: Acontplus.Notifications, 1.5.2"
#:package Acontplus.Notifications@1.5.2
#addin nuget:?package=Acontplus.Notifications&version=1.5.2
#tool nuget:?package=Acontplus.Notifications&version=1.5.2
Acontplus.Notifications
Production-ready email notification library with MailKit and Amazon SES support. Features template caching, rate limiting, connection pooling, and enterprise-grade scalability.
๐ Features
v1.5.0 - Performance & Caching
- โก Template Caching: 50x faster template loading (30min memory cache)
- ๐ 99% Less I/O: Cached templates eliminate repeated disk reads
- ๐ Backward Compatible: Optional
IMemoryCacheinjection
Core Capabilities
- ๐ง Email notifications via MailKit (SMTP) and Amazon SES (HTTP)
- ๐จ Templated emails with Scriban engine
- ๐ Retry logic with Polly (exponential backoff)
- ๐ฆ Rate limiting (SES: 14 emails/sec default, SMTP: auth throttling)
- ๐ Connection pooling for SMTP (configurable pool size)
- ๐ฆ Bulk sending with batching (SES: 50 recipients/batch)
- ๐งต Thread-safe concurrent operations
- ๐จ Attachments support (PDF, images, documents)
- ๐ WhatsApp and push notification support (planned)
๐ฆ Installation
NuGet Package Manager
Install-Package Acontplus.Notifications -Version 1.5.0
.NET CLI
dotnet add package Acontplus.Notifications --version 1.5.0
PackageReference
<PackageReference Include="Acontplus.Notifications" Version="1.5.0" />
๐ฏ Quick Start
1. Configure Services
// In Program.cs or Startup.cs
var builder = WebApplication.CreateBuilder(args);
// Option 1: Amazon SES (Recommended for Production)
builder.Services.AddSingleton<IMailKitService, AmazonSesService>();
// Option 2: MailKit SMTP
builder.Services.AddSingleton<IMailKitService, MailKitService>();
// Optional: Enable template caching for better performance
builder.Services.AddMemoryCache();
2. Configure appsettings.json
Amazon SES Configuration:
{
"AWS": {
"SES": {
"Region": "us-east-1",
"DefaultFromEmail": "noreply@example.com",
"MaxSendRate": 14,
"BatchSize": 50,
"BatchDelayMs": 100,
"AccessKey": "AKIA...",
"SecretKey": "your-secret-key"
}
},
"Templates": {
"Path": "Templates"
},
"Media": {
"ImagesPath": "wwwroot/images"
}
}
MailKit SMTP Configuration:
{
"MailKit": {
"MaxPoolSize": 3,
"MinAuthIntervalSeconds": 30,
"MaxAuthAttemptsPerHour": 10
}
}
3. Send an Email
public class EmailController : ControllerBase
{
private readonly IMailKitService _emailService;
public EmailController(IMailKitService emailService)
{
_emailService = emailService;
}
[HttpPost("send")]
public async Task<IActionResult> SendEmail([FromBody] EmailRequest request)
{
var email = new EmailModel
{
SenderName = "My App",
SenderEmail = "noreply@example.com",
RecipientEmail = request.To,
Subject = request.Subject,
Body = request.HtmlBody,
IsHtml = true
};
var success = await _emailService.SendAsync(email, CancellationToken.None);
return success ? Ok("Email sent") : StatusCode(500, "Failed to send email");
}
}
4. Send with Template (NEW in v1.5.0 - Cached!)
var email = new EmailModel
{
SenderEmail = "noreply@example.com",
RecipientEmail = "user@example.com",
Subject = "Welcome!",
Template = "welcome-email.html", // Cached for 30 minutes!
Body = JsonSerializer.Serialize(new
{
UserName = "John",
ActivationLink = "https://example.com/activate"
}),
IsHtml = false // Will process template
};
await _emailService.SendAsync(email, CancellationToken.None);
๐ Advanced Usage
Bulk Email Sending (Amazon SES)
var emails = new List<EmailModel>();
for (int i = 0; i < 1000; i++)
{
emails.Add(new EmailModel
{
SenderEmail = "noreply@example.com",
RecipientEmail = $"user{i}@example.com",
Subject = "Newsletter",
Body = "<h1>Hello!</h1>",
IsHtml = true
});
}
// Automatically batched (50 per batch) with rate limiting (14/sec)
var success = await _emailService.SendBulkAsync(emails, CancellationToken.None);
// Completes in ~70 seconds with smooth throttling
Email with Attachments
var email = new EmailModel
{
SenderEmail = "noreply@example.com",
RecipientEmail = "user@example.com",
Subject = "Invoice",
Body = "<h1>Your Invoice</h1>",
IsHtml = true,
Files = new List<EmailAttachment>
{
new EmailAttachment
{
FileName = "invoice.pdf",
Content = pdfBytes
}
}
};
await _emailService.SendAsync(email, CancellationToken.None);
Template with Logo
var email = new EmailModel
{
SenderEmail = "noreply@example.com",
RecipientEmail = "user@example.com",
Subject = "Welcome!",
Template = "welcome.html",
Logo = "company-logo.png", // From Media:ImagesPath/Logos/
Body = JsonSerializer.Serialize(new { UserName = "John" }),
IsHtml = false
};
await _emailService.SendAsync(email, CancellationToken.None);
โ๏ธ Configuration Options
Amazon SES Settings
| Setting | Default | Description |
|---|---|---|
Region |
us-east-1 | AWS SES region |
DefaultFromEmail |
- | Default sender email |
MaxSendRate |
14 | Max emails per second |
BatchSize |
50 | Recipients per bulk batch |
BatchDelayMs |
100 | Delay between batches |
AccessKey |
- | AWS access key (optional if using IAM) |
SecretKey |
- | AWS secret key (optional if using IAM) |
MailKit SMTP Settings
| Setting | Default | Description |
|---|---|---|
MaxPoolSize |
3 | SMTP connection pool size |
MinAuthIntervalSeconds |
30 | Min time between auth attempts |
MaxAuthAttemptsPerHour |
10 | Auth rate limiting |
Template Caching (v1.5.0+)
Automatic when IMemoryCache is registered:
- Cache Duration: 30 minutes (sliding expiration)
- Priority: Normal
- Key Format:
email_template:{templateName}
// Enable caching (optional but recommended)
builder.Services.AddMemoryCache(options =>
{
options.SizeLimit = 100; // Max cached templates
options.CompactionPercentage = 0.25;
});
๐ Performance
v1.5.0 Template Caching Impact
| Metric | v1.4.x | v1.5.0 (Cached) | Improvement |
|---|---|---|---|
| Template load time | 10-50ms | <1ms | 50x faster |
| Disk I/O (high volume) | Every request | Once per 30min | 99% reduction |
| Memory overhead | ~0KB | ~50KB/template | Minimal |
Rate Limiting Behavior
Amazon SES:
- Default: 14 emails/second (AWS sandbox limit)
- Production: Configurable up to account limits
- Automatic throttling with logging
MailKit:
- SMTP connection pooling (default: 3 connections)
- Auth rate limiting prevents account lockouts
- Configurable intervals and max attempts
๐ง API Documentation
IMailKitService Interface
public interface IMailKitService
{
Task<bool> SendAsync(EmailModel email, CancellationToken ct);
Task<bool> SendBulkAsync(IEnumerable<EmailModel> emails, CancellationToken ct);
}
EmailModel Class
public class EmailModel
{
public string SenderName { get; set; }
public string SenderEmail { get; set; }
public string RecipientEmail { get; set; } // Multiple: "a@x.com,b@x.com"
public string? Cc { get; set; }
public string Subject { get; set; }
public string Body { get; set; }
public bool IsHtml { get; set; }
public string? Template { get; set; } // Template file name
public string? Logo { get; set; }
public List<EmailAttachment>? Files { get; set; }
// SMTP specific (MailKit only)
public string? SmtpServer { get; set; }
public int SmtpPort { get; set; }
public string? Password { get; set; }
}
๐ค Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
Development Setup
git clone https://github.com/acontplus/acontplus-dotnet-libs.git
cd acontplus-dotnet-libs
dotnet restore
dotnet build
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Support
- ๐ง Email: proyectos@acontplus.com
- ๐ Issues: GitHub Issues
- ๐ Documentation: Wiki
๐จโ๐ป Author
Ivan Paz - @iferpaz7
๐ข Company
Acontplus - Software solutions
Built with โค๏ธ for the .NET community
| 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
- Acontplus.Core (>= 2.1.1)
- Acontplus.Utilities (>= 2.0.5)
- AWSSDK.Core (>= 4.0.3.6)
- AWSSDK.SimpleEmailV2 (>= 4.0.11)
- BCrypt.Net-Next (>= 4.0.3)
- MailKit (>= 4.14.1)
- Microsoft.Extensions.Caching.Memory (>= 10.0.1)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Options (>= 10.0.1)
- Polly (>= 8.6.5)
- Scriban (>= 6.5.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.5.2 | 0 | 12/25/2025 |
| 1.5.1 | 59 | 12/23/2025 |
| 1.5.0 | 260 | 12/16/2025 |
| 1.4.7 | 127 | 12/11/2025 |
| 1.4.6 | 162 | 12/5/2025 |
| 1.4.5 | 191 | 12/4/2025 |
| 1.4.4 | 188 | 12/3/2025 |
| 1.4.2 | 183 | 11/27/2025 |
| 1.4.1 | 181 | 11/26/2025 |
| 1.4.0 | 182 | 11/23/2025 |
| 1.3.26 | 389 | 11/17/2025 |
| 1.3.25 | 379 | 11/17/2025 |
| 1.3.24 | 384 | 11/17/2025 |
| 1.3.23 | 272 | 11/11/2025 |
| 1.3.22 | 266 | 11/11/2025 |
| 1.3.21 | 197 | 11/5/2025 |
| 1.3.20 | 188 | 11/5/2025 |
| 1.3.19 | 180 | 11/5/2025 |
| 1.3.18 | 191 | 11/5/2025 |
| 1.3.17 | 195 | 11/2/2025 |
| 1.3.16 | 183 | 10/23/2025 |
| 1.3.15 | 166 | 9/26/2025 |
| 1.3.14 | 182 | 9/25/2025 |
| 1.3.13 | 181 | 9/25/2025 |
| 1.3.12 | 177 | 9/24/2025 |
| 1.3.11 | 225 | 9/14/2025 |
| 1.3.10 | 233 | 9/14/2025 |
| 1.3.9 | 234 | 9/14/2025 |
| 1.3.8 | 179 | 9/10/2025 |
| 1.3.7 | 185 | 9/9/2025 |
| 1.3.6 | 199 | 9/3/2025 |
| 1.3.5 | 212 | 8/24/2025 |
| 1.3.4 | 174 | 8/21/2025 |
| 1.3.3 | 166 | 8/19/2025 |
| 1.3.2 | 186 | 8/13/2025 |
| 1.3.1 | 178 | 8/8/2025 |
| 1.3.0 | 254 | 8/7/2025 |
| 1.2.6 | 256 | 8/5/2025 |
| 1.2.5 | 142 | 7/31/2025 |
| 1.2.4 | 557 | 7/23/2025 |
| 1.2.3 | 130 | 7/18/2025 |
| 1.2.2 | 174 | 7/15/2025 |
| 1.2.1 | 173 | 7/15/2025 |
| 1.2.0 | 178 | 7/14/2025 |
| 1.1.0 | 175 | 7/14/2025 |
| 1.0.20 | 120 | 7/11/2025 |
| 1.0.19 | 126 | 7/11/2025 |
| 1.0.18 | 183 | 7/10/2025 |
| 1.0.17 | 174 | 7/10/2025 |
| 1.0.16 | 172 | 7/10/2025 |
| 1.0.15 | 184 | 7/9/2025 |
| 1.0.14 | 175 | 7/9/2025 |
| 1.0.13 | 190 | 7/7/2025 |
| 1.0.12 | 178 | 7/6/2025 |
| 1.0.11 | 171 | 7/6/2025 |
| 1.0.10 | 128 | 7/4/2025 |
| 1.0.9 | 178 | 7/3/2025 |
| 1.0.6 | 179 | 7/2/2025 |
| 1.0.5 | 184 | 7/2/2025 |
| 1.0.4 | 183 | 7/1/2025 |
v1.5.0: Added template caching with IMemoryCache (30min sliding expiration) for improved performance on high-frequency templates. Reduces I/O operations and speeds up email rendering. Backward compatible - optional IMemoryCache injection in AmazonSesService constructor.