mirror of
https://github.com/python/cpython.git
synced 2025-07-18 16:55:20 +00:00

Briefly (from the NEWS file): - Updates for the email package: + All deprecated APIs that in email 2.x issued warnings have been removed: _encoder argument to the MIMEText constructor, Message.add_payload(), Utils.dump_address_pair(), Utils.decode(), Utils.encode() + New deprecations: Generator.__call__(), Message.get_type(), Message.get_main_type(), Message.get_subtype(), the 'strict' argument to the Parser constructor. These will be removed in email 3.1. + Support for Python earlier than 2.3 has been removed (see PEP 291). + All defect classes have been renamed to end in 'Defect'. + Some FeedParser fixes; also a MultipartInvariantViolationDefect will be added to messages that claim to be multipart but really aren't. + Updates to documentation.
28 lines
981 B
Python
28 lines
981 B
Python
# Copyright (C) 2001-2004 Python Software Foundation
|
||
# Author: Barry Warsaw
|
||
# Contact: email-sig@python.org
|
||
|
||
"""Class representing text/* type MIME documents."""
|
||
|
||
from email.MIMENonMultipart import MIMENonMultipart
|
||
from email.Encoders import encode_7or8bit
|
||
|
||
|
||
|
||
class MIMEText(MIMENonMultipart):
|
||
"""Class for generating text/* type MIME documents."""
|
||
|
||
def __init__(self, _text, _subtype='plain', _charset='us-ascii'):
|
||
"""Create a text/* type MIME document.
|
||
|
||
_text is the string for this message object.
|
||
|
||
_subtype is the MIME sub content type, defaulting to "plain".
|
||
|
||
_charset is the character set parameter added to the Content-Type
|
||
header. This defaults to "us-ascii". Note that as a side-effect, the
|
||
Content-Transfer-Encoding header will also be set.
|
||
"""
|
||
MIMENonMultipart.__init__(self, 'text', _subtype,
|
||
**{'charset': _charset})
|
||
self.set_payload(_text, _charset)
|