Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 superuser.com 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
add comment

3 Answers 3

up vote 2 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
add comment

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

1328040798.M558634P29803.equal,S=17876,W=18294:2,FS

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
    msgbase=${msg%,*}
    flags=${msg##*,}
    flags=${flags//S/}
    mv -v "$msg" "$msgbase,$flags"
done

...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
add comment

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:

mail/cur/
mail/new/
mail/tmp/
mail/.personal/cur/
mail/.personal/new/
mail/.personal/tmp/

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
1  
@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
add comment

Your Answer

 
discard

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.