- Edited
I wanted my users to autoconfigure their clients with mail.theirdomain.com instead of the server hostname as I tend to move accounts around when doing server maintenance or upgrades; thus the server hostname is not always the one serving the emails, but mail.theirdomain.com always points to the correct IP as I have a script to bulk update them whenever I need to.
Long story short I replaced the $autodiscover_config
part of data/web/inc/vars.inc.php
with
// serve autodiscover from mail subdomain
$mail_domain = 'mail.' . implode('.', array_slice(explode('.', explode(':', $_SERVER['HTTP_HOST'])[0]), -2));
$autodiscover_config = array(
// General autodiscover service type: "activesync" or "imap"
// emClient uses autodiscover, but does not support ActiveSync. mailcow excludes emClient from ActiveSync.
// With SOGo disabled, the type will always fallback to imap. CalDAV and CardDAV will be excluded, too.
'autodiscoverType' => 'activesync',
// If autodiscoverType => activesync, also use ActiveSync (EAS) for Outlook desktop clients (>= Outlook 2013 on Windows)
// Outlook for Mac does not support ActiveSync
'useEASforOutlook' => 'no',
// Please don't use STARTTLS-enabled service ports in the "port" variable.
// The autodiscover service will always point to SMTPS and IMAPS (TLS-wrapped services).
// The autoconfig service will additionally announce the STARTTLS-enabled ports, specified in the "tlsport" variable.
'imap' => array(
'server' => $mail_domain,
'port' => (int)filter_var(substr(getenv('IMAPS_PORT'), strrpos(getenv('IMAPS_PORT'), ':')), FILTER_SANITIZE_NUMBER_INT),
'tlsport' => (int)filter_var(substr(getenv('IMAP_PORT'), strrpos(getenv('IMAP_PORT'), ':')), FILTER_SANITIZE_NUMBER_INT)
),
'pop3' => array(
'server' => $mail_domain,
'port' => (int)filter_var(substr(getenv('POPS_PORT'), strrpos(getenv('POPS_PORT'), ':')), FILTER_SANITIZE_NUMBER_INT),
'tlsport' => (int)filter_var(substr(getenv('POP_PORT'), strrpos(getenv('POP_PORT'), ':')), FILTER_SANITIZE_NUMBER_INT)
),
'smtp' => array(
'server' => $mail_domain,
'port' => (int)filter_var(substr(getenv('SMTPS_PORT'), strrpos(getenv('SMTPS_PORT'), ':')), FILTER_SANITIZE_NUMBER_INT),
'tlsport' => (int)filter_var(substr(getenv('SUBMISSION_PORT'), strrpos(getenv('SUBMISSION_PORT'), ':')), FILTER_SANITIZE_NUMBER_INT)
),
'activesync' => array(
'url' => 'https://' . $mail_domain . ($https_port == 443 ? '' : ':' . $https_port) . '/Microsoft-Server-ActiveSync',
),
'caldav' => array(
'server' => $mail_domain,
'port' => $https_port,
),
'carddav' => array(
'server' => $mail_domain,
'port' => $https_port,
),
);
and edited mailcow.conf
with ADDITIONAL_SAN=mail.*