On this page
mailbox.MaildirMessage
Prev: mailbox.Maildir | Up: mailbox | Next: mailbox.mbox
Rel: mailbox.Babyl, mailbox.BabylMessage, mailbox.Error, mailbox.ExternalClashError
Ref: docs.python.org — mailbox.MaildirMessage
Tags: #public #python3 #stdlib #mailbox
Import
import mailbox
from mailbox import MaildirMessage
Signature & Overview
mailbox.MaildirMessage(message=None)
Message with Maildir-specific properties.
Methods & Attributes
MaildirMessage.add_flag(self, flag)— Set the given flag(s) without changing others.MaildirMessage.add_header(self, _name, _value, **_params)— Extended header setting.MaildirMessage.as_bytes(self, unixfrom=False, policy=None)— Return the entire formatted message as a bytes object.MaildirMessage.as_string(self, unixfrom=False, maxheaderlen=0, policy=None)— Return the entire formatted message as a string.MaildirMessage.attach(self, payload)— Add the given payload to the current payload.MaildirMessage.del_param(self, param, header='content-type', requote=True)— Remove the given parameter completely from the Content-Type header.MaildirMessage.get(self, name, failobj=None)— Get a header value.MaildirMessage.get_all(self, name, failobj=None)— Return a list of all the values for the named field.MaildirMessage.get_boundary(self, failobj=None)— Return the boundary associated with the payload if present.MaildirMessage.get_charset(self)— Return the Charset instance associated with the message's payload.MaildirMessage.get_charsets(self, failobj=None)— Return a list containing the charset(s) used in this message.MaildirMessage.get_content_charset(self, failobj=None)— Return the charset parameter of the Content-Type header.MaildirMessage.get_content_disposition(self)— Return the message's content-disposition if it exists, or None.MaildirMessage.get_content_maintype(self)— Return the message's main content type.MaildirMessage.get_content_subtype(self)— Returns the message's sub-content type.MaildirMessage.get_content_type(self)— Return the message's content type.MaildirMessage.get_date(self)— Return delivery date of message, in seconds since the epoch.MaildirMessage.get_default_type(self)— Return the 'default' content type.MaildirMessage.get_filename(self, failobj=None)— Return the filename associated with the payload if present.MaildirMessage.get_flags(self)— Return as a string the flags that are set.MaildirMessage.get_info(self)— Get the message's "info" as a string.MaildirMessage.get_param(self, param, failobj=None, header='content-type', unquote=True)— Return the parameter value if found in the Content-Type header.MaildirMessage.get_params(self, failobj=None, header='content-type', unquote=True)— Return the message's Content-Type parameters, as a list.MaildirMessage.get_payload(self, i=None, decode=False)— Return a reference to the payload.MaildirMessage.get_subdir(self)— Return 'new' or 'cur'.MaildirMessage.get_unixfrom(self)—MaildirMessage.get_unixfrommethod/property.MaildirMessage.is_multipart(self)— Return True if the message consists of multiple parts.MaildirMessage.items(self)— Get all the message's header fields and values.MaildirMessage.keys(self)— Return a list of all the message's header field names.MaildirMessage.raw_items(self)— Return the (name, value) header pairs without modification.MaildirMessage.remove_flag(self, flag)— Unset the given string flag(s) without changing others.MaildirMessage.replace_header(self, _name, _value)— Replace a header.MaildirMessage.set_boundary(self, boundary)— Set the boundary parameter in Content-Type to 'boundary'.MaildirMessage.set_charset(self, charset)— Set the charset of the payload to a given character set.MaildirMessage.set_date(self, date)— Set delivery date of message, in seconds since the epoch.MaildirMessage.set_default_type(self, ctype)— Set the 'default' content type.MaildirMessage.set_flags(self, flags)— Set the given flags and unset all others.MaildirMessage.set_info(self, info)— Set the message's "info" string.MaildirMessage.set_param(self, param, value, header='Content-Type', requote=True, charset=None, language='', replace=False)— Set a parameter in the Content-Type header.MaildirMessage.set_payload(self, payload, charset=None)— Set the payload to the given value.
Usage
import mailbox
msg = mailbox.MaildirMessage()
msg.set_subdir("cur")
msg.add_flag("S") # Seen
assert msg.get_subdir() == "cur" and "S" in msg.get_flags()
Gotchas
- Standard flags:
S(Seen),R(Replied),F(Flagged),T(Trashed),D(Draft).
REPL Inspect
from mailbox import MaildirMessage
help(MaildirMessage)
Linked from
Related notes
- tuts/python3/stdlib_module/mailbox/Maildir Linked here; links to this page; shared tags: #mailbox, #stdlib
- tuts/python3/stdlib_module/mailbox/mbox 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/mboxMessage shared tags: #mailbox, #stdlib