mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-04-21 17:53:23 +02:00
Use the IDNA encoding for non-ascii hostnames
This commit is contained in:
parent
b91fb7b502
commit
26e978bc2f
1 changed files with 3 additions and 4 deletions
|
|
@ -9,9 +9,8 @@
|
|||
* Background delivery with failures being saved in a maildir mailbox
|
||||
'''
|
||||
|
||||
import sys, traceback, os, socket
|
||||
from calibre import isbytestring
|
||||
from calibre.utils.filenames import ascii_text
|
||||
import sys, traceback, os, socket, encodings.idna as idna
|
||||
from calibre import isbytestring, force_unicode
|
||||
|
||||
def create_mail(from_, to, subject, text=None, attachment_data=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
|
||||
# https://bugs.launchpad.net/bugs/1256549
|
||||
try:
|
||||
local_hostname = ascii_text(fqdn)
|
||||
local_hostname = idna.ToASCII(force_unicode(fqdn))
|
||||
except:
|
||||
local_hostname = 'localhost.localdomain'
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in a new issue