diff --git a/django/core/mail/message.py b/django/core/mail/message.py
index 39f7afc..7347391 100644
a
|
b
|
class EmailMessage(object):
|
311 | 311 | mimetype = DEFAULT_ATTACHMENT_MIME_TYPE |
312 | 312 | attachment = self._create_mime_attachment(content, mimetype) |
313 | 313 | if filename: |
| 314 | try: |
| 315 | filename = filename.encode('ascii') |
| 316 | except UnicodeEncodeError: |
| 317 | filename = ('utf-8', '', filename.encode('utf-8')) |
314 | 318 | attachment.add_header('Content-Disposition', 'attachment', |
315 | 319 | filename=filename) |
316 | 320 | return attachment |
diff --git a/tests/regressiontests/mail/tests.py b/tests/regressiontests/mail/tests.py
index 52e251f..ed44cb9 100644
a
|
b
|
class MailTests(TestCase):
|
189 | 189 | msg = EmailMultiAlternatives(subject, text_content, from_email, [to], headers=headers) |
190 | 190 | msg.attach_alternative(html_content, "text/html") |
191 | 191 | msg.attach("an attachment.pdf", "%PDF-1.4.%...", mimetype="application/pdf") |
| 192 | # Test also with unicode in file name |
| 193 | msg.attach(u"une pièce jointe.pdf", "%PDF-1.4.%...", mimetype="application/pdf") |
192 | 194 | msg_str = msg.message().as_string() |
193 | 195 | message = email.message_from_string(msg_str) |
194 | 196 | self.assertTrue(message.is_multipart()) |
… |
… |
class MailTests(TestCase):
|
197 | 199 | payload = message.get_payload() |
198 | 200 | self.assertEqual(payload[0].get_content_type(), 'multipart/alternative') |
199 | 201 | self.assertEqual(payload[1].get_content_type(), 'application/pdf') |
| 202 | self.assertEqual(payload[2].get_filename(), u'une pièce jointe.pdf') |
200 | 203 | |
201 | 204 | def test_dummy_backend(self): |
202 | 205 | """ |