mboxutils - Unix mailbox utilities¶
Useful utilities for working with the mbox-formatted mailboxes. Credit to Mark Williams for these.
mbox_readonlydir(path, factory=None, create=True, maxmem=1048576)[source]¶
A subclass of
mailbox.mboxsuitable for use with mboxs insides a read-only mail directory, e.g.,
/var/mail. Otherwise the API is exactly the same as the built-in mbox.
Deletes messages via truncation, in the manner of Heirloom mailx.
- path (str) – Path to the mbox file.
- factory (type) – Message type (defaults to
- create (bool) – Create mailbox if it does not exist. (defaults
- maxmem (int) – Specifies, in bytes, the largest sized mailbox to attempt to copy into memory. Larger mailboxes will be copied incrementally which is more hazardous. (defaults to 4MB)
Because this truncates and rewrites parts of the mbox file, this class can corrupt your mailbox. Only use this if you know the built-in
mailbox.mboxdoes not work for your use case.