Home | History | Annotate | Download | only in mime
      1 # Copyright (C) 2001-2006 Python Software Foundation
      2 # Author: Barry Warsaw
      3 # Contact: email-sig (at] python.org
      4 
      5 """Class representing text/* type MIME documents."""
      6 
      7 __all__ = ['MIMEText']
      8 
      9 from email.encoders import encode_7or8bit
     10 from email.mime.nonmultipart import MIMENonMultipart
     11 
     12 
     13 
     15 class MIMEText(MIMENonMultipart):
     16     """Class for generating text/* type MIME documents."""
     17 
     18     def __init__(self, _text, _subtype='plain', _charset='us-ascii'):
     19         """Create a text/* type MIME document.
     20 
     21         _text is the string for this message object.
     22 
     23         _subtype is the MIME sub content type, defaulting to "plain".
     24 
     25         _charset is the character set parameter added to the Content-Type
     26         header.  This defaults to "us-ascii".  Note that as a side-effect, the
     27         Content-Transfer-Encoding header will also be set.
     28         """
     29         MIMENonMultipart.__init__(self, 'text', _subtype,
     30                                   **{'charset': _charset})
     31         self.set_payload(_text, _charset)
     32