def ace_address(self):
if not is_pure_ascii(self.mailbox):
raise ValueError('address {} has no ASCII-compatable encoding'
.format(self.address.encode('utf-8')))
ace_hostname = self.hostname
if not is_pure_ascii(self.hostname):
try:
ace_hostname = idna.encode(self.hostname)
except idna.IDNAError:
raise ValueError('address {} has no ASCII-compatable encoding'
.format(self.address.encode('utf-8')))
return '{}@{}'.format(self.mailbox, ace_hostname)
评论列表
文章目录