Fix: syncSysmailDomain mit Fallback für fehlende BASE_DOMAIN + Toast bei Fehler

Leitet BASE_DOMAIN aus config → env → mail_domain-Setting ab.
Gibt Toast-Meldung aus wenn Seeder fehlschlägt, statt still zu scheitern.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
main v1.1.372
boban 2026-04-26 23:51:16 +02:00
parent fb6573598d
commit 2ec10a8a81
1 changed files with 24 additions and 2 deletions

View File

@ -227,7 +227,21 @@ class SettingsForm extends Component
private function syncSysmailDomain(): void
{
$platformBase = strtolower(config('mailpool.platform_zone', env('BASE_DOMAIN', '')));
// BASE_DOMAIN aus config, env oder mail_domain ableiten
$platformBase = strtolower((string) config('mailpool.platform_zone', ''));
if (!$platformBase || $platformBase === 'example.com') {
$platformBase = strtolower((string) env('BASE_DOMAIN', ''));
}
if (!$platformBase || $platformBase === 'example.com') {
// Fallback: aus mail_domain den Hostnamen ohne ersten Subdomain-Teil
$mailDomain = strtolower(trim((string) Setting::get('mail_domain', '')));
if ($mailDomain) {
$parts = explode('.', $mailDomain);
$platformBase = count($parts) > 2
? implode('.', array_slice($parts, 1))
: $mailDomain;
}
}
if (!$platformBase || $platformBase === 'example.com') return;
$systemSub = strtolower(config('mailpool.platform_system_zone', 'sysmail'));
@ -253,8 +267,16 @@ class SettingsForm extends Component
'--class' => 'Database\\Seeders\\SystemDomainSeeder',
'--force' => true,
]);
\Illuminate\Support\Facades\Log::info('SystemDomainSeeder ok', ['fqdn' => $expectedFqdn]);
} catch (\Throwable $e) {
\Illuminate\Support\Facades\Log::error('SystemDomainSeeder failed', ['error' => $e->getMessage()]);
\Illuminate\Support\Facades\Log::error('SystemDomainSeeder failed', [
'fqdn' => $expectedFqdn,
'error' => $e->getMessage(),
'trace' => $e->getTraceAsString(),
]);
$this->dispatch('toast', type: 'warn', badge: 'Sysmail',
title: 'System-Domain konnte nicht angelegt werden',
text: $e->getMessage(), duration: 8000);
}
}