blob: 5747db5d670c8082999cc6f089dcc416db07ddba [file] [log] [blame]
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001# Copyright (C) 2001-2006 Python Software Foundation
Barry Warsawbb113862004-10-03 03:16:19 +00002# Author: Barry Warsaw
3# Contact: email-sig@python.org
Barry Warsawba925802001-09-23 03:17:28 +00004
Barry Warsawbb113862004-10-03 03:16:19 +00005"""Class representing text/* type MIME documents."""
Barry Warsawba925802001-09-23 03:17:28 +00006
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00007__all__ = ['MIMEText']
8
9from email.encoders import encode_7or8bit
10from email.mime.nonmultipart import MIMENonMultipart
Barry Warsawba925802001-09-23 03:17:28 +000011
12
Barry Warsawe968ead2001-10-04 17:05:11 +000013
Barry Warsaw524af6f2002-06-02 19:05:08 +000014class MIMEText(MIMENonMultipart):
Barry Warsawba925802001-09-23 03:17:28 +000015 """Class for generating text/* type MIME documents."""
16
Barry Warsawbb113862004-10-03 03:16:19 +000017 def __init__(self, _text, _subtype='plain', _charset='us-ascii'):
Barry Warsawba925802001-09-23 03:17:28 +000018 """Create a text/* type MIME document.
19
Barry Warsawcbec7002003-03-11 05:04:09 +000020 _text is the string for this message object.
Barry Warsawba925802001-09-23 03:17:28 +000021
Barry Warsaw3dd978d2001-09-26 05:34:30 +000022 _subtype is the MIME sub content type, defaulting to "plain".
Barry Warsawba925802001-09-23 03:17:28 +000023
Barry Warsaw2d7fab12002-10-01 00:52:27 +000024 _charset is the character set parameter added to the Content-Type
Barry Warsaw409a4c02002-04-10 21:01:31 +000025 header. This defaults to "us-ascii". Note that as a side-effect, the
Barry Warsaw2d7fab12002-10-01 00:52:27 +000026 Content-Transfer-Encoding header will also be set.
Barry Warsawba925802001-09-23 03:17:28 +000027 """
Barry Warsaw524af6f2002-06-02 19:05:08 +000028 MIMENonMultipart.__init__(self, 'text', _subtype,
29 **{'charset': _charset})
Barry Warsaw409a4c02002-04-10 21:01:31 +000030 self.set_payload(_text, _charset)