From 57fc19e3978c22312ea9da2f4f3ffbea990e7523 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 18 Mar 2026 16:46:37 +0100 Subject: [PATCH] wait #8073 @0.25 --- .env.production | 9 ++++++++- app/Jobs/ProcessEmailBatch.php | 13 ++++++++++--- config/app.php | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.env.production b/.env.production index df68a69..7243f09 100644 --- a/.env.production +++ b/.env.production @@ -49,11 +49,18 @@ MAIL_MAILER=mailgun #Mailgun MAILGUN_SIGN_KEY="565a54d53dd589271b7ce51b451c2f9e-aa4b0867-7a09fa43" MAILGUN_API_KEY="565a54d53dd589271b7ce51b451c2f9e-aa4b0867-7a09fa43" +MAILGUN_SECRET=565a54d53dd589271b7ce51b451c2f9e-aa4b0867-7a09fa43 MAILGUN_DOMAIN="email.prescription-quotidien.com" MAILGUN_TEST_MODE=no -MAILGUN_SECRET=565a54d53dd589271b7ce51b451c2f9e-aa4b0867-7a09fa43 MAILGUN_ENDPOINT=api.eu.mailgun.net +#MAILGUN_SIGN_KEY="d9b9d88f289ab3a68dfeeca0e48572c2-ccbfdc2c-f7f8f5fd" +#MAILGUN_API_KEY="d9b9d88f289ab3a68dfeeca0e48572c2-ccbfdc2c-f7f8f5fd" +#MAILGUN_SECRET="d9b9d88f289ab3a68dfeeca0e48572c2-ccbfdc2c-f7f8f5fd" +#MAILGUN_DOMAIN=sandboxed4b7470d0044151991d2009409eb5ec.mailgun.org +#MAILGUN_TEST_MODE=yes +#MAILGUN_ENDPOINT=api.mailgun.net + MAIL_FROM_ADDRESS=noreply@email.prescription-quotidien.com MAIL_FROM_NAME="Prescription Santé - Le Quotidien" MAIL_REPLYTO=olivier.robichon@prescription-quotidien.com diff --git a/app/Jobs/ProcessEmailBatch.php b/app/Jobs/ProcessEmailBatch.php index 0ab4552..0eb4a20 100644 --- a/app/Jobs/ProcessEmailBatch.php +++ b/app/Jobs/ProcessEmailBatch.php @@ -15,11 +15,14 @@ use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Collection; use Illuminate\Foundation\Bus\Dispatchable; +use Illuminate\Mail\Message; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Arr; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Mail; use Illuminate\Support\Str; +use Swift_Message; class ProcessEmailBatch implements ShouldQueue @@ -147,11 +150,13 @@ class ProcessEmailBatch implements ShouldQueue $this->html = $this->batch->render(); $this->templateVariables = $this->processVariablesForMailer(); + $batchID = $this->batch; foreach ($this->users as $user) { - for ($j = 0; $j < 4; $j++) { + for ($j = 0; $j < 1; $j++) { try { - Mail::send([], [], function ($message) use ($user) { + Mail::send([], [], function ($message) use ($user, $batchID) { + /* @var Message $message */ $h = $this->html; $h = str_replace('%name%', $user->name, $h); $h = str_replace('%url%', $this->batch->file->getMailableUrl($user), $h); @@ -162,10 +167,12 @@ class ProcessEmailBatch implements ShouldQueue $message->setBody($h, 'text/html'); $message->to($user->email); $message->replyTo(env('MAIL_REPLYTO')); + $message->getSwiftMessage()->getHeaders()->addTextHeader('X-Mailgun-Tag', $batchID); }); break; } catch (\Exception $e) { - sleep(30); + Log::error($e); + sleep(60); } } diff --git a/config/app.php b/config/app.php index 7412901..0d64add 100644 --- a/config/app.php +++ b/config/app.php @@ -128,7 +128,7 @@ return [ 'version' => '1.0.0', 'emails' => [ - 'subscriptions' => 'abonnement@prescription-quotidien.com', + 'subscriptions' => 'test+psq@fluidbook.com', 'olivier' => 'olivier.robichon@prescription-quotidien.com', 'moi' => 'test+psq@fluidbook.com' ], -- 2.39.5