all2md.options.mbox

Configuration options for MBOX (mailbox archive) parsing.

This module defines options for parsing Unix mailbox format files.

class all2md.options.mbox.MboxOptions

Bases: EmlOptions

Configuration options for MBOX-to-Markdown conversion.

This dataclass contains settings specific to mailbox archive processing, extending EmlOptions with mailbox-specific features like format detection, message filtering, and folder handling.

Parameters:
  • mailbox_format ({"auto", "mbox", "maildir", "mh", "babyl", "mmdf"}, default "auto") – Mailbox format type. “auto” detects format based on file structure.

  • output_structure ({"flat", "hierarchical"}, default "flat") – Output structure mode: - “flat”: All messages sequentially with H1 headings - “hierarchical”: Preserve folder structure with nested headings

  • max_messages (int or None, default None) – Maximum number of messages to process. None means no limit. Useful for testing or processing large mailboxes in chunks.

  • date_range_start (datetime.datetime or None, default None) – Only process messages sent on or after this date.

  • date_range_end (datetime.datetime or None, default None) – Only process messages sent on or before this date.

  • folder_filter (list[str] or None, default None) – For maildir format, only process messages from these folders. None means process all folders.

  • preserve_folder_metadata (bool, default True) – Include folder name in message metadata when using flat output structure.

Examples

Convert mailbox with specific format:
>>> options = MboxOptions(mailbox_format="maildir")
Limit to 100 most recent messages:
>>> options = MboxOptions(max_messages=100)
Filter by date range:
>>> from datetime import datetime
>>> options = MboxOptions(
...     date_range_start=datetime(2024, 1, 1),
...     date_range_end=datetime(2024, 12, 31)
... )
Hierarchical output with folder structure:
>>> options = MboxOptions(output_structure="hierarchical")
mailbox_format: Literal['auto', 'mbox', 'maildir', 'mh', 'babyl', 'mmdf'] = 'auto'
output_structure: Literal['flat', 'hierarchical'] = 'flat'
max_messages: int | None = None
date_range_start: datetime | None = None
date_range_end: datetime | None = None
folder_filter: list[str] | None = None
preserve_folder_metadata: bool = True
__init__(attachment_mode: AttachmentMode = 'alt_text', alt_text_mode: AltTextMode = 'default', attachment_output_dir: str | None = None, attachment_base_url: str | None = None, max_asset_size_bytes: int = 52428800, attachment_filename_template: str = '{stem}_{type}{seq}.{ext}', attachment_overwrite: AttachmentOverwriteMode = 'unique', attachment_deduplicate_by_hash: bool = False, attachments_footnotes_section: str | None = 'Attachments', extract_metadata: bool = False, include_headers: bool = True, preserve_thread_structure: bool = True, date_format_mode: DateFormatMode = 'strftime', date_strftime_pattern: str = '%m/%d/%y %H:%M', convert_html_to_markdown: bool = False, clean_quotes: bool = True, detect_reply_separators: bool = True, normalize_headers: bool = True, preserve_raw_headers: bool = False, clean_wrapped_urls: bool = True, url_wrappers: list[str] | None = <factory>, html_network: NetworkFetchOptions = <factory>, sort_order: EmailSortOrder = 'asc', subject_as_h1: bool = True, include_attach_section_heading: bool = True, attach_section_title: str = 'Attachments', include_html_parts: bool = True, include_plain_parts: bool = True, include_rtf_parts: bool = True, mailbox_format: MailboxFormatType = 'auto', output_structure: OutputStructureMode = 'flat', max_messages: int | None = None, date_range_start: datetime.datetime | None = None, date_range_end: datetime.datetime | None = None, folder_filter: list[str] | None = None, preserve_folder_metadata: bool = True) None