Skip to content

Repository files navigation

MailerSend.AspNetCore NuGet

ASP.NET Core library for MailerSend

Installation

.NET CLI

dotnet add package MailerSend.AspNetCore

Package Manager

Install-Package MailerSend.AspNetCore

Configuration

publicclassStartup{publicvoidConfigureServices(IServiceCollectionservices){services.AddMailerSend(options =>{options.ApiToken="API-TOKEN";options.SenderEmail="mail@domain.com";options.SenderName="MailerSend";});}}

appsettings.json

{
"MailerSend": {
"ApiToken": "API-TOKEN",
"SenderEmail": "mail@domain.com",
"SenderName": "MailerSend"
}
}
publicclassStartup{publicvoidConfigureServices(IServiceCollectionservices){services.Configure<MailerSendOptions>(Configuration.GetSection("MailerSend"));services.AddMailerSend();}}

Dependency injection

publicclassEmailController:ControllerBase{privatereadonlyMailerSendService_mailerSend;publicEmailController(MailerSendServicemailerSend){_mailerSend=mailerSend;}[HttpPost("send")]publicasyncTask<IActionResult>SendEmailAsync(CancellationTokenct){varto=newList<Recipient>(){newRecipient(){Email="user@domain.com",Name="User",Substitutions=newDictionary<string,string>(){{"var1","value1"},{"var2","value2"}}}};await_mailerSend.SendMailAsync(to,subject:"subject",text:"Test text",cancellationToken:ct);returnOk();}}

About

ASP.NET Core library for MailerSend

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages