10000 [Mailer] Add MailerSend bridge by doobas · Pull Request #49461 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Mailer] Add MailerSend bridge #49461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use ->toArray() to get response content.
  • Loading branch information
doobas committed Feb 23, 2023
commit 834b4a7a756f3e6dc253aa0995c4d83e18a31ea6
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Mailer\Bridge\MailerSend\Tests\Transport;

use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpClient\Exception\JsonException;
use Symfony\Component\HttpClient\MockHttpClient;
use Symfony\Component\HttpClient\Response\MockResponse;
use Symfony\Component\Mailer\Bridge\MailerSend\Transport\MailerSendApiTransport;
Expand Down Expand Up @@ -191,8 +192,8 @@ public function testSendThrowsForBadResponse()
->from(new Address('test_from@example.com', 'Test from name'))
->text('Lorem ipsum.');

$this->expectException(HttpTransportException::class);
$this->expectExceptionMessage('Unable to send an email: "test" (code 202).');
$this->expectException(JsonException::class);
$this->expectExceptionMessage('Syntax error for "https://api.mailersend.com/v1/email');
$transport->send($mail);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,7 @@ protected function doSendApi(SentMessage $sentMessage, Email $email, Envelope $e
throw new HttpTransportException('Could not reach the remote MailerSend server.', $response, 0, $e);
}

if ('' !== $content) {
try {
$result = json_decode($content, true, 512, \JSON_THROW_ON_ERROR);
} catch (\JsonException $e) {
throw new HttpTransportException(sprintf('Unable to send an email: "%s" (code %d).', $content, $statusCode), $response, 0, $e);
}
}
$result = '' !== $content ? $response->toArray(false) : null;

if (202 !== $statusCode) {
throw new HttpTransportException('Unable to send an email: '.($result['message'] ?? '').sprintf(' (code %d).', $statusCode), $response);
Expand Down
0