Function
email.quopriMIME.header_encode

Signature

header_encode(header, charset='iso-8859-1', keep_eols=False, maxlinelen=76, eol='\n')

Documentation String

Encode a single header line with quoted-printable (like) encoding.

Defined in RFC 2045, this `Q' encoding is similar to quoted-printable, but used specifically for email header fields to allow charsets with mostly 7 bit characters (and some 8 bit) to remain more or less readable in non-RFC 2045 aware mail clients.

charset names the character set to use to encode the header. It defaults to iso-8859-1.

The resulting string will be in the form:

"=?charset?q?I_f=E2rt_in_your_g=E8n=E8ral_dire=E7tion?\n =?charset?q?Silly_=C8nglish_Kn=EEghts?="

with each line wrapped safely at, at most, maxlinelen characters (defaults to 76 characters). If maxlinelen is None, the entire string is encoded in one chunk with no splitting.

End-of-line characters (\r, \n, \r\n) will be automatically converted to the canonical email line separator \r\n unless the keep_eols parameter is True (the default is False).

Each line of the header will be terminated in the value of eol, which defaults to "\n". Set this to "\r\n" if you are using the result of this function directly in email.