diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index 4870007b7a..e97a113dbd 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -249,8 +249,19 @@ class NinjaMailerJob implements ShouldQueue if ($e instanceof PostmarkException) { //postmark specific failure + + try { + $response = json_decode($e->getMessage(), true); + if (is_array($response) && isset($response['Message'])) { + $message = $response['Message']; + } + } catch (\Exception $jsonError) { + // If JSON decode fails, use the original message + $message = "Unknown issue sending via Postmark, please try again later."; + } + $this->fail(); - $this->entityEmailFailed($e->getMessage()); + $this->entityEmailFailed($message); $this->cleanUpMailers(); return; diff --git a/app/Services/Email/Email.php b/app/Services/Email/Email.php index cb6660cb7c..f7d3dc1d8c 100644 --- a/app/Services/Email/Email.php +++ b/app/Services/Email/Email.php @@ -370,17 +370,26 @@ class Email implements ShouldQueue } - - /** * Post mark buries the proper message in a guzzle response * this merges a text string with a json object * need to harvest the ->Message property using the following */ if ($e instanceof PostmarkException) { //postmark specific failure + + // Try to decode the JSON response if present + try { + $response = json_decode($e->getMessage(), true); + if (is_array($response) && isset($response['Message'])) { + $message = $response['Message']; + } + } catch (\Exception $jsonError) { + // If JSON decode fails, use the original message + $message = "Unknown issue sending via Postmark, please try again later."; + } $this->fail(); - $this->entityEmailFailed($e->getMessage()); + $this->entityEmailFailed($message); $this->cleanUpMailers(); return; diff --git a/composer.lock b/composer.lock index 7cd53db4c7..dbfe91c169 100644 --- a/composer.lock +++ b/composer.lock @@ -5169,16 +5169,16 @@ }, { "name": "laravel/framework", - "version": "v11.44.4", + "version": "v11.44.7", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "6b29bb79b18474ea5265b7022ba7b0f76eebeb4f" + "reference": "00bc6ac91a6d577bf051c18ddaa638c0d221e1c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/6b29bb79b18474ea5265b7022ba7b0f76eebeb4f", - "reference": "6b29bb79b18474ea5265b7022ba7b0f76eebeb4f", + "url": "https://api.github.com/repos/laravel/framework/zipball/00bc6ac91a6d577bf051c18ddaa638c0d221e1c7", + "reference": "00bc6ac91a6d577bf051c18ddaa638c0d221e1c7", "shasum": "" }, "require": { @@ -5380,7 +5380,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2025-04-23T23:35:40+00:00" + "time": "2025-04-25T12:40:47+00:00" }, { "name": "laravel/octane",