By Rudderstack Team

How to load data from Mandrill to SQL Data Warehouse

Mandrill is a transactional email API for Mailchimp Users and it is ideal for sending data-driven emails, including targeted and personalized one-to-one messages to your customers. But that traffic creates more data. How can you analyze the data you generate with Mandrill as part of your transactional email campaigns, on SQL Data Warehouse? This guide is going to provide you with a clear picture of how to load data from Mandrill to SQL Data Warehouse. Alternatively, you can use products like RudderStack that can handle this kind of problem automatically for you.

We will use Mandrill’s API to access and extract email-related data and load it into SQL Data Warehouse for further analysis. You will need to write the code to get the data and make sure that this process will run every time new data is generated.

What is Mandrill?

Mandrill is a transactional email API for Mailchimp Users. Although in the past, Mandrill was perceived as a different product than Mailchimp, right now it is offered as a Mailchimp plugin. Mandrill is reliable, powerful, and ideal for sending data-driven emails, including targeted and personalized one-to-one messages to your customers.

You might wonder what are the differences between Mandrill and Mailchimp, as both of them handle the delivery of emails to your customers. Some key differences between the two are the following:

  • Mandrill is designed for developers. If you are not comfortable with writing code then it would be better if you find someone before you start using it. On the other hand, Mailchimp is designed mainly for marketeers so no technical skills are required to use it.
  • Mandrill focuses more on transactional emails, which are different from the promotional/campaign based emails that marketeers send using Mailchimp. Transactional emails are more tailor made for cases like one to one messages to your customers, like resetting passwords, welcoming them etc.
  • Mailchimp offers richer reporting, but with Mandrill it is easier to have access to all the raw events related to your emails as they happen, so you can run your own analytics if you wish. In general, raw data from Mandrill are much more accessible than in Mailchimp.
  • If you wish to run complicated campaigns with Mandrill you will have to implement the logic behind running them, with Mailchimp you can do that using the drag-n-drop environment that it offers.

In general, you can perceive the two services as complementary, Mailchimp allows your marketing department to easily and fast execute their marketing strategies, while with Mandrill you have access to a very flexible and rich environment where you can build complex products on top of email services, but it requires the involvement of your R&D team.

Mandrill, as an email API, exposes all its functionality through it. So apart from being possible to execute a number of operations like sending emails based on specific events, we can also use this API to pull out data or setup our infrastructure in such a way that Mandrill will send to us data over time they are generated. In this article, we will see in detail the different ways of pulling data from Mandrill that can be useful for running our analytics.

What is Microsoft Azure SQL Data Warehouse?

SQL Data Warehouse is the data warehousing solution that you can use if you are a user of Microsoft Azure. It’s an elastic data warehousing as a service solution, emphasizing it’s enterprise focus. It also speaks SQL like the previous two solutions and it supports querying both relational and non-relational data.

It offers a number of enterprise-class features like support for hybrid cloud installations and strong security. It’s probably the less mature solution compared to the two others though, it’s still in “Preview” mode although accessible to existing Azure subscribers.

How to Extract my data from Mandrill?

There are two main methods to get our data from Mandrill, the first one is to pull data out from it and the second one is to ask Mandrill to push data to us whenever something of importance happens. We will see the difference between these two solutions and how we can access data from both.

In order to pull data from Mandrill, we need to access its HTTP API. As a Web API following the RESTful architecture principles, it can be accessed through HTTP. As a RESTful API, interacting with it can be achieved by using tools like CURL or Postman or by using http clients for your favorite language or framework. A few suggestions:

Mandrill maintains a number of officially supported clients or SDKs that you can use with your favorite language to access it without having to mess with the raw underlying HTTP calls. These are the following:

There are also a number of unofficial clients that you can use if you prefer. The complete list can be found here.

In this post, we will consider the more generic case of accessing the HTTP endpoints directly for our examples, but of course, you are free to use the client of your choice for your project.

Mandrill API Authentication

In order to use the Mandrill API, you first have to generate an API key through your MandrillApp account. When you have created the key you can use it to access the API. You can actually have multiple keys per account, something that adds versatility to the platform. In most cases with the Mandrill API, you make a POST call to access an endpoint with a JSON body containing the access key.

Mandrill rate limiting


API rate limiting with Mandrill is a bit of a more complicated matter than in most cases of APIs out there. The reason is that Mandrill is mainly an SMTP as a service platform, in most cases when we make a call to its API we do it in order to send an email to someone, so rate limiting in the typical sense that we find it in web APIs does not apply in Mandrill.

What is actually happening is that every Mandrill account has a reputation and an hourly quota, the main reason that rate limiting is a bit more complicated in Mandrill is because they need to take special car