How to send Mail using mandrill API - Correct me

785 views
Skip to first unread message

Vijay Raj

unread,
Jul 17, 2012, 10:07:01 AM7/17/12
to mandrill-a...@googlegroups.com
Hi All,

I am trying to send a mail via mandrill API. I am not get any response for this call. Could anybody give some sample script or correct me if am doing wrong.

Please find the attached code below

My Script:

$url = 'https://mandrillapp.com/api/1.0/messages/send.json';

$headers = array('key' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx',
        'message' => array(
            "html"=> "Example HTML",
            "text"=> "Example TEXT",
            "subject"=> "My Emai Subject",
            "from_email"=> "ad...@mydomain.com",
            "from_name"=> "BuckSense",
            "to"=>array("email"=> "xxx...@gmail.com", "name"=> "My Name")
        ));
$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_POST, true);
curl_setopt($curl_handle, CURLOPT_HEADER, false);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_handle, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, json_encode($headers));


$response = curl_exec($curl_handle);
curl_close($curl_handle);
   
var_dump( $response);


Thanks,
Vijay

Kaitlin

unread,
Jul 20, 2012, 9:47:43 PM7/20/12
to mandrill-a...@googlegroups.com
It looks like we got you taken care of directly through email, but but if anyone else is curious, adding the following before the curl_close($curl_handle) will make sure that errors are shown instead of just showing 'false' to be able to see where the issue is arising:

if(!$response) var_dump(curl_error($curl_handle));
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages