Awesome dude.


Published:

Frontpage
On mandrill | api | newsletter | dogproject | php

Playing with Mandrill API

I recently played around with the Mandrill API for our dog project! It did look quite confusing in the beginning, since their API is pretty huge and is designed for different and multiple platforms such as. Ruby, Python, JSON, etc.

I manage to finish the integration and did developed a small (but strong) system to send out weekly emails to all our users for our dog project. I hope this will link our users and website even more ongoing!

In general this update is a nice update for me, and I'm pretty positive that this will help building even more traffic on the website!


Code snippet: PHP API

try {
$mandrill = new Mandrill();
$template_name = 'tmp';
$template_content = array(
    array(
        'name' => 'the name',
        'content' => 'newsletter content'
    )
);
$message = array(
    'html' => '',
    'text' => '',
    'subject' => 'subject',
    'from_email' => 'message.from_email@example.com',
    'from_name' => 'Example Name',
    'to' => array(
        array(
            'email' => 'recipient.email@example.com',
            'name' => 'Recipient Name',
            'type' => 'to'
        )
    )
);
$result = $mandrill->messages->sendTemplate($template_name, $template_content, $message);


} catch(Mandrill_Error $e) {
echo 'A mandrill error occurred: ' . get_class($e) . ' - ' . $e->getMessage();
throw $e;
}

Preview from the admin: preview