I have an MBOX file created by dragging a folder from Outlook (For Mac v.16) into Finder (because the Export wizard in Outlook For Mac only generates OLM files).

I can look at the MBOX contents as plain text, and it looks sane. I would like to verify the number of messages contained. But mailx doesn't seem to see any messages:

% mailx -f archive.mbox Mail version 8.1 6/6/93. Type ? for help. "archive.mbox": 0 messages ? f No applicable messages ? h No applicable messages ?

I realize it's a very old version of mailx, but that is what shipped with the Mac.

How does mailx expect messages to be delimited in the MBOX file? Could I fix this with a simple find-replace?


It could be that mailx objects to DOS linefeeds or some other problem with the export from Outlook. The format should otherwise be very simple; records start with a "From " line which is followed by the message headers, a blank line, and then the message body and I think another blank line before the next "From " record. So to count the number of records

grep -c '^From ' archive.mbox

should suffice, as that pattern may not appear in a message body (this is why you may see "From" in messages prefixed with some character when using mailbox files).

There are other tools that can parse mailbox files e.g. Mail::Box (which I have not used) that might have better error messages than mailx.

  • Thanks! You are right. Replacing carriage returns with newlines fixed it. In my case, sed $'s/\\\r/\\\n/g' archive.mbox > fixed-archive.mbox – wemily Oct 19 '18 at 20:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.