diff --git a/app/Http/Controllers/MailgunController.php b/app/Http/Controllers/MailgunController.php index d2bc0bffefc1..7db6f3dc773b 100644 --- a/app/Http/Controllers/MailgunController.php +++ b/app/Http/Controllers/MailgunController.php @@ -128,7 +128,7 @@ class MailgunController extends BaseController if (!$authorizedByHash && !$authorizedByToken) return response()->json(['message' => 'Unauthorized'], 403); - ProcessMailgunInboundWebhook::dispatch($input["sender"] . "|" . $input["recipient"] . "|" . $input["message-url"])->delay(rand(2, 10)); + ProcessMailgunInboundWebhook::dispatch($input["sender"], $input["recipient"], $input["message-url"])->delay(rand(2, 10)); return response()->json(['message' => 'Success.'], 200); } diff --git a/app/Jobs/Mailgun/ProcessMailgunInboundWebhook.php b/app/Jobs/Mailgun/ProcessMailgunInboundWebhook.php index f278cdba0153..565cf2af4e34 100644 --- a/app/Jobs/Mailgun/ProcessMailgunInboundWebhook.php +++ b/app/Jobs/Mailgun/ProcessMailgunInboundWebhook.php @@ -34,7 +34,7 @@ class ProcessMailgunInboundWebhook implements ShouldQueue * Create a new job instance. * $input consists of 3 informations: sender/from|recipient/to|messageUrl */ - public function __construct(private string $input) + public function __construct(private string $sender, private string $recipient, private string $message_url) { $this->engine = new InboundMailEngine(); } @@ -167,8 +167,8 @@ class ProcessMailgunInboundWebhook implements ShouldQueue */ public function handle() { - $from = explode("|", $this->input)[0]; - $to = explode("|", $this->input)[1]; + $from = $this->sender;//explode("|", $this->input)[0]; + $to = $this->recipient; //explode("|", $this->input)[1]; // $messageId = explode("|", $this->input)[2]; // used as base in download function // Spam protection @@ -196,7 +196,7 @@ class ProcessMailgunInboundWebhook implements ShouldQueue if ($company_mailgun_domain && $company_mailgun_secret) { $credentials = $company_mailgun_domain . ":" . $company_mailgun_secret . "@"; - $messageUrl = explode("|", $this->input)[2]; + $messageUrl = $this->message_url;//explode("|", $this->input)[2]; $messageUrl = str_replace("http://", "http://" . $credentials, $messageUrl); $messageUrl = str_replace("https://", "https://" . $credentials, $messageUrl); @@ -207,7 +207,7 @@ class ProcessMailgunInboundWebhook implements ShouldQueue 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]; + $messageUrl = $this->message_url;//explode("|", $this->input)[2]; $messageUrl = str_replace("http://", "http://" . $credentials, $messageUrl); $messageUrl = str_replace("https://", "https://" . $credentials, $messageUrl); $mail = json_decode(file_get_contents($messageUrl)); @@ -219,7 +219,7 @@ class ProcessMailgunInboundWebhook implements ShouldQueue } else { $credentials = config('services.mailgun.domain') . ":" . config('services.mailgun.secret') . "@"; - $messageUrl = explode("|", $this->input)[2]; + $messageUrl = $this->message_url; //explode("|", $this->input)[2]; $messageUrl = str_replace("http://", "http://" . $credentials, $messageUrl); $messageUrl = str_replace("https://", "https://" . $credentials, $messageUrl); $mail = json_decode(file_get_contents($messageUrl)); diff --git a/app/Services/InboundMail/InboundMailEngine.php b/app/Services/InboundMail/InboundMailEngine.php index c6934b50decc..8173f5286861 100644 --- a/app/Services/InboundMail/InboundMailEngine.php +++ b/app/Services/InboundMail/InboundMailEngine.php @@ -310,7 +310,7 @@ class InboundMailEngine } private function logBlocked(Company $company, string $data) { - nlog("[InboundMailEngine][company:" . $company->id . "] " . $data); + nlog("[InboundMailEngine][company:" . $company->company_key . "] " . $data); ( new SystemLogger(