VoDA.AspNetCore.Services.Email
1.0.0
dotnet add package VoDA.AspNetCore.Services.Email --version 1.0.0
NuGet\Install-Package VoDA.AspNetCore.Services.Email -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="VoDA.AspNetCore.Services.Email" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add VoDA.AspNetCore.Services.Email --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: VoDA.AspNetCore.Services.Email, 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.
// Install VoDA.AspNetCore.Services.Email as a Cake Addin #addin nuget:?package=VoDA.AspNetCore.Services.Email&version=1.0.0 // Install VoDA.AspNetCore.Services.Email as a Cake Tool #tool nuget:?package=VoDA.AspNetCore.Services.Email&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Description
This library provides a simple way to send emails from your ASP.NET Core application.
Installation
Install the NuGet package into your project.
Usage
1. Configure SMTP
public void ConfigureServices(IServiceCollection services)
{
services.AddEmailService(options =>
{
options.Host = "smtp.example.com";
options.Port = 587;
options.Email = "email@example.com";
options.Password = "password";
options.DisplayName = "Example";
options.EnableSsl = true;
options.UseDefaultCredentials = false;
options.EmailTemplatesFolder = "EmailTemplates";
});
}
2. Create email template
Create a file EmailTemplates/MyTemplate.html
with the following content:
<!DOCUMENT html>
<html>
<head>
<title>Activate Account</title>
<meta name="subject" content="Activate Account"/>
</head>
<body>
<h1>Activate Account</h1>
<p>Hi {{firstName}},</p>
<p>Thank you for registering with us. Please click on the link below to activate your account.</p>
<p><a href="{{link}}">Activate Account</a></p>
<p>Regards,</p>
<p>Team</p>
</body>
</html>
3. Send email
public class MyController : Controller
{
private readonly IEmailService _emailService;
public MyController(IEmailService emailService)
{
_emailService = emailService;
}
public async Task<IActionResult> SendEmail()
{
Dictionary<string, string> model = new Dictionary<string, string>
{
{ "firstName", "John" },
{ "link", "https://example.com/activate-account" }
};
await _emailService.SendEmailUseTemplate("some.email@example.com", "MyTemplate", model);
return Ok();
}
}
License
This project is licensed under the MIT License - see the LICENSE file for details.
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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Extensions.Options (>= 8.0.1)
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.0 | 150 | 1/15/2024 |