blob: 5ef187673a1bea260d6925f3192c9e27eb94c798 [file] [log] [blame]
Barry Warsawbb113862004-10-03 03:16:19 +00001# Copyright (C) 2001-2004 Python Software Foundation
2# 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
Barry Warsaw524af6f2002-06-02 19:05:08 +00007from email.MIMENonMultipart import MIMENonMultipart
8from email.Encoders import encode_7or8bit
Barry Warsawba925802001-09-23 03:17:28 +00009
10
Barry Warsawe968ead2001-10-04 17:05:11 +000011
Barry Warsaw524af6f2002-06-02 19:05:08 +000012class MIMEText(MIMENonMultipart):
Barry Warsawba925802001-09-23 03:17:28 +000013 """Class for generating text/* type MIME documents."""
14
Barry Warsawbb113862004-10-03 03:16:19 +000015 def __init__(self, _text, _subtype='plain', _charset='us-ascii'):
Barry Warsawba925802001-09-23 03:17:28 +000016 """Create a text/* type MIME document.
17
Barry Warsawcbec7002003-03-11 05:04:09 +000018 _text is the string for this message object.
Barry Warsawba925802001-09-23 03:17:28 +000019
Barry Warsaw3dd978d2001-09-26 05:34:30 +000020 _subtype is the MIME sub content type, defaulting to "plain".
Barry Warsawba925802001-09-23 03:17:28 +000021
Barry Warsaw2d7fab12002-10-01 00:52:27 +000022 _charset is the character set parameter added to the Content-Type
Barry Warsaw409a4c02002-04-10 21:01:31 +000023 header. This defaults to "us-ascii". Note that as a side-effect, the
Barry Warsaw2d7fab12002-10-01 00:52:27 +000024 Content-Transfer-Encoding header will also be set.
Barry Warsawba925802001-09-23 03:17:28 +000025 """
Barry Warsaw524af6f2002-06-02 19:05:08 +000026 MIMENonMultipart.__init__(self, 'text', _subtype,
27 **{'charset': _charset})
Barry Warsaw409a4c02002-04-10 21:01:31 +000028 self.set_payload(_text, _charset)