django__django-11532
Email messages crash on non-ASCII domain when email encoding is non-unicode.
Verdict: the fix is stated in the issue (Tier A).
diff --git a/django/core/mail/utils.py b/django/core/mail/utils.py index d18dfe4667..68f9e464d6 100644 --- a/django/core/mail/utils.py +++ b/django/core/mail/utils.py @@ -14,6 +14,10 @@ class CachedDnsName: def get_fqdn(self): if not hasattr(self, '_fqdn'): self._fqdn = socket.getfqdn() + try: + self._fqdn.encode('ascii') + except UnicodeEncodeError: + self._fqdn = self._fqdn.encode('idna').decode('ascii') return self._fqdn
The text states the fix: “diff --git a/django/core/mail/utils.py b/django/core/mail/utils.py index d18dfe4667..68f9e464d6 100644 --- a/django/core/mail/utils.py +++ b/django/core/mail/utils.py @@…”
All SWE-bench Verified tasks · more django/django tasks · How the check works