15

How to open a mbox file? Mutt displays no mails when calling mutt -f sent.mbox.

The mbox format is "From" without colon.

Is there any mbox viewer for Linux?

Thank you in advance.

guntbert
  • 13,485
chris
  • 786
  • 1
  • 10
  • 20
  • Mutt should be able to open an mbox file. It's normal to have a From line without a colon at the top: this is for the email's envelope. It's difficult to diagnose your problem without seeing the file contents. Of course I appreciate the file contents is probably too private to publish. Look at the file as a text file (for example with less). Is the From line followed by header lines (From:, Subject: and so on)? Is there a Lines: header, a Content-Length: header? – Gilles 'SO- stop being evil' Mar 18 '12 at 19:29
  • It looks like this: http://pastebin.com/49fG0N7E I deleted the recipient, content and domain name. – chris Mar 18 '12 at 20:46
  • how about alpine? It was called pine before. – Nicholas Saunders Nov 27 '23 at 20:14

5 Answers5

7

In thunderbird you can open the file by placing it in thunderbirds local profile folder, under $HOME/.thunderbird/<profilename>.default/Mail/Local Folders/ An .mbox file there will be picked up by Thunderbird and displayed. See also the detailed instructions linked by prashanth in a different comment.

JanKanis
  • 683
  • 9
  • 14
  • This is the best answer. I was able to view all my 100K messages downloaded from GMail backup this way. Thanks. – Slava Fomin II Jan 22 '21 at 22:16
  • Tested as of Thunderbird 102.13.0 Ubuntu 23.04, I can't find out how to create a profile without actually logging into some email account, it seems to check no matter what I try (linked post mentions this is a required step, but was able to avoid actual linkup with a dummy account). Annoying. – Ciro Santilli OurBigBook.com Sep 03 '23 at 16:54
  • @CiroSantilliOurBigBook.com - To create new profile try thunderbird -P – Mohnish Aug 09 '25 at 18:54
4

Any text editor is capable of opening .mbox. Besides text editors Mozilla Thunderbird can open them too.

Rinzwind
  • 310,127
  • Do I have to copy the file to the Thunderbird profile? I don't want to change it. – chris Mar 18 '12 at 20:50
  • 1
    Yes. I was able to open mbox file in Thunderbird. This link provided the steps to be followed. https://commons.lbl.gov/display/~jwelcher@lbl.gov/Reading+an+mbox+file+with+Thunderbird – prashanth Nov 29 '17 at 14:36
  • @prashanth 's link is a working solution. I could download my gmail archive as an .mbox file (https://takeout.google.com/settings/takeout) and open it with Thunderbird. All you have to do is place the .mbox-file in the Local Folder path on your file system. Before that you must create at least a newsgroup account with your real email adress (write anything as the news server address, it doesn't matter). Restart Thunderbird and then you have a new folder with all your mails and attachements. – aliopi May 09 '18 at 08:31
4

The first line of the mail is the “envelope From line”. It begins with the 5 characters From␣ where is a space character. This is normal.

From Christian xxx <cg@xxx> Mon May  15 20:22:35 2010

What is unusual is that the email address is between <…>. This is unusual. I don't know if it's against the RFCs or not, but I can see Mutt chokes on it.

You should get a valid mailbox (as in, one that Mutt can parse) by processing the mailbox file through the formail command from procmail Install procmail.

formail -ds sed '1 s/^From .* <\(.*\)>/From \1/' <sent.mbox >sent-reformatted.mbox
mutt -f sent-reformatted.mbox
  • I appreciate your answer. Unfortunately, formail doesn't add this header. RFC 822 / 4155 knows nothing about it. – chris Mar 18 '12 at 22:04
  • After reformatting the file with formail, four (of a hundred) mails are displayed in mutt. – chris Mar 18 '12 at 22:11
  • @chris How many files does formail -ds sh -c 'cat >$FILENO.mail' create? Can mutt read them as individual mailboxes containing a single mail? – Gilles 'SO- stop being evil' Mar 18 '12 at 22:20
  • 606 files are generated. But Mutt doesn't read them. – chris Mar 19 '12 at 17:32
  • @chris Damn. Again, this is difficult to diagnose without seeing a mail. Can you take one of these single-mail files and edit out all private data, check that mutt still can't open it, and post it here? – Gilles 'SO- stop being evil' Mar 19 '12 at 18:04
  • this is a simple mail without mime-multiparts: http://pastebin.com/2aQFgxe2 It contains German umlauts. Do they make trouble? – chris Mar 19 '12 at 20:32
  • I deleted the umlauts. Even so, the mail isn't displayed. – chris Mar 19 '12 at 20:41
  • 1
    @chris Ok, I've reproduced this and found the problem: Mutt doesn't like it when the envelope From line isn't of the form From something@somewhere trailer text. In particular, it ignores a line where the envelope from address is John Doe <add@ress>. Now I'm going to see how to fix this. – Gilles 'SO- stop being evil' Mar 19 '12 at 20:57
  • 1
    @chris I don't know whether it's a bug in mutt or in the program that produced this mailbox, but see my answer for a fix. – Gilles 'SO- stop being evil' Mar 19 '12 at 22:12
  • Thank you very much. I'll clean the mbox files up with your script. – chris Mar 20 '12 at 21:23
4

After a bit of nightmare on Windows with Firefox, where the .mbox gets open but only the first message is available, I found that Evolution works well: I created a new folder and then from File\Import... (I'm from Italy, the menu it's actually Importa...) I was able to read that old messages...

CapelliC
  • 285
0

In order to view an mbox file in Thunderbird, I needed the following:

  • add the Import/Export extension, otherwise the "import" option in the Tools menu did not give me the option to import a file (only data, etc., from another account/app); and
  • to use an account which was configured for POP, not IMAP (since the import into IMAP is not possible -- at least with the mbox file I was importing).

With those two conditions in place, everything worked well, and the file was available "as mail" in Thunderbird after import (with attachments intact).

Dɑvïd
  • 2,206
  • All the import/export extension does is copy the mbox file to thunderbird's local profile folder. You can also do that manually. – JanKanis May 22 '18 at 09:32