Feat: Sysmail-Domain wird automatisch angelegt wenn eine Maildomain erstellt wird
Beim Anlegen einer neuen User-Domain (kein is_system, kein is_server) wird automatisch 'sysmail.[domain]' als System-Domain mit DKIM/SPF/DMARC (via DomainObserver) und das Postfach 'sysmail@sysmail.[domain]' angelegt. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>main v1.1.362
parent
a2ba9a7c03
commit
50a68047fc
|
|
@ -4,6 +4,7 @@ namespace App\Observers;
|
||||||
|
|
||||||
use App\Models\DkimKey;
|
use App\Models\DkimKey;
|
||||||
use App\Models\Domain;
|
use App\Models\Domain;
|
||||||
|
use App\Models\MailUser;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Process;
|
use Illuminate\Support\Facades\Process;
|
||||||
|
|
||||||
|
|
@ -17,6 +18,11 @@ class DomainObserver
|
||||||
{
|
{
|
||||||
if ($domain->is_server) return;
|
if ($domain->is_server) return;
|
||||||
|
|
||||||
|
// Auto-create sysmail subdomain for every new user domain
|
||||||
|
if (!$domain->is_system) {
|
||||||
|
$this->provisionSysmail($domain);
|
||||||
|
}
|
||||||
|
|
||||||
$selector = (string) config('mailpool.defaults.dkim_selector', 'mwl1');
|
$selector = (string) config('mailpool.defaults.dkim_selector', 'mwl1');
|
||||||
$bits = (int) config('mailpool.defaults.dkim_bits', 2048);
|
$bits = (int) config('mailpool.defaults.dkim_bits', 2048);
|
||||||
|
|
||||||
|
|
@ -40,6 +46,45 @@ class DomainObserver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function provisionSysmail(Domain $domain): void
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$sysmailFqdn = 'sysmail.' . $domain->domain;
|
||||||
|
|
||||||
|
$sysmailDomain = Domain::firstOrCreate(
|
||||||
|
['domain' => $sysmailFqdn],
|
||||||
|
[
|
||||||
|
'is_active' => true,
|
||||||
|
'is_system' => true,
|
||||||
|
'max_mailboxes' => 2,
|
||||||
|
'max_aliases' => 20,
|
||||||
|
'default_quota_mb' => 512,
|
||||||
|
'max_quota_per_mailbox_mb' => 2048,
|
||||||
|
'total_quota_mb' => 2048,
|
||||||
|
'rate_limit_per_hour' => 600,
|
||||||
|
'description' => 'System-Maildomäne für ' . $domain->domain,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
MailUser::firstOrCreate(
|
||||||
|
['domain_id' => $sysmailDomain->id, 'localpart' => 'sysmail'],
|
||||||
|
[
|
||||||
|
'email' => 'sysmail@' . $sysmailFqdn,
|
||||||
|
'display_name' => 'System Mail',
|
||||||
|
'password_hash' => null,
|
||||||
|
'is_system' => true,
|
||||||
|
'is_active' => true,
|
||||||
|
'can_login' => false,
|
||||||
|
'quota_mb' => 512,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
Log::info('Sysmail domain provisioned', ['sysmail' => $sysmailFqdn, 'for' => $domain->domain]);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::error('Sysmail provisioning failed', ['domain' => $domain->domain, 'error' => $e->getMessage()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Beim Löschen alle DKIM-Selector dieser Domain aus OpenDKIM entfernen.
|
* Beim Löschen alle DKIM-Selector dieser Domain aus OpenDKIM entfernen.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue