Fix sending email failing of the computer's FQDN is set to a single period. Fixes #1730166 [Failing to send book by email](https://bugs.launchpad.net/calibre/+bug/1730166)

This commit is contained in:
Kovid Goyal 2017-11-05 13:54:34 +05:30
parent ddcbe31727
commit 9daf8f7f7e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 3 additions and 2 deletions

View File

@ -18,7 +18,7 @@ def safe_localhost():
# 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]).
fqdn = socket.getfqdn() fqdn = socket.getfqdn()
if '.' in 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
try: try:

View File

@ -279,7 +279,7 @@ class SMTP:
# 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]).
fqdn = socket.getfqdn() fqdn = socket.getfqdn()
if '.' in fqdn: if '.' in fqdn and fqdn != '.':
self.local_hostname = fqdn self.local_hostname = fqdn
else: else:
# We can't find an fqdn hostname, so use a domain literal # We can't find an fqdn hostname, so use a domain literal
@ -800,6 +800,7 @@ class SMTP:
self.close() self.close()
return res return res
if _have_ssl: if _have_ssl:
class SMTP_SSL(SMTP): class SMTP_SSL(SMTP):