from the raw message headers. As we learned in Chapters 9 and 11, the underlying
tkinter toolkit generally renders decoded str better than raw bytes.
So far, we’ve displayed Internationalized emails, but PyMailGUI allows us to send them
as well, and handles any encoding tasks implied by the text content. Figure 14-43 shows
the result of running replies and forwards to the Russian language email, with the To
address changed to protect the innocent. Headers in the view window were decoded
for display, encoded when sent, and decoded back again for display; text parts in the
mail body were similarly decoded, encoded, and re-decoded along the way and headers
are also decoded within the “>” quoted original text inserted at the end of the message.
And finally, Figure 14-44 shows a portion of the raw text of the Russian language reply
message that appears in the lower right of the formatted view of Figure 14-43. Again,
double-click to see these details live. Notice how both headers and body text have been
encoded per email and MIME standards.
As configured, the body text is always MIME encoded to UTF-8 when sent if it fails to
encode as ASCII, the default setting in the mailconfig module. Other defaults can be
used if desired and will be encoded appropriately for sends; in fact, text that won’t work
in the full text of email is MIME encoded the same way as binary parts such as images.
This is also true for non-Internationalized character sets—the text part of a message
written in English with any non-ASCII quotes, for example, will be UTF-8 and Base64
encoded in the same way as the message in Figure 14-44, and assume that the recipient’s
email reader will decode (any reasonable modern email client will). This allows non-
ASCII text to be embedded in the full email text sent.
Figure 14-42. Main text parts of Internationalized mails, decoded in PyEdit pop-ups
A PyMailGUI Demo| 1057