This commit is contained in:
2025-05-12 14:25:25 +02:00
parent ab2db755ef
commit 9e378ca2b7
2719 changed files with 46505 additions and 60181 deletions

View File

@@ -120,6 +120,10 @@ class Email extends Message
*/
public function from(Address|string ...$addresses): static
{
if (!$addresses) {
throw new LogicException('"from()" must be called with at least one address.');
}
return $this->setListAddressHeaderBody('From', $addresses);
}
@@ -325,7 +329,7 @@ class Email extends Message
*
* @return $this
*/
public function attach($body, string $name = null, string $contentType = null): static
public function attach($body, ?string $name = null, ?string $contentType = null): static
{
return $this->addPart(new DataPart($body, $name, $contentType));
}
@@ -333,7 +337,7 @@ class Email extends Message
/**
* @return $this
*/
public function attachFromPath(string $path, string $name = null, string $contentType = null): static
public function attachFromPath(string $path, ?string $name = null, ?string $contentType = null): static
{
return $this->addPart(new DataPart(new File($path), $name, $contentType));
}
@@ -343,7 +347,7 @@ class Email extends Message
*
* @return $this
*/
public function embed($body, string $name = null, string $contentType = null): static
public function embed($body, ?string $name = null, ?string $contentType = null): static
{
return $this->addPart((new DataPart($body, $name, $contentType))->asInline());
}
@@ -351,7 +355,7 @@ class Email extends Message
/**
* @return $this
*/
public function embedFromPath(string $path, string $name = null, string $contentType = null): static
public function embedFromPath(string $path, ?string $name = null, ?string $contentType = null): static
{
return $this->addPart((new DataPart(new File($path), $name, $contentType))->asInline());
}
@@ -412,7 +416,7 @@ class Email extends Message
private function ensureBodyValid(): void
{
if (null === $this->text && null === $this->html && !$this->attachments) {
if (null === $this->text && null === $this->html && !$this->attachments && null === parent::getBody()) {
throw new LogicException('A message must have a text or an HTML part or attachments.');
}
}