Skip to content

Instantly share code, notes, and snippets.

@priteshgupta
Created March 7, 2014 16:06
Show Gist options
  • Save priteshgupta/9414309 to your computer and use it in GitHub Desktop.
Save priteshgupta/9414309 to your computer and use it in GitHub Desktop.

Revisions

  1. priteshgupta created this gist Mar 7, 2014.
    28 changes: 28 additions & 0 deletions mandrill_json.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    <?php
    $uri = 'https://mandrillapp.com/api/1.0/messages/send.json';

    $params = array(
    "key" => 'KEY_GOES_HERE',
    "message" => array(
    "html" => 'HTML_MAIL',
    "to" => array(
    array("email" => 'TO_MAIL')
    ),
    "from_email" => 'From_Email',
    "from_name" => 'From_Name',
    "subject" => 'Email_Subject',
    "auto_text" => true,
    "track_opens" => true,
    "track_clicks" => true
    ),
    "async" => false
    );

    $postString = json_encode($params);

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $uri);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
    curl_exec($ch);