diff --git a/app/Livewire/Ui/System/SettingsForm.php b/app/Livewire/Ui/System/SettingsForm.php index 24ea737..def979c 100644 --- a/app/Livewire/Ui/System/SettingsForm.php +++ b/app/Livewire/Ui/System/SettingsForm.php @@ -199,6 +199,23 @@ class SettingsForm extends Component $this->applyDomains(false); } + // System-Domain (sysmail.) provisionieren, falls noch nicht vorhanden + $platformBase = config('mailpool.platform_zone', env('BASE_DOMAIN', '')); + if ($platformBase && $platformBase !== 'example.com') { + $systemSub = config('mailpool.platform_system_zone', 'sysmail'); + $systemFqdn = strtolower("{$systemSub}.{$platformBase}"); + if (!\App\Models\Domain::where('domain', $systemFqdn)->exists()) { + try { + Artisan::call('db:seed', [ + '--class' => 'Database\\Seeders\\SystemDomainSeeder', + '--force' => true, + ]); + } catch (\Throwable $e) { + \Illuminate\Support\Facades\Log::error('SystemDomainSeeder failed', ['error' => $e->getMessage()]); + } + } + } + $this->loadSslStatus(); $this->dispatch('toast', type: 'done', badge: 'Domains', diff --git a/database/seeders/SystemDomainSeeder.php b/database/seeders/SystemDomainSeeder.php index ea71369..c2166da 100644 --- a/database/seeders/SystemDomainSeeder.php +++ b/database/seeders/SystemDomainSeeder.php @@ -140,7 +140,7 @@ class SystemDomainSeeder extends Seeder $this->command->line("System-Domain angelegt: {$systemDomain->domain}"); } - $noReply = MailUser::firstOrCreate( + $noReply = MailUser::updateOrCreate( ['domain_id' => $systemDomain->id, 'localpart' => 'no-reply'], [ 'email' => 'no-reply@' . $systemDomain->domain,