class email.mime.text.MIMEText(_text, _subtype='plain', _charset=None)
Module: email.mime.text
A subclass of MIMENonMultipart
, the MIMEText
class is used to create MIME objects of major type text. _text is the string for the payload. _subtype is the minor type and defaults to plain. _charset is the character set of the text and is passed as an argument to the MIMENonMultipart
constructor; it defaults to us-ascii
if the string contains only ascii
code points, and utf-8
otherwise. The _charset parameter accepts either a string or a Charset
instance.
Unless the _charset argument is explicitly set to None
, the MIMEText object created will have both a Content-Type header with a charset
parameter, and a Content-Transfer-Endcoding header. This means that a subsequent set_payload
call will not result in an encoded payload, even if a charset is passed in the set_payload
command. You can “reset” this behavior by deleting the Content-Transfer-Encoding
header, after which a set_payload
call will automatically encode the new payload (and add a new Content-Transfer-Encoding header).
Changed in version 3.5: _charset also accepts Charset
instances.
Please login to continue.