What is SparkPost?
I’ve used Mandrill for as long as I can remember. It sends transactional email, like the kind you receive when you sign up for a new account. Like me, many have been happy to use a free account for sending a relatively low number of emails a month.
That is, until recently, when Mandrill caused a bit of a stir. The heart of the matter is that Mandrill removed their free tier. Anybody wishing to send mail through Mandrill now requires a paid-for MailChimp account.
Perhaps they grew tired of making no money for sending lots of emails. Whatever the reason, many folks were surprised, and some even angry at the move. It’s akin to a popular open source library suddenly going closed-source.
What is SparkPost?
Mindful that people are looking for alternatives (to power their personal newsletters or whatever), I spoke to Aydrian Howard. Aydrian is the Developer Advocate at SparkPost, whom I met at FluentConf. We talked for a bit about SparkPost and what makes it different from MailChimp…
1. What are your thoughts on the recent MailChimp/Mandrill news?
We have a lot of respect for MailChimp and think they are a great company. We understand when they say that transactional email isn’t the business they’re in. Thanks to our great relationship with MailChimp, they are recommending us as a Mandrill replacement.
2. How long has the service been around, and what is its purpose?
We got our start in the late 1990s when Message Systems launched Momentum, the high-performance messaging platform servicing high-volume senders. Over time the Momentum customer base grew to send over 25% of all legitimate email and saw the launch of a managed cloud offering. In 2014 we launched SparkPost, providing developers with the same deliverability, scalability and speed as we provide to the biggest senders in the world, in an easily integrated cloud service.
3. What do Mandrill and SparkPost have in common?
We’re both SMTP & API-driven email infrastructure services.
4. What can you do with SparkPost that you can’t with Mandrill?
With SparkPost, you have the ability to use a single platform to send all your bulk and transactional messages. That means a single API, templating language, tracking, metadata and metrics. We are the industry’s leading email delivery service with nearly 98% inbox placement, which is 15 points higher than the industry average. We also provide to the minute tracking data (versus hourly) across all of our 35+ metrics. As part of our commitment to transparency, we include delivery latency numbers in our metrics. We are highly focused on developers. We maintain 8 client libraries (so far) and a growing selection of integrations. Our developer community is a very important part of SparkPost. We like to encourage and enable everyone to build something awesome.
5. How does SparkPost pricing work?
We just published a great FAQ Blogpost on our pricing.
After talking to Aydrian, I decided to try SparkPost. Turns out it’s quite easy to set up! To use it, you have to create an account:
When you first register, you’ll be presented with a couple of steps to set up your first application.
You can choose to send mail through SMTP or the JSON API. Click “Get a key” and keep that key close at hand for the code we’re about to write.
Next, create a working directory, and download the official SparkPost PHP SDK:
composer require sparkpost/php-sparkpost
You might see a warning about outdated dependencies. The SDK maintainers know about this and are working on a new version.
config.php file, to store the key:
return [ "sparkpost" => [ "key" => "<your key here>", ], ];
It’s a good idea to ignore this file in Git, so create a
.gitignore. It’s also a good place to ignore other common files:
Now, let’s create
send.php, to send emails through SparkPost:
require("vendor/autoload.php"); use SparkPost\SparkPost; use GuzzleHttp\Client; use Ivory\HttpAdapter\Guzzle6HttpAdapter; $config = require("config.php"); $adapter = new Guzzle6HttpAdapter(new Client()); $client = new SparkPost($adapter, [ "key" => $config["sparkpost"]["key"], ]); $results = $client->transmission->send([ "from" => "Sandbox <firstname.lastname@example.org>", "html" => "<html><body>hello html email</body></html>", "text" => "hello plain text email", "subject" => "Testing SparkPost Email", "recipients" => [ [ "address" => [ "name" => "Chris", "email" => "email@example.com", ], ], ], ]);
The official PHP SDK requires an adapter library called
Ivory\HttpAdapter. This abstracts the HTTP layer, so that you can swap from GuzzleHttp to something else. This is probably just to cater for folks stuck on PHP 5.4, who can’t use the latest and greatest version of Guzzle.
With the adapter, we then create an instance of the SparkPost client. On this we can access the
transmission property and the
The properties here are only a fraction of what you can specify through the JSON API. I am curious to see how easy it would be to use that directly, but hopefully this illustrates how to begin to use SparkPost, with minimal effort.
Stay tuned for more on this topic, as we explore how to use the SparkPost API to do more interesting things. Let us know if you’re interested in integrating SparkPost into your application or favorite framework, in the comments below.