Mandrill.net 7.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Mandrill.net --version 7.1.1
NuGet\Install-Package Mandrill.net -Version 7.1.1
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="7.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Mandrill.net --version 7.1.1
#r "nuget: Mandrill.net, 7.1.1"
#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 Mandrill.net as a Cake Addin
#addin nuget:?package=Mandrill.net&version=7.1.1

// Install Mandrill.net as a Cake Tool
#tool nuget:?package=Mandrill.net&version=7.1.1

Mandrill.net

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

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> Dependabot Status

API Docs

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

Getting Started

Install-Package Mandrill.net

Building

dotnet build src/Mandrill.net
# if on mac/linux, you cannot build against the .net461 target:
# dotnet build src/Mandrill.net -f netstandard2.0

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 tests

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. For example, an ASP.NET Core service registration that registers the API Interfaces as singletons:

var api = new MandrillApi("YOUR_API_KEY_GOES_HERE");
services.AddSingleton<IMandrillMessagesApi>(api.Messages);

Processing a web hook batch

[HttpPost]
public IHttpActionResult MyWebApiControllerMethod(FormDataCollection value)
{
    //optional: validate your webhook signature
    // see https://mandrill.zendesk.com/hc/en-us/articles/205583257-How-to-Authenticate-Webhook-Requests
    if(!ValidateRequest(value))
    {
      return Forbidden();
    }

    var events = MandrillMessageEvent.ParseMandrillEvents(value.Get("mandrill_events"));
    foreach (var messageEvent in events)
    {
        // do something with the event
    }
    return Ok();
}

private bool ValidateRequest(FormDataCollection value)
{
   IEnumerable<string> headers;
   if (!Request.Headers.TryGetValues("X-Mandrill-Signature", out headers))
   {
     return false;
   }
   var signature = headers.Single();
   var key = "MANDRILL_WEBHOOK_KEY_HERE";

   return WebHookSignatureHelper.VerifyWebHookSignature(signature, key, Request.RequestUri, value.ReadAsNameValueCollection());
}

API coverage

See this issue to track progress of api implementation

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 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

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
9.0.1 7,825 3/26/2024
9.0.0 10,763 2/29/2024
8.3.0 64,149 11/20/2023
8.2.0 455,861 4/20/2022
8.1.0 193,173 12/11/2021
8.0.0 1,245 12/10/2021
8.0.0-prerelease4 185 12/10/2021
7.3.2 1,428,182 8/11/2020
7.3.1 121,812 5/12/2020
7.3.0 1,220 5/10/2020
7.2.0 170,821 3/24/2020
7.1.2 22,441 2/17/2020
7.1.1 224,155 11/30/2019
7.1.0 245,718 4/30/2019
7.0.0 163,549 3/17/2019
6.0.0 55,643 12/29/2018
5.0.0 199,819 6/18/2018
4.2.0 13,476 5/31/2018
4.1.0 515,272 4/9/2017
4.0.0 4,053 3/12/2017
3.3.0 37,544 12/24/2016
3.2.1 13,678 6/28/2016
3.0.0 13,996 5/3/2016
2.2.30 3,495 5/1/2016
2.2.12 10,479 2/18/2016
2.2.0 1,226 2/7/2016
2.1.2 2,413 1/14/2016
2.0.22 2,755 1/3/2016
1.0.2 14,641 8/8/2015
0.9.1 1,306 7/31/2015
0.9.0 1,778 6/20/2015
0.8.0 1,275 5/26/2015
0.7.0 2,265 3/28/2015
0.6.1 1,863 2/19/2015
0.6.0 1,484 2/18/2015
0.5.0 1,456 1/24/2015
0.4.0 1,571 1/15/2015
0.3.0 1,885 1/12/2015
0.2.0 1,226 1/12/2015