From 4ac3289819726312bc5f6148f95d673246b9e72e Mon Sep 17 00:00:00 2001 From: paulwer Date: Sun, 7 Apr 2024 14:10:42 +0200 Subject: [PATCH] brevo fixes --- app/Jobs/Brevo/ProcessBrevoInboundWebhook.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Jobs/Brevo/ProcessBrevoInboundWebhook.php b/app/Jobs/Brevo/ProcessBrevoInboundWebhook.php index be11b4905f0f..02901132fee1 100644 --- a/app/Jobs/Brevo/ProcessBrevoInboundWebhook.php +++ b/app/Jobs/Brevo/ProcessBrevoInboundWebhook.php @@ -121,6 +121,8 @@ class ProcessBrevoInboundWebhook implements ShouldQueue public function handle() { + $foundOneRecipient = false; // used for spam documentation below + // brevo defines recipients as array, we check all of them, to be sure foreach ($this->input["Recipients"] as $recipient) { @@ -134,10 +136,11 @@ class ProcessBrevoInboundWebhook implements ShouldQueue $company = MultiDB::findAndSetDbByExpenseMailbox($recipient); if (!$company) { Log::info('[ProcessBrevoInboundWebhook] unknown Expense Mailbox occured while handling an inbound email from brevo: ' . $recipient); - // $this->engine->saveMeta($this->input["From"]["Address"], $recipient, true); // @turbo124 disabled, because recipents contains all recipients, and will likly result in false bans?! => normally important to save this, to protect from spam continue; } + $foundOneRecipient = true; + try { // important to save meta if something fails here to prevent spam $company_brevo_secret = $company->settings?->email_sending_method === 'client_brevo' && $company->settings?->brevo_secret ? $company->settings?->brevo_secret : null; @@ -195,5 +198,11 @@ class ProcessBrevoInboundWebhook implements ShouldQueue $this->engine->handleExpenseMailbox($inboundMail); } + + // document for spam => mark all recipients as handled emails with unmatched mailbox => otherwise dont do any + if (!$foundOneRecipient) + foreach ($this->input["Recipients"] as $recipient) { + $this->engine->saveMeta($this->input["From"]["Address"], $recipient, true); + } } }