Select

Mandrill API – An alternate to SMTP and SendMail Email Transport

We live in the world where Cloud Computing and Internet of Things are buzzwords. We have been working with various Enterprises who may like to host their applications right from a
commodity shared hardware and software to Cloud based services of Amazon. There are certain hosting providers in the market who provide hosting solutions relatively “Cheap” to
speak. While we subscribe their hosting services we do not know the underlying (*conditions apply) conditions which we may have to follow in order for our systems to work.
Problem
We came across a similar situation while we were working with a Start-up which is providing its Mobility Software developed by us. Until the Software is exposed out of Private Beta the goal
was to run the Software hosted on GoDaddy hosting. We know that GoDaddy is a relatively “Cheap” hosting provider but it has its underlying conditions. The Software product was a SaaS
based solution which requires Emails and SMS to be floated to the subscribers of the requests per property on SaaS model. Our challenge was on GoDaddy we do get SMTP services with a
basic relay bridge and we do not get SendMail service. With SMTP relay bridge there is a limitation that a hosting at max can send 250 emails a day with the free relay bridge. One
solution for us was to buy more paid SMTP Relay bridges and get done with the problem. We reached out to our client with a Simple question on “How Many unique requests and
subscribers are we expecting per day for the request email consumption?” The answer was rightly “We can not predict”. Understanding the problem we wanted to explore one thing
whether we can use another third party SMTP on GoDaddy? The answer came out to be a BIG NO. What to do now?
Solution
We started our thoughts in various areas with how can we achieve it? Do we need to use any other transport layer to send the Emails? How do we do it? I came across a fantastic industry
recognized solution called Mandrill Emails. How could I implement it in my system? I wanted to run it on HTTP so that the GoDaddy doesn't have to support any other transport mechanism
protocol. I decided to implement it with API. In order to do this I had to perform an interesting but very useful design change in my architecture where I changed implementation from Factory
Method to Facade and delegation. Facade is implemented at the Mandrill's end which allows us to subscribe to their API and we need to call only the API end point with data in certain format
so that it could delegate the information in its underlying Messaging architecture. This HTTP based API integration now allows us to send more than thousands of emails to the subscribers.
We have also taken care of fall back messaging queue in case of Mandrill services are unavailable.
Here's a sample implementation snippet to it:
$message_array = array("text" => "Maulik...", "subject" => "IS TEst", "from_email" =>
"abc@apexon.com", "to" => array(0 => array("email" => "abc@gmail.com")));
$params = array("key" => "mandrill-subscriber-key", "message" => $message_array, "async"
=> true);
$params = json_encode($params);
$messages_api_end_point = "https://mandrillapp.com/api/1.0/messages/send.json";
$ch = curl_init($messages_api_end_point);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($params))
);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
$curl_error = curl_errno($ch);
if ($info['http_code'] != 200) {
$error_text = '';
if (preg_match('/<title>(.*?)<\/title>/s', $response, $match)) {
$error_text = $match[0];
}
return FALSE;
}
curl_close($ch);
print_r($response);
For us it became a blessing and we get a lot of Data Matrices on emails which we need and the best part was we did not have to develop it at our end where as we get it from the provider
system itslef. Mandill comes with out of the box analysis reports on email systems.
For more details on Mandrill please log on to: http://mandrill.com/about/
For more details on Mandrill API documentation : https://mandrillapp.com/api/docs

Interested in our Development Services?

Contact Apexon +1 408-727-1100

By submitting this form, you agree that you have read and understand Apexon’s Terms and Conditions. You can opt-out of communications at any time. We respect your privacy.

By submitting this form, you agree that you have read and understand Apexon’s Terms and Conditions. You can opt-out of communications at any time. We respect your privacy.

Other stories you may enjoy...

One Year In: Technology Success Stories from the Pandemic

This time last year, US companies were forced to face a new and unsettling reality: business as usual was no longer an option. I wrote then about how businesses could shift their...

How to Work with Your Remote Development Team

Working with remote teams to develop and release new products has become the norm for almost all aspects of software development.  Nowhere is that more true than in the mobile...

Think You Know Your App Dev Needs? Think Again.

The pace of change in mobile app development has been mind-blowing. Here at Apexon, we’ve been working on mobile apps since their inception. With every project we learn...