I run a mail server on which I have courier imap and pop3 running. Recently I moved some local messages from my machine (previously downloaded with pop3) onto the server so I could use imap. I used Mail.app on Mac OS X 10.5.8 to do this.
This resulted in a series of files on the mail server that look like this:
1324697191.M91227P15574V000000000000CA00I0004B07D_556.hostname,S=5622:2,S 1324697192.M322096P15574V000000000000CA00I0004B07F_557.hostname,S=225691:2,RS 1324697196.M144018P15574V000000000000CA00I0004B081_558.hostname,S=7702:2,RS 1324697197.M715598P15574V000000000000CA00I0004B083_559.hostname,S=15741:2,S 1324697199.M327587P15574V000000000000CA00I0004B085_560.hostname,S=8744:2,RS
The received times of these messages, in the same order as listed above, are:
01/15/2010 01/09/2009 07/13/2010 02/21/2010 05/06/2010
Now this isn't a problem with desktop mail clients -- they simply fetch all the messages, sort them, and everything is fine. Several google searches on this subject yielded threads where people were trying to get their messages in the correct order and the suggested remedy was "sort them on the client side."
Unfortunately, on iOS 5.0.1, the mail application assumes the order of the messages it gets from the imap server is already sorted by date. Due to the messages in this example having a filename that doesn't match their receive timestamp, but instead their reupload timestamp, this means that messages appear in the wrong order on an iOS device. To fix this, I have to load ALL of the mail by tapping the "Load More Messages" button a bunch of times.
I would like to simply be able to rebuild these message files such that the timestamp in the filename (which looks to be the first set of digits before the period) matches the receive timestamp. They would then be sorted in the right order for when an iOS device tries to load them. I don't know enough about how courier organizes messages -- can I simply write a script that replaces the first set of digits in the filename with the unix timestamp of the message receive time?