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 $tbwa_config = tbwa_config_php(); ?> <!DOCTYPE html> <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]--> <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]--> <!--[if IE 9]> <html class="no-js ie9"> <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js preload"> <!--<![endif]--> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui" /> <link rel="alternate" href="http://www.comfortenergy.be/nl" hreflang="nl-be" /> <link rel="alternate" href="http://www.comfortenergy.be/fr" hreflang="fr-be" /> <?php echo $head; ?> <title><?php echo $head_title; ?> </title> <!-- Drupal styles ((--> <?php echo $styles; ?> <!-- Drupal styles )) --> <!-- Drupal scripts ((-->