diff --git a/src/calibre/utils/smtp.py b/src/calibre/utils/smtp.py index b716099f5b..68dfdde3c9 100644 --- a/src/calibre/utils/smtp.py +++ b/src/calibre/utils/smtp.py @@ -34,7 +34,13 @@ def safe_localhost(): # 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 # instead (essentially an encoded IP address like [A.B.C.D]). - fqdn = decode_fqdn(socket.getfqdn()) + try: + 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 != '.': # Some mail servers have problems with non-ascii local hostnames, see # https://bugs.launchpad.net/bugs/1256549