"""Email message and email sending related helper functions."""importsocket# Cache the hostname, but do it lazily: socket.getfqdn() can take a couple of# seconds, which slows down the restart of the server.classCachedDnsName(object):def__str__(self):returnself.get_fqdn()defget_fqdn(self):ifnothasattr(self,'_fqdn'):self._fqdn=socket.getfqdn()returnself._fqdnDNS_NAME=CachedDnsName()