Naravel.Mail
0.2.0
dotnet add package Naravel.Mail --version 0.2.0
NuGet\Install-Package Naravel.Mail -Version 0.2.0
<PackageReference Include="Naravel.Mail" Version="0.2.0" />
<PackageVersion Include="Naravel.Mail" Version="0.2.0" />
<PackageReference Include="Naravel.Mail" />
paket add Naravel.Mail --version 0.2.0
#r "nuget: Naravel.Mail, 0.2.0"
#:package Naravel.Mail@0.2.0
#addin nuget:?package=Naravel.Mail&version=0.2.0
#tool nuget:?package=Naravel.Mail&version=0.2.0
Naravel.Mail
Typed mail contract for Naravel: Mailable classes, named transports (log, array, SMTP via an optional package) and a test fake, built on Naravel.Foundation.
| Fact | Detail |
|---|---|
| Install | dotnet add package Naravel.Mail |
| Targets | .NET 10 |
| Needs | Naravel.Foundation, which NuGet installs with it |
| Transports | log (the default) and array are built in; add Naravel.Mail.Smtp to deliver for real and Naravel.Mail.Queue to send through a queue |
What you get
- A message is a class. A
Mailablebuilds itsMailMessagewithMailBuilder, andmailer.To(email).SendAsync(new WelcomeMail(name))sends it. - Named transports.
Mail:Defaultpicks the oneIMaileruses; the default,log, logs the message and delivers nothing. - No network dependency in the core. SMTP is the optional
Naravel.Mail.Smtppackage and queued sending isNaravel.Mail.Queue. - Prepared messages too.
IMailer.SendAsync(MailMessage)sends an explicit message without a mailable. - A test fake.
MailFakerecords the sent and queued messages and offersAssertSent,AssertSentCountandAssertQueued.
Quick start
{ "Mail": { "From": "app@example.com" } }
using Naravel.Mail;
builder.Services.AddNaravelMail(builder.Configuration); // Mail:Default is "log": the message is logged, nothing is delivered
app.MapPost("/welcome", async (string email, string name, IMailer mailer, CancellationToken ct) =>
{
await mailer.To(email).SendAsync(new WelcomeMail(name), ct);
return Results.Accepted();
});
public sealed class WelcomeMail(string name) : Mailable
{
public override MailMessage Build(MailBuilder mail) =>
mail.Subject("Welcome").Text($"Hi {name}").Html($"<p>Hi {name}</p>").Build();
}
Related packages
| Package | Adds |
|---|---|
Naravel.Mail.Smtp |
Optional SMTP transport for Naravel.Mail, built on MailKit. |
Naravel.Mail.Queue |
Optional Naravel.Mail adapter that delivers mail through Naravel.Queue: QueueAsync stores only the built message data. |
Learn more
- Mail: English guide
- Changelog · Source and issues · MIT license
Part of Naravel: Laravel's names, .NET's type system. All Naravel packages share one version.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Microsoft.Extensions.Configuration (>= 10.0.14)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.14)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Options (>= 10.0.14)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.14)
- Naravel.Foundation (>= 0.2.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Naravel.Mail:
| Package | Downloads |
|---|---|
|
Naravel.Mail.Smtp
Optional SMTP transport for Naravel.Mail, built on MailKit. |
|
|
Naravel.Notifications.Mail
Optional Naravel.Notifications adapter: a "mail" channel that delivers a notification through Naravel.Mail. |
|
|
Naravel.Mail.Queue
Optional Naravel.Mail adapter that delivers mail through Naravel.Queue: QueueAsync stores only the built message data. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Release notes: https://github.com/km-arc/Naravel/releases/tag/v0.2.0 - full history: https://github.com/km-arc/Naravel/blob/main/CHANGELOG.md