MH.EmailService
1.0.0
See the version list below for details.
dotnet add package MH.EmailService --version 1.0.0
NuGet\Install-Package MH.EmailService -Version 1.0.0
<PackageReference Include="MH.EmailService" Version="1.0.0" />
<PackageVersion Include="MH.EmailService" Version="1.0.0" />
<PackageReference Include="MH.EmailService" />
paket add MH.EmailService --version 1.0.0
#r "nuget: MH.EmailService, 1.0.0"
#addin nuget:?package=MH.EmailService&version=1.0.0
#tool nuget:?package=MH.EmailService&version=1.0.0
EmailService
A lightweight .NET 8 library for sending emails via SMTP, designed for seamless integration with ASP.NET Core applications.
Features
- Simple and intuitive API for sending emails
- Supports SMTP configuration via
appsettings.json
- Built-in dependency injection support
- Clean separation of concerns using
IEmailService
interface - Fully configurable via
EmailSettings
Installation
Install the package via NuGet Package Manager:
dotnet add package EmailService
Configuration
Add the following section to your appsettings.json
:
"EmailSettings": {
"from": "your-email@example.com",
"appPassword": "your-app-password",
"host": "smtp.example.com",
"port": 587
}
Usage
1. Register the EmailService
In your Program.cs
or Startup.cs
, register the service:
builder.Services.AddEmailService(builder.Configuration);
2. Inject and Use IEmailService
In your classes or controllers, inject IEmailService
and use it to send emails:
public class NotificationService
{
private readonly IEmailService _emailService;
public NotificationService(IEmailService emailService)
{
_emailService = emailService;
}
public async Task NotifyUserAsync()
{
var email = new SendEmailDto
{
to = "recipient@example.com",
subject = "Welcome!",
body = "Thank you for signing up."
};
await _emailService.SendEmailAsync(email);
}
}
API Reference
SendEmailDto
Property | Type | Description |
---|---|---|
to |
string | Recipient email address |
subject |
string | Email subject |
body |
string | Email body content |
EmailSettings
Property | Type | Description |
---|---|---|
from |
string | Sender email address |
appPassword |
string | SMTP app password or token |
host |
string | SMTP server host |
port |
int | SMTP server port (e.g., 587) |
Authors
- Mohammad
- Heba
License
This project is licensed under the MIT License. See the LICENSE file for details.
Repository
For more information, visit the GitHub repository.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
-
net8.0
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection (>= 8.0.1)
- Microsoft.Extensions.Options (>= 8.0.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.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.