mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Use the IDNA encoding for non-ascii hostnames
This commit is contained in:
parent
b91fb7b502
commit
26e978bc2f
@ -9,9 +9,8 @@ This module implements a simple commandline SMTP client that supports:
|
|||||||
* Background delivery with failures being saved in a maildir mailbox
|
* Background delivery with failures being saved in a maildir mailbox
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import sys, traceback, os, socket
|
import sys, traceback, os, socket, encodings.idna as idna
|
||||||
from calibre import isbytestring
|
from calibre import isbytestring, force_unicode
|
||||||
from calibre.utils.filenames import ascii_text
|
|
||||||
|
|
||||||
def create_mail(from_, to, subject, text=None, attachment_data=None,
|
def create_mail(from_, to, subject, text=None, attachment_data=None,
|
||||||
attachment_type=None, attachment_name=None):
|
attachment_type=None, attachment_name=None):
|
||||||
@ -71,7 +70,7 @@ def safe_localhost():
|
|||||||
# 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:
|
||||||
local_hostname = ascii_text(fqdn)
|
local_hostname = idna.ToASCII(force_unicode(fqdn))
|
||||||
except:
|
except:
|
||||||
local_hostname = 'localhost.localdomain'
|
local_hostname = 'localhost.localdomain'
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user