On this page
mailbox.MMDFMessage
Prev: mailbox.MMDF | Up: mailbox | Next: mailbox.NoSuchMailboxError
Rel: mailbox.Babyl, mailbox.BabylMessage, mailbox.Error, mailbox.ExternalClashError
Ref: docs.python.org — mailbox.MMDFMessage
Tags: #public #python3 #stdlib #mailbox
Import
import mailbox
from mailbox import MMDFMessage
Signature & Overview
mailbox.MMDFMessage(message=None)
Message with MMDF-specific properties.
Methods & Attributes
MMDFMessage.add_flag(self, flag)— Set the given flag(s) without changing others.MMDFMessage.add_header(self, _name, _value, **_params)— Extended header setting.MMDFMessage.as_bytes(self, unixfrom=False, policy=None)— Return the entire formatted message as a bytes object.MMDFMessage.as_string(self, unixfrom=False, maxheaderlen=0, policy=None)— Return the entire formatted message as a string.MMDFMessage.attach(self, payload)— Add the given payload to the current payload.MMDFMessage.del_param(self, param, header='content-type', requote=True)— Remove the given parameter completely from the Content-Type header.MMDFMessage.get(self, name, failobj=None)— Get a header value.MMDFMessage.get_all(self, name, failobj=None)— Return a list of all the values for the named field.MMDFMessage.get_boundary(self, failobj=None)— Return the boundary associated with the payload if present.MMDFMessage.get_charset(self)— Return the Charset instance associated with the message's payload.MMDFMessage.get_charsets(self, failobj=None)— Return a list containing the charset(s) used in this message.MMDFMessage.get_content_charset(self, failobj=None)— Return the charset parameter of the Content-Type header.MMDFMessage.get_content_disposition(self)— Return the message's content-disposition if it exists, or None.MMDFMessage.get_content_maintype(self)— Return the message's main content type.MMDFMessage.get_content_subtype(self)— Returns the message's sub-content type.MMDFMessage.get_content_type(self)— Return the message's content type.MMDFMessage.get_default_type(self)— Return the 'default' content type.MMDFMessage.get_filename(self, failobj=None)— Return the filename associated with the payload if present.MMDFMessage.get_flags(self)— Return as a string the flags that are set.MMDFMessage.get_from(self)— Return contents of "From " line.MMDFMessage.get_param(self, param, failobj=None, header='content-type', unquote=True)— Return the parameter value if found in the Content-Type header.MMDFMessage.get_params(self, failobj=None, header='content-type', unquote=True)— Return the message's Content-Type parameters, as a list.MMDFMessage.get_payload(self, i=None, decode=False)— Return a reference to the payload.MMDFMessage.get_unixfrom(self)—MMDFMessage.get_unixfrommethod/property.MMDFMessage.is_multipart(self)— Return True if the message consists of multiple parts.MMDFMessage.items(self)— Get all the message's header fields and values.MMDFMessage.keys(self)— Return a list of all the message's header field names.MMDFMessage.raw_items(self)— Return the (name, value) header pairs without modification.MMDFMessage.remove_flag(self, flag)— Unset the given string flag(s) without changing others.MMDFMessage.replace_header(self, _name, _value)— Replace a header.MMDFMessage.set_boundary(self, boundary)— Set the boundary parameter in Content-Type to 'boundary'.MMDFMessage.set_charset(self, charset)— Set the charset of the payload to a given character set.MMDFMessage.set_default_type(self, ctype)— Set the 'default' content type.MMDFMessage.set_flags(self, flags)— Set the given flags and unset all others.MMDFMessage.set_from(self, from_, time_=None)— Set "From " line, formatting and appending time_ if specified.MMDFMessage.set_param(self, param, value, header='Content-Type', requote=True, charset=None, language='', replace=False)— Set a parameter in the Content-Type header.MMDFMessage.set_payload(self, payload, charset=None)— Set the payload to the given value.MMDFMessage.set_raw(self, name, value)— Store name and value in the model without modification.MMDFMessage.set_type(self, type, header='Content-Type', requote=True)— Set the main type and subtype for the Content-Type header.MMDFMessage.set_unixfrom(self, unixfrom)—MMDFMessage.set_unixfrommethod/property.
Usage
import mailbox
msg = mailbox.MMDFMessage()
msg["Subject"] = "Hi"
assert msg["Subject"] == "Hi"
Gotchas
- Message subclass for
MMDFmailboxes.
REPL Inspect
from mailbox import MMDFMessage
help(MMDFMessage)
Linked from
Related notes
- tuts/python3/stdlib_module/mailbox/MMDF Linked here; links to this page; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/NoSuchMailboxError Linked here; links to this page; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/Babyl Linked here; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/BabylMessage Linked here; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/Error Linked here; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/ExternalClashError Linked here; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/Mailbox Linked here; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/mailbox/FormatError shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/Maildir shared tags: #mailbox, #stdlib