diff --git a/app/Http/Controllers/BrevoController.php b/app/Http/Controllers/BrevoController.php index 53dbe9bceaf1..d462f06683c0 100644 --- a/app/Http/Controllers/BrevoController.php +++ b/app/Http/Controllers/BrevoController.php @@ -194,14 +194,14 @@ class BrevoController extends BaseController return response()->json(['message' => 'Unauthorized'], 403); if (!array_key_exists('items', $input)) { - Log::info('Failed: Message could not be parsed, because required parameters are missing.'); + nlog('Failed: Message could not be parsed, because required parameters are missing.'); return response()->json(['message' => 'Failed. Invalid Parameters.'], 400); } foreach ($input["items"] as $item) { if (!array_key_exists('Recipients', $item) || !array_key_exists('MessageId', $item)) { - Log::info('Failed: Message could not be parsed, because required parameters are missing. At least one item was invalid.'); + nlog('Failed: Message could not be parsed, because required parameters are missing. At least one item was invalid.'); return response()->json(['message' => 'Failed. Invalid Parameters. At least one item was invalid.'], 400); } diff --git a/app/Http/Controllers/MailgunController.php b/app/Http/Controllers/MailgunController.php index 8413185db528..d8cae5c6b7e7 100644 --- a/app/Http/Controllers/MailgunController.php +++ b/app/Http/Controllers/MailgunController.php @@ -120,7 +120,7 @@ class MailgunController extends BaseController $input = $request->all(); if (!array_key_exists('sender', $input) || !array_key_exists('recipient', $input) || !array_key_exists('message-url', $input)) { - Log::info('Failed: Message could not be parsed, because required parameters are missing. Please ensure contacting this api-endpoint with a store & notify operation instead of a forward operation!'); + nlog('Failed: Message could not be parsed, because required parameters are missing. Please ensure contacting this api-endpoint with a store & notify operation instead of a forward operation!'); return response()->json(['message' => 'Failed. Missing Parameters. Use store and notify!'], 400); } diff --git a/app/Http/Controllers/PostMarkController.php b/app/Http/Controllers/PostMarkController.php index 88272a445e7d..7e4b967c1b7e 100644 --- a/app/Http/Controllers/PostMarkController.php +++ b/app/Http/Controllers/PostMarkController.php @@ -280,7 +280,7 @@ class PostMarkController extends BaseController return response()->json(['message' => 'Unauthorized'], 403); if (!(array_key_exists("MessageStream", $input) && $input["MessageStream"] == "inbound") || !array_key_exists("To", $input) || !array_key_exists("From", $input) || !array_key_exists("MessageID", $input)) { - Log::info('Failed: Message could not be parsed, because required parameters are missing.'); + nlog('Failed: Message could not be parsed, because required parameters are missing.'); return response()->json(['message' => 'Failed. Missing/Invalid Parameters.'], 400); } @@ -292,7 +292,7 @@ class PostMarkController extends BaseController $company = MultiDB::findAndSetDbByExpenseMailbox($input["To"]); if (!$company) { - Log::info('[PostmarkInboundWebhook] unknown Expense Mailbox occured while handling an inbound email from mailgun: ' . $input["To"]); + nlog('[PostmarkInboundWebhook] unknown Expense Mailbox occured while handling an inbound email from mailgun: ' . $input["To"]); $inboundEngine->saveMeta($input["From"], $input["To"], true); // important to save this, to protect from spam return; } diff --git a/app/Jobs/Brevo/ProcessBrevoInboundWebhook.php b/app/Jobs/Brevo/ProcessBrevoInboundWebhook.php index 864b0bdb9af8..4adbd567f6ed 100644 --- a/app/Jobs/Brevo/ProcessBrevoInboundWebhook.php +++ b/app/Jobs/Brevo/ProcessBrevoInboundWebhook.php @@ -135,7 +135,7 @@ class ProcessBrevoInboundWebhook implements ShouldQueue // match company $company = MultiDB::findAndSetDbByExpenseMailbox($recipient); if (!$company) { - Log::info('[ProcessBrevoInboundWebhook] unknown Expense Mailbox occured while handling an inbound email from brevo: ' . $recipient); + nlog('[ProcessBrevoInboundWebhook] unknown Expense Mailbox occured while handling an inbound email from brevo: ' . $recipient); continue; } @@ -171,7 +171,7 @@ class ProcessBrevoInboundWebhook implements ShouldQueue } catch (\Error $e) { if (config('services.brevo.secret')) { - Log::info("[ProcessBrevoInboundWebhook] Error while downloading with company credentials, we try to use default credentials now..."); + nlog("[ProcessBrevoInboundWebhook] Error while downloading with company credentials, we try to use default credentials now..."); $brevo = new InboundParsingApi(null, Configuration::getDefaultConfiguration()->setApiKey("api-key", config('services.brevo.secret'))); $attachment = $brevo->getInboundEmailAttachment($attachment["DownloadToken"]); diff --git a/app/Jobs/Mailgun/ProcessMailgunInboundWebhook.php b/app/Jobs/Mailgun/ProcessMailgunInboundWebhook.php index 1bf6caeb44dc..b11078047124 100644 --- a/app/Jobs/Mailgun/ProcessMailgunInboundWebhook.php +++ b/app/Jobs/Mailgun/ProcessMailgunInboundWebhook.php @@ -180,7 +180,7 @@ class ProcessMailgunInboundWebhook implements ShouldQueue // match company $company = MultiDB::findAndSetDbByExpenseMailbox($to); if (!$company) { - Log::info('[ProcessMailgunInboundWebhook] unknown Expense Mailbox occured while handling an inbound email from mailgun: ' . $to); + nlog('[ProcessMailgunInboundWebhook] unknown Expense Mailbox occured while handling an inbound email from mailgun: ' . $to); $this->engine->saveMeta($from, $to, true); // important to save this, to protect from spam return; } @@ -205,7 +205,7 @@ class ProcessMailgunInboundWebhook implements ShouldQueue $mail = json_decode(file_get_contents($messageUrl)); } catch (\Error $e) { if (config('services.mailgun.secret')) { - Log::info("[ProcessMailgunInboundWebhook] Error while downloading with company credentials, we try to use default credentials now..."); + nlog("[ProcessMailgunInboundWebhook] Error while downloading with company credentials, we try to use default credentials now..."); $credentials = config('services.mailgun.domain') . ":" . config('services.mailgun.secret') . "@"; $messageUrl = explode("|", $this->input)[2]; @@ -253,7 +253,7 @@ class ProcessMailgunInboundWebhook implements ShouldQueue } catch (\Error $e) { if (config('services.mailgun.secret')) { - Log::info("[ProcessMailgunInboundWebhook] Error while downloading with company credentials, we try to use default credentials now..."); + nlog("[ProcessMailgunInboundWebhook] Error while downloading with company credentials, we try to use default credentials now..."); $credentials = config('services.mailgun.domain') . ":" . config('services.mailgun.secret') . "@"; $url = $attachment->url; diff --git a/app/Services/InboundMail/InboundMailEngine.php b/app/Services/InboundMail/InboundMailEngine.php index 5880c9ee5bfa..057ed43d1ac0 100644 --- a/app/Services/InboundMail/InboundMailEngine.php +++ b/app/Services/InboundMail/InboundMailEngine.php @@ -69,11 +69,11 @@ class InboundMailEngine { // invalid email if (!filter_var($from, FILTER_VALIDATE_EMAIL)) { - Log::info('E-Mail blocked, because from e-mail has the wrong format: ' . $from); + nlog('E-Mail blocked, because from e-mail has the wrong format: ' . $from); return true; } if (!filter_var($to, FILTER_VALIDATE_EMAIL)) { - Log::info('E-Mail blocked, because to e-mail has the wrong format: ' . $from); + nlog('E-Mail blocked, because to e-mail has the wrong format: ' . $from); return true; } @@ -85,14 +85,14 @@ class InboundMailEngine return false; } if (in_array($domain, $this->globalBlacklistDomains)) { - Log::info('E-Mail blocked, because the domain was found on globalBlocklistDomains: ' . $from); + nlog('E-Mail blocked, because the domain was found on globalBlocklistDomains: ' . $from); return true; } if (in_array($domain, $this->globalWhitelistSenders)) { return false; } if (in_array($from, $this->globalBlacklistSenders)) { - Log::info('E-Mail blocked, because the email was found on globalBlocklistEmails: ' . $from); + nlog('E-Mail blocked, because the email was found on globalBlocklistEmails: ' . $from); return true; } @@ -103,13 +103,13 @@ class InboundMailEngine // sender occured in more than 500 emails in the last 12 hours $senderMailCountTotal = Cache::get('inboundMailCountSender:' . $from, 0); if ($senderMailCountTotal >= 5000) { - Log::info('E-Mail blocked permanent, because the sender sended more than ' . $senderMailCountTotal . ' emails in the last 12 hours: ' . $from); + nlog('E-Mail blocked permanent, because the sender sended more than ' . $senderMailCountTotal . ' emails in the last 12 hours: ' . $from); $this->blockSender($from); $this->saveMeta($from, $to); return true; } if ($senderMailCountTotal >= 1000) { - Log::info('E-Mail blocked, because the sender sended more than ' . $senderMailCountTotal . ' emails in the last 12 hours: ' . $from); + nlog('E-Mail blocked, because the sender sended more than ' . $senderMailCountTotal . ' emails in the last 12 hours: ' . $from); $this->saveMeta($from, $to); return true; } @@ -117,7 +117,7 @@ class InboundMailEngine // sender sended more than 50 emails to the wrong mailbox in the last 6 hours $senderMailCountUnknownRecipent = Cache::get('inboundMailCountSenderUnknownRecipent:' . $from, 0); if ($senderMailCountUnknownRecipent >= 50) { - Log::info('E-Mail blocked, because the sender sended more than ' . $senderMailCountUnknownRecipent . ' emails to the wrong mailbox in the last 6 hours: ' . $from); + nlog('E-Mail blocked, because the sender sended more than ' . $senderMailCountUnknownRecipent . ' emails to the wrong mailbox in the last 6 hours: ' . $from); $this->saveMeta($from, $to); return true; } @@ -125,7 +125,7 @@ class InboundMailEngine // wrong recipent occurs in more than 100 emails in the last 12 hours, so the processing is blocked $mailCountUnknownRecipent = Cache::get('inboundMailCountUnknownRecipent:' . $to, 0); // @turbo124 maybe use many to save resources in case of spam with multiple to addresses each time if ($mailCountUnknownRecipent >= 200) { - Log::info('E-Mail blocked, because anyone sended more than ' . $mailCountUnknownRecipent . ' emails to the wrong mailbox in the last 12 hours. Current sender was blocked as well: ' . $from); + nlog('E-Mail blocked, because anyone sended more than ' . $mailCountUnknownRecipent . ' emails to the wrong mailbox in the last 12 hours. Current sender was blocked as well: ' . $from); $this->blockSender($from); $this->saveMeta($from, $to); return true; @@ -263,7 +263,7 @@ class InboundMailEngine } private function logBlocked(Company $company, string $data) { - Log::info("[InboundMailEngine][company:" . $company->id . "] " . $data); + nlog("[InboundMailEngine][company:" . $company->id . "] " . $data); ( new SystemLogger(