diff --git a/app/Ninja/Mailers/Mailer.php b/app/Ninja/Mailers/Mailer.php index c1b127c106..c38a2c8704 100644 --- a/app/Ninja/Mailers/Mailer.php +++ b/app/Ninja/Mailers/Mailer.php @@ -102,7 +102,15 @@ class Mailer private function handleFailure($exception) { if (isset($_ENV['POSTMARK_API_TOKEN']) && method_exists($exception, 'getResponse')) { - $response = $exception->getResponse()->getBody()->getContents(); + $response = $exception->getResponse(); + + if (! $response) { + $error = trans('texts.postmark_error', ['link' => link_to('https://status.postmarkapp.com/')]); + Utils::logError($error); + return $error; + } + + $response = $response->getBody()->getContents(); $response = json_decode($response); $emailError = nl2br($response->Message); } else { diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 91028c5fe0..f575503cb2 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2227,7 +2227,8 @@ $LANG = array( 'entity_state' => 'State', 'payment_status_name' => 'Status', 'client_created_at' => 'Date Created', - 'json_import_help' => 'We recommend importing into an empty account.' + 'json_import_help' => 'We recommend importing into an empty account.', + 'postmark_error' => 'There was a problem sending the email through Postmark: :link', );