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

Skip to content

Commit a5f39b1

Browse files
committed
exception wording + adds tests
1 parent a5e4659 commit a5f39b1

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Symfony/Component/Mime/Message.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function generateMessageId(): string
141141
$sender = $this->headers->get('Sender')->getAddress();
142142
} elseif ($this->headers->has('From')) {
143143
if (empty($froms = $this->headers->get('From')->getAddresses())) {
144-
throw new LogicException('Your email has a From header but no addresses. Did you forgot to add emails in the "from" method ?');
144+
throw new LogicException('Your email has a From header that contains no addresses. Did you forgot to add emails in the "from" method ?');
145145
}
146146
$sender = $froms[0];
147147
} else {

src/Symfony/Component/Mime/Tests/MessageTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@ public function testGetPreparedHeadersHasSenderWhenNeeded()
125125
$this->assertEquals('[email protected]', $message->getPreparedHeaders()->get('Sender')->getAddress()->getAddress());
126126
}
127127

128+
public function testGenerateMessageIdThrowsWhenHasFromButNoAddresses()
129+
{
130+
$this->expectException(\LogicException::class);
131+
$message = new Message();
132+
$message->getHeaders()->addMailboxListHeader('From', []);
133+
$message->generateMessageId();
134+
}
135+
128136
public function testToString()
129137
{
130138
$message = new Message();

0 commit comments

Comments
 (0)