diff --git a/app/Livewire/Ui/System/SettingsForm.php b/app/Livewire/Ui/System/SettingsForm.php index d54b5cc..9e7e201 100644 --- a/app/Livewire/Ui/System/SettingsForm.php +++ b/app/Livewire/Ui/System/SettingsForm.php @@ -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); } }