mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-23 05:11:04 -05:00
Fix UnicodeEncodeError error while reporting invalid email address.
Fixes #148.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import json
|
||||
from traceback import format_exception_only
|
||||
|
||||
@@ -40,7 +42,7 @@ class AnymailError(Exception):
|
||||
|
||||
def __str__(self):
|
||||
parts = [
|
||||
" ".join([str(arg) for arg in self.args]),
|
||||
" ".join([six.text_type(arg) for arg in self.args]),
|
||||
self.describe_raised_from(),
|
||||
self.describe_send(),
|
||||
self.describe_response(),
|
||||
|
||||
@@ -158,13 +158,13 @@ def parse_address_list(address_list, field=None):
|
||||
for address in parsed:
|
||||
if address.username == '' or address.domain == '':
|
||||
# Django SMTP allows username-only emails, but they're not meaningful with an ESP
|
||||
errmsg = "Invalid email address '{problem}' parsed from '{source}'{where}.".format(
|
||||
errmsg = u"Invalid email address '{problem}' parsed from '{source}'{where}.".format(
|
||||
problem=address.addr_spec,
|
||||
source=", ".join(address_list_strings),
|
||||
where=" in `%s`" % field if field else "",
|
||||
source=u", ".join(address_list_strings),
|
||||
where=u" in `%s`" % field if field else "",
|
||||
)
|
||||
if len(parsed) > len(address_list):
|
||||
errmsg += " (Maybe missing quotes around a display-name?)"
|
||||
errmsg += u" (Maybe missing quotes around a display-name?)"
|
||||
raise AnymailInvalidAddress(errmsg)
|
||||
|
||||
return parsed
|
||||
|
||||
Reference in New Issue
Block a user