Skip to content
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 account related emails.

Already on GitHub? Sign in to your account

[Mailer] Handle null & empty to/cc/bcc/reply-to addresses #54748

Open
mote0230 opened this issue Apr 26, 2024 · 0 comments
Open

[Mailer] Handle null & empty to/cc/bcc/reply-to addresses #54748

mote0230 opened this issue Apr 26, 2024 · 0 comments

Comments

@mote0230
Copy link

Description

Similar to this drupal issue: Allow removal of to/cc/bcc/reply-to addresses (after they are added to an email) (not sure why they didn't try to upstream their patch)

Currently I have to refactor my code from

$message = (new TemplatedEmail())
                ->subject('foo')
                ->from('bar')
                ->to($obj->getEmail())
                ->cc($obj->getCc())

To

 $message = (new TemplatedEmail())
                ->subject('foo')
                ->from('bar');
 if(!is_null($obj->getCc()) && !empty($obj->getCc())) {
     $message->cc($obj->getCc())
}
 if(!is_null($obj->getEmail()) && !empty($obj->getEmail())) {
     $message->to($obj->getEmail())
}

And so on, every time. That's a lot of repeating yourself.

Current behavior is to throw an exception.

Swiftmailer handled this, and it seems more logical to me to handle it there.

Additionally, it would fix the problem in the linked drupal issue. It also contains a patch that can probably be used as a starting point.

Example

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants