3

https://docs.python.org/2/library/email.encoders.html lists way to encode the email payload. Is there a way to decode the payload that was received over email?

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.

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?

1 Answer 1

5

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:

import quopri
quopri.decodestring(email_multipart_payload) # payload has 7bit encoded data
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.