eryx
ad2:
read -p " Subdomain Name (SUBDOMAIN.example.com) ? " SUBDOMAIN
read -p " Domainname (subdomain.EXAMPLE.COM) ? " DOMAIN
so: $DOMAIN=example.com
than: hostnamectl set-hostname $DOMAIN
so: hostname=example.com
but hostname should be only subdomain or subdomain.example.com
ad3: it is related to point 2.
If hostname=$SUBDOMAIN than autodiscover config file must name autodiscover.ini and should contain:
[database]
host=$DBHOST
username=$DBUSER
password=$DBPASSWD
dbname=$DBNAME
[exchange]
hostname=$FQDN
where $FQDN=$SUBDOMAIN.$DOMAIN
php script which generate Autodiscover.xml looks in /etc/gromox/autodiscover.ini at chapter [exchange] for variable hostname. This variable must contain FQDN. If the chapter [exchange] is missing or autodiscover.ini is missing (actual name is autodiscover.cfg) the hostname is taken from system hostname. And when system hostname is: hostnamectl set-hostname $DOMAIN
the URL for Autodiscover.xml are: https://example.com/.... but you need https://hostname.domain.com/...
and my personal opinion:
at mailserver which host mailboxes for more domains I do not want to have hostname the same like primary email domain which must be in public dns records. Therefore I need autodiscover.ini with above content.