bug #36947 [Mime] Allow email message to have "To", "Cc", or "Bcc" header to be valid (Ernest Hymel)

This PR was submitted for the master branch but it was merged into the 4.4 branch instead.

Discussion
----------

[Mime] Allow email message to have "To", "Cc", or "Bcc" header to be valid

| Q             | A
| ------------- | ---
| Branch?       | 5.0
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #36944
| License       | MIT
| Doc PR        | N/A

Allow emails to have any one of To:, Cc:, or Bcc: fields rather than forcing a required To: field.

Commits
-------

35b7e1cb9a Allow email message to have "To", "Cc", or "Bcc" header to be valid
This commit is contained in:
Fabien Potencier 2020-05-25 07:42:40 +02:00
commit b524e04300
1 changed files with 2 additions and 2 deletions

View File

@ -122,8 +122,8 @@ class Message extends RawMessage
public function ensureValidity()
{
if (!$this->headers->has('To')) {
throw new LogicException('An email must have a "To" header.');
if (!$this->headers->has('To') && !$this->headers->has('Cc') && !$this->headers->has('Bcc')) {
throw new LogicException('An email must have a "To", "Cc", or "Bcc" header.');
}
if (!$this->headers->has('From') && !$this->headers->has('Sender')) {