Fix: BASE_DOMAIN wird beim Speichern der Domains aus mail_domain abgeleitet
War auf Live-Server noch 'example.com' weshalb sysmail nie angelegt wurde. mx.pxo.at → BASE_DOMAIN=pxo.at, MTA_SUB=mx automatisch gesetzt. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>main v1.1.373
parent
2ec10a8a81
commit
742c39f91a
|
|
@ -445,24 +445,38 @@ class SettingsForm extends Component
|
|||
|
||||
private function syncDomainsToEnv(): void
|
||||
{
|
||||
$base = rtrim((string) config('mailwolt.domain.base', ''), '.');
|
||||
// BASE_DOMAIN aus mail_domain ableiten (mx.pxo.at → pxo.at)
|
||||
$derivedBase = '';
|
||||
if ($this->mail_domain) {
|
||||
$parts = explode('.', strtolower(trim($this->mail_domain)));
|
||||
$derivedBase = count($parts) > 2
|
||||
? implode('.', array_slice($parts, 1))
|
||||
: implode('.', $parts);
|
||||
}
|
||||
|
||||
$base = $derivedBase ?: rtrim((string) config('mailwolt.domain.base', ''), '.');
|
||||
|
||||
$sub = function (string $full) use ($base): string {
|
||||
$full = strtolower(trim($full));
|
||||
if ($base && str_ends_with($full, '.' . $base)) {
|
||||
return substr($full, 0, -(strlen($base) + 1));
|
||||
}
|
||||
// Kein passender Base — ersten Label nehmen
|
||||
$parts = explode('.', $full);
|
||||
return count($parts) > 1 ? $parts[0] : '';
|
||||
};
|
||||
|
||||
$this->writeEnv([
|
||||
$env = [
|
||||
'WEBMAIL_SUB' => $this->webmail_domain ? $sub($this->webmail_domain) : '',
|
||||
'WEBMAIL_DOMAIN' => $this->webmail_domain ?: '',
|
||||
'UI_SUB' => $this->ui_domain ? $sub($this->ui_domain) : '',
|
||||
'MTA_SUB' => $this->mail_domain ? $sub($this->mail_domain) : '',
|
||||
]);
|
||||
];
|
||||
|
||||
if ($derivedBase && $derivedBase !== 'example.com') {
|
||||
$env['BASE_DOMAIN'] = $derivedBase;
|
||||
}
|
||||
|
||||
$this->writeEnv($env);
|
||||
|
||||
Artisan::call('config:clear');
|
||||
Artisan::call('route:clear');
|
||||
|
|
|
|||
Loading…
Reference in New Issue