MBOX (.mbox)


    • MIME type: application/mbox
    • Unix mailbox format.
    • Holds a collection of email messages.
    • Native archive format of email clients such as Unix mail, Thunderbird, and many others.
    • Textual format with encoded binary data.
    • Stores messages in EML format, concatenated with separator lines.
    • Supports RFC 4155.

Import & Export

  • Import["file.mbox"] imports an MBOX file, returning a list of message summaries given as associations.
  • Import["file.mbox"] returns an expression of the form {msg1,msg2,}, where the msgi are associations giving basic elements of individual mail messages.
  • Import["file.mbox",elem] imports the specified element from an MBOX file.
  • Import["file.mbox",{elem,suba,subb,}] imports a subelement.
  • Import["file.mbox",{{elem1,elem2,}}] imports multiple elements.
  • The import format can be specified with Import["file","MBOX"] or Import["file",{"MBOX",elem,}].
  • See Import for full general information.
  • ImportString supports the MBOX format.

Import Elements

  • General Import elements:
  • "Elements" list of elements and options available in this file
    "Rules"full list of rules for each element and option
    "Options"list of rules for options, properties, and settings
  • Complete mailbox elements:
  • "MessageSummaries"list of associations giving basic elements for each message
    "MessageElements"list of associations giving main elements for each message
    "FullMessageElements"list of associations giving all available message elements
    "MessageCount"number of messages appearing in the mailbox
  • Import by default uses the "MessageSummaries" element.
  • Basic elements from within messages in the mailbox:
  • "From"sender names and email addresses
    "FromAddress"sender raw email addresses
    "Subject"subjects of the emails
    "Body"message bodies as strings
    "Attachments"lists of processed attachments as expressions
    "AttachmentData"lists of associations giving raw data on attachments
  • Additional sender and recipient elements:
  • "FromName"sender full names
    "ToList"lists of recipient names and addresses
    "ToAddressList"lists of recipient addresses
    "ToNameList"lists of recipient full names
    "CcList"lists of copied recipient names and addresses
    "CcAddressList"lists of copied recipient addresses
    "CcNameList"lists of copied recipient full names
    "ReturnPath"declared return paths for the mail
    "ReplyToList"lists of reply-to names and addresses
    "ReplyToAddressList"lists of reply-to addresses
    "ReplyToNameList"lists of reply-to full names
  • Message-body elements:
  • "NewBodyContent"parts of the bodies that are not replies or forwards
    "QuotedContent"parts of the bodies that are quoted
  • Attachment-related elements:
  • "AttachmentSummaries"list of associations giving basic attachment elements
    "Attachments"lists of expressions giving the content of attachments
    "AttachmentNames"lists of names assigned to attachments
    "AttachmentAssociations"associations giving content and metadata of attachments
  • Message-identification and threading elements:
  • "MessageID"message ID for each message
    "ReplyToMessageID"lists of any IDs of messages to which each message replies
  • Message-routing-related elements:
  • "Precedence"declared mail precedences
    "ReturnReceiptRequested"whether return receipts are requested
    "DeliveryChainHostnames"lists of hostnames on mail delivery chains
    "DeliveryChainRecords"lists of full records on mail delivery chains
  • Mail-header-related elements:
  • "HeaderString"complete email headers as strings
    "HeaderRules"lists of rules for all headers
    "CharacterEncoding"list of character encodings for each message
    "ContentType"MIME content types of email bodies
  • Message-origination-related elements:
  • "OriginatingMailClient"types of originating mail clients
    "OriginatingIPAddress"IP addresses of originating client machines
    "OriginatingHostname"hostnames of originating client machines
    "OriginatingCountry"geoIP-inferred originating countries
    "OriginatingDate"client dates and times from email headers
    "OriginatingTimezone"client time zones based on email headers
    "ServerOriginatingDate"dates and times on originating servers
    "ServerOriginatingTimezone"time zones of originating servers
  • The setting for "AttachmentAssociations" is a list giving an association for each attachment. The elements of this association are typically as follows:
  • "Content"attachment content as an expression
    "Name"name assigned to the attachment
    "MIMEType"MIME type used to encode the content
    "RawContent"raw encoded content as a string
    "ByteCount"number of bytes in the raw encoded content
    "ModificationDate"modification date recorded for the attachment


open all close all

Basic Examples  (4)

Import message summaries for a sample MBOX file:

Click for copyable input

Determine the number of messages in a MBOX file:

Click for copyable input

Import messages from the MBOX file:

Click for copyable input

Extract message subjects from a MBOX file:

Click for copyable input

Import message dates:

Click for copyable input

Scope  (2)

Import Elements  (50)

Applications  (5)

Introduced in 2007
Updated in 2016