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

Skip to content

Commit a5e4659

Browse files
committed
adds more descriptive error message when giving no email to the form method of the email class
1 parent afe2c27 commit a5e4659

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Symfony/Component/Mime/Message.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,10 @@ public function generateMessageId(): string
140140
if ($this->headers->has('Sender')) {
141141
$sender = $this->headers->get('Sender')->getAddress();
142142
} elseif ($this->headers->has('From')) {
143-
$sender = $this->headers->get('From')->getAddresses()[0];
143+
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 ?');
145+
}
146+
$sender = $froms[0];
144147
} else {
145148
throw new LogicException('An email must have a "From" or a "Sender" header.');
146149
}

0 commit comments

Comments
 (0)