Skip to content

Commit 09383eb

Browse files
committed
Fix missing BCC recipients in SES bridge
1 parent 9b719ab commit 09383eb

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('saif.gmati@symfony.com', $body['Destinations_member_1']);
66+
$this->assertArrayHasKey('Destinations_member_2', $body);
67+
$this->assertSame('jeremy@derusse.com', $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('saif.gmati@symfony.com', 'Saif Eddin'))
92+
->bcc(new Address('jeremy@derusse.com', 'Jérémy Derussé'))
8693
->from(new Address('fabpot@symfony.com', '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)