Add sendEmails util
An util used to send emails to participants regarding the game.
Change-Id: Ibe557ad2888497a883f20841817658478ac6ccdf
diff --git a/utils/sendEmails.php b/utils/sendEmails.php
new file mode 100644
index 0000000..f93db90
--- /dev/null
+++ b/utils/sendEmails.php
@@ -0,0 +1,49 @@
+<?php
+ $inscrits = array_map('str_getcsv', file('php://stdin'));
+ array_shift($inscrits);
+
+ require 'config.php';
+ require 'vendor/autoload.php';
+ use \Mailjet\Resources;
+ $mj = new \Mailjet\Client($API_CLIENT, $API_SECRET, true, ['version' => 'v3.1']);
+
+ $messages = [];
+ foreach ($inscrits as $inscrit) {
+ $nom = $inscrit[0];
+ $pass = $inscrit[3];
+ $email = $inscrit[4];
+ $messages[] = [
+ 'From' => [
+ 'Email' => "vuit@operacio236.ml",
+ 'Name' => "Octavi de Planta 8",
+ ],
+ 'To' => [
+ [
+ 'Name' => $nom,
+ 'Email' => $email,
+ ]
+ ],
+ 'TemplateID' => 4405516,
+ 'TemplateLanguage' => true,
+ 'Subject' => "Arriba la Carrot Cake!",
+ 'Variables' => [
+ 'name' => $nom,
+ 'pass' => $pass,
+ ],
+ 'TrackOpens' => 'disabled',
+ 'TrackClicks' => 'disabled',
+ 'CustomCampaign' => 'carrotcake',
+ ];
+ }
+
+ $body = [
+ 'Messages' => $messages
+ ];
+ $response = $mj->post(Resources::$Email, ['body' => $body]);
+ if ($response->success()) {
+ echo json_encode($response->getData());
+ } else {
+ echo "ERROR:".PHP_EOL;
+ var_dump($response->getData());
+ }
+?>