diff --git a/django/core/mail/message.py b/django/core/mail/message.py index 7ab54144829..f12531af4c8 100644 --- a/django/core/mail/message.py +++ b/django/core/mail/message.py @@ -381,7 +381,7 @@ class EmailMessage: elif not isinstance(content, Message): # For compatibility with existing code, parse the message # into an email.Message object if it is not one already. - content = message_from_string(content) + content = message_from_string(force_text(content)) attachment = SafeMIMEMessage(content, subtype) else: diff --git a/tests/mail/attachments/file.eml b/tests/mail/attachments/file.eml new file mode 100644 index 00000000000..b5b23c1be14 --- /dev/null +++ b/tests/mail/attachments/file.eml @@ -0,0 +1,44 @@ +MIME-Version: 1.0 +Received: by 10.220.191.194 with HTTP; Wed, 11 May 2011 12:27:12 -0700 (PDT) +Date: Wed, 11 May 2011 13:27:12 -0600 +Delivered-To: jncjkq@gmail.com +Message-ID: +Subject: Test +From: Bill Jncjkq +To: bookmarks@jncjkq.net +Content-Type: multipart/mixed; boundary=bcaec54eecc63acce904a3050f79 + +--bcaec54eecc63acce904a3050f79 +Content-Type: multipart/alternative; boundary=bcaec54eecc63acce604a3050f77 + +--bcaec54eecc63acce604a3050f77 +Content-Type: text/plain; charset=ISO-8859-1 + +-- +Bill Jncjkq + +--bcaec54eecc63acce604a3050f77 +Content-Type: text/html; charset=ISO-8859-1 + +
--
Bill Jncjkq
+ +--bcaec54eecc63acce604a3050f77-- +--bcaec54eecc63acce904a3050f79 +Content-Type: text/html; charset=US-ASCII; name="bookmarks-really-short.html" +Content-Disposition: attachment; filename="bookmarks-really-short.html" +Content-Transfer-Encoding: base64 +X-Attachment-Id: f_gnknv6u70 + +PCFET0NUWVBFIE5FVFNDQVBFLUJvb2ttYXJrLWZpbGUtMT4KCTxIVE1MPgoJPE1FVEEgSFRUUC1F +UVVJVj0iQ29udGVudC1UeXBlIiBDT05URU5UPSJ0ZXh0L2h0bWw7IGNoYXJzZXQ9VVRGLTgiPgoJ +PFRpdGxlPkJvb2ttYXJrczwvVGl0bGU+Cgk8SDE+Qm9va21hcmtzPC9IMT4KCQk8RFQ+PEgzIEZP +TERFRD5UZWNoIE5ld3M8L0gzPgoJCTxETD48cD4KCQkJPERUPjxBIEhSRUY9Imh0dHA6Ly93d3cu +Y25ldC5jb20vIj5DTmV0PC9BPgoJCQk8RFQ+PEEgSFJFRj0iaHR0cDovL3d3dy53aXJlZC5jb20v +Ij5XaXJlZCBOZXdzPC9BPgoJCTwvREw+PHA+CgkJPERUPjxIMyBGT0xERUQ+VG9vbHMgYW5kIFJl +ZmVyZW5jZTwvSDM+CgkJPERMPjxwPgoJCQk8RFQ+PEEgSFJFRj0iaHR0cDovL3d3dy5tb25zdGVy +LmNvbS8iPk1vbnN0ZXIuY29tPC9BPgoJCQk8RFQ+PEEgSFJFRj0iaHR0cDovL3d3dy53ZWJtZC5j +b20vIj5XZWJNRDwvQT4KCQk8L0RMPjxwPgoJCTxEVD48SDMgRk9MREVEPlRyYXZlbDwvSDM+CgkJ +PERMPjxwPgoJCQk8RFQ+PEEgSFJFRj0iaHR0cDovL2ZvZG9ycy5jb20vIj5Gb2RvcnM8L0E+CgkJ +CTxEVD48QSBIUkVGPSJodHRwOi8vd3d3LnRyYXZlbG9jaXR5LmNvbS8iPlRyYXZlbG9jaXR5PC9B +PgoJCTwvREw+PHA+Cgk8L0RMPjxwPgo8L0hUTUw+ +--bcaec54eecc63acce904a3050f79-- \ No newline at end of file diff --git a/tests/mail/tests.py b/tests/mail/tests.py index a9d98856504..25279329973 100644 --- a/tests/mail/tests.py +++ b/tests/mail/tests.py @@ -401,6 +401,7 @@ class MailTests(HeadersCheckMixin, SimpleTestCase): ('file_png', None), ('file_txt.png', 'image/png'), ('file_png.txt', 'text/plain'), + ('file.eml', 'message/rfc822'), ) test_mimetypes = ['text/plain', 'image/png', None]