Fix: Allow test emails to be sent to any email address (#7600)

This commit is contained in:
Andras Bacsai 2025-12-12 11:15:49 +01:00 committed by GitHub
commit c1380e7dba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 15 deletions

View file

@ -43,6 +43,10 @@ public function send(SendsEmail $notifiable, Notification $notification): void
throw new Exception('No email recipients found'); throw new Exception('No email recipients found');
} }
// Skip team membership validation for test notifications
$isTestNotification = data_get($notification, 'isTestNotification', false);
if (! $isTestNotification) {
foreach ($recipients as $recipient) { foreach ($recipients as $recipient) {
// Check if the recipient is part of the team // Check if the recipient is part of the team
if (! $members->contains('email', $recipient)) { if (! $members->contains('email', $recipient)) {
@ -60,6 +64,7 @@ public function send(SendsEmail $notifiable, Notification $notification): void
throw new Exception('Recipient is not part of the team'); throw new Exception('Recipient is not part of the team');
} }
} }
}
$mailMessage = $notification->toMail($notifiable); $mailMessage = $notification->toMail($notifiable);

View file

@ -23,6 +23,8 @@ class Test extends Notification implements ShouldQueue
public $tries = 5; public $tries = 5;
public bool $isTestNotification = true;
public function __construct(public ?string $emails = null, public ?string $channel = null, public ?bool $ping = false) public function __construct(public ?string $emails = null, public ?string $channel = null, public ?bool $ping = false)
{ {
$this->onQueue('high'); $this->onQueue('high');

View file

@ -8,6 +8,8 @@
class Test extends CustomEmailNotification class Test extends CustomEmailNotification
{ {
public bool $isTestNotification = true;
public function __construct(public string $emails, public bool $isTransactionalEmail = true) public function __construct(public string $emails, public bool $isTransactionalEmail = true)
{ {
$this->onQueue('high'); $this->onQueue('high');