VOOZH about

URL: https://www.nuget.org/packages/Mandrill.net/

⇱ NuGet Gallery | Mandrill.net 10.0.0




👁 Image
Mandrill.net 10.0.0

dotnet add package Mandrill.net --version 10.0.0
 
 
NuGet\Install-Package Mandrill.net -Version 10.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="Mandrill.net" Version="10.0.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Mandrill.net" Version="10.0.0" />
 
Directory.Packages.props
<PackageReference Include="Mandrill.net" />
 
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 Mandrill.net --version 10.0.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Mandrill.net, 10.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 Mandrill.net@10.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=Mandrill.net&version=10.0.0
 
Install as a Cake Addin
#tool nuget:?package=Mandrill.net&version=10.0.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Mandrill.net

Simple, cross-platform Mandrill api wrapper for .NET Core

👁 Coverage Status
<a href="http://www.nuget.org/packages/Mandrill.net/"><img src="https://img.shields.io/nuget/v/Mandrill.net.svg" title="NuGet Status"></a>

API Docs

https://mandrillapp.com/api/docs/

Getting Started

dotnet add package Mandrill.net

# use Mandrill with HttpClientFactory
dotnet add package Mandrill.net.Extensions.DependencyInjection

Send a new transactional message through Mandrill

var api = new MandrillApi("YOUR_API_KEY_GOES_HERE");
var message = new MandrillMessage("from@example.com", "to@example.com",
 "hello mandrill!", "...how are you?");
var result = await api.Messages.SendAsync(message);

Send a new transactional message through Mandrill using a template

var api = new MandrillApi("YOUR_API_KEY_GOES_HERE");
var message = new MandrillMessage();
message.FromEmail = "no-reply@acme.com";
message.AddTo("recipient@example.com");
message.ReplyTo = "customerservice@acme.com";
//supports merge var content as string
message.AddGlobalMergeVars("invoice_date", DateTime.Now.ToShortDateString());
//or as objects (handlebar templates only)
message.AddRcptMergeVars("recipient@example.com", "invoice_details", new[]
{
 new Dictionary<string, object>
 {
 {"sku", "apples"},
 {"qty", 4},
 {"price", "0.40"}
 },
 new Dictionary<string, object>
 {
 {"sku", "oranges"},
 {"qty", 6},
 {"price", "0.30"}

 }
});

var result = await api.Messages.SendTemplateAsync(message, "customer-invoice");

Service Registration

It is recommended that you do not create an instance of the MandrillApi for every request, to effectively pool connections to mandrill, and prevent socket exhaustion in your app. If you are using .net dependency injection, you can use the Mandrill.net.Extensions.DependencyInjection package which includes a IServiceCollection.AddMandrill() extension method, allowing you to register all the needed interfaces and also customize the HttpClientFactory to efficiently manage the HttpClient connections.

using Microsoft.Extensions.DependencyInjection;
using Mandrill;
using Mandrill.Model;
using Mandrill.Extensions.DependencyInjection;

var services = ConfigureServices(new ServiceCollection()).BuildServiceProvider();
var api = services.GetRequiredService<IMandrillApi>();
// we can also target specific mandrill api endpoint interfaces...
//var messagesApi = services.GetRequiredService<IMandrillMessagesApi>();
var message = new MandrillMessage("from@example.com", "to@example.com",
 "hello mandrill!", "...how are you?");
var result = await api.Messages.SendAsync(message);

static IServiceCollection ConfigureServices(IServiceCollection services)
{
 services.AddMandrill(options =>
 {
 options.ApiKey = "YOUR_API_KEY_GOES_HERE"; // Load the api key from configuration
 });

 return services;
}

Processing a web hook batch

Mandrill sends a HEAD request to verify the endpoint before activating it, and then POSTs batches of up to 1,000 events as application/x-www-form-urlencoded with a mandrill_events field. Use minimal APIs to handle both:

// HEAD request: Mandrill sends this to verify the endpoint is reachable
app.MapMethods("/api/webhooks/mandrill", ["HEAD"], () => Results.Ok());

// POST request: Mandrill sends batches of events
app.MapPost("/api/webhooks/mandrill", async (HttpRequest request) =>
{
 if (!request.Headers.TryGetValue("X-Mandrill-Signature", out var signature))
 {
 return Results.Unauthorized();
 }

 var form = await request.ReadFormAsync();
 var body = form["mandrill_events"].ToString();

 var events = MandrillMessageEvent.ParseMandrillEvents(body);

 // accept an empty test request (Mandrill sends one when the HEAD request fails)
 if (events.Count == 0)
 {
 return Results.Accepted();
 }

 // If your app runs behind a reverse proxy (e.g. nginx, a cloud load balancer), request.Scheme
 // and request.Host must reflect the original public URL — not the proxy's internal address —
 // otherwise signature verification will fail. Configure forwarded headers middleware:
 // https://learn.microsoft.com/aspnet/core/host-and-deploy/proxy-load-balancer
 var url = new Uri($"{request.Scheme}://{request.Host}{request.Path}");
 if (!WebHookSignatureHelper.VerifyWebHookSignature(signature, "WEBHOOK_SECRET_KEY_HERE", url,
 form.ToDictionary(x => x.Key, x => x.Value.ToString())))
 {
 return Results.Forbid();
 }

 foreach (var messageEvent in events)
 {
 // do something with the event
 }

 return Results.Ok();
});

Building

dotnet build

Testing

You must set the user environment variable MANDRILL_API_KEY in order to run these tests. Go to https://mandrillapp.com/ to obtain an api key.

In order for the email from address to match your allowed sending domains, you can set MANDRILL_SENDING_DOMAIN to match your account.

# include MANDRILL_API_KEY and MANDRILL_SENDING_DOMAIN in your env. For example:
# MANDRILL_API_KEY=xxxxxxxxx MANDRILL_SENDING_DOMAIN=acme.com dotnet test tests
dotnet test

API coverage

See this issue to track progress of api implementation

Product Versions Compatible and additional computed target framework versions.
.NET net10.0 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on Mandrill.net:

Package Downloads
Mandrill.net.Extensions.DependencyInjection

integrate Mandrill.net with HttpClientFactory and Microsoft.Extensions.DependencyInjection

NServiceBus.Mandrill

NServiceBus feature to send Mandrill API requests over the bus

AMMS.Shared.Core

Thư viện dùng chung cho AMMS

Webezi.MailKit.Mandrill

Webezi.MailKit.Mandrill is used Mandrillto implements mailkit abstractions.

Altairis.Services.Mailing.Mandrill

E-mail sending services for ASP.NET Core applications using the Mandrill service.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.0 478 6/16/2026
10.0.0-prerelease.2 63 5/29/2026
9.0.2 110,883 11/20/2025
9.0.1 963,748 3/26/2024
9.0.0 46,237 2/29/2024
8.3.0 193,888 11/20/2023
8.2.0 671,232 4/20/2022
8.1.0 584,603 12/11/2021
8.0.0 4,000 12/10/2021
8.0.0-prerelease4 422 12/10/2021
7.3.2 3,749,625 8/11/2020
7.3.1 154,992 5/12/2020
7.3.0 3,719 5/10/2020
7.2.0 175,019 3/24/2020
7.1.2 28,381 2/17/2020
7.1.1 233,315 11/30/2019
Loading failed