public function addtomailjet($email, $idlist) { $mj = new Mailjet(); $params = array('method' => 'POST', 'contact' => $email, 'id' => $idlist); $response = $mj->listsAddContact($params); return $contact_id = $response->contact_id; }
/** * Implementation of hook_civicrm_pageRun * * Handler for pageRun hook. */ function mailjet_civicrm_pageRun(&$page) { if (get_class($page) == 'CRM_Mailing_Page_Report') { $mailingId = $page->_mailing_id; $mailingJobs = civicrm_api3('MailingJob', 'get', $params = array('mailing_id' => $mailingId)); $stats = array('BlockedCount' => 0, 'BouncedCount' => 0, 'ClickedCount' => 0, 'DeliveredCount' => 0, 'OpenedCount' => 0, 'ProcessedCount' => 0, 'QueuedCount' => 0, 'SpamComplaintCount' => 0, 'UnsubscribedCount' => 0); foreach ($mailingJobs['values'] as $key => $job) { if ($job['job_type'] == 'child') { $jobId = $key; require_once 'packages/mailjet-0.3/php-mailjet-v3-simple.class.php'; // Create a new Mailjet Object $mj = new Mailjet(MAILJET_API_KEY, MAILJET_SECRET_KEY); $mj->debug = 0; $mailJetParams = array('method' => 'VIEW', 'unique' => CRM_Mailjet_BAO_Event::getMailjetCustomCampaignId($jobId)); $response = $mj->campaign($mailJetParams); $page->assign('mailjet_params', $mailJetParams); if (!empty($response)) { if ($response->Count == 1) { $campaign = $response->Data[0]; $mailJetParams = array('method' => 'VIEW', 'unique' => $campaign->ID); $response = $mj->campaignstatistics($mailJetParams); if ($response->Count == 1) { $stats = sumUpStats($stats, get_object_vars($response->Data[0])); } } } } } $page->assign('mailjet_stats', $stats); CRM_Core_Region::instance('page-header')->add(array('template' => 'CRM/Mailjet/Page/Report.tpl')); } }
public function testDeleteLastContactslist() { $mj = new Mailjet(getenv('API_KEY'), getenv('API_SECRET_KEY')); $mj->contactslist(); $lastid = $mj->_response->Data[count($mj->_response->Data) - 1]->ID; $params = array("method" => "DELETE", "ID" => $lastid); $mj->contactslist($params); $this->assertEquals(204, $mj->_response_code); }
public static function getDataApi() { $obj = new Mailjet(); if (self::$data_api === null) { self::$data_api = mailjetdata::getInstance(); self::$data_api->setKeys($obj->getAccountSettingsKey('API_KEY'), $obj->getAccountSettingsKey('SECRET_KEY')); } return self::$data_api; }
public function show_settings_menu() { if (!empty($_POST)) { $this->save_settings(); } echo '<div class="wrap"><div class="icon32"><img src="' . plugin_dir_url(__FILE__) . '/images/mj_logo_med.png" /></div><h2>'; echo __('Mailjet Settings', 'wp-mailjet'); echo '</h2>'; echo '<div class="postbox-container updated" style="width:25%;float:right"> <h3>' . __('Share the love!', 'wp-mailjet') . '</h3> <div style="margin-bottom:10px"> <iframe src="//www.facebook.com/plugins/like.php?href=https%3A%2F%2Fwww.facebook.com%2FMailjet&send=false&layout=button_count&width=150&show_faces=false&action=like&colorscheme=light&font&height=21&appId=352489811497917" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:150px; height:21px;" allowTransparency="true"></iframe> </div> <div style="margin-bottom:10px"> <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.mailjet.com" data-text="' . __('Improve your email deliverability and monitor action in real time.', 'wp-mailjet') . '" data-via="mailjet">' . __('Tweet', 'wp-mailjet') . '</a><script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> </div> </div> <div style="width:70%;float:left;">'; $form = new Mailjet_Options_Form('admin.php?page=wp_mailjet_options_top_menu&action=save_options'); $desc = '<ol>'; $desc .= '<li>' . __('<a href="https://www.mailjet.com/signup">Create your Mailjet account</a> or visit your <a href="https://fr.mailjet.com/account/api_keys">account page</a> to get your API keys.', 'wp-mailjet') . '</li>'; $desc .= '<li>' . __('<a href="https://fr.mailjet.com/contacts/lists/add">Create a new list</a> if you don\'t have one or need a new one.', 'wp-mailjet') . '</li>'; $desc .= '<li>' . __('<a href="widgets.php">Add</a> the email collection widget to your sidebar or footer.', 'wp-mailjet') . '</li>'; $desc .= '<li>' . __('<a href="https://fr.mailjet.com/campaigns/create">Create a campaign</a> on mailjet.com to send your newsletter.', 'wp-mailjet') . '</li>'; $desc .= '</ol>'; $generalFieldset = new Options_Form_Fieldset(__('Mailjet Plugin', 'wp-mailjet'), array(), $desc); $form->addFieldset($generalFieldset); $generalOptions[] = new Options_Form_Option('mailjet_enabled', ' ' . __('Enabled', 'wp-mailjet'), 'checkbox', get_option('mailjet_enabled'), __('Enable email through <b>Mailjet</b>', 'wp-mailjet')); $generalOptions[] = new Options_Form_Option('mailjet_ssl', ' ' . __('SSL Enabled', 'wp-mailjet'), 'checkbox', get_option('mailjet_ssl'), __('Enable <b>SSL</b> communication with mailjet.com', 'wp-mailjet')); $ports = array(array('value' => 25, 'label' => 25), array('value' => 465, 'label' => 465), array('value' => 587, 'label' => 587), array('value' => 588, 'label' => 588), array('value' => 80, 'label' => 80)); $generalOptions[] = new Options_Form_Option('mailjet_port', '', 'select', get_option('mailjet_port'), __('Port to use for SMTP communication', 'wp-mailjet'), false, $ports); $generalOptions[] = new Options_Form_Option('mailjet_test', ' ' . __('Send test email', 'wp-mailjet'), 'checkbox', get_option('mailjet_test'), __('Send test email now', 'wp-mailjet')); $test_email = get_option('mailjet_test_address') ? get_option('mailjet_test_address') : get_option('admin_email'); $generalOptions[] = new Options_Form_Option('mailjet_test_address', __('Recipient of test email', 'wp-mailjet'), 'email', $test_email); $from_email = get_option('mailjet_from_email') ? get_option('mailjet_from_email') : get_option('admin_email'); $generalOptions[] = new Options_Form_Option('mailjet_from_email', __('<code>From:</code> email address', 'wp-mailjet'), 'email', $from_email); if (get_option('mailjet_password') && get_option('mailjet_username')) { $MailjetApi = new Mailjet(get_option('mailjet_username'), get_option('mailjet_password')); $resp = $MailjetApi->listsAll(); if ($resp->status == 'OK') { $lists = array(array('value' => '', 'label' => __('Disable autosubscribe', 'wp-mailjet'))); foreach ($resp->lists as $list) { $lists[] = array('value' => $list->id, 'label' => $list->label); } } $generalOptions[] = new Options_Form_Option('mailjet_auto_subscribe_list_id', '', 'select', get_option('mailjet_auto_subscribe_list_id'), __('Autosubscribe new users to this list', 'wp-mailjet'), false, $lists); } $generalFieldset = new Options_Form_Fieldset(__('General Settings', 'wp-mailjet'), $generalOptions, __('Enable or disable the sending of your emails through your Mailjet account', 'wp-mailjet')); $form->addFieldset($generalFieldset); $apiOptions[] = new Options_Form_Option('mailjet_username', __('API key', 'wp-mailjet'), 'text', get_option('mailjet_username'), null, true); $apiOptions[] = new Options_Form_Option('mailjet_password', __('API secret', 'wp-mailjet'), 'text', get_option('mailjet_password'), null, true); $apiFieldset = new Options_Form_Fieldset(__('API Settings', 'wp-mailjet'), $apiOptions, sprintf(__('You can get your API keys from <a href="https://www.mailjet.com/account/api_keys">your mailjet account</a>. Please also make sure the sender address %s is active in <a href="https://www.mailjet.com/account/sender">your account</a>', 'wp-mailjet'), get_option('admin_email'))); $form->addFieldset($apiFieldset); $form->display(); echo '</div></div>'; }
function sendEmailMailjet($email, $titre_mail, $contenu_mail, $headers, $email_exp, $contenu_mail_txt) { if (!isset($mailjet_apiKey)) { include 'config.php'; } require_once 'includes/php-mailjet-v3-simple.class.php'; $mj = new Mailjet($mailjet_apiKey, $mailjet_secretKey); $params = array("method" => "POST", "from" => $email_exp, "to" => $email, "subject" => $titre_mail, "text" => $contenu_mail_txt, "html" => $contenu_mail); $result = $mj->sendEmail($params); if ($mj->_response_code == 200) { $result = true; } else { $result = false; } return $result; }
public static function send_mail($to, $subject, $message) { /* Maak het mailjet object aan, en geef de mailjet api sleutels mee. */ $mailjet = new Mailjet(Config::$mailjet_keys['username'], Config::$mailjet_keys['secret']); /* Maak een array aan met de gevens die verstuurd moeten worden. */ $array = array("method" => "POST", "from" => "*****@*****.**", "to" => $to, "subject" => $subject, "html" => str_replace('%message%', $message, Self::get_body())); /* Stuur de array met gegevens naar de API, en laat die de gegevens mailen. */ $result = $mailjet->sendEmail($array); /* Controleren of het emailen gelukt is. */ if ($mailjet->_response_code == 200) { /* Return een true. */ return true; } else { /* Foutmelding, gooi deze. */ throw new Exception('Er ging wat fout tijdens het versturen van een email. <i>' . $mailjet->_response_code . '</i>'); } }
public static function l($string, $specific = false) { $module = new Mailjet(); if ($string == $module->l($string, $specific)) { $trad_file = _PS_MODULE_DIR_ . 'mailjet/translations/' . Context::getContext()->language->iso_code . '.php'; if (file_exists($trad_file)) { $_MODULE = array(); @(include $trad_file); $key = '<{mailjet}prestashop>segmentation_' . md5(str_replace('\'', '\\\'', $string)); /* if (!isset($_MODULE[$key]) && Context::getContext()->language->iso_code!='en') { $f = fopen($trad_file,"a+"); fwrite($f, '$_MODULE[\''.$key.'\'] = \''.$string.'\';'.PHP_EOL); fclose($f); } */ } return isset($_MODULE[$key]) ? $_MODULE[$key] : $module->l($string, $specific); } else { return $module->l($string, $specific); } }
function sendEmail($email, $judul, $isi) { $mj = new Mailjet(); $params = array("method" => "POST", "from" => $this->senderMail, "to" => $email, "subject" => $judul, "text" => $isi); //echo "success - email sent"; return $mj->sendEmail($params); }
} } print '</table>'; print "</div>"; // Clone confirmation if ($action == 'clone') { // Create an array for form $formquestion = array('text' => $langs->trans("ConfirmClone"), array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneContent"), 'value' => 1), array('type' => 'checkbox', 'name' => 'clone_receivers', 'label' => $langs->trans("CloneReceivers") . ' (' . $langs->trans("FeatureNotYetAvailable") . ')', 'value' => 0, 'disabled' => true)); // Paiement incomplet. On demande si motif = escompte ou autre print $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneEMailing'), $langs->trans('ConfirmCloneEMailing', $object->ref), 'confirm_clone', $formquestion, 'yes', 2, 240); } dol_htmloutput_mesg($mesg); if ($conf->mailjet->enabled) { dol_include_once("/mailjet/class/mailjet.class.php"); $langs->load("mailjet@mailjet"); $mailjet = new Mailjet($db); print $mailjet->statistic($mil->id); } /* * Boutons d'action */ if (GETPOST("cancel") || $confirm == 'no' || $action == '' || in_array($action, array('valid', 'delete', 'sendall', 'clone'))) { print "\n\n<div class=\"tabsAction\">\n"; if (($object->statut == 0 || $object->statut == 1) && $user->rights->mailing->creer) { print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=edit&id=' . $object->id . '">' . $langs->trans("EditMailing") . '</a>'; } //print '<a class="butAction" href="fiche.php?action=test&id='.$object->id.'">'.$langs->trans("PreviewMailing").'</a>'; if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) { print '<a class="butActionRefused" href="#" title="' . dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")) . '">' . $langs->trans("TestMailing") . '</a>'; } else { print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=test&id=' . $object->id . '">' . $langs->trans("TestMailing") . '</a>';
public function send_mail($subject, $title, $message) { $emails = get_option('um_emails', ''); if ($emails != '') { $email = ''; ob_start(); include dirname(__FILE__) . '/mail.php'; $email = ob_get_contents(); ob_end_clean(); $api = get_option('um_api', ''); $secret = get_option('um_secret', ''); $from = get_option('um_from', ''); if ($api != '' and $secret != '' and $from != '') { $mj = new Mailjet($api, $secret); $params = array('method' => 'POST', 'from' => $from, 'to' => explode(',', $emails), 'subject' => $subject, 'html' => $email); $mj->sendEmail($params); } else { add_filter('wp_mail_content_type', function ($content_type) { return 'text/html'; }); wp_mail($emails, $subject, $email); add_filter('wp_mail_content_type', function ($content_type) { return 'text/plain'; }); } } }
if (_PS_VERSION_ < '1.5' || !defined('_PS_ADMIN_DIR_')) { require_once realpath(dirname(__FILE__) . '/../../init.php'); } if (Tools::getIsset('data')) { $data = (object) Tools::getValue('data'); } else { if (Tools::getIsset('mailjet')) { $mailjet = Tools::jsonDecode(Tools::getValue('mailjet')); $data = $mailjet->data; } else { $data = new stdClass(); } } require_once _PS_MODULE_DIR_ . 'mailjet/mailjet.php'; require_once _PS_MODULE_DIR_ . 'mailjet/classes/MailJetLog.php'; $mj = new Mailjet(); MailJetLog::init(); if (Tools::getIsset('response')) { $response = (object) Tools::getValue('response'); } if ($data->next_step_url) { if (!empty($response) && ($response->message == 'last change of campaigns parameters' || $response->message == 'send details saved successfully')) { $mj_data = new Mailjet_Api($mj->getAccountSettingsKey('API_KEY'), $mj->getAccountSettingsKey('SECRET_KEY')); $campaignId = (int) $data->campaign_id; $html = $mj_data->data('newsletter', $campaignId, 'HTML', 'text/html', null, 'GET', 'LAST')->getResponse(); /* On enregistre la campagne en BDD et on génère un token */ $sql = 'SELECT * FROM ' . _DB_PREFIX_ . 'mj_campaign WHERE campaign_id = ' . $campaignId; $res_campaign = Db::getInstance()->GetRow($sql); if (empty($res_campaign)) { $token_presta = md5(uniqid('mj', true)); $sql = 'INSERT INTO ' . _DB_PREFIX_ . 'mj_campaign (campaign_id, token_presta, date_add)
/** * Process the mailjet bounce emails * * @return boolean always returns true (for the api). at a later stage we should * fix this to return true on success / false on failure etc */ static function processBounces($mailingId = NULL) { require_once 'packages/mailjet-0.1/php-mailjet.class-mailjet-0.1.php'; // Create a new Mailjet Object @php-mailjet.class-mailjet-0.1.php $mj = new Mailjet(MAILJET_API_KEY, MAILJET_SECRET_KEY); //G: TODO $mj->debug = 0; if ($mailingId) { $apiParams = array('mailing_id' => $mailingId); $campaignJobId = 0; $mailJobResult = civicrm_api3('MailingJob', 'get', $apiParams); foreach ($mailJobResult['values'] as $jobId => $currentJob) { if (isset($currentJob['job_type'])) { $jobType = $currentJob['job_type']; //if job is not test if ($jobType == 'child') { $campaignJobId = $jobId; } } } $mailjetParams = array('custom_campaign' => CRM_Mailjet_BAO_Event::getMailjetCustomCampaignId($campaignJobId)); //G: https://uk.mailjet.com/docs/api/message/list //List all your messages (both transactional and campaign) with numerous filters. $response = $mj->messageList($mailjetParams); if (!$response) { return TRUE; //always return true - we don't process bounces if there is no reponse. } $campaign = $response->result[0]; //G: https://uk.mailjet.com/docs/api/report/emailbounce //Lists emails declared as bounce. //Call $response = $mj->reportEmailBounce(array('campaign_id' => $campaign->id)); } else { $response = $mj->reportEmailBounce(); } //Result $bounces = $response->bounces; foreach ($bounces as $bounce) { $params = array('email' => $bounce->email, 'sequential' => 1); $emailResult = civicrm_api3('Email', 'get', $params); if (!empty($emailResult['values'])) { //we always get the first result //TODO: might related to bounce record issue $contactId = $emailResult['values'][0]['contact_id']; $emailId = $emailResult['values'][0]['id']; $emailAddress = $emailResult['values'][0]['email']; if (!$bounce->customcampaign) { //do not process bounce if we dont have custom campaign continue; } $campaingArray = explode("MJ", $bounce->customcampaign); //TODO: related to bounce record issue $jobId = $campaingArray[0]; $mailingJobResult = civicrm_api3('MailingJob', 'get', array('id' => $jobId)); $mailingResult = civicrm_api3('Mailing', 'get', array('id' => $mailingJobResult['values'][$jobId]['mailing_id'])); $currentMailingId = 0; foreach ($mailingResult['values'] as $mailingId => $mailing) { $currentMailingId = $mailingId; } /*$params = array( 'mailing_id' => $mailingId, ); $result = civicrm_api3('MailingJob', 'get', $params); $jobIds = array(); foreach ($result['values'] as $id => $value) { $jobIds[] = $id; } $jobIds = implode(",", $jobIds); $params = array( 1 => array( $contactId, 'Integer'), 2 => array( $emailId, 'Integer') );*/ $query = "SELECT eq.id\n FROM civicrm_mailing_event_bounce eb\n LEFT JOIN civicrm_mailing_event_queue eq ON eq.id = eb.event_queue_id\n WHERE 1\n AND eq.job_id = {$jobId}\n AND eq.email_id = {$emailId}\n AND eq.contact_id = {$contactId}"; $dao = CRM_Core_DAO::executeQuery($query); $isBounceRecord = FALSE; while ($dao->fetch()) { $isBounceRecord = TRUE; break; } //if bounce record doesn't exsit so we record it if (!$isBounceRecord) { $bounceArray = array('is_spam' => FALSE, 'mailing_id' => $currentMailingId, 'job_id' => $jobId, 'contact_id' => $contactId, 'email_id' => $emailId, 'email' => $emailAddress, 'blocked' => 0, 'hard_bounce' => $bounce->hard_bounce, 'date_ts' => $bounce->date_ts, 'error_related_to' => $bounce->error_related_to, 'error' => $bounce->error); CRM_Mailjet_BAO_Event::recordBounce($bounceArray); } } } // always returns true, i.e. never fails :) return TRUE; }
case 'London': $id = '1044322'; break; case 'North England': $id = '1044323'; break; case 'East England': $id = '1044325'; break; case 'Midlands': $id = '1044326'; break; case 'Scotland': $id = '1044379'; break; case 'International / Global': $id = '1044328'; break; } } } */ // Include Mailjet's API Class include_once 'mailjet-api-class.php'; // Create a new Object $mj = new Mailjet(); # Parameters $params = array('method' => 'POST', 'contact' => $email, 'id' => $id); # Call $response = $mj->listsAddContact($params); # Result $contact_id = $response->contact_id;
* * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <*****@*****.**> * @copyright 2007-2015 PrestaShop SA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ require_once dirname(__FILE__) . '/../../config/config.inc.php'; require_once dirname(__FILE__) . '/../../init.php'; require_once _PS_MODULE_DIR_ . 'mailjet/mailjet.php'; $mailjet = new Mailjet(); if (Tools::getValue('token') != $mailjet->getToken()) { die('No hackers allowed here ! ;-)'); } function utf8Outtags($text) { $notags = strip_tags($text); $utf8 = htmlentities($notags); preg_match_all('/&([0-9A-Za-z]+);/', $utf8, $res); foreach ($res[0] as $preg) { $text = str_replace(html_entity_decode($preg), $preg, $text); } return $text; } function findCode($code) {
header('Pragma: no-cache'); exit; } $post = trim(Tools::file_get_contents('php://input')); /* mail("*****@*****.**", "callback ajax mailjet", $post.print_r($_POST, true).print_r($_GET, true)); */ /* die(); */ require_once _PS_ROOT_DIR_ . '/config/config.inc.php'; $method = Tools::getValue('method'); $back_office_method = Tools::getValue('back_office_method'); if (in_array($method, $back_office_method)) { define('_PS_ADMIN_DIR_', true); } require_once _PS_MODULE_DIR_ . 'mailjet/mailjet.php'; $method = Tools::isSubmit('method') ? Tools::getValue('method') : ''; $token = Tools::isSubmit('token') ? Tools::getValue('token') : ''; $mj = new Mailjet(); $result = array(); MailJetLog::write(MailJetLog::$file, 'New request sent'); if ($mj->getToken() != Tools::getValue('token')) { $result['error'] = $mj->l('Bad token sent'); } else { if (!method_exists($mj, $method)) { $result['error'] = $mj->l('Method requested doesn\'t exist:') . ' ' . $method; } else { $result = $mj->{$method}(); } } $message = isset($result['error']) ? $result['error'] : 'Success with method: ' . $method; MailJetLog::write(MailJetLog::$file, $message); header('Content-Type: application/json'); die(Tools::jsonEncode($result));
<?php $ini = eZINI::instance('mailjet.ini'); $listID = $ini->variable('MailjetSettings', 'ListID'); $apiKey = $ini->variable('MailjetSettings', 'ApiKey'); $apiSecretKey = $ini->variable('MailjetSettings', 'ApiSecretKey'); $mailjet = new Mailjet($apiKey, $apiSecretKey); $email = $Params['e-mail']; function mailjetStatusCode($response_code) { switch ($response_code) { case 200: $status = "OK."; break; case 201: $status = "A new insertion was done."; break; case 204: $status = "No content found or expected to return."; break; case 304: $status = "Nothing was modified."; break; case 400: $status = "One or more arguments are missing or maybe mispelling."; break; case 401: $status = "You have specified an incorrect ApiKey."; break; case 404: $status = "The method your are trying to reach don't exists.";
* versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <*****@*****.**> * @copyright 2007-2015 PrestaShop SA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ include_once realpath(dirname(__FILE__) . '/../../') . '/config/config.inc.php'; include_once _PS_MODULE_DIR_ . 'mailjet/classes/MailJetLog.php'; include_once _PS_MODULE_DIR_ . 'mailjet/classes/MailJetTranslate.php'; include_once _PS_MODULE_DIR_ . 'mailjet/classes/MailJetEvents.php'; include_once _PS_MODULE_DIR_ . 'mailjet/classes/hooks/Events.php'; include_once _PS_ROOT_DIR_ . '/init.php'; require_once _PS_MODULE_DIR_ . 'mailjet/mailjet.php'; $mj = new Mailjet(); if ($mj->getEventsHash() !== Tools::getValue('h')) { header('HTTP/1.1 401 Unauthorized'); return; } # Catch Event $post = trim(Tools::file_get_contents('php://input')); # No Event sent if (empty($post)) { header('HTTP/1.1 421 No event'); /* => do action */ return; } # Decode Trigger Informations $t = Tools::jsonDecode($post, true); # No Informations sent with the Event
* * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <*****@*****.**> * @copyright 2007-2015 PrestaShop SA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ require_once dirname(__FILE__) . '/../../config/config.inc.php'; require_once dirname(__FILE__) . '/../../init.php'; require_once _PS_MODULE_DIR_ . 'mailjet/mailjet.php'; $mailjet = new Mailjet(); if (Tools::getValue('token') !== Configuration::get('SEGMENT_CUSTOMER_TOKEN')) { die('No hackers allowed here ! ;-)'); } function utf8Outtags($text) { $notags = strip_tags($text); $utf8 = htmlentities($notags); preg_match_all('/&([0-9A-Za-z]+);/', $utf8, $res); foreach ($res[0] as $preg) { $text = str_replace($preg, html_entity_decode($preg), $text); } return $text; } function findCode($code) {
private function listContacts() { $mj = new Mailjet(); $result = $mj->contact(); /* if ($mj->_response_code == 200) echo "success - listed contacts"; else echo "error - ".$mj->_response_code; */ return $result; }
* the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ /** * \file htdocs/public/mailjet/evenements.php * \ingroup core * \brief Get the json objet for triggers. * \author Patrick Mary * \version $Id: evenements.php,v 1 2011/11/27 13:44:21 synry63 Exp $ */ define("NOLOGIN",1); define("NOCSRFCHECK",1); $res=@include("../../main.inc.php");// For "custom" directory if (! $res) $res=@include("../main.inc.php"); dol_include_once('/mailjet/class/mailjet.class.php'); $data = json_decode(file_get_contents('php://input')); $mailJet = new Mailjet($db); $mailJet->event($data); ?>
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * @author Dream me up * @copyright 2011 Mailjet SAS * @license hhttp://opensource.org/licenses/mit-license MIT License * International Registred Trademark & Property of Mailjet SAS */ require '../../config/config.inc.php'; require 'mailjet.php'; if (Tools::getValue('token') == '' || Tools::getValue('token') != Configuration::get('MAILJET_AJAX_TOKEN')) { die('Invalid Token'); } $obj_mailjet = new Mailjet(); $email_from = urldecode($_GET['email_from']); try { $sujet = $obj_mailjet->l('Mailjet Test E-mail'); $message = $obj_mailjet->l('Hello') . ",\r\n\r\n" . $obj_mailjet->l('This E-mail confirms you that Mailjet has successfully been installed on your shop.'); $result = Mail::sendMailTest(true, "in.mailjet.com", $message, $sujet, "text/plain", $email_from, $email_from, $_GET['mailjet_api_key'], $_GET['mailjet_secret_key'], $smtpPort = 465, "tls"); if ($result === true) { echo "true"; } else { if ($result == 999) { $result = $obj_mailjet->l('The E-mail was not successfully sent'); } echo "false|" . $result; reset_config_mailjet(); } } catch (Exception $e) {
function mailjet_subscribe_unsub_user_to_list($subscribe, $user_id) { if (get_option('mailjet_password') && get_option('mailjet_username')) { $user = get_userdata($user_id); $MailjetApi = new Mailjet(get_option('mailjet_username'), get_option('mailjet_password')); if ($subscribe && ($list_id = get_option('mailjet_auto_subscribe_list_id'))) { $params = array('method' => 'POST', 'contact' => $user->data->user_email, 'id' => $list_id); $response = $MailjetApi->listsAddContact($params); } elseif (!$subscribe && ($list_id = get_option('mailjet_auto_subscribe_list_id'))) { $params = array('method' => 'POST', 'contact' => $user->data->user_email, 'id' => $list_id); $response = $MailjetApi->listsRemoveContact($params); } } }