Decode message

Max Destiny
Max Destiny used Ask the Experts™
well  how can I decode the emails  so i can get plain text?

import poplib;

import io;

import string;

import encodings;


 server = poplib.POP3_SSL("",poplib.POP3_SSL_PORT);




response = server.user('');

response1 =  server.pass_('XXXXXXXX');



# download the first message in the list

messages = server.list();



Open in new window

help appreciated
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
David FavorFractional CTO
Distinguished Expert 2018

You'll do this via...

1) Retrieve the message from where it lives.

Your code above looks like it's starting to bring up a server, rather than a client.

You have to connect as a client to an existing server.

2) Then break the message apart into components, might be text or MIME.

3) Then decode each component, which will occur differently based on MIME type.

Based on your code above, this might be a new process for you.

Likely best to start with some GitHub sample code. Likely there are many snippets you'll find useful.

For a 100% solution, you'll have to build a tool like the NeoMutt email client from scratch... which will be... a substantial task...

You might provide an example of an email your trying to decode.

If you have a specific type of email, this will be far simpler than a generalized approach for decoding all possible email that can every be generated.
nociSoftware Engineer
Distinguished Expert 2018

The email module can do the heavylifting for you:

Some examples of it's use:
EirmanChief Operations Manager

I suggest that you download and install Pegasus Email (It's free)

If the message is still on the server you can download it,
choosing whether you want to leave it on the server.

Then ....
View the RAW message by clicking on the Raw View tab
Truncated to protect my privacy
It may give you the decoded view you are looking for,
but seeing how the message is composed can be useful.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial