blob: f93db9083002bd1e53706a84c8de4924691d415f [file] [log] [blame]
<?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());
}
?>