attachments composed headers when sending new mailsif header lines or the name component of an email address in address-related lines do not encode properly as ascii textwe first encode the header per email internationalization standard this is done per utf- by defaultbut mailconfig setting can request different encoding in email address pairsnames which cannot be encoded are droppedand only the email address is used it is assumed that servers will respect the encoded names in email addresses displayed text parts when viewing fetched mailunicode encoding names in message headers are used to decode whenever possible the main-text part is decoded into str unicode text per header information prior to inserting it into pyedit component the content of all other text partsas well as all binary partsis saved in bytes form in binarymode filesfrom where the part may be opened later in the gui on demand when such on-demand text parts are openedthey are displayed in pyedit pop-up windows by passing to pyedit the name of the part' binary-mode fileas well as the part' encoding name obtained from part message headers if the encoding name in text part' header is absent or fails to decodeencoding guesses are tried for main-text partsand pyedit' separate unicode policies are applied to text parts opened on demand (see --it may prompt for an encoding if not knownin addition to these ruleshtml text parts are saved in binary mode and opened in web browserrelying on the browser' own character set supportthis may in turn use tags in the html itselfguessesor user encoding selections displayed headers when viewing emailmessage headers are automatically decoded per email standards this includes both full headers such as subjectas well as the name components of all email address fields in address-related headers such as fromtoand ccand allows these components to be completely encoded or contain encoded substrings because their content gives their mime and unicode encodingsno user interaction is required to decode headers in other wordspymailgui now supports internationalized message display and composition for both payloads and headers for broadest utilitythis support is distributed across multiple packages and examples for exampleunicode decoding of full message text on fetches actually occurs deep in the imported mailtool package classes because of thisfull (unparsedmessage text is always unicode str here similarlyheaders are decoded for display here using tools implemented in mailtoolsbut headers encoding is both initiated and performed within mailtools itself on sends full text decoding illustrates the types of choices required it is done according to the fetchencoding variable in the mailconfig module this user setting is used across an the pymailgui client