Add wildcard domain support in preconfig

Use '*' as a catch-all domain key in ident_switch.preconfig to provide
default settings for any domain not explicitly listed.
This commit is contained in:
Laurent Dinclaux
2026-02-10 17:46:58 +11:00
parent fc13088c62
commit 780cfc6a7e
2 changed files with 9 additions and 1 deletions

View File

@@ -14,6 +14,7 @@
/*
* Preconfigured settings for different mail domains.
* Appropriate set of values is searched by mapping domain of email (from identity) to array key.
* Use '*' as a wildcard to match any domain not explicitly listed.
*/
$config['ident_switch.preconfig'] = [
@@ -49,6 +50,13 @@ $config['ident_switch.preconfig'] = [
'smtp_host' => 'tls://mail.another.tld:587',
'user' => 'mbox',
],
// Wildcard: default settings for any domain not listed above.
// '*' => [
// 'imap_host' => 'ssl://mail.example.com:993',
// 'smtp_host' => 'tls://mail.example.com:587',
// 'user' => 'email',
// ],
];
/*

View File

@@ -38,7 +38,7 @@ class IdentSwitchPreconfig
$this->plugin->load_config();
$cfg = rcmail::get_instance()->config->get('ident_switch.preconfig', []);
$cfg = $cfg[$dom] ?? null;
$cfg = $cfg[$dom] ?? $cfg['*'] ?? null;
if ($cfg) {
if (empty($cfg['imap_host']) && empty($cfg['host'])) {