Skip to content

Make Mailgun Header compatible with other Bridges #41380

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

Merged
merged 1 commit into from
May 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion UPGRADE-5.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ Inflector
Mailer
------

* Deprecated passing Mailgun headers without their "h:" prefix.
* Deprecated the `SesApiTransport` class. It has been replaced by SesApiAsyncAwsTransport Run `composer require async-aws/ses` to use the new classes.
* Deprecated the `SesHttpTransport` class. It has been replaced by SesHttpAsyncAwsTransport Run `composer require async-aws/ses` to use the new classes.

Expand Down
6 changes: 6 additions & 0 deletions src/Symfony/Component/Mailer/Bridge/Mailgun/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
CHANGELOG
=========

5.2
---

* Not prefixing headers with "h:" is no more deprecated

5.1.0
-----

* Not prefixing headers with "h:" is deprecated.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ public function testTagAndMetadataHeaders()
$json = json_encode(['foo' => 'bar']);
$email = new Email();
$email->getHeaders()->addTextHeader('h:X-Mailgun-Variables', $json);
$email->getHeaders()->addTextHeader('Custom-Header', 'value');
$email->getHeaders()->add(new TagHeader('password-reset'));
$email->getHeaders()->add(new MetadataHeader('Color', 'blue'));
$email->getHeaders()->add(new MetadataHeader('Client-ID', '12345'));
Expand All @@ -223,9 +224,10 @@ public function testTagAndMetadataHeaders()
$method = new \ReflectionMethod(MailgunApiTransport::class, 'getPayload');
$method->setAccessible(true);
$payload = $method->invoke($transport, $email, $envelope);

$this->assertArrayHasKey('h:x-mailgun-variables', $payload);
$this->assertEquals($json, $payload['h:x-mailgun-variables']);
$this->assertArrayHasKey('h:custom-header', $payload);
$this->assertEquals('value', $payload['h:custom-header']);
$this->assertArrayHasKey('o:tag', $payload);
$this->assertSame('password-reset', $payload['o:tag']);
$this->assertArrayHasKey('v:Color', $payload);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ private function getPayload(Email $email, Envelope $envelope): array
if (\in_array($prefix, ['h:', 't:', 'o:', 'v:']) || \in_array($name, ['recipient-variables', 'template', 'amp-html'])) {
$headerName = $name;
} else {
// fallback to prefix with "h:" to not break BC
$headerName = 'h:'.$name;
@trigger_error(sprintf('Not prefixing the Mailgun header name with "h:" is deprecated since Symfony 5.1. Use header name "%s" instead.', $headerName), \E_USER_DEPRECATED);
}

$payload[$headerName] = $header->getBodyAsString();
Expand Down