decoded addresses (possibly in full nameformat)client must parse to split these on delimitersor use multiline inputnote that smtp allows full nameformat in recipients ebcc addrs now used for send/envelopebut header is dropped eduplicate recipients removedelse will get > copies of mailcaveatno support for multipart/alternative mailsjust /mixed"" eassume main body text is already in desired encodingclients can decode to user pickdefaultor utf fallbackeither wayemail needs either str xor bytes specificallyif fix_text_required(bodytextencoding)if not isinstance(bodytextstr)bodytext bodytext decode(bodytextencodingelseif not isinstance(bodytextbytes)bodytext bodytext encode(bodytextencodingmake message root if not attachesmsg message(msg set_payload(bodytextcharset=bodytextencodingelsemsg mimemultipart(self addattachments(msgbodytextattachesbodytextencodingattachesencodings enon-ascii hdrs encoded on sendsencode just name in addresselse smtp may drop the message completelyencodes all envelope to names (but not addralsoand assumes servers will allowmsg as_string retains any line breaks added by encoding headershdrenc mailconfig headersencodeto or 'utf- default=utf subj self encodeheader(subjhdrencfull header from self encodeaddrheader(fromhdrencemail names to [self encodeaddrheader(thdrencfor in toeach recip tos 'join(tohdr+envelope add headers to root msg['from'from msg['to'tos poss manyaddr list msg['subject'subj servers reject ';sept msg['date'email utils formatdate(curr datetimerfc utc recip to for namevalue in extrahdrsccbccx-maileretc if valueif name lower(not in ['cc''bcc']value self encodeheader(valuehdrencmsg[namevalue elsevalue [self encodeaddrheader(vhdrencfor in valuerecip +value some servers reject ['' client-side scripting