Python: decode 7bit or 8bit encoded email body
<p><a href="https://docs.python.org/2/library/email.encoders.html" rel="nofollow">https://docs.python.org/2/library/email.encoders.html</a> lists way to encode the email payload. Is there a way to decode the payload that was received over email?</p>

<p>I need to decode the html body from the email encoded in base64 or 7/8bit or quoted printable formats and mine some data. Luckily there are modules that can deal with quoted printable(quopri) and base64 formats. </p>

<p>I tried finding one for the 7/8bit encoded emails, but was unable to find anything satisfactory. What is the best way to decode such email payloads?</p>

<p>Looks like the easiest way to decode 7bit data is to use the quopri module in python. Essentially quoted-printable is a format which is used to send 8bit data over a 7bit channel. The code below is working well for me:</p>

<pre><code>import quopri
quopri.decodestring(email_multipart_payload) # payload has 7bit encoded data
</code></pre>

python email encoding html-email