Skip to content

Commit

Permalink
[Mailer] fixed Mailgun support when a response is not JSON as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Sep 2, 2019
1 parent d423b0f commit 3b2db42
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Expand Up @@ -58,9 +58,11 @@ protected function doSendEmail(Email $email, SmtpEnvelope $envelope): void
]);

if (200 !== $response->getStatusCode()) {
$error = $response->toArray(false);
if ('application/json' === $response->getHeaders(false)['content-type'][0]) {
throw new TransportException(sprintf('Unable to send an email: %s (code %s).', $response->toArray(false)['message'], $response->getStatusCode()));
}

throw new TransportException(sprintf('Unable to send an email: %s (code %s).', $error['message'], $response->getStatusCode()));
throw new TransportException(sprintf('Unable to send an email: %s (code %s).', $response->getContent(false), $response->getStatusCode()));
}
}

Expand Down
Expand Up @@ -59,9 +59,11 @@ protected function doSend(SentMessage $message): void
]);

if (200 !== $response->getStatusCode()) {
$error = $response->toArray(false);
if ('application/json' === $response->getHeaders(false)['content-type'][0]) {
throw new TransportException(sprintf('Unable to send an email: %s (code %s).', $response->toArray(false)['message'], $response->getStatusCode()));
}

throw new TransportException(sprintf('Unable to send an email: %s (code %s).', $error['message'], $response->getStatusCode()));
throw new TransportException(sprintf('Unable to send an email: %s (code %s).', $response->getContent(false), $response->getStatusCode()));
}
}
}

0 comments on commit 3b2db42

Please sign in to comment.