Skip to content

A free open source IT asset/license management system

Notifications: Fixed #19426 - Allow multiple addresses in CC field

snipe0aa274c41264
diff --git a/app/Listeners/CheckoutablesCheckedOutInBulkListener.php b/app/Listeners/CheckoutablesCheckedOutInBulkListener.php
index 3f6a367c97..130969c374 100644
--- a/app/Listeners/CheckoutablesCheckedOutInBulkListener.php
+++ b/app/Listeners/CheckoutablesCheckedOutInBulkListener.php
@@ -9,7 +9,6 @@ use App\Models\Location;
use App\Models\Setting;
use App\Models\User;
use Exception;
-use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
@@ -49,8 +48,15 @@ class CheckoutablesCheckedOutInBulkListener
}
if ($shouldSendEmailToAlertAddress && Setting::getSettings()->admin_cc_email) {
+ // admin_cc_email is validated as a comma-separated list
+ // (email_array validator on the settings request). CheckoutableListener
+ // already explodes on comma before handing to Mail::to; this listener
+ // used to pass the raw string, which Symfony Mailer would treat as
+ // one recipient and reject as invalid. See #19426.
+ $recipients = array_filter(array_map('trim', explode(',', Setting::getSettings()->admin_cc_email)));
+
try {
- Mail::to(Setting::getSettings()->admin_cc_email)->send(new BulkAssetCheckoutMail(
+ Mail::to($recipients)->send(new BulkAssetCheckoutMail(
$event->assets,
$event->target,
$event->admin,
diff --git a/resources/lang/en-US/admin/settings/general.php b/resources/lang/en-US/admin/settings/general.php
index afea20c2c1..e3ad8274f7 100644
--- a/resources/lang/en-US/admin/settings/general.php
+++ b/resources/lang/en-US/admin/settings/general.php
@@ -8,7 +8,7 @@ return [
'ad_append_domain' => 'Append domain name to username field',
'ad_append_domain_help' => 'User isn\'t required to write "[email protected]", they can just type "username".',
'admin_cc_email' => 'CC Email',
- 'admin_cc_email_help' => 'Send a copy of checkin/checkout emails to this address.',
+ 'admin_cc_email_help' => 'Send a copy of checkin/checkout emails to this address. Multiple recipients can be specified comma-separated.',
'admin_cc_always' => 'Always send copy upon checkin/checkout',
'admin_cc_when_acceptance_required' => 'Only send copy upon checkout if acceptance is required',
'admin_settings' => 'Admin Settings',
diff --git a/resources/views/settings/alerts.blade.php b/resources/views/settings/alerts.blade.php
index a17321746f..112f89d21c 100644
--- a/resources/views/settings/alerts.blade.php
+++ b/resources/views/settings/alerts.blade.php
@@ -70,14 +70,17 @@
input_group_addon="right"
/>
- <!-- Admin CC Email -->
+ <!-- Admin CC Email. Do not switch back to type="email":
+ HTML5 native validation rejects comma-separated input,
+ which blocks operators from entering multiple recipients
+ even though the server-side email_array validator and the
+ send paths accept them. See #19426. -->
<x-form.row
name="admin_cc_email"
- type="email"
:item="$setting"
:label="trans('admin/settings/general.admin_cc_email')"
:help_text="trans('admin/settings/general.admin_cc_email_help')"
- placeholder="[email protected]"
input_icon="email"
input_group_addon="right"
/>
diff --git a/tests/Feature/Notifications/Email/BulkCheckoutEmailTest.php b/tests/Feature/Notifications/Email/BulkCheckoutEmailTest.php
index 10a42c09fd..b9f764e9b2 100644
--- a/tests/Feature/Notifications/Email/BulkCheckoutEmailTest.php
+++ b/tests/Feature/Notifications/Email/BulkCheckoutEmailTest.php
@@ -171,6 +171,25 @@ class BulkCheckoutEmailTest extends TestCase
});
}
+ public function test_sent_to_multiple_cc_addresses_when_admin_cc_email_is_comma_separated()
+ {
+ // Regression for #19426. Bulk checkout used to pass the raw
+ // admin_cc_email string to Mail::to, so a comma-separated value
+ // hit Symfony Mailer as a single mangled recipient. Both
+ // addresses must land as individual recipients on the send.
+ $this->assets = Asset::factory()->requiresAcceptance()->count(2)->create();
+
+ $this->settings->enableAdminCC('[email protected], [email protected]')->disableAdminCCAlways();
+
+ $this->sendRequest();
+
+ $this->assertSingularCheckoutEmailNotSent();
+
+ Mail::assertSent(BulkAssetCheckoutMail::class, function (BulkAssetCheckoutMail $mail) {
+ return $mail->hasTo('[email protected]') && $mail->hasTo('[email protected]');
+ });
+ }
+
public function test_sent_to_cc_address_when_assets_do_not_require_acceptance_or_have_eula_but_admin_cc_always_enabled()
{
$this->settings->enableAdminCC('[email protected]')->enableAdminCCAlways();