diff options
| author | Jannis Leidel <jannis@leidel.info> | 2010-12-21 15:26:49 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2010-12-21 15:26:49 +0000 |
| commit | d4ef8414957e8e5db43d396eeb77bac4cf654bf8 (patch) | |
| tree | 3c4b600f2b7e65157f02afec2833bb56794587ab /django | |
| parent | 673e6fc7fb243ed44841b9969d26a161c25733b3 (diff) | |
Fixed #14301 -- Further refine changes made in r14216 to support non-ASCII characters in email addresses. Thanks, Claude Peroz and Andi Albrecht.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15006 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/mail/backends/smtp.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/django/core/mail/backends/smtp.py b/django/core/mail/backends/smtp.py index 63efe438d3..3b2962f7d8 100644 --- a/django/core/mail/backends/smtp.py +++ b/django/core/mail/backends/smtp.py @@ -91,13 +91,19 @@ class EmailBackend(BaseEmailBackend): self._lock.release() return num_sent + def _sanitize(self, email): + name, domain = email.split('@', 1) + email = '@'.join([name, domain.encode('idna')]) + return email + def _send(self, email_message): """A helper method that does the actual sending.""" if not email_message.recipients(): return False + from_email = self._sanitize(email_message.from_email) + recipients = map(self._sanitize, email_message.recipients()) try: - self.connection.sendmail(email_message.from_email, - email_message.recipients(), + self.connection.sendmail(from_email, recipients, email_message.message().as_string()) except: if not self.fail_silently: |
