Debian Codegraph @

django/core/mail/utils.py

raw
1 """
2 Email message and email sending related helper functions.
3 """
4
5 import socket
6
7 from django.utils.encoding import punycode
8
9
10 # Cache the hostname, but do it lazily: socket.getfqdn() can take a couple of
11 # seconds, which slows down the restart of the server.
12 class CachedDnsName:
13 def __str__(self):
14 return self.get_fqdn()
15
16 def get_fqdn(self):
17 if not hasattr(self, "_fqdn"):
18 self._fqdn = punycode(socket.getfqdn())
19 return self._fqdn
20
21
22 DNS_NAME = CachedDnsName()