What Is an MBOX File?
MBOX — short for “mailbox” — is one of the oldest and most widely used email storage formats in computing. It stores multiple email messages in a single plain-text file, with each message separated by a special delimiter line. The format dates back to the early Unix systems of the 1970s and remains in active use today by email clients like Mozilla Thunderbird, by Google as the Gmail export format, and by countless mail servers and tools across the Unix/Linux ecosystem.
The beauty of MBOX lies in its simplicity. Open an MBOX file in a text editor and you can read the emails directly. There is no binary encoding, no proprietary database structure, no special software required to understand the data. This simplicity has made MBOX one of the most enduring file formats in computing history.
Despite its age, MBOX continues to be relevant. Every time you export your Gmail data through Google Takeout, you get an MBOX file. Every time Thunderbird saves your local mail folders, it uses MBOX. Understanding this format is essential for anyone working with email archives, migrations, or data preservation.
The History of MBOX
Unix Origins
The MBOX format originated in the early Unix mail systems, likely around Fifth Edition Unix in the mid-1970s. The original concept was elegantly simple: concatenate all email messages into a single file, using a line beginning with “From ” (the word “From” followed by a space) as the delimiter between messages.
Evolution and Variants
As Unix systems proliferated, different implementations made slightly different choices about how to handle edge cases — particularly the problem of the “From ” line appearing within message bodies. This led to several MBOX variants:
- mboxo — The original format. “From ” lines in message bodies are not escaped, which can cause parsing ambiguity.
- mboxrd — Escapes “From ” lines in message bodies by prepending ”>”. When reading, one ”>” is removed from lines starting with “>From ”. This is the most common variant today.
- mboxcl — Adds a Content-Length header to each message, allowing parsers to skip directly to the next message without scanning for “From ” lines.
- mboxcl2 — Like mboxcl but also escapes “From ” lines for safety.
Modern Usage
Today, mboxrd is the de facto standard. Thunderbird, Google Takeout, and most modern tools use this variant. When people say “MBOX” without qualification, they almost always mean mboxrd.
MBOX File Structure
The Basic Format
An MBOX file is a sequence of email messages, each preceded by a “From ” line:
From sender@example.com Wed Mar 25 10:30:00 2026
From: sender@example.com
To: recipient@example.com
Subject: First message
Date: Wed, 25 Mar 2026 10:30:00 +0100
Content-Type: text/plain
This is the body of the first message.
From another@example.com Wed Mar 25 11:00:00 2026
From: another@example.com
To: recipient@example.com
Subject: Second message
Date: Wed, 25 Mar 2026 11:00:00 +0100
Content-Type: text/plain
This is the body of the second message.
The “From ” Separator Line
The separator line always starts with “From ” (capital F, followed by a space). It is not the same as the “From:” header inside the email. The separator typically includes:
- The sender’s email address
- The date in Unix ctime format
- Sometimes additional routing information
Messages Within MBOX
Each message within the MBOX file is a standard RFC 5322 email message — essentially an EML file. This makes extraction straightforward: split on “From ” lines, and each chunk is a valid EML message.
Empty Lines
Messages within an MBOX file are separated by the “From ” line. A blank line at the end of each message body ensures clean separation.
Where MBOX Is Used
Mozilla Thunderbird
Thunderbird is the most popular desktop email client that uses MBOX. Each folder in Thunderbird corresponds to an MBOX file stored in your Thunderbird profile directory:
Inbox— MBOX file for your inboxSent— MBOX file for sent messagesDrafts— MBOX file for drafts- Custom folders are individual MBOX files named after the folder
Thunderbird also creates .msf (Mail Summary File) index files alongside each MBOX file for fast search and display. These index files can be safely deleted — Thunderbird will rebuild them.
Gmail (Google Takeout)
When you export your Gmail data using Google Takeout, the email portion is delivered as one or more MBOX files. This includes all messages from all labels, with Gmail labels represented as X-Gmail-Labels headers within each message.
Apple Mail (Legacy)
Older versions of Apple Mail used MBOX for local storage. Modern versions have moved to EMLX (individual message files), but you may still encounter MBOX files from older Mac systems.
Unix/Linux Mail Systems
MBOX is the traditional storage format for Unix mail delivery agents. Sendmail, Postfix (with local delivery), and many other Unix mail tools use MBOX for mailbox storage.
Email Libraries and Tools
Countless email processing tools and programming libraries work with MBOX format: Python’s mailbox module, Ruby’s mail gem, Perl’s Mail::Box, and many more.
How to Open MBOX Files
Using Thunderbird
The most straightforward way to open an MBOX file is with Thunderbird:
- Install the ImportExportTools NG add-on for Thunderbird
- Right-click on Local Folders in Thunderbird
- Select ImportExportTools NG > Import mbox file
- Browse to your MBOX file
- The messages appear as a new folder in Thunderbird
Using Apple Mail
On macOS, you can import MBOX files into Apple Mail:
- Open Apple Mail
- Go to File > Import Mailboxes
- Select “Files in mbox format”
- Browse to your MBOX file
- Import creates a new folder under “Import” in your sidebar
Using a Text Editor
For quick inspection, you can open an MBOX file in any text editor. The file is plain text, so you can read headers and message bodies directly. This is useful for debugging or checking file integrity, but impractical for reading large archives.
Converting for Other Clients
If your email client does not support MBOX directly, convert it:
- Convert MBOX to PST for Microsoft Outlook
- Convert MBOX to EML for individual message files
- Convert MBOX to MSG for Outlook-compatible individual messages
Converting MBOX Files
MBOX to PST
Convert MBOX to PST is the most common conversion for people moving from Thunderbird or Gmail to Microsoft Outlook. MailtoPst handles this conversion online:
- Upload your MBOX file
- MailtoPst processes the file on secure EU servers
- Download the resulting PST file
- Import into Outlook
The conversion preserves folder structure, message content, attachments, and metadata.
MBOX to EML
Convert MBOX to EML extracts individual messages from the MBOX file. This is useful when you need to:
- Work with messages individually
- Import into email clients that accept EML but not MBOX
- Search and organize messages at the file level
- Produce individual messages for legal review
MBOX to MSG
Convert MBOX to MSG creates individual Microsoft MSG files from each message in the MBOX archive. This is useful for Outlook-specific workflows where MSG format is required.
Other Conversion Paths
- MBOX to EMLX — For Apple Mail
- MBOX to OLM — For Outlook for Mac
All conversions through MailtoPst are processed on GDPR-compliant EU servers with automatic file deletion after 24 hours.
Working with MBOX Files Programmatically
Python
Python’s standard library includes an mbox module in the mailbox package:
import mailbox
mbox = mailbox.mbox("archive.mbox")
for message in mbox:
print(f"From: {message['from']}")
print(f"Subject: {message['subject']}")
print(f"Date: {message['date']}")
print("---")
Splitting MBOX into EML
A common task is splitting an MBOX file into individual EML files:
import mailbox
import os
mbox = mailbox.mbox("archive.mbox")
os.makedirs("output", exist_ok=True)
for i, message in enumerate(mbox):
with open(f"output/message_{i:05d}.eml", "w") as f:
f.write(str(message))
Merging EML into MBOX
The reverse operation — combining EML files into an MBOX file:
import mailbox
import glob
mbox = mailbox.mbox("merged.mbox")
for eml_path in sorted(glob.glob("emails/*.eml")):
with open(eml_path, "r") as f:
mbox.add(mailbox.mboxMessage(f.read()))
mbox.close()
MBOX File Management
Size Considerations
MBOX files can grow very large, especially for active mailboxes:
- A personal inbox might be 1-5 GB
- A corporate mailbox archive could reach 10-50 GB
- Gmail exports can exceed 100 GB for heavy users
Large MBOX files present challenges:
- Text editors may not open them
- Parsing takes time (the entire file must be scanned)
- Corruption of any part can make subsequent messages unreadable
- No random access — you cannot jump to message #50,000 without scanning the first 49,999
Compacting MBOX Files
When messages are deleted from an MBOX file, they are typically marked as deleted but the space is not reclaimed. Compacting (or expunging) rewrites the file without the deleted messages.
In Thunderbird: right-click a folder and select “Compact.” This rewrites the MBOX file without deleted messages.
Splitting Large MBOX Files
For very large MBOX files, splitting into smaller files improves manageability:
- Split by date range (one file per month or year)
- Split by message count (e.g., 10,000 messages per file)
- Split by size (e.g., 2 GB per file)
Backing Up MBOX Files
Because MBOX files are plain text, they compress well. A ZIP or GZIP archive of MBOX files typically reduces size by 60-80%. This makes backups efficient and fast.
MBOX vs. Other Formats
MBOX vs. PST
| Feature | MBOX | PST |
|---|---|---|
| Developer | Unix community (open) | Microsoft (proprietary) |
| Structure | Plain text, concatenated | Binary B-tree database |
| Multiple messages | Yes (one file = many messages) | Yes (database format) |
| Random access | No (sequential scanning) | Yes (B-tree indexed) |
| Cross-platform | Excellent | Limited (Windows-centric) |
| Human-readable | Yes | No |
| Content types | Email only | Email, contacts, calendar, tasks |
| Used by | Thunderbird, Gmail, Unix | Outlook (Windows) |
If you need to move from MBOX to the Microsoft ecosystem, convert MBOX to PST. Going the other direction, convert PST to MBOX.
MBOX vs. EML
| Feature | MBOX | EML |
|---|---|---|
| Messages per file | Multiple | One |
| File count | One per folder | One per message |
| Storage efficiency | Higher (fewer files) | Lower (filesystem overhead) |
| Random access | Requires parsing | Direct (open any file) |
| Partial corruption | Can affect subsequent messages | Only affects one message |
| Search | Requires parsing or index | OS-level file search works |
MBOX vs. Maildir
Maildir is an alternative to MBOX that stores each message as a separate file in a directory structure with three subdirectories: new/, cur/, and tmp/. Maildir avoids the file locking issues of MBOX and handles concurrent access safely. However, Maildir is primarily used by mail servers rather than desktop email clients.
MBOX Security Considerations
Data Protection
MBOX files are plain text with no built-in encryption or access control. Any email content — including confidential information, personal data, and attachments — is accessible to anyone with file-level access.
To protect MBOX files:
- Use filesystem encryption (BitLocker, FileVault, LUKS)
- Apply appropriate file permissions (restrict read access)
- Use encrypted archives (password-protected ZIP) for transfer
- Delete MBOX files securely when no longer needed
GDPR Compliance
MBOX archives containing personal data of EU residents fall under GDPR. Organizations must:
- Know what personal data exists in their MBOX archives
- Apply appropriate retention periods
- Be able to search and produce data for subject access requests
- Securely delete MBOX files when retention periods expire
When converting MBOX files, use GDPR-compliant tools. MailtoPst processes all conversions on EU servers with automatic 24-hour file deletion and no data retention.
Troubleshooting MBOX Issues
Corrupted MBOX Files
MBOX corruption typically occurs when:
- The application crashes while writing to the file
- The file is accessed simultaneously by multiple applications
- The storage device has errors
Signs of corruption:
- Missing messages
- Merged messages (two messages appear as one)
- Garbled content
- Application fails to open the file
To recover a corrupted MBOX file:
- Make a backup of the corrupted file
- Open in a text editor and look for “From ” separator lines
- Try to manually separate recoverable messages
- Use a dedicated MBOX repair tool
- As a last resort, convert recoverable portions using MBOX to EML
Gmail MBOX Export Issues
Common problems with Google Takeout MBOX exports:
- Duplicate messages — Gmail assigns multiple labels to messages, which can appear as duplicates in the MBOX export
- Large file sizes — Active Gmail accounts can produce MBOX files of 50 GB or more
- Missing labels — Gmail labels are stored as X-Gmail-Labels headers, not as folder structure; some tools may not recognize them
- Split archives — Very large exports are split into multiple MBOX files
Thunderbird MBOX Issues
- Disappearing messages — Usually caused by a corrupted index file (.msf). Delete the .msf file and let Thunderbird rebuild it.
- Slow performance — Large MBOX files (over 4 GB) can slow Thunderbird. Compact your folders and consider archiving older messages.
- Import failures — If Thunderbird fails to import an MBOX file, check for encoding issues or try the ImportExportTools NG add-on.
Frequently Asked Questions
What program opens MBOX files?
Mozilla Thunderbird is the most popular application for opening MBOX files. You can also use Apple Mail (File > Import Mailboxes), various email viewers, or convert to another format. To open MBOX files in Outlook, you need to convert MBOX to PST first.
How do I convert MBOX to PST for Outlook?
Use MailtoPst to convert MBOX to PST online. Upload your MBOX file, and MailtoPst will produce a PST file you can import directly into Outlook. The conversion preserves all messages, attachments, and folder structure. No software installation is required.
Can I open an MBOX file in Outlook?
Outlook does not natively support MBOX files. You need to either convert MBOX to PST and import the PST, or convert MBOX to EML and drag individual EML files into Outlook.
How do I export Gmail as MBOX?
Go to Google Takeout (takeout.google.com), select “Mail” from the list of Google products, and create an export. Google will generate one or more MBOX files containing all your Gmail messages. You can then open these in Thunderbird or convert to other formats.
Is MBOX a good format for email archiving?
MBOX is excellent for archiving: it is an open format, human-readable, widely supported, and compresses well. However, for very large archives, consider splitting into smaller files and maintaining an index. For individual message access, converting to EML may be more practical.
Can MBOX files contain attachments?
Yes. Attachments are stored within the MBOX file as Base64-encoded MIME parts, just as they would be in individual EML files. The attachments are fully preserved during conversion between MBOX and other formats.
What is the maximum size of an MBOX file?
There is no hard limit in the MBOX specification. However, practical limits depend on the tools you use. Thunderbird can struggle with files over 4 GB. Some operating systems have filesystem limitations (FAT32 limits files to 4 GB). For best performance, keep MBOX files under 2-4 GB and split larger archives.