Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm migrating my mails from an old server to a new one, the configuration is good (mysql virtual accounts & imap only), with dovecot and postfix. It's already running for other users, I just want to merge old accounts from the old server to the new one.

The migration went fine, I just wanted to know how I could "show" all the old mails in UA Clients. I mean, is there any dovecot index file or such that could be re-created, destroyed, so that all old mails are "flagged" as new ?

share|improve this question

migrated from Feb 15 '12 at 12:14

This question came from our site for computer enthusiasts and power users.

Are you using mbox or maildir format for the email store? – Paul Jan 31 '12 at 22:23
Actually maildir – Lucas Jan 31 '12 at 22:25
up vote 1 down vote accepted

Maildir actually uses a unique format that makes this quite easy. Simply place the mail in new/ directory inside the mail users mailroot if you want it to show up as new. Otherwise it goes in the cur/ directory.

share|improve this answer
Is the ,S flag appended to the file name that makes the Seen status for IMAP and POP3. cur and new folders are kept only for efficiency matters – bleemboy Oct 20 '15 at 20:44
I suppose it depends on the MUA implementation but as I understand it (admittedly not having read the source for Dovecot) is that flags such as S are not read when emails are in new/ and are instead added when the MUA moves the file from new/ to cur/. I've not come across anything that considers these two directories as vestigial; every Maildir implementation I've run into uses them. See: – Garrett Oct 21 '15 at 0:29

For Maildir messages, such flags are stored in the file name. For example:


The letters FS after the comma mean Flagged and Seen. To mark the message as "unseen", either remove the S flag...

for msg in maildir/cur/*; do
    mv -v "$msg" "$msgbase,$flags"

...or simply throw the messages into the new folder:

mv maildir/cur/* maildir/new/
share|improve this answer
Thank you for your answer, but Garret & Paul answered right before you ! ;) – Lucas Jan 31 '12 at 22:48
Deserves a +1 just because of the nifty BaSH-ery! :) – Garrett Jan 31 '12 at 23:00

The Maildir format consists of a series of directories - matching the IMAP folder structure, within which are the emails, one file per email.

In order to copy emails from one email system to another, you can simply copy the directories and files, and ensure the permissions for those directories and files are correct at the destination.

The Maildir structure looks like this:


This shows the INBOX folder (cur, new, tmp) and another folder called "personal". Note the dot prefix showing that this folder is hidden, so this should be accounted for in your transfer.

The new folder contains any emails that have not been seen by a client, and the cur folder contains current emails. The tmp folder should be empty if the mail server is not operating.

share|improve this answer
Thank you for the clear summary ! It worked good ! :) – Lucas Jan 31 '12 at 22:48
@grawity - just so you are aware, the actual name of the mail directory varies across distributions - I used the placeholder "Maildir" to signify the maildir folder, not necessarily that it is called that (I should have noted this of course, and incidentally, on some of my mail servers it actually is Maildir) – Paul Jan 31 '12 at 23:20
@Paul: Many configurations do call it "Maildir", which often causes confusion -- people think that Maildir-format mailboxes are always located in ~/Maildir, or they don't know when someone is talking about the path versus the format... that's the reason why I changed your example. (On the second thought, I probably shouldn't have.) – grawity Jan 31 '12 at 23:37
@grawity No, hang on, you are right - I generally have mailboxes in ~ but this is definitely not always the case and I didn't consider that. The edit makes sense. – Paul Jan 31 '12 at 23:45
After playing with files remember to delete dovecot-uidlist and courierimapuiddb files otherwise mail clients won't see changes inmediately – bleemboy Oct 21 '15 at 15:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.