M
M
mx60012017-05-21 21:40:42
Django
mx6001, 2017-05-21 21:40:42

Why does Django have strange encoding when sending email?

Sending HTML:

msg = EmailMessage(subject, HTML, from_user, [email])
msg.content_subtype = "html"
msg.send()

For some reason, all messages in places where there are quotes or an equal sign adds 3D :
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DU=
TF-8">

<td style=3D"vertical-align: top;    backgr=
ound: #2D3349; text-align: center;border-radius: 3px 3px 0 0;padding: 40px =
0px;">

The text itself in the message looks like this:
=D0=A4=D0=BE=D0=
=BD=D0=B4 =D0=90=D0=BB=D1=8C=D1=82=D0=B5=D1=80=D0=BD=D0=B0=D1=82=D0=B8=D0=
=B2=D0=BD=D1=8B=D1=85 =D0=98=D0=BD=D0=B2=D0=B5=D1=81=D1=82=D0=B8=D1=86=D0=
=B8=D0=B9

Email headers

Content-Type: text/html; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Subject: =?utf-8?b?0JfQsNC/0YDQvtGBINC90LAg0LLQtdGA0LjRhNC40LrQsNGG0LjRjg==?=
From: [email protected]
To: [email protected]
Date: Sun, 21 May 2017 18:40:26 -0000
Message-ID: <[email protected]>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2017-05-21
@mx6001

https://www.google.com.ua/search?q=http-equiv%3D3D
The HTML is encoded with what is called quoted-printable . Basically an = at the end of a line indicates a line wrap, so
he=
llo
should be read as "hello" and not as "he llo"
because the = has this special meaning some other character (sequence) is needed to put = characters in the text literally, and that is =3D

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question