OLD | NEW |
(Empty) | |
| 1 # Copyright (C) 2001-2006 Python Software Foundation |
| 2 # Author: Barry Warsaw |
| 3 # Contact: email-sig@python.org |
| 4 |
| 5 """Class representing message/* MIME documents.""" |
| 6 from __future__ import unicode_literals |
| 7 from __future__ import division |
| 8 from __future__ import absolute_import |
| 9 |
| 10 __all__ = ['MIMEMessage'] |
| 11 |
| 12 from future.backports.email import message |
| 13 from future.backports.email.mime.nonmultipart import MIMENonMultipart |
| 14 |
| 15 |
| 16 class MIMEMessage(MIMENonMultipart): |
| 17 """Class representing message/* MIME documents.""" |
| 18 |
| 19 def __init__(self, _msg, _subtype='rfc822'): |
| 20 """Create a message/* type MIME document. |
| 21 |
| 22 _msg is a message object and must be an instance of Message, or a |
| 23 derived class of Message, otherwise a TypeError is raised. |
| 24 |
| 25 Optional _subtype defines the subtype of the contained message. The |
| 26 default is "rfc822" (this is defined by the MIME standard, even though |
| 27 the term "rfc822" is technically outdated by RFC 2822). |
| 28 """ |
| 29 MIMENonMultipart.__init__(self, 'message', _subtype) |
| 30 if not isinstance(_msg, message.Message): |
| 31 raise TypeError('Argument is not an instance of Message') |
| 32 # It's convenient to use this base class method. We need to do it |
| 33 # this way or we'll get an exception |
| 34 message.Message.attach(self, _msg) |
| 35 # And be sure our default type is set correctly |
| 36 self.set_default_type('message/rfc822') |
OLD | NEW |