Shubham Dixit, email forensics and data extraction expert

Written by Jennifer Walsh. Reviewed for technical accuracy by Shubham Dixit, Independent Expert in Email Forensics and Data File Conversion.

Shubham is an independent external reviewer and not an employee of PCDOTS.

Quick answer. An MBOX is a plain text file, so the email addresses inside it are already readable in the From, To and Cc lines. You can pull them all out for free with a one line grep command or a short Python script, and a tool does it click and go if you would rather not touch a command line. Whichever you use, use the addresses lawfully.

It’s plain text, so this is easy

Good news before you download anything. An MBOX is just a plain text file, every message in your mailbox stored one after another, and the From, To and Cc lines are right there in readable text. So extracting the addresses is really a text search, not a special operation, and you can do the whole thing for free with tools your computer already has. MBOX is the format behind Thunderbird, Apple Mail, Google Takeout, SeaMonkey and Eudora among others, so this works whatever client produced the file. A dedicated extractor is genuinely useful for big jobs or if you would rather click than type, but it is a convenience here, not a requirement. Below are a few ways, from a single command to a friendly window, so you can pick what suits you.

From [email protected] …From: [email protected]To: [email protected]Cc: [email protected]Subject: Invoice MBOX, plain text extract, unique [email protected][email protected][email protected]one copy of each address

The addresses are already in the text, extraction just collects them.

“Because MBOX is plain text, a single grep will happily list every address in the file, and for a quick pull that is often all you need. The one thing to be aware of is where the addresses come from, raw grep will scoop up anything with an at sign, including signatures and quoted replies buried in the message bodies. If you only want the real senders and recipients, read the actual From, To and Cc headers instead, which is what a short Python script or a proper tool does. And a reminder I give every client, an extracted list is personal data, so keep it to legitimate uses and lawful mail, never scraped cold contacts.” Shubham Dixit, Email Forensics reviewer (draft, pending approval)

The one line way, grep

If you are comfortable with a terminal, this is the fastest route and it directly answers the common wish to get all the addresses. On Linux, Mac or Windows with Git Bash or WSL, point grep at your file with an email regex and sort for unique results: grep -rhoE '[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}' mailbox.mbox | sort -u. That prints every unique address it finds, one per line, which you can send to a file by adding > addresses.txt at the end, and because grep also reads a whole folder, one command can sweep many mailboxes. You can narrow it too, add | grep '@company.com' to keep a single domain, or | grep -v noreply to drop system addresses. It takes seconds even on a large mailbox. Just remember it catches every address in the whole file, bodies included, so it is broad rather than precise.

The clean way, Python

When you want just the real senders and recipients, not every address quoted in a reply, a few lines of Python do it cleanly, and Python is free on any system. Its built in mailbox module opens the MBOX and walks through each message, so you can read the actual From, To, Cc and Bcc header fields, collect them into a set to keep only unique ones and write the result to a CSV. Because you are reading the headers rather than scanning raw text, the output is the genuine contact list rather than a pile of everything with an at sign in it. A few extra lines can even count how often each sender appears, handy when you want your most frequent contacts first. It is the right tool when accuracy matters, or when you want to script the job across a folder of mailboxes.

MBOX fileplain text grep … | sort -uor Python mailbox unique addressesone per line CSV

Free and built in, one command or a short script.

The no-code way, a tool

Not a command line person, or facing many MBOX files at once? A dedicated extractor gives you the same result through a window. The PCDOTS MBOX Converter opens your MBOX files, lets you pick which fields to pull addresses from, From, To, Cc, Bcc or Subject, filter by domain or date, removes duplicates and saves the list as a text file, CSV or vCard, across many files and MBOX variants in one run. It works on Windows with a free trial that previews everything and saves the first ten addresses per file, so you can check the output first. If you want to stay free and still skip the command line, you can import the MBOX into Thunderbird with the free ImportExportTools NG add-on and read the messages there, though pulling a clean address list still comes down to Thunderbird’s own export or one of the methods above. For a one off pull the free grep or Python route is plenty, the paid tool is for volume and a no-fuss window.

1Run itOn Windows,open the menu 2Add MBOXFiles or awhole folder 3ExtractAddresses,pick fields 4SaveText or CSV,no repeats iFor a one off pull, the free grep or Python route above is plenty.

