The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Migration problem from Ancient Neomail Server

Discussion in 'E-mail Discussions' started by matthewchan, Nov 4, 2006.

  1. matthewchan

    matthewchan Member

    Jul 3, 2006
    Likes Received:
    Trophy Points:
    Hi all, I have migrate my ancient Neomail server ( installed since age of RH 7.0 ...) to CPanel , however , I got one big problem.

    In the ancient Neomail server, it store all mail of each user into one HUGE mail file (with name = username). When I migrate to CPanel maildir , I copy that HUGE mail file to user's cur folder, after I login with that user account, there is only ONE mail instead of all mail(many) previously stored in Old server.

    I noticed that maildir store every mail into individual files, that wasn't the case in old server. How can I migrate these HUGE mail file into maildir format??

    Pls help:confused:

  2. AndyReed

    AndyReed Well-Known Member

    May 29, 2004
    Likes Received:
    Trophy Points:
    Minneapolis, MN
    You shouldn't migrate or import any files, manually, to any of your mail accounts, after you converted your mail server to Maildir format.

    Maildir is a structure for directories of incoming mail messages. It solves the reliability problems that plague Mbox files and mh folders.

    A directory in maildir format has three subdirectories, all on the same filesystem:
    Each file in new is a newly delivered mail message.

    is used to ensure reliable delivery.

    and cur:
    Files in cur are just like files in new. The big difference is that files in cur are no longer new mail: they have been seen by the user's mail-reading program.

    Just run this cPanel script one more time and you should be fine, no manual work involved please:
    #2 AndyReed, Nov 4, 2006
    Last edited: Nov 4, 2006
  3. matthewchan

    matthewchan Member

    Jul 3, 2006
    Likes Received:
    Trophy Points:
    thx for your reply

    thx for your reply

    I understand, but I must recover my user's email , they are stored in HUGE file format....How can I recover them??Pls help...

    one example attached

    Attached Files:

  4. matthewchan

    matthewchan Member

    Jul 3, 2006
    Likes Received:
    Trophy Points:
    i got the solution~

    credit to "web1"

    I am sitting on my a s s doing nothing waiting for a update of UW-imap, but someone here said that it's available, so being new to this cpanel thing, can I manually update just that part?

    I am a little worried about hitting the update thing in WHM because it will probably just go off and update everything, I haven't done any upgrades yet and have it all set to manual. I like to read the forums before upgrading anything.

    I don't like the idea of changing to that maildir thing, it will require any of the imap users to change the way the mailbox is handled. I assume that on pop3 it doesn't matter to the end users because that's not a direct copy of the inbox like imap is.

    Also, why do we need this maildir thing anyway? I have "normal" inboxes on my local linux box that are way over 80MB and my mail client "KMail" handles it just fine all these years.

    ostyler 10-20-2005 06:01 PM


    Conversion to maildir ... not seamless, but not tooo bad.

    I went ahead and pushed the button on the cpanel script to make the move from mbox to maildir.

    Here's how it went for me, in case it should prove helpful. The way I did it isn't the easiest way, by far, but it worked ok.

    When I pushed the button, Exim was rebuilt, uw-imap was replaced, cppop and imap continued to work fine on regular and ssl ports both. Custom configuration to the /etc/exim.conf file remained in place.

    BUT ... the actual conversion of /home/username/mail/inbox files into the respective maildir directories did not occur.

    (This is where the new messages live, one file per message)

    any new mail sent went into these directories, but the old mail was still in the 'inbox' file.

    I poked around and found that the actual conversion of those files is supposed to be handled by /usr/local/cpanel/3rdparty/mb2md/mb2md
    (as called by /usr/local/cpanel/bin/convertmaildir). But there was no local copy of mb2md.

    I called the support line for cpanel, and was told that running cpup --force should put a copy of mb2md on my machine.

    That may work, I don't know. Something about the --force made me leary and by then I had found a copy of (the same program, or one with the same name) mb2md on the net.

    Figured it would be faster to run that than to wait on the cpup to run.

    I got mb2md from
    ... I put it in /usr/local/bin, along with it's companion
    script addtomaildir

    I edited mb2md, line 48 to call '/usr/local/bin/addtomaildir' rather than just 'addtomaildir'.

    From there you could:
    mb2md /home/username/mail/inbox /tmp/mailfix
    cp /tmp/mailfix/cur/* /home/username/mail/cur/
    cp /tmp/mailfix/new/* /home/username/mail/new/
    chown username.mail /home/username/mail/cur/*
    chmod 660 username.mail /home/username/mail/cur/*
    chown username.mail /home/username/mail/new/*
    chmod 660 username.mail /home/username/mail/new/*

    Or, if you're doing that more than about 4 times, script it.

    Well, OK then.


    mb2md: convert mailbox to Maildir
    The traditional Unix mailbox format -- often called "mbox" -- sucks. Maildir, a format invented by Dan Bernstein of qmail fame, sucks much, much less. Unfortunately, all the tools that I could find to convert mbox files to maildirs suck even more than the mbox format itself. (Eg. they do a bogus/incomplete conversion and then delete the input mbox without warning -- that sort of thing.)

    So I wrote my own mbox-to-maildir conversion tool, called mb2md (all the obvious names were taken). Bragging points:

    mb2md does not destroy your valuable email. It insists that the output maildir not exist when you start, so you know that the output maildir exactly matches the input mbox. More importantly, it does not remove the input mbox when finished -- so if you decide you don't like what mb2md did, you can fallback to your old mbox.
    mb2md (or rather, the addtomaildir script that does the real work) takes considerable pains to preserve all useful information from your mbox file. Specifically, new/old/read messages in the mbox remain new/old/read in the maildir. Also, it attempts to figure out the delivery time of each message in the mbox, and sets the mtime of the corresponding message file in the maildir from it -- that way, you can easily sort the maildir by delivery time.
    You'll need three things to make it work:

    an external tool to split the input mbox; currently, either one of the following will work:
    formail (supplied with procmail)
    reformail (supplied with maildrop)
    my addtomaildir script, which does the real work of analyzing each message from the mbox and adding it to the maildir (requires Python 2.2 or greater)
    the mb2md shell script itself
    Obviously, you'll need to make sure that the two scripts are executable after you download them:
    chmod +x mb2md addtomaildir
    Thanks to the following people for patches and so forth:

    Roman Neuhauser (neuhauser at bellavista dot cz)
    (made it work with reformail in addition to formail)
    Freek Dijkstra (freek at macfreek dot nl)
    (tweaked "From " regex in addtomaildir to support Postfix)
    Share and enjoy!

    A couple of people have reported a peculiar problem with mb2md: when formail runs addtomaildir, it runs it as a shell script, not as a Python script. Unsurprisingly, this does not work very well. (Yes, in both cases I told the person to make sure addtomaildir was executable, and in both cases it was.) Unfortunately, since I don't maintain mb2md at all (it's a one-off tool: convert your mailboxes and you're done with it), I have no time to investigate. But there's an alternative: Juri Haberland's . Give it a try.

    Attached Files:


Share This Page