diff --git a/django/core/mail/utils.py b/django/core/mail/utils.py
index 322a3a1..a28ffad 100644
a
|
b
|
class CachedDnsName(object):
|
13 | 13 | |
14 | 14 | def get_fqdn(self): |
15 | 15 | if not hasattr(self, '_fqdn'): |
16 | | self._fqdn = socket.getfqdn() |
| 16 | fqdn = socket.getfqdn() |
| 17 | if '.' in fqdn: |
| 18 | self._fqdn = fqdn |
| 19 | else: |
| 20 | # logic from smtplib -- use domain literal if no fqdn can be found |
| 21 | addr = '127.0.0.1' |
| 22 | try: |
| 23 | addr = socket.gethostbyname(socket.gethostname()) |
| 24 | except socket.gaierror: |
| 25 | pass |
| 26 | self._fqdn = '[%s]' % addr |
| 27 | |
17 | 28 | return self._fqdn |
18 | 29 | |
19 | 30 | DNS_NAME = CachedDnsName() |