Dovecot doesn't look at the new files' mtimes or ctimes, because that would require stat()ing the file, which slows it down. So it's using the timestamp in the Maildir filename itself.
Thanks Timo for the clarification. Whats Dovecot's strategy when the file-name does not contain a time-stamp and its just a sequential long number such as 1494829006737776656. My problem is that I am manually copying a lot of mail into the "new" directory of a Maildir. The file names range from: 1280369043768241070 - 1514890738113019895 but Dovecot is always assigning first UID to the mail in the file 1494829006737776656. And I am failing to understand why. I tried this 3-4 times using different ways. First by simply hard linking the files into "new" dir, second by copying them over, third by copying and then touching the file in a way that lower in sequence has a lower mtime, fourth by copying them into "new" in proper ascending sequence (according to file name) and then giving them appropriate mtime related to their sequence. But no matter what i do, Dovecot assigns first UID to file 1494829006737776656 only.
-Akash