UtilKit.EmailSender
1.0.0
See the version list below for details.
dotnet add package UtilKit.EmailSender --version 1.0.0
NuGet\Install-Package UtilKit.EmailSender -Version 1.0.0
<PackageReference Include="UtilKit.EmailSender" Version="1.0.0" />
<PackageVersion Include="UtilKit.EmailSender" Version="1.0.0" />
<PackageReference Include="UtilKit.EmailSender" />
paket add UtilKit.EmailSender --version 1.0.0
#r "nuget: UtilKit.EmailSender, 1.0.0"
#:package UtilKit.EmailSender@1.0.0
#addin nuget:?package=UtilKit.EmailSender&version=1.0.0
#tool nuget:?package=UtilKit.EmailSender&version=1.0.0
UtilKit.EmailSender
A lightweight SMTP email sender for .NET. Works with Gmail, Zoho, Outlook, AWS SES — any SMTP provider. Falls back to logging if SMTP not configured.
Install
dotnet add package UtilKit.EmailSender
Quick Start
With appsettings.json (recommended)
{
"SmtpSettings": {
"Host": "smtp.gmail.com",
"Port": 587,
"SenderEmail": "your-email@gmail.com",
"SenderPassword": "your-app-password",
"SenderName": "MyApp",
"EnableSsl": true
}
}
// Program.cs
builder.Services.AddUtilKitEmailSender(builder.Configuration);
// Or with custom section name
builder.Services.AddUtilKitEmailSender(builder.Configuration, "EmailConfig");
With inline config
builder.Services.AddUtilKitEmailSender(options =>
{
options.Host = "smtp.gmail.com";
options.Port = 587;
options.SenderEmail = "your-email@gmail.com";
options.SenderPassword = "your-app-password";
options.SenderName = "MyApp";
});
Send Email
public class NotificationService
{
private readonly IEmailSender _email;
public NotificationService(IEmailSender email)
{
_email = email;
}
public async Task SendWelcome(string userEmail, string userName)
{
await _email.SendAsync(
userEmail,
"Welcome!",
$"<h1>Hello {userName}!</h1><p>Welcome to our app.</p>"
);
}
}
Send with CC and BCC
await _email.SendAsync(
"user@example.com",
"Invoice",
"<p>Your invoice is attached.</p>",
ccEmails: new List<string> { "manager@example.com" },
bccEmails: new List<string> { "archive@example.com" }
);
Without DI
var logger = LoggerFactory.Create(b => b.AddConsole()).CreateLogger<SmtpEmailSender>();
var sender = new SmtpEmailSender(new SmtpOptions
{
Host = "smtp.gmail.com",
Port = 587,
SenderEmail = "your-email@gmail.com",
SenderPassword = "your-app-password",
SenderName = "MyApp"
}, logger);
await sender.SendAsync("user@example.com", "Test", "<p>Hello!</p>");
SMTP Providers
| Provider | Host | Port |
|---|---|---|
| Gmail | smtp.gmail.com | 587 |
| Zoho | smtp.zoho.com | 587 |
| Outlook | smtp.office365.com | 587 |
| AWS SES | email-smtp.us-east-1.amazonaws.com | 587 |
| SendGrid | smtp.sendgrid.net | 587 |
Gmail: Use an App Password, not your regular password.
Fallback
If Host is empty or not configured, emails are logged instead of sent. This is useful for development — you see the email content in logs without needing SMTP.
Environment Variables
Keep credentials out of code:
setx SmtpSettings__Host "smtp.gmail.com"
setx SmtpSettings__SenderEmail "your-email@gmail.com"
setx SmtpSettings__SenderPassword "your-app-password"
Cloud Secret Managers
This package reads from IConfiguration — it works automatically with any configuration source. No code change needed in your app.
AWS Secrets Manager
dotnet add package AWSSDK.SecretsManager
dotnet add package Kralizek.Extensions.Configuration.AWSSecretsManager
// Program.cs — just add the source
builder.Configuration.AddSecretsManager();
// UtilKit.EmailSender reads from IConfiguration as usual
builder.Services.AddUtilKitEmailSender(builder.Configuration);
Azure Key Vault
dotnet add package Azure.Extensions.AspNetCore.Configuration.Secrets
dotnet add package Azure.Identity
builder.Configuration.AddAzureKeyVault(
new Uri("https://your-vault.vault.azure.net/"),
new DefaultAzureCredential());
builder.Services.AddUtilKitEmailSender(builder.Configuration);
Priority Order
Cloud Secrets > Environment Variables > appsettings.json > Inline code
Higher priority sources override lower ones. Your SMTP credentials can come from any source — the package doesn't need to know.
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 was computed. 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. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.Extensions.Configuration.Abstractions (>= 6.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Options (>= 6.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.