add_header('content-type''text/plain' ['mime-version'' set_param('charset''us-ascii' add_header('content-transfer-encoding'' bit'data 'spamm set_payload(data decode('ascii')data read as bytes here print(mmime-version content-typetext/plaincharset="us-asciicontent-transfer-encoding bit spam print(mimetext('spam'_charset='ascii')mime-version content-typetext/plaincharset="us-asciicontent-transfer-encoding bit samebut type-specific spam to do the same for other kinds of text that require mime encodingjust insert an extra encoding stepalthough we're concerned with text parts herea similar imitative approach could address the binary parts text generation bug we met earlierm message( add_header('content-type''text/plain' ['mime-version'' set_param('charset''utf- ' add_header('content-transfer-encoding''base 'data 'spamfrom binascii import a_base add mime encode if needed data a_base (datadata read as bytes here too set_payload(data decode('ascii')print(mmime-version content-typetext/plaincharset="utf- content-transfer-encodingbase bhbq=print(mimetext( 'spam'_charset='utf- ')content-typetext/plaincharset="utf- mime-version content-transfer-encodingbase samebut type-specific bhbq=this worksbut besides the redundancy and dependency it createsto use this approach broadly we' also have to generalize to account for all the various kinds of unicode encodings and mime encodings possiblelike the email package already does internally we might also have to support encoding name synonyms to be flexibleadding further redundancy in other wordsthis requires additional workand in the endwe' still have to specialize our code for different unicode types emailparsing and composing mail content