Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6eff263

Browse files
bug #39743 [Mailer] Fix missing BCC recipients in SES bridge (jderusse)
This PR was merged into the 4.4 branch. Discussion ---------- [Mailer] Fix missing BCC recipients in SES bridge | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #36333 | License | MIT | Doc PR | - When using the `ses` (alias of `ses+https`) scheme, the bridge send the RawEmail to AWS. But RawEmails does not contains the BCC recipients. This PR adds the envelope's recipients to the list of Destinations in Amazon SES payload. Commits ------- 1cfc763 Fix missing BCC recipients in SES bridge
2 parents 0211b9a + 1cfc763 commit 6eff263

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesHttpTransportTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ public function testSend()
6060
$this->assertStringContainsString('AWS3-HTTPS AWSAccessKeyId=ACCESS_KEY,Algorithm=HmacSHA256,Signature=', $options['headers'][0] ?? $options['request_headers'][0]);
6161

6262
parse_str($options['body'], $body);
63+
64+
$this->assertArrayHasKey('Destinations_member_1', $body);
65+
$this->assertSame('[email protected]', $body['Destinations_member_1']);
66+
$this->assertArrayHasKey('Destinations_member_2', $body);
67+
$this->assertSame('[email protected]', $body['Destinations_member_2']);
68+
6369
$content = base64_decode($body['RawMessage_Data']);
6470

6571
$this->assertStringContainsString('Hello!', $content);
@@ -83,6 +89,7 @@ public function testSend()
8389
$mail = new Email();
8490
$mail->subject('Hello!')
8591
->to(new Address('[email protected]', 'Saif Eddin'))
92+
->bcc(new Address('[email protected]', 'Jérémy Derussé'))
8693
->from(new Address('[email protected]', 'Fabien'))
8794
->text('Hello There!');
8895

src/Symfony/Component/Mailer/Bridge/Amazon/Transport/SesHttpTransport.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected function doSendHttp(SentMessage $message): ResponseInterface
5252
$date = gmdate('D, d M Y H:i:s e');
5353
$auth = sprintf('AWS3-HTTPS AWSAccessKeyId=%s,Algorithm=HmacSHA256,Signature=%s', $this->accessKey, $this->getSignature($date));
5454

55-
$response = $this->client->request('POST', 'https://'.$this->getEndpoint(), [
55+
$request = [
5656
'headers' => [
5757
'X-Amzn-Authorization' => $auth,
5858
'Date' => $date,
@@ -61,7 +61,13 @@ protected function doSendHttp(SentMessage $message): ResponseInterface
6161
'Action' => 'SendRawEmail',
6262
'RawMessage.Data' => base64_encode($message->toString()),
6363
],
64-
]);
64+
];
65+
$index = 1;
66+
foreach ($message->getEnvelope()->getRecipients() as $recipient) {
67+
$request['body']['Destinations.member.'.$index++] = $recipient->getAddress();
68+
}
69+
70+
$response = $this->client->request('POST', 'https://'.$this->getEndpoint(), $request);
6571

6672
$result = new \SimpleXMLElement($response->getContent(false));
6773
if (200 !== $response->getStatusCode()) {

0 commit comments

Comments
 (0)