UtilKit.EmailSender 1.0.0

There is a newer version of this package available.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="UtilKit.EmailSender" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="UtilKit.EmailSender" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="UtilKit.EmailSender" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add UtilKit.EmailSender --version 1.0.0
                    
#r "nuget: UtilKit.EmailSender, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package UtilKit.EmailSender@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=UtilKit.EmailSender&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=UtilKit.EmailSender&version=1.0.0
                    
Install as a Cake Tool

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

{
  "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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.0.1 134 4/21/2026
1.0.0 105 4/21/2026