I'm trying to switch my site over to Mandrill, however I'm having some problems with the PHP API.
There are two problems:
- First, it is sending the email twice. The code at the bottom is all the code I have (except for the PHP opening and closing tags) and I cannot figure out why it would be sending the email twice every time.
 - Second, I get an error from cURL saying the URL is not set. The email is being sent, so obviously there is a URL set. The error is below.
 
Here is my code:
require_once './libraries/Mandrill.php';
try {
    $mandrill = new Mandrill('myapikey');
    $template_name = 'my-template-slug';
    $template_content = '';
    $message = array(
        'to' => array(
            array(
                'email' => 'a_test@emailaddress.com',
                'name' => 'RecipientsName',
                'type' => 'to'
            )
        ),
        'auto_text' => true,
        'merge_vars' => array(
            array(
                'rcpt' => 'a_test@emailaddress.com',
                'vars' => array(
                    array(
                        'name' => 'USERNAME',
                        'content' => 'user1234'
                    ),
                    array(
                        'name' => 'CONFIRM_CODE',
                        'content' => '19874lahg62378hwsi'
                    )
                )
            )
        )
    );
    $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;
}
And here is the error:
A mandrill error occurred: Mandrill_HttpError - API call to messages/send-template failed: No URL set! Fatal error: Uncaught exception 'Mandrill_HttpError' with message 'API call to messages/send-template failed: No URL set!' in /Users/Gavin/Desktop/Web/mandrill-test/libraries/Mandrill.php:126 Stack trace: #0 /Users/Gavin/Desktop/Web/mandrill-test/libraries/Mandrill/Messages.php(160): Mandrill->call('messages/send-t...', Array) #1 /Users/Gavin/Desktop/Web/mandrill-test/index.php(70): Mandrill_Messages->sendTemplate('my-template-slug', Array, Array) #2 /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/php/setup.php(131): require('/Users/Gavin/De...') #3 {main} thrown in /Users/Gavin/Desktop/Web/mandrill-test/libraries/Mandrill.php on line 126