The tool route, addresses from many MBOX files in one pass.

The tool follows four short steps.

Step 1. Install and run the software on Windows, then open the menu.

Open the MBOX extractor menu

Step 2. Add your MBOX files or a whole folder.

Select the MBOX files

Step 3. Choose Extract, then Email Addresses, then pick the fields.

Extract email addresses from chosen fields

Step 4. Save the de-duplicated list as text or CSV.

Save the extracted address list

Related reading, our guides to extract email addresses from a PST file. To browse a mailbox first, the free MBOX viewer opens a .mbox without any client, and the CSV Duplicate Remover tidies a list that still has repeats.

Free Download
Buy Now

Getting a cleaner, targeted list

Whichever method you use, a raw pull is rarely the final list, so a little targeting saves time later. The big one is where the address comes from. A plain grep sweeps the entire file, so it also grabs addresses sitting in signatures and quoted replies inside message bodies, useful for a wide net but noisy. Reading the From, To, Cc and Bcc headers instead, with Python or a field-aware tool, gives you the real senders and recipients. From there you can narrow further, keep only a single domain to pull business contacts, exclude noreply and system addresses, limit to a date range or count how often each sender appears to rank your most active contacts. A quick clean and de-duplicate in Excel or Google Sheets finishes the job.

raw grep, whole file [email protected] (From header) [email protected] (To header) [email protected] (a quoted reply) [email protected] (a signature) broad, includes body noise read the headers [email protected] [email protected] [email protected] just real senders and recipients

Grep casts a wide net, reading the headers keeps only the real contacts.

What it’s good for, and the rules

People pull addresses out of a mailbox for plenty of sound reasons, building a contact list from your own correspondence, preparing a migration, tidying and de-duplicating an address book or working through a mailbox for e-discovery or an internal investigation. All fair. One important caveat though, an extracted list is personal data, and the people on it did not necessarily agree to be on a list. So use it lawfully, for your own records, analysis or contacts you have a relationship with, and do not use it to send unsolicited or bulk marketing mail. Rules like GDPR and CAN-SPAM exist precisely around this, and a harvested list is exactly what they restrict.

The methods compared

All three give you a list of addresses, so pick by comfort and scale.

Method Best for Good to know
grep one liner A fast pull of everything Free, broad, includes bodies
Python mailbox Clean senders and recipients Free, reads headers, to CSV
Extractor tool No code, many files Windows, pick fields, dedup

Frequently asked questions

How do I extract all email addresses from an MBOX file?
Because an MBOX is plain text, a grep command with an email pattern piped to sort -u lists every unique address. Or read the From, To and Cc headers with a short Python script.

Can I do it without any software?
Yes. grep and Python are free and built into or freely available on most systems, so you need no paid tool for a one time extraction.

How do I get only senders and recipients, not addresses from message bodies?
Read the header fields rather than scanning raw text. A Python script using the mailbox module, or a dedicated extractor that lets you pick fields, targets just From, To and Cc.

Can I extract from many MBOX files at once?
Yes. A script can loop over a folder, and a tool can load multiple files and MBOX variants together, then output one combined, de-duplicated list.

What format is the output?
Usually a plain text file with one address per line, or a CSV. Both open in Excel or Google Sheets for sorting and cleaning.

Is it legal to use the extracted addresses?
For your own records, analysis or existing contacts, yes. Sending unsolicited or bulk marketing to a harvested list is restricted by laws like GDPR and CAN-SPAM, so keep to lawful use.

So what will you do with the list?

The extraction itself is the easy part, a grep line for a quick sweep, a little Python for a clean sender and recipient list or the tool for many files without any typing. The question worth pausing on is what happens next. If it is your own contact list, a migration or an investigation, you are on solid ground and any of these methods gets you there in minutes. If you are tempted to mail people who never asked to hear from you, that is the one use these addresses are not for. So grab the list the way that fits you, then put it to a use you would be happy to explain?

Shubham Dixit

Reviewed by Shubham Dixit

Independent Expert in Email Forensics and Data File Conversion. Shubham reviewed this guide for technical accuracy. He is an independent external reviewer and not an employee of PCDOTS.

Profile  |  LinkedIn