Ubuntu set hostname via hostnamectl with multiple virtual hosts

Solution 1:

Hostnames for most part are internal settings - your DNS settings will enable traffic to reach your server if the FQDN is set, and the point of virtualhosts is to serve different sites based on what hostname it is. In the case of email, its just one server, and your mail server config (the flurdy guide is pretty useful - and stores these in a database) should handle it.

You don't generally need to set it there, and the hostname of a system can be independent of its domain name, and your mailserver can respond to one or more domains, the same way apache can do virtualhosts.

You set up the appropriate nameserver records for the domains you want to serve (mx and/or a/aaaa names) and set the mail server to listen for and serve those domains. As such, you don't 'need' to set the hostname to anything specific, and its better leaving it as a identifier for whoever's logged in.