Converters

How to Convert EML to MBOX on Mac

Many EML files are hard to import, while a single MBOX file goes into most mail apps in one step.

5 min read

Quick AnswerConvert EML to MBOX on Mac in 2 ways. Use a Python script or converter software. Python suits a folder of a few hundred files. Converter software suits thousands of files and nested folders. Work on copies of your EML files. Count the messages in the output MBOX file. Test a small batch before the full conversion.

Some mail tools save every message as its own EML file so you end up with folders of thousands of files. Mail apps import one mailbox file far more easily. This guide shows how to convert EML to MBOX on Mac with a Python script or with converter software.

What Is the Difference Between EML and MBOX?

EML stores one message per file. MBOX stores many messages in one file, with a From line plus a space marking every new message (RFC 4155). Both use RFC 5322 form, which is why conversion is mostly a matter of packing files together. Our guide to the MBOX format has more background.

Which Two Ways Merge EML Files on Mac?

RouteBest forWatch out for
Python scriptA folder of a few hundred filesFlat folders only and no progress report
Converter softwareThousands of files and nested foldersTest on a copy first

How Can Python Merge EML Files Into MBOX?

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 creates MBOX files. Save the script as eml_to_mbox.py. Then enter python3 eml_to_mbox.py folder out.mbox in Terminal, where folder is your EML folder.

import sys
import mailbox
from pathlib import Path

source = Path(sys.argv[1])
box = mailbox.mbox(sys.argv[2])
box.lock()
count = 0
for path in sorted(source.glob("*.eml")):
    with open(path, "rb") as f:
        box.add(mailbox.mboxMessage(f.read()))
    count += 1
box.flush()
box.unlock()
print(count, "messages written to", sys.argv[2])
Tested on two sample EML files, one with an accented subject and a PDF attachment. Output was two messages.

Files are processed in name order and subfolders are skipped. Your originals are untouched but an existing out.mbox gets new messages appended so use a fresh name every time.

How Does MacXTools Convert EML Files to MBOX?

Who it suits. Anyone with thousands of EML files or nested folders. Source file size limit. Product page states no limit on one EML file or on the number of files. Extra application. Java JDK and JRE 8.

MacXTools opens EML and EMLX files and saves them as MBOX, PST, MSG, PDF and other formats. You add single files or an entire folder and the list shows the path and size of every row. A date range filter exports only the messages inside the dates you set. The folder hierarchy is rebuilt in the output or written flat on request.

  1. Open MacXTools and select Add File(s) or Add Folder(s).
  2. Review the path and size of every row.
  3. Select MBOX as the output format.
  4. Choose the destination folder and start the export.
  5. Count the messages in the new MBOX file.

Source files open in read only mode so the originals remain unchanged. Check the details on the MacXTools EML Converter page. Our article on opening EML files shows how to inspect single messages first. Need PDF or PST output instead? Our guide on how to convert EML to PDF and PST on Mac covers both.

What Does EML to MBOX Conversion Preserve?

Converting EML to MBOX is mostly packaging. Both follow the same message format so headers, body text and attachments travel unchanged. What does differ is the container. Single files become entries in one long file, with a From line added before every message to mark where it starts. Anything that lived only in the file system, like the file date or the folder a file sat in, does not travel into the mailbox.

How Should You Plan the Conversion?

Decide how many output files the conversion should create. One MBOX file per source folder is the usual choice, since the format has no folders of its own. If your EML files sit in subfolders by year or project, start the conversion once per subfolder and name the output after the folder. That makes your structure visible when you import later.

Should You Test a Small Batch First?

Before you convert EML to MBOX on Mac at full size, copy twenty files into a test folder and convert those. Import the result into a spare folder in your mail app and open five messages, including one with an attachment. A small test takes a few minutes and tells you whether your files are ordinary messages and whether the mail app accepts the output. Those two checks catch most surprises.

How Should You Sort and Name the MBOX Output?

Name order decides the output order. If your files are named by date, the output will be roughly chronological. If they contain random names, the output order is random too, though mail apps sort by date after import. Give the output a clear name that includes the source folder and the date of conversion, like projects-2024-converted.mbox so you can find it later.

How Do You Convert a Large EML Folder in Batches?

A folder with tens of thousands of files is slow to import in one piece. Split the work by year or by sender folder and create one MBOX file for every batch. Each batch stays small enough to import in a few minutes and a failed import costs you one batch and not the whole archive.

Name every batch after its source folder and write the file count beside it. Compare that count with the MBOX result before you start the next batch. Batches also make a rerun cheap because you repeat only the part that failed.

Which Problems Affect EML to MBOX Work?

Most trouble when you convert EML to MBOX on Mac comes from the input and not the script. Odd file names, damaged messages and mixed folders cause nearly every complaint and every cause has a quick check below.

  • Outputs with fewer messages than files point to skipped files. Files without the .eml ending were skipped or they sat in subfolders.
  • Messages look broken in the mail app. Open the source EML in a text editor and check that it is a full message, not a fragment.
  • Script errors on one file point to a bad message. Move that file aside and repeat, then examine it on its own.
  • Output grows every time you repeat the script. Use a new output name every time.
  • Import into the mail app is slow. Split the output into smaller parts and import them one at a time.

What Is the Step by Step Routine?

  1. Copy your EML folder and note the file count.
  2. Direct the script to a new output name.
  3. List the output with our listing script and compare the count.
  4. Import the MBOX file into a test folder in your mail app.
  5. Open a few messages with attachments to confirm they work.

If the counts match and the samples open, the conversion is sound. Note the counts in a file beside the output file so anyone who opens it later can see what went in and what came out. Preserve the original EML files until you have used the result for a few weeks.

How Do You Check the MBOX File?

Count the EML files you started with and compare that number with the messages in the result. Any gap after this conversion means some files were skipped, for example files sitting in subfolders or files without the .eml extension. Fix those, then repeat the conversion into a new output file. Our guide to opening MBOX files includes a script that lists them. Then follow our article on checking a converted mailbox.

Common Questions

Can I Convert EML to MBOX on a Mac for Free?

Yes. Python is free and its mailbox module creates MBOX files, as the script above shows.

Do Attachments Survive EML to MBOX Conversion?

Attachments live inside the message so they travel with it. Open a few converted messages with attachments to confirm.

Can the Script Handle Subfolders?

No. Only the top folder gets processed. Use converter software for nested folders.

How Do I Check the Result?

Count the messages and open a sample. Our listing script prints every message in the output.

Does the MBOX Output Preserve My Folder Structure?

No. MBOX is a flat list so create one MBOX file per source folder and import every into a matching folder.

Why Is My Output File Growing Every Time?

Existing output files get messages appended. Use a new output name for every start.

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