blob: f93db9083002bd1e53706a84c8de4924691d415f [file] [log] [blame]
Adrià Vilanova Martínez0e748c62022-12-10 20:26:42 +01001<?php
2 $inscrits = array_map('str_getcsv', file('php://stdin'));
3 array_shift($inscrits);
4
5 require 'config.php';
6 require 'vendor/autoload.php';
7 use \Mailjet\Resources;
8 $mj = new \Mailjet\Client($API_CLIENT, $API_SECRET, true, ['version' => 'v3.1']);
9
10 $messages = [];
11 foreach ($inscrits as $inscrit) {
12 $nom = $inscrit[0];
13 $pass = $inscrit[3];
14 $email = $inscrit[4];
15 $messages[] = [
16 'From' => [
17 'Email' => "vuit@operacio236.ml",
18 'Name' => "Octavi de Planta 8",
19 ],
20 'To' => [
21 [
22 'Name' => $nom,
23 'Email' => $email,
24 ]
25 ],
26 'TemplateID' => 4405516,
27 'TemplateLanguage' => true,
28 'Subject' => "Arriba la Carrot Cake!",
29 'Variables' => [
30 'name' => $nom,
31 'pass' => $pass,
32 ],
33 'TrackOpens' => 'disabled',
34 'TrackClicks' => 'disabled',
35 'CustomCampaign' => 'carrotcake',
36 ];
37 }
38
39 $body = [
40 'Messages' => $messages
41 ];
42 $response = $mj->post(Resources::$Email, ['body' => $body]);
43 if ($response->success()) {
44 echo json_encode($response->getData());
45 } else {
46 echo "ERROR:".PHP_EOL;
47 var_dump($response->getData());
48 }
49?>