Skip to content

Commit 1aa4273

Browse files
Oipnetnicolas-grekas
authored andcommitted
[Mime] Allow to add some headers as a strings
1 parent 4f1791b commit 1aa4273

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

Header/Headers.php

+2
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 ('addMailboxListHeader' === $method && !\is_array($argument)) {
151+
$argument = [$argument];
150152
}
151153

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

Tests/Header/HeadersTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public function testAddHeader()
6969
{
7070
$headers = new Headers();
7171
$headers->addHeader('from', ['[email protected]']);
72+
$headers->addHeader('reply-to', '[email protected]');
7273
$headers->addHeader('return-path', '[email protected]');
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('[email protected]')], $headers->get('from')->getBody());
7980

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

0 commit comments

Comments
 (0)