I am just trying to integrate mandrill mail sending with my app below is my code in php
$args = array(
'key' => '73357ad2-e59e-4669---------',
'message' => array(
"html" => "<p>\r\n\tHi Adam,</p>\r\n<p>\r\n\tThanks for <a href=\"http://mandrill.com\">registering</a>.</p>\r\n<p>etc etc</p>",
"text" => null,
"from_email" => "[email protected]",
"from_name" => "SIVOnline",
"subject" => "Your recent registration",
"to" => array(array("email" => "[email protected]")),
"track_opens" => true,
"track_clicks" => true,
"auto_text" => true
)
);
// Open a curl session for making the call
$curl = curl_init('https://mandrillapp.com/api/1.0/messages/send.json' );
// Tell curl to use HTTP POST
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
// Tell curl not to return headers, but do return the response
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
// Set the POST arguments to pass on
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($args));
// Make the REST call, returning the result
$response = curl_exec($curl);
// Close the connection
curl_close( $curl );
and it is giving me invalid api key after regenarating the key still i am getting the same error.
Don't JSON-encode the $args
variable when passing it to the CURLOPT_POSTFIELDS setopt call.
BTW, you should try to make a users/ping call first.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With