How to recover broken or corrupted Marcel mailboxes

Although Marcel is reasonably tolerant of malformed or corrupt email messages, there can occasionally be times when your mailboxes appear to be empty or some messages fail to appear - despite the Ant Suite telling you it's just downloaded a batch of new ones.

The first indication that something might be wrong is when you download some new messages and open Marcel in order to read them, only to find that no new messages appear. This means that your mailbox file, or INBOX, has become corrupted in some way.

Location of your INBOX

All incoming messages are stored in a single file on your hard disc, usually called INBOX and stored inside your UserDir.Mail directory.

By default the Ant Suite installs a single user, called root into which all your messages are delivered. Some people may have created additional users, either for other people in their household or in order to filter messages on different topics - for instance subscribers to mailing lists may create additional local users in order to better manage incoming emails.
Each local user has a directory similar to the default UserDir one. Each user directory contains a !MarcelDir directory and a Mail directory, which contains the INBOX for the relevant local user.

The diagram below shows the default location of the various files that exist when you install the Ant Suite.

The UserDir is the default location of your local user directory, which contains your email, address book and other information for Marcel. You may have more than one 'UserDir' directory, depending upon how many local users you have setup (see sidebox).

InetSuite files

Quick solution to get you going and be able to receive future emails....

Before we examine how to fix your INBOX and recover your lost messages, let me give you a quick method by which you can start receiving emails again. This will get you going again and able to start receiving emails again.

Quit Marcel if it is loaded and locate the INBOX file (see diagram) and simply rename it - to INBOX2, for example. When you next load Marcel it will see that the original INBOX file is missing (because you've renamed it) and it will recreate a new one - in which future emails will be delivered - so you're back and running again and should be able to receive new emails again.

Recovering INBOX files:-

Note that all Marcel mailbox files contain the same internal format, so although I'm describing here, how to repair your main INBOX file, the same process equally applies to any other file which may be corrupt - such as your 'sent' messages file or any other files you may have created (via the filing cabinet icon).

How it works:-

When someone sends you an email and the Ant Suite downloads new emails, it literally just adds any new messages onto the end of your INBOX file. All messages are stored as plain text, including any attachments that may have been sent. Attachments are encoded in a special format so that they can be transmitted as plain text, either as UUEncoded or MIME encoded. At this stage you don't need to know the difference between attachment encoding methods though.

Once the Ant Suite has added all your newly delivered messages onto the end of the INBOX file, you normally just load Marcel in order to read them.

Marcel is reasonably dumb in this sense. It merely goes through the INBOX file reading the messages one at a time. The first message in the file is your oldest message and the last message in the file is the newest. Note that this isn't necessarily the same order that you view them on screen - simply because Marcel offers you different ways of 'sorting' your messages. This is purely for display purposes though and doesn't actually alter the physical order of the messages in the INBOX file, which is always oldest first, newest last.

If a message is corrupt or damaged in some way, then Marcel will simply give up at that point and assume that the email before the corrupt one is the last one - which is why you don't see your new messages - Marcel has simply given up before getting to them, as they're no doubt stored beyond the corrupted message.

In theory, you just manually delete the corrupted message and Marcel will be able to read your messages again. However, this is easier said than done and I will now describe how to go about doing this.

The format of the INBOX file is quite simple. Each message starts with a 'From' line. Note however, that this is NOT the 'From:' header line which you see in Marcel when you read the messages. This is an internal from line which contains not only the sender of the message but the date of the message too. This line is crucial for Marcel to understand that what follows is the actual email.

Immediately after this 'From' line is the actual message - including all of the header lines and any attachments (which will appear as regular columns of gobbledegook!)

At the end of the message will be three blank lines (carriage returns) and then the 'From' line of the next message - and so on throughout the entire file.

The key to successful INBOX recovery relies in removing the ENTIRE corrupted message, and not just the bit which is corrupted. This means you need to delete back as far as, and including, the 'From' line at the beginning of the message, as well as deleting forward to, and including, the three blank lines after the message. If you do this for each corrupt message, Marcel should be able to read your INBOX successfully again.

To summarise, the format of the INBOX file is:

From [recipient information] [time and date of email] ....message itself, including the detailed header lines...
[three blank lines]
From [recipient information] [time and date of email]
....message itself, including the detailed header lines...
[three blank lines]
From [recipient information] [time and date of email]
....message itself, including the detailed header lines...
[three blank lines]
etc etc. throughout the entire INBOX file.

How do you edit the file then?

In order to manually edit the INBOX file you will need a text editor. You can use !Edit (which is built into all RISC OS computers) or use a third-party one such as StrongED or Zap (the latter of which I personally recommend).

Locate the INBOX file. Hold the SHIFT key down and, whilst holding the SHIFT key, double-click on the INBOX file. This will force the INBOX file to load into your text editor. This will then display the raw contents of the file, in the format described above. The example screenshot below shows how the file will display in !Zap. Zap's colour syntax coding makes understanding the contents of the file a bit easier.

Note that the very first line of the file is a 'From' line followed by the path of the message and the time/date. After this is the full header of the first message in the file (all the Received: and other header lines). You should be able to see the one line message - "This is a test message for demonstration purposes." and the signature of the person sending the message, if they used one (mine in this example).

The message is then followed by three blank lines - but don't confuse with any blank lines in the message text itself - and then the From ..... of the following message.

InetSuite files

The screenshot below shows the same INBOX file, but this time it is corrupted. As you can see, part of the original header has been overwritten and the message itself appears to contain nothing but garbled characters.

In order to 'fix' this INBOX you need to select all of the corrupted email - back as far as the 'From' line and forward as far as the next 'From' line (but not including it), which is the start of the next message.

In case you're unsure of how to 'select' text, simply move the mouse pointer to the beginning of the message you want to delete, then click the left (SELECT) button and, keeping it pressed down, drag the mouse to the end of the message. This will highlight a portion of the file, which can subsequently be deleted.

InetSuite files

The screenshot below shows a legitimately encoded attachment. Notice that the attachment is a regular column of alphanumeric characters and not a random, continuous section of 'gobbledegook' as in the screenshot above.

InetSuite files

Once you've manually deleted any messages which you believe are corrupted, you should save the INBOX file back to disc. You should then open the directory called '/overview' (if it exists) which is in the same directory as the INBOX file. This is a directory containing various pointers that Marcel uses in order to index messages. Find a file inside this directory with the same name as your corrupted mailbox - ie. INBOX - and delete this file. Don't worry because Marcel will automatically recreate it next time you run it. Deleting it forces Marcel to rebuild its internal pointers etc.

You should now be able to reload Marcel and read your messages successfully.

I hope this article has helped you to understand the format of the Marcel mailboxes, and also give you some confidence at being able to repair broken INBOXes. Although it's a complex topic, I hope I've managed to explain it in an easy to understand fashion. If any part of it is confusing or could be explained better, please let me know and I'll see if I can improve these instructions.

Add a comment to this article

I am sorry to report that no further comments are to be left for articles here. We thank you for past comments. This feature has been disabled.

Email Email this page to a friend

Last edit: 10th Apr 2016 at 1:55pm
(2968 days ago)

Bookmark with:What are these?
delicious Deliciousdigg Diggreddit redditfacebook Facebookstumbleupon StumbleUpon

RSS Feed

Viewed 5664 times since 11th May 2006,
~ 0 views per day

Valid HTML 4.01!
Valid CSS!
Best viewed with a cup of tea Crafted by RISC OS