| 115 | # Regression for #12791 - Encode body correctly with other encodings than utf-8 |
| 116 | >>> email = EmailMessage('Subject', 'Æ e trønder æ å hærregud kor tøff æ e', 'from@example.com', ['other@example.com']) |
| 117 | >>> message = email.message() |
| 118 | >>> message.as_string() |
| 119 | 'Content-Type: text/plain; charset="utf-8"\nMIME-Version: 1.0\nContent-Transfer-Encoding: quoted-printable\nSubject: Subject\nFrom: from@example.com\nTo: other@example.com\nDate: ...\nMessage-ID: <...>\n\n=C3=86 e tr=C3=B8nder =C3=A6 =C3=A5 h=C3=A6rregud kor t=C3=B8ff =C3=A6 e' |
| 120 | |
| 121 | >>> email.encoding = 'iso-8859-1' |
| 122 | >>> message = email.message() |
| 123 | >>> message.as_string() |
| 124 | 'Content-Type: text/plain; charset="iso-8859-1"\nMIME-Version: 1.0\nContent-Transfer-Encoding: quoted-printable\nSubject: Subject\nFrom: from@example.com\nTo: other@example.com\nDate: ...\nMessage-ID: <...>\n\n=C6 e tr=F8nder =E6 =E5 h=E6rregud kor t=F8ff =E6 e' |
| 125 | |
| 126 | # Make sure MIME attachments also works correctly with other encodings than utf-8 |
| 127 | >>> text_content = 'Firstname Sürname is a great guy.' |
| 128 | >>> html_content = '<p>Firstname Sürname is a <strong>great</strong> guy.</p>' |
| 129 | >>> msg = EmailMultiAlternatives('Subject', text_content, 'from@example.com', ['to@example.com']) |
| 130 | >>> msg.encoding = 'iso-8859-1' |
| 131 | >>> msg.attach_alternative(html_content, "text/html") |
| 132 | >>> msg.message().as_string() |
| 133 | 'Content-Type: multipart/alternative; boundary="===============...=="\nMIME-Version: 1.0\nSubject: Subject\nFrom: from@example.com\nTo: to@example.com\nDate: ...\nMessage-ID: <...>\n\n--===============...==\nContent-Type: text/plain; charset="iso-8859-1"\nMIME-Version: 1.0\nContent-Transfer-Encoding: quoted-printable\n\nFirstname S=FCrname is a great guy.\n--===============...==\nContent-Type: text/html; charset="iso-8859-1"\nMIME-Version: 1.0\nContent-Transfer-Encoding: quoted-printable\n\n<p>Firstname S=FCrname is a <strong>great</strong> guy.</p>\n--===============...==--' |
| 134 | |