The HOSTNAME environment var only contains the first part of the domain name. Use the fqdn to have it entirely.