Addresses of the internal communication in the admin (notification recipients, contact/reply-to, sender)
Deploy / test (push) Failing after 2s
Deploy / deploy (push) Skipped

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lars StommerandClaude Opus 5.5 committed 2026-10-23 07:14:25 +02:00
1 parent 749537342e
commit 0c98d82cf2
20 files changed
+165 -20

No files matched your search

+51 -1
View File
@@ -19,6 +19,16 @@ class Settings
public const TEST_RECIPIENT = 'operations.test_recipient';
/** Comma-separated: who is informed about new requests, answered offers, portal events … */
public const NOTIFICATION_RECIPIENTS = 'addresses.notifications';
/** Contact address shown on the website and in the contract; reply-to of guest mails. */
public const CONTACT_EMAIL = 'addresses.contact';
public const SENDER_EMAIL = 'addresses.sender_email';
public const SENDER_NAME = 'addresses.sender_name';
public const MODE_TEST = 'test';
public const MODE_LIVE = 'live';
@@ -46,9 +56,49 @@ public static function save(array $values): void
}
Cache::forget(self::CACHE_KEY);
self::applyAddressOverrides();
self::applyMailRouting();
}
/**
* The recipients of internal notifications (admin setting, else FEWO_NOTIFICATION_EMAIL).
*
* @return list<string>
*/
public static function notificationRecipients(): array
{
return self::addressList(self::get(self::NOTIFICATION_RECIPIENTS) ?: (string) config('fewo.notification_email'));
}
/**
* "a@x.de, b@y.de; c@z.de" → valid addresses only.
*
* @return list<string>
*/
public static function addressList(?string $value): array
{
return array_values(array_filter(
array_map('trim', preg_split('/[,;\s]+/', (string) $value) ?: []),
fn (string $address): bool => filter_var($address, FILTER_VALIDATE_EMAIL) !== false,
));
}
/**
* Admin settings for the contact address and the sender override the .env values for this request.
*/
public static function applyAddressOverrides(): void
{
$overrides = array_filter([
'fewo.owner.email' => self::get(self::CONTACT_EMAIL),
'mail.from.address' => self::get(self::SENDER_EMAIL),
'mail.from.name' => self::get(self::SENDER_NAME),
]);
if ($overrides !== []) {
config($overrides);
}
}
public static function isLive(): bool
{
return self::get(self::MODE, self::MODE_TEST) === self::MODE_LIVE;
@@ -69,7 +119,7 @@ public static function mailRedirect(): ?string
return null;
}
return self::get(self::TEST_RECIPIENT) ?: (config('fewo.notification_email') ?: null);
return self::get(self::TEST_RECIPIENT) ?: (self::notificationRecipients()[0] ?? null);
}
/**