diff --git a/django/core/mail/message.py b/django/core/mail/message.py index 39f7afc61b..7347391f0b 100644 --- a/django/core/mail/message.py +++ b/django/core/mail/message.py @@ -311,6 +311,10 @@ class EmailMessage(object): mimetype = DEFAULT_ATTACHMENT_MIME_TYPE attachment = self._create_mime_attachment(content, mimetype) if filename: + try: + filename = filename.encode('ascii') + except UnicodeEncodeError: + filename = ('utf-8', '', filename.encode('utf-8')) attachment.add_header('Content-Disposition', 'attachment', filename=filename) return attachment diff --git a/docs/ref/unicode.txt b/docs/ref/unicode.txt index 08f738c879..1286dcfdd0 100644 --- a/docs/ref/unicode.txt +++ b/docs/ref/unicode.txt @@ -322,7 +322,9 @@ can be non-ASCII:: sender = u'Arnbjörg Ráðormsdóttir ' recipients = ['Fred