From 0da9f2116f32b91a94d8b6ebc84dd7063817e8b4 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 18 May 2022 16:50:08 +0100 Subject: [PATCH] Adds `reason` to SES exceptions (#42426) --- src/Illuminate/Mail/Transport/SesTransport.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Mail/Transport/SesTransport.php b/src/Illuminate/Mail/Transport/SesTransport.php index ed88a75d8191..d6a64da89d67 100644 --- a/src/Illuminate/Mail/Transport/SesTransport.php +++ b/src/Illuminate/Mail/Transport/SesTransport.php @@ -73,7 +73,13 @@ protected function doSend(SentMessage $message): void ) ); } catch (AwsException $e) { - throw new Exception('Request to AWS SES API failed.', is_int($e->getCode()) ? $e->getCode() : 0, $e); + $reason = $e->getAwsErrorMessage() ?? $e->getMessage(); + + throw new Exception( + sprintf('Request to AWS SES API failed. Reason: %s.', $reason), + is_int($e->getCode()) ? $e->getCode() : 0, + $e + ); } $messageId = $result->get('MessageId');