From d4ef8414957e8e5db43d396eeb77bac4cf654bf8 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Tue, 21 Dec 2010 15:26:49 +0000 Subject: 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 --- tests/regressiontests/mail/tests.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests') diff --git a/tests/regressiontests/mail/tests.py b/tests/regressiontests/mail/tests.py index 327159eb7f..a6cd60e2ac 100644 --- a/tests/regressiontests/mail/tests.py +++ b/tests/regressiontests/mail/tests.py @@ -408,3 +408,25 @@ class MailTests(TestCase): self.assertEqual(message.from_email, from_email) self.assertEqual(message.to, [to_email]) self.assertTrue(message.message().as_string().startswith('Content-Type: text/plain; charset="utf-8"\nMIME-Version: 1.0\nContent-Transfer-Encoding: quoted-printable\nSubject: Subject\nFrom: =?utf-8?b?ZnLDtm1Aw7bDpMO8LmNvbQ==?=\nTo: =?utf-8?b?dMO2QMO2w6TDvC5jb20=?=')) + + def test_idn_smtp_send(self): + import smtplib + smtplib.SMTP = MockSMTP + from_email = u'fröm@öäü.com' + to_email = u'tö@öäü.com' + connection = mail.get_connection('django.core.mail.backends.smtp.EmailBackend') + self.assertTrue(send_mail('Subject', 'Content', from_email, [to_email], connection=connection)) + +class MockSMTP(object): + def __init__(self, host='', port=0, local_hostname=None, + timeout=1): + pass + + def sendmail(self, from_addr, to_addrs, msg, mail_options=[], + rcpt_options=[]): + for addr in to_addrs: + str(addr.split('@', 1)[-1]) + return {} + + def quit(self): + return 0 -- cgit v1.3