Sending a template email from Mandrill using API is empty

api, email, json, mandrill, php

Solution

i didn't change the messaging URL from "/messages/send.json" to "/messages/send-template.json". Hopefully this helps someone else!

Problem

I am trying to send an email using the Mandrill API with JSON and PHP through curl. I can send a text based email and basic HTML formatting, but when i try to send a template from PHP it does not work. However, when copy and paste my JSON poststring to the Mandril API page (https://mandrillapp.com/api/docs/messages.html) it works and sends correctly! Am I missing something that the website is adding? ``` { "key": "XXX", "template_name": "temp-name", "template_content": [ { "name": "example name", "content": "example content" } ], "message": { "subject": "Welcome to our website", "from_email": "xxx@gmail.com", "from_name": "name", "to": [ { "email": "xxx@gmail.com", "name": "name" } ], "important": false, "track_opens": true, "merge": true, "global_merge_vars": [ { "name": "merge1", "content": "merge1 content" } ], "merge_vars": [ { "rcpt": "recipient.email@example.com", "vars": [ { "name": "merge2", "content": "merge2 content" } ] } ], "tags": [ "invite-send" ] }, "async": false, "ip_pool": "Main Pool" } ```

Original source