Skip to content

Commit 96d7ef0

Browse files
committed
symfony/mime does not allow to add some headers as a strings, only as arrays
1 parent 9b2a4db commit 96d7ef0

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/Symfony/Component/Mime/Header/Headers.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ public function addHeader(string $name, mixed $argument, array $more = []): stat
147147
$method = 'addTextHeader';
148148
} elseif ('addIdentificationHeader' === $method) {
149149
$method = 'addIdHeader';
150+
} elseif ($method === 'addMailboxListHeader' && !\is_array($argument)) {
151+
$argument = [$argument];
150152
}
151153

152154
return $this->$method($name, $argument, $more);

src/Symfony/Component/Mime/Tests/Header/HeadersTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public function testAddHeader()
6969
{
7070
$headers = new Headers();
7171
$headers->addHeader('from', ['from@example.com']);
72+
$headers->addHeader('reply-to', 'reply@example.com');
7273
$headers->addHeader('return-path', 'return@example.com');
7374
$headers->addHeader('foo', 'bar');
7475
$headers->addHeader('date', $now = new \DateTimeImmutable());
@@ -77,6 +78,9 @@ public function testAddHeader()
7778
$this->assertInstanceOf(MailboxListHeader::class, $headers->get('from'));
7879
$this->assertEquals([new Address('from@example.com')], $headers->get('from')->getBody());
7980

81+
$this->assertInstanceOf(MailboxListHeader::class, $headers->get('reply-to'));
82+
$this->assertEquals([new Address('reply@example.com')], $headers->get('reply-to')->getBody());
83+
8084
$this->assertInstanceOf(PathHeader::class, $headers->get('return-path'));
8185
$this->assertEquals(new Address('return@example.com'), $headers->get('return-path')->getBody());
8286

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy