8000 [Mime] fix PHP 7 compatibility by xabbuh · Pull Request #57228 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Mime] fix PHP 7 compatibility #57228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you 8000 account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/Symfony/Component/Mime/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,18 @@ public function toIterable(): iterable

public function ensureValidity()
{
if (!$this->headers->get('To')?->getBody() && !$this->headers->get('Cc')?->getBody() && !$this->headers->get('Bcc')?->getBody()) {
$to = (null !== $header = $this->headers->get('To')) ? $header->getBody() : null;
$cc = (null !== $header = $this->headers->get('Cc')) ? $header->getBody() : null;
$bcc = (null !== $header = $this->headers->get('Bcc')) ? $header->getBody() : null;

if (!$to && !$cc && !$bcc) {
throw new LogicException('An email must have a "To", "Cc", or "Bcc" header.');
}

if (!$this->headers->get('From')?->getBody() && !$this->headers->get('Sender')?->getBody()) {
$from = (null !== $header = $this->headers->get('From')) ? $header->getBody() : null;
$sender = (null !== $header = $this->headers->get('Sender')) ? $header->getBody() : null;

if (!$from && !$sender) {
throw new LogicException('An email must have a "From" or a "Sender" header.');
}

Expand Down
Loading
0