mbxtest is a small script I've written to help fix broken Washington formatted MBX mail boxes, as used by their imapd.
It was really intended for internal consumption, hence the lack docs, etc. but feel free to give it ago. All it does scan through the mailbox specified on the command line, and displays all the message index markers, with some extra debugging counts. Any lines beginning with ## are out of the expected sequence, you can then use a suitable editor (I use emacs, taking care not to slip into DOS mode, and vim for really large mail folders) and the debugging numbers to patch up the file.
Sept 2006: Slight update to fix the pattern matching to find messages that aren't in +GMT timezones.
Click here to download it. Or if I've forgotten to update this link when/if I upload a new version, search for it.
The output of the script should look something like this:
2049 :07-Aug-2002 10:36:31 +0100,2359;000000180001-0000000e: next should be 4463:prev+2049 4463 :07-Aug-2002 15:08:42 +0100,931;000000080001-0000001b: next should be 5448:prev+2359 ## 5449 :08-Aug-2002 16:11:00 +0100,1330;000000180001-00000036: next should be 6833:prev+932 6833 :12-Aug-2002 14:50:16 +0100,3854;000000180009-00000050: next should be 10742:prev+1330
There are 4 colon separated fields per line. The first field is the byte count into the file where the script found the MBX message header line (field 2). Field 3 just states the byte count that the message message should be found on. Field 4 states that the previous message is +???? bytes in size.
Any line beginning with ## is out of the expected sequence. So in the above example, the header at byte 4463 is expecting to find the next message header at byte 5448 (4463+931+length of the header), but instead it was found at byte 5449. To fix this you could either edit the INBOX and change the header at byte 4463 to say the message is 932 bytes long, rather than the current 931, or you could just remove the extraneous byte from the message body of the message that began at byte 4463.
Of course editting the mailfolder is entirely at your own risk. I always make sure I've a spare copy in case things go wrong.