views:

64

answers:

1

I recently asked this question and worked out that the reason a single email message is displaying out of order is not in fact because of the date, but because of the order of the messages. I would like to modify my script to make sure all messages are in the correct order, but am unsure how to do this. Is it just based on the order in which the files appear, or is there a special part of the maildir headers which specify this?

Here is an example of what I mean: Example

In general, every MUA I use, including Thunderbird, Evolution and mail2web.com can order by date, but will be default order by the "message number". I am on a shared host which I believe uses qmail. The message number tag information must be kept somewhere.

edit: I tried moving all files to a temp directory and back again, which has shown that it is the file order which is responsible for the message number. I am however unsure as to why the messages from a few days in December have been moved to a much lower number than the numbers of messages on either side of those date. The filenames are timestamps and should be sequential, so unless mv movied the files in a strange order, I do not understand why the message numbers would not be restored for these particular files.

+1  A: 

With maildirs, there is no inherent order for the messages. The program that displays them can show them in the order it wishes, which may be random, but can also be based, for example, on the Date header.

Your example does not identify the program that shows them, and it's anybody's guess how it orders the mails. You need to figure out what it does and fix it to order the mails in the order you want.

EDIT: The Maildir specification may be useful for digging out. If your MTA actually creates unique filenames by putting reliable timestamps, you can perhaps make do with ordering by filename. Even such filenames aren't guaranteed, it may be good enough for you.

Lars Wirzenius
question updated
Joshxtothe4
answer updated, hopefully to be more helpful
Lars Wirzenius
I have looked at the maildir spec, and the filename of the out of order email has a reliable timestamp and should be in order. See the example of the filenames in the link to my previous question
Joshxtothe4
In that case my best guess is that the MUA assigns numbers to the mails using some heuristic that is not inherent from the filename or other data in the maildir, but perhaps based on the order in which the MUA first sees the mails, and perhaps also based on the order in which the user deletes mails.
Lars Wirzenius
hmmmmm. I will try moving all files to a tmp directory, and then back again
Joshxtothe4
OK, it is definitely based on the file "order", as the result of moving the files was that the order has changed, however not correctly. However if the filenames are timestamps they should be sequential, and moved in order, so I am unsure why mv would have moved them sporadically
Joshxtothe4