Skip to content

Commit

Permalink
bug #36947 [Mime] Allow email message to have "To", "Cc", or "Bcc" he…
Browse files Browse the repository at this point in the history
…ader 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
-------

35b7e1c Allow email message to have "To", "Cc", or "Bcc" header to be valid
  • Loading branch information
fabpot committed May 25, 2020
2 parents aa53bdb + 35b7e1c commit b524e04
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Symfony/Component/Mime/Message.php
Expand Up @@ -122,8 +122,8 @@ public function toIterable(): iterable

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')) {
Expand Down

0 comments on commit b524e04

Please sign in to comment.