I copied and pasted sections of the Python
mailboxdocs into ChatGPT-4 and asked it to distill the information in short bullets for me. This is what it came up with.
- Interface for format-specific subclasses
- Dictionary-like with small keys for messages
- Add/remove messages using
add(),remove(),discard(), anddel - Default iterator iterates over messages, not keys
add(message): Add message to the mailbox and return the keyremove(key),__delitem__(key),discard(key): Delete message corresponding to key__setitem__(key, message): Replace message corresponding to key with messageiterkeys(),keys(): Return iterator or list of keysitervalues(),__iter__(),values(): Return iterator or list of message representationsiteritems(),items(): Return iterator or list of (key, message) pairsget(key, default=None),__getitem__(key): Return message representation or default/raise KeyErrorget_message(key): Return message representation as format-specific Message subclassget_bytes(key): Return byte representation of the messageget_string(key): Return string representation of the messageget_file(key): Return file-like representation of the message__contains__(key): Check if key corresponds to a message__len__(): Return message count in the mailboxclear(): Delete all messages from the mailboxpop(key, default=None): Return message representation and delete messagepopitem(): Return and delete an arbitrary (key, message) pairupdate(arg): Update mailbox with key-to-message mapping or iterable of (key, message) pairsflush(): Write pending changes to the filesystemlock(): Acquire an exclusive advisory lock on the mailboxunlock(): Release the lock on the mailboxclose(): Flush the mailbox, unlock it, and close any open files
- A message with mbox-specific behaviors
- Messages stored in a single file with "From " line, Status, and X-Status headers
- Flags: R (Read), O (Old), D (Deleted), F (Flagged), A (Answered)
get_from(): Get "From " lineset_from(from_, time_=None): Set "From " line and optional timeget_flags(): Get current flagsset_flags(flags): Set flags and unset othersadd_flag(flag): Add specified flag(s) without changing othersremove_flag(flag): Remove specified flag(s) without changing others
- mboxMessage instances can be created from MaildirMessage, MHMessage, BabylMessage, or MMDFMessage instances with specific flag and state conversions
- A subclass of Mailbox for mailboxes in mbox format
- Stores all messages in a single file with "From " line indicating start of each message
- mbox format variations exist, but mbox implements the original format (mboxo)
mailbox.mbox(path, factory=None, create=True): mbox constructorfactory: Callable object for custom message representation (default: mboxMessage)create: If True, creates mailbox if it doesn't exist
get_file(key): Using the file afterflush()orclose()may result in unpredictable results or exceptionslock(),unlock(): Uses dot locking and, if available, flock() and lockf() system calls
Then I asked it to do the same thing with the
mboxman page
- Format for mail message storage on Unix systems
- Text file containing multiple email messages
- Each message consists of a postmark and an email message formatted according to RFC5322
- Postmark line: "From" followed by a space, sender address, whitespace, and timestamp
- Quoting schemes: MBOXO (quotes plain "From " lines) and MBOXRD (quotes all "From " lines)
- MBOXCL: MBOXO with "Content-Length" field
- mbox files should be locked when accessed
- Three common locking mechanisms:
- fcntl(2) locking: used on POSIX-compliant systems, recommended for NFS access
- flock(2) locking: used on BSD-based systems
- Dotlocking: used on various systems, involves creating a hard link named folder.lock
/var/spool/mail/$LOGNAME: Incoming mail folder$HOME/mbox: User's archived mail messages$HOME/Mail/: Directory commonly used to hold mbox format folders
- mutt(1), fcntl(2), flock(2), link(2), stat(2), maildir(5), mmdf(5), RFC976, RFC4155, RFC5322