Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 06ec3b0

Browse filesBrowse files
committed
[Mailer] Add custom header "h:sender" for HTTP transport type
1 parent 0d474f8 commit 06ec3b0
Copy full SHA for 06ec3b0

File tree

2 files changed

+11
-2
lines changed
Filter options

2 files changed

+11
-2
lines changed

‎src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Transport/MailgunHttpTransportTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Transport/MailgunHttpTransportTest.php
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ public function testSend()
6969
$this->assertStringContainsString('Subject: Hello!', $content);
7070
$this->assertStringContainsString('To: Saif Eddin <saif.gmati@symfony.com>', $content);
7171
$this->assertStringContainsString('From: Fabien <fabpot@symfony.com>', $content);
72+
$this->assertStringContainsString('Sender: Senior Fabien Eddin <fabpot@symfony.com>', $content);
73+
$this->assertStringContainsString('h:sender: "Senior Fabien Eddin" <fabpot@symfony.com>', $content);
7274
$this->assertStringContainsString('Hello There!', $content);
7375

7476
return new MockResponse(json_encode(['id' => 'foobar']), [
@@ -79,11 +81,17 @@ public function testSend()
7981
$transport->setPort(8984);
8082

8183
$mail = new Email();
84+
$toAddress = new Address('saif.gmati@symfony.com', 'Saif Eddin');
85+
$fromAddress = new Address('fabpot@symfony.com', 'Fabien');
86+
$senderAddress = new Address('fabpot@symfony.com', 'Senior Fabien Eddin');
8287
$mail->subject('Hello!')
83-
->to(new Address('saif.gmati@symfony.com', 'Saif Eddin'))
84-
->from(new Address('fabpot@symfony.com', 'Fabien'))
88+
->to($toAddress)
89+
->from($fromAddress)
90+
->sender($senderAddress)
8591
->text('Hello There!');
8692

93+
$mail->getHeaders()->addHeader('h:sender', $mail->getSender()->toString());
94+
8795
$message = $transport->send($mail);
8896

8997
$this->assertSame('foobar', $message->getMessageId());

‎src/Symfony/Component/Mailer/Bridge/Mailgun/Transport/MailgunHttpTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mailer/Bridge/Mailgun/Transport/MailgunHttpTransport.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public function __toString(): string
5353
protected function doSendHttp(SentMessage $message): ResponseInterface
5454
{
5555
$body = new FormDataPart([
56+
'h:sender' => $message->getEnvelope()->getSender()->toString(),
5657
'to' => implode(',', $this->stringifyAddresses($message->getEnvelope()->getRecipients())),
5758
'message' => new DataPart($message->toString(), 'message.mime'),
5859
]);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.