function send_mail($mailtos, $body, $target) { global $language; // $subject = ( $language->language == 'nl' ) // ? 'Welkom bij Comfort Energy ' // : 'Bienvenue à Comfort Energy'; $subject = tt('cr_subjectline_confirmation_mail'); # add something to the subject that makes it unique (within 10 seconds) and goes up if ($target == 'dev_victim') { $subject .= ' (' . floor((time() - 1427268600) / 10) . ')'; } # not live and not staging? => don't allow mails being sent to comfort energy $tbwa_config = tbwa_config_php(); if ($tbwa_config['environment'] !== 'live' && $tbwa_config['environment'] !== 'staging') { if ($target == 'comfort_energy') { return array('debug' => '=> comfort energy: not sending'); } } # structure it the Mandrill way $mailtos = array_map(function ($e) { return array('email' => $e, 'type' => 'to'); }, $mailtos); # message parameters $message = array("key" => 'MN7hyMoFVC0Zo4ZwYM83hw', "message" => array('to' => $mailtos, "from_name" => 'Comfort Energy', 'from_email' => '*****@*****.**', 'subject' => $subject, 'html' => $body, 'text' => 'Please view this mail with a mail client that supports HTML.', 'track_opens' => true, 'subaccount' => '11COE15001_Comfort_Energy')); // echo '<pre>'; // print_r($message['message']['html']); // exit; $message = array('subject' => 'Test message', 'from_email' => 'MyEmailAddress', 'html' => '<p>this is a test message with Mandrill\'s PHP wrapper!.</p>', 'to' => array(array('email' => 'MyEmailAddress', 'name' => 'David Splat')), 'merge_vars' => array(array('rcpt' => 'MyEmailAddress', 'vars' => array(array('name' => 'FIRSTNAME', 'content' => $fName), array('name' => 'LASTNAME', 'content' => $lName))))); # send message $mandrill = new \Mandrill('MN7hyMoFVC0Zo4ZwYM83hw'); $result = $mandrill->call('/messages/send', $message); return $result; }
<?php /** * This examples shows how Mandrill library is used to obtain information about a user. */ require '../Mandrill.php'; require 'config.php'; Mandrill::call(array('type' => 'webhooks', 'call' => 'list'));
<?php /** * This examples shows how Mandrill library is used to obtain information about a user. */ require '../Mandrill.php'; require 'config.php'; Mandrill::call(array('type' => 'users', 'call' => 'ping'));
public function sendMessage() { $apiKey = $this->_helper->getApiKey(); $api = new \Mandrill($apiKey); $message = array('subject' => $this->_message->getSubject(), 'from_name' => $this->_message->getFromName(), 'from_email' => $this->_message->getFrom()); foreach ($this->_message->getTo() as $to) { $message['to'][] = array('email' => $to); } foreach ($this->_message->getBbc() as $bcc) { $message['to'][] = array('email' => $bcc, 'type' => 'bcc'); } if ($att = $this->_message->getAttachments()) { $message['attachments'] = $att; } if ($headers = $this->_message->getHeaders()) { $message['headers'] = $headers; } switch ($this->_message->getType()) { case \Magento\Framework\Mail\MessageInterface::TYPE_HTML: $message['html'] = $this->_message->getBody(); break; case \Magento\Framework\Mail\MessageInterface::TYPE_TEXT: $message['text'] = $this->_message->getBody(); break; } $api->call('messages/send', array("message" => $message)); return; }
public static function handleRedirectReturn($data = false) { if (!isset($data['key'])) { return 'There was an error. (general) Please try again.'; } else { require_once CASH_PLATFORM_ROOT . '/lib/mandrill/Mandrill.php'; $m = new Mandrill($data['key']); $user_info = $m->getUserInfo(); $username = $user_info['username']; // we can safely assume (AdminHelper::getPersistentData('cash_effective_user') as the OAuth // calls would only happen in the admin. If this changes we can f**k around with it later. $new_connection = new CASHConnection(AdminHelper::getPersistentData('cash_effective_user')); $result = $new_connection->setSettings($username . ' (Mandrill)', 'com.mandrillapp', array('key' => $data['key'])); if (!$result) { return 'There was an error. (adding the connection) Please try again.'; } // set up webhooks $api_credentials = CASHSystem::getAPICredentials(); $webhook_api_url = CASH_API_URL . '/verbose/people/processwebhook/origin/com.mandrillapp/api_key/' . $api_credentials['api_key']; //$m->webhooksDelete($webhook_api_url); // remove duplicate webhooks //$m->webhooksAdd($webhook_api_url,array('send','hard_bounce','soft_bounce','open','click','spam','unsub','reject')); // add it, all events $m->call('webhooks/add', array("url" => $webhook_api_url, "events" => array('hard_bounce', 'soft_bounce', 'open', 'click', 'spam', 'unsub', 'reject'))); if (isset($data['return_result_directly'])) { return $result; } else { if ($result) { AdminHelper::formSuccess('Success. Connection added. You\'ll see it in your list of connections.', '/settings/connections/'); } else { AdminHelper::formFailure('Error. Something just didn\'t work right.'); } } } }
function send($msg = '', $data = array()) { global $app; $mandrill = new Mandrill(config('mandrill.apikey')); if (!is_array($msg)) { parse_str($msg, $msg); } foreach (array('text', 'html') as $t) { if (!empty($msg[$t]) && strpos(trim($msg[$t]), 'slim:') === 0) { $view = new \Slim\View(); $view->appendData($data); $view->setTemplatesDirectory($app->config('templates.path')); $msg[$t] = $view->fetch('email/' . substr(trim($msg[$t]), 5)); } } if (isset($msg['from'])) { $msg['from_email'] = $msg['from']; unset($msg['from']); } if (!is_array($msg['to'])) { $msg['to'] = array(array('email' => $msg['to'])); } return $mandrill->call('/messages/send', array('message' => $msg)); }
public function testUserSenders() { $o = Mandrill::call(array('type' => 'users', 'call' => 'senders')); $this->assertTrue(is_array($o)); }
/** * Overwrite to allow empty params. * * @param string $url * @param array $params * @return array Result */ public function call($url, $params = []) { return parent::call($url, $params); }
<?php /** * This examples shows how Mandrill library is used to send a message. */ require '../Mandrill.php'; require 'config.php'; $request_json = '{"type":"messages","call":"send","message":{"html": "<h1>test</h1>", "text": "example text", "subject": "Google", "from_email": "*****@*****.**", "from_name": "Esferasoft", "to":[{"email": "*****@*****.**", "name": "Wes Widner"}],"headers":{"...": "..."},"track_opens":true,"track_clicks":true,"auto_text":true,"url_strip_qs":true,"tags":["test","example","sample"],"google_analytics_domains":["werxltd.com"],"google_analytics_campaign":["..."],"metadata":["..."]}}'; $ret = Mandrill::call((array) json_decode($request_json)); print_r($ret);
<?php /** * This examples shows how Mandrill library is used to obtain information about a user. */ require '../Mandrill.php'; require 'config.php'; Mandrill::call(array('type' => 'users', 'call' => 'verify-sender', 'email' => '*****@*****.**'));
<?php /** * This examples shows how Mandrill library is used to obtain information about a user. */ require '../Mandrill.php'; require 'config.php'; Mandrill::call(array('type' => 'tags', 'call' => 'list'));
function send_email($from, $fromname, $emailtos, $subject, $message, $template) { $formvars['key'] = 'ed3f246e-b16c-4ffb-8a19-e0c36c8877ea'; $formvars['template_name'] = $template['slug']; $formvars['template_content'] = array(); foreach ($template['data'] as $key => $value) { $content = array(); $content['name'] = $key; $content['content'] = $value; $formvars['template_content'][] = $content; } $formvars['message'] = array(); //$formvars['message']['html'] = "test email"; //$formvars['message']['text'] = "test email"; $formvars['message']['subject'] = $subject; $formvars['message']['from_email'] = $from; $formvars['message']['from_name'] = $fromname; /* $email = array(); $email['email'] = $to; $email['name'] = $toname; $formvars['message']['to'][] = $emails; */ $formvars['message']['to'] = $emailtos; /* $formvars['message']['headers'] = array(); $formvars['message']['headers']["X-MC-MergeVars"] = $template['data']; $formvars['message']['headers']["X-MC-Template"] = $template['slug']; */ $formvars['message']['track_opens'] = true; $formvars['message']['track_clicks'] = true; $formvars['message']['auto_text'] = true; $formvars['message']['async'] = true; //exit(); /* $sp = new Snoopy(); //agent spoof and curl binary setup $sp->agent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 (.NET CLR 3.5.30729)"; if(isset($_SERVER['WINDIR']) && strpos($_SERVER['WINDIR'], 'Windows') !== false) $sp->curl_path = dirname(__FILE__)."/magpie_0.72/extlib/curlwin32/curl"; else $sp->curl_path = "/usr/bin/curl"; //assumed return curl binary path for linux $sp->temp_dir = dirname(__FILE__)."/tmp"; //$URI = "https://mandrillapp.com/api/1.0/messages/send.json"; $URI = "http://mandrillapp.com/api/1.0/users/info.json"; $sp->submit($URI, $formvars); echo $sp->results; */ $m = new Mandrill('ed3f246e-b16c-4ffb-8a19-e0c36c8877ea'); //print_r($m->call("users/info", $formvars['message'])); $r = $m->call("messages/send-template", $formvars); if (trim($r[0]['status']) != 'sent') { print_r($formvars); print_r($r); } }
<?php /** * This examples shows how Mandrill library is used to obtain information about a user. */ require '../Mandrill.php'; require 'config.php'; Mandrill::call(array('type' => 'users', 'call' => 'senders'));
<?php /** * This examples shows how Mandrill library is used to obtain information about a user. */ require '../Mandrill.php'; require 'config.php'; Mandrill::call(array('type' => 'users', 'call' => 'info'));