Skip to content

Instantly share code, notes, and snippets.

@i-tabu
Created April 26, 2016 16:34
Show Gist options
  • Save i-tabu/8cf16849972adad735f663385ce3534b to your computer and use it in GitHub Desktop.
Save i-tabu/8cf16849972adad735f663385ce3534b to your computer and use it in GitHub Desktop.
Pepipost_API_using_mandrill_SDK
<?php
/**
* Steps to install Mandrill SDK
* curl -s http://getcomposer.org/installer | php
* php composer.phar require mandrill/mandrill
* Edit
* vendor/mandrill/mandrill/src/Mandrill.php
* //public $root = 'https://mandrillapp.com/api/1.0';
* public $root = 'https://api.pepipost.com/api/1.0';
*/
require 'vendor/autoload.php';
$mandrill = new Mandrill('yourPepipostsecretkey'); // PEPIPOST API KEY HERE
$message = array(
'subject' => "This is your subject",
'from_name' => 'sender name',
'from_email' => '[email protected]',
'html' => '<p>hi [% NAME %], Pepipost Mandrill Migration API Testing Test</p>',//file_get_contents($template_files[$j]),
'to' => array(
array(
"email" => '[email protected]',
"name" => ''
)
),
'important' => true,
'track_opens' => true,
'track_clicks' => true,
'tags' => array("Tag1"),
'merge_vars' => array(
array(
"rcpt" => '[email protected]',
"vars" => array(
array(
"name" => "NameOfRecipient1",
"age" => "11"
)
)
)
)
);
//$result = $mandrill->messages->send($message, $async, $ip_pool, $send_at);
try{
$result = $mandrill->messages->send($message);
}
catch(Mandrill_Error $e) {
// Mandrill errors are thrown as exceptions
echo 'A mandrill(via Pepipost) error occurred: ' . get_class($e) . ' - ' . $e->getMessage();
// A mandrill error occurred: Mandrill_Unknown_Subaccount - No subaccount exists with the id 'customer-123'
throw $e;
}
print_r($result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment