HACKER Q&A
📣 rahimnathwani

How do you handle mbox files?


A relative asked me to help him download a few thousand emails from Gmail, in a format that he could easily share with someone else.

The options I considered:

1. Selecting 50 emails at a time, and doing 'Forward as attachment', to convert each email into an .EML file and attach it to an email.

2. Using Microsoft Outlook on his computer to connect to Gmail via IMAP. Then selecting multiple emails in Outlook, and choosing 'Print...' to 'print' 50 at a time to PDF files.

3. (best option so far) Use Google Takeout to get an mbox file, and then use https://github.com/frehder/mbox2eml and https://github.com/andrewferrier/email2pdf to convert the emails into a set of PDF files.

Although this isn't a very common need, I'm sure someone here has been asked the same thing by a friend or relative. How did you solve it?


  👤 dredmorbius Accepted Answer ✓
Mutt: <http://www.mutt.org/>

You can directly access any arbitrary mailbox format with the '-f' option:

  mbox -f mymail.mbox
From there it's trivial to move mail to another format, "bounce" it to a specified address, or any number of other options. There are reasons mutt remains my preferred email tool....

Among other factors, mutt can manage mbox, Maildir, mdir, and networked (pop, IMAP) mail archives. In particular, if you set up or connect to an IMAP server, you can use mutt to translate between mbox and an IMAP server quite easily.

There are also a set of mail-handling utilities which are part of mh / xmh, a command-line. Jerry Peek, an O'Reilly author and general shell wizard is a fan and expert with that system:

<https://www.oreilly.com/openbook/mh/howwor.htm>

Mozilla Thunderbird, GNOME Evolution, KDE Kmail, Sylpheed, Eudora, Alpine, Balsa, and if my GPT session is to be trusted, should also all handle mbox and other mailbox formats. For Apple see:

<https://support.apple.com/guide/mail/import-or-export-mailbo...>


👤 Leftium
MailStore Home[1] is a free email archiving program.

- It has indexed (read: fast) search + basic reader/browser.

- Portable version so you can just copy to USB and share with anyone.

- Successfully downloaded 10+ GB of Gmail. (190,000+ emails.)

- The one caveat is the restore/upload isn't very good. It is very slow, and I never got it to succeed. (No resume; must start all over on error.)

So for email backup/transfer, I switched to GYB (which can resume and successfully restored/transferred nearly all of the emails): https://github.com/GAM-team/got-your-back

[1]: https://www.mailstore.com/en/products/mailstore-home/


👤 walterbell
Old-school Windows app (free) from Germany can archive mail from cloud services and export in multiple formats, https://www.mailstore.com/en/products/mailstore-home/

  As pioneers of standard email archiving software, we have been offering our customers a simple, safe, flexible, and scalable technology since 2006 .. In 2014, MailStore was acquired by Carbonite Inc., a company specializing in data-protection solutions headquartered in Boston, MA (USA). Since December 2019 we have been part of the Cybersecurity division of the Canadian software vendor OpenText.

👤 pabs3
Ask the person he is sharing with what format they want them in, then use any mail client that can connect to Gmail to download them, then convert to the desired format from there.

👤 tyrionbean
I used mbsync + mu(4e). It allowed me to whittle down all of the spam/notifications emails with fast searches. Then I archived it with tar.

👤 eb0la
You can get the contents using Apache Tika (use the Python library, it is easier)

Attachments will be trickier, but also doable with Tika.


👤 learningmore
The last I checked, I was surprised how often people recommended Thunderbird to convert between email formats. Sometimes a manual process (where the human is the glue between systems) is “best”. Good luck. Curious what others recommend.