Windows: Fix sending email on computers with non-ascii computer names

This commit is contained in:
Kovid Goyal 2020-10-31 19:00:32 +05:30
parent 1191be9cb0
commit 0d4559f0fe
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -34,7 +34,13 @@ def safe_localhost():
# RFC 2821 says we should use the fqdn in the EHLO/HELO verb, and # RFC 2821 says we should use the fqdn in the EHLO/HELO verb, and
# if that can't be calculated, that we should use a domain literal # if that can't be calculated, that we should use a domain literal
# instead (essentially an encoded IP address like [A.B.C.D]). # instead (essentially an encoded IP address like [A.B.C.D]).
try:
fqdn = decode_fqdn(socket.getfqdn()) fqdn = decode_fqdn(socket.getfqdn())
except UnicodeDecodeError:
if not iswindows:
raise
from calibre_extensions.winutil import get_computer_name
fqdn = get_computer_name()
if '.' in fqdn and fqdn != '.': if '.' in fqdn and fqdn != '.':
# Some mail servers have problems with non-ascii local hostnames, see # Some mail servers have problems with non-ascii local hostnames, see
# https://bugs.launchpad.net/bugs/1256549 # https://bugs.launchpad.net/bugs/1256549