composedand respect the unicode encodings in text parts and mail headers of messages fetched to make this work with the partially crippled email package in python thoughwe'll apply the following unicode policies in various email clients in this bookuse user preferences and defaults for the preparse decoding of full mail text fetched and encoding of text payloads sent use header informationif availableto decode the bytes payloads returned by get_payload when text parts must be treated as str textbut use binary mode files to finesse the issue in other contexts use formats prescribed by email standard to decode and encode message headers such as from and subject if they are not simple text apply the fix described to work around the message text generation issue for binary parts special-case construction of text message objects according to unicode types and email behavior these are not necessarily complete solutions for examplesome of this edition' email clients allow for unicode encodings for both text attachments and mail headersbut they do nothing about encoding the full text of messages sent beyond the policies inherited from smtplib and implement policies that might be inconvenient in some use cases but as we'll seedespite their limitationsour email clients will still be able to handle complex email tasks and very large set of emails againsince this story is in flux in python todaywatch this book' website for updates that may improve or be required of code that uses email in the future future email may handle unicode encodings more accurately like python xthoughbackward compatibility may be sacrificed in the process and require updates to this book' code for more on this issuesee the web as well as up-to-date python release notes although this quick tour captures the basic flavor of the interfacewe need to step up to larger examples to see more of the email package' power the next section takes us on the first of those steps console-based email client let' put together what we've learned about fetchingsendingparsingand composing email in simple but functional command-line console email tool the script in example - implements an interactive email session--users may type commands to readsendand delete email messages it uses poplib and smtplib to fetch and sendand uses the email package directly to parse and compose console-based email client