Converters

How to Open an MBOX File on Mac

MBOX stores a full folder of mail in one file so double clicking it rarely does what you expect.

4 min read

Quick AnswerOpen an MBOX file on Mac in 3 ways. Use a text editor, a Python script or converter software. Raw messages show one after another in a text editor. Python lists the date, sender and subject. Converter software moves the mail into another app. Large MBOX files can freeze a text editor. Work on a copy of the file first.

Mail exports from Gmail, Thunderbird and other tools end in .mbox. Mac has no built in viewer for them, which leaves people staring at one huge text file. Here is what the format contains and how to look inside.

What Does an MBOX Mailbox Contain?

Every MBOX file is a plain text mailbox. Messages follow RFC 5322 form. Any line starting with From followed by a space starts every new message. RFC 4155 registers the format under the media type application/mbox.

Why Is MBOX Mail Hard to Open?

Size is the first problem. Ten years of mail can reach many gigabytes, which overwhelms a text editor. Encoding is the second. Accents and attachments show as symbols because mail apps decode them for display. Our article on opening EML files explains those encodings.

How Can You Open MBOX Files on Mac?

RouteWhat you seeBest for
Text editorRaw messages one after anotherSmall files and a quick look
Python scriptA numbered list of dates, senders and subjectsChecking what a large file contains
Converter softwareMail in a format your app opensMoving a mailbox into another app

How Do You List Messages in an MBOX File?

Who it suits. Technical users who work in Terminal. Source file size limit. None in the script. Extra application. Python 3 installed on your Mac.

Python’s mailbox module reads the format directly. Save the script as list_mbox.py and enter python3 list_mbox.py export.mbox in Terminal.

import sys
import mailbox
from email import message_from_binary_file, policy


def parse(f):
    return message_from_binary_file(f, policy=policy.default)


box = mailbox.mbox(sys.argv[1], factory=parse)
for i, msg in enumerate(box, 1):
    print(i, msg["Date"], "|", msg["From"], "|", msg["Subject"])
Tested on a two message sample. Output showed the date, sender and decoded subject per message.

Your file is left untouched. Try it on a copy first.

How Does MacXTools Convert MBOX Files?

Scripts only list mail. For moving a mailbox into another app, MacXTools MBOX Converter handles the conversion without code. Our guide to the MBOX format explains where these files come from. Another article shows how to extract attachments from an MBOX file.

How Do Large MBOX Files Behave?

Because mailboxes are a single long text file, size is the main practical issue. Mailboxes of a few hundred messages open in a second. One with a decade of mail and attachments can reach many gigabytes and a text editor can freeze or refuse to open it. Scripts process the file in sequence and uses little memory, which makes it the safer way to look inside a large file. If the archive is too big to handle comfortably, our guide on splitting a large MBOX file explains how to cut it into parts.

What Does the Format Not Store?

MBOX is a flat list of messages. Folder structure, seen flags and labels are not part of the standard format, though some tools add their own headers. When you move mail between apps, expect to rebuild folders manually or by importing several files, one per folder. Knowing this in advance prevents the surprise of finding every message in a single list.

Which Problems Affect MBOX Mail?

  • Files that open as strange text are normal. That is normal, since bodies and attachments are encoded for transport.
  • Listings with fewer messages than expected point to damage. Damaged or truncated files end early so compare with the size you exported.
  • Dates look out of order. Mailboxes are stored in the order messages were added, not sorted by date.
  • Messages starting with a stray character have escaped From lines. Lines beginning with From inside a body are escaped by some tools, which can alter how text appears.
  • Imports that stop partway need a smaller test. Try the import with a smaller part of the file to find where it breaks.

Plan for the unexpected as well. Archives collected over many years can include damaged files, duplicates and messages in odd encodings. None of these is a reason to avoid the format but all of them argue for counting and sampling before you trust a result.

Which Route Suits Your MBOX File?

SituationBest route
Quick peek at a small fileText editor
Count and list messages in a big filePython script
Move mail into another appConverter or direct import
Mailbox too large to handleSplit it into parts first

What Should Your First MBOX Session Look Like?

  1. Copy the mailbox and work on the copy.
  2. Use the listing script and note the message count.
  3. Open a few messages to confirm the data looks right.
  4. Decide whether to import directly, split or convert.
  5. Repeat the count after any conversion and compare.

Routines this short avoid the two worst outcomes, which are damaging the only copy and losing messages without noticing.

How Do You Check a Converted Mailbox?

Count messages before and after conversion, then open a few with attachments. Our article on checking a converted mailbox shows the method.

Common Questions

What Is an MBOX File?

Plain text that stores many email messages one after another. Lines starting with From and a space mark every new message.

Can a Text Editor Open MBOX Files?

Yes, though large files open slowly and the text shows encoded content. Scripts and converters suit for big mailboxes.

How Many Emails Fit in an MBOX File?

As many as the mailbox contained when it was exported. Only file size and your tools limit it.

Does an MBOX File Store Folders and Labels?

Standard MBOX is a flat list. Folder structure and labels need extra handling so export one file per folder.

How Do I See the Subjects Inside an MBOX File?

Use a short Python script with the mailbox module. You get one line per message with the date, sender and subject.

Why Are the Messages in My MBOX File Out of Date Order?

MBOX stores messages in the order they were added so sort by date in your mail app after import.

Can I Move MBOX Mail Into Another App?

Yes. Many apps import the format directly while converter software serves apps that do not.

Sources

Every version, option and date above is taken from these pages and not from memory.

  1. RFC 4155, The application/mbox Media Type IETF
  2. RFC 5322, Internet Message Format IETF
  3. mailbox, manipulate mailboxes in various formats, Python documentation Python Software Foundation