A bit of searching produces this useful PHP routine, which almost worked. Two tweaks got it all the way there:
- force the correct time zone
- quote the write-mode parameter in fopen
The changes, with line numbers in parens (line 347 was line 345 before the first change, OK?):
76: // force timezone
77: date_default_timezone_set("America/New_York");
347: $this->mboxhnd = fopen($this->mboxfn,'w');
After that, run the script as directed to convert the entire maildir tree in one fell swoop.
cp -a /from-wherever/Mail/ /tmp cd /tmp php maildir2mbox.php Mail ll mboxfiles
The output files appear in the mboxfiles directory adjacent to the top-level maildir directory. Don’t use the -e parameter, which would add a .mbox suffix to each file.
Evolution’s import “feature” is a major pain, as you must import the converted files One. MBOX. File. At. A. Time. Sheesh.
Rather than that, just slide the whole mboxfiles structure into place. Some case changes were in order for my setup, which may be due to historic considerations:
- Drafts
- Inbox
- Outbox
- sent-mail -> Sent
- Spam (will become Junk in Evo)
- Templates (not that I use any)
Then put the mboxfiles directory somewhere on the NFS server and fiddle the Evolution directory structure:
cp -ap mboxfiles /mnt/nfs-place/mail/ cd ~/.evolution/mail mv local local.base ln -s /mnt/nfs-place/mail/ local
Evolution will build all its indexes when it first sees the new files, so it’s all good.
Comments
4 responses to “Kmail to Evolution: Converting Maildir to Mbox”
Those line numbers do not appear to be in parentheses, not that it matters. Maybe it’s my web browser.
Poof! History rewritten to make the answer come out right…
wait, what? I thought the entire point of this exercise was that maildir is non-negotiable?
You’re absolutely correct. I got far enough into Evolution before I discovered that it *only* uses mbox that I figured, eh, just do it.
As it turns out, I was converting my esteemed wife’s account at that point, so she’s now running Evolution and I’m still running the truncated Kmail (which continues to screw up its index files). The conversion process wasn’t nearly as smooth as I’d like for my collection of files; hers seems to have come through unscathed.
I think the only way out is installing dovecot on the file server that holds the mail files, have it maintain maildir files on the back end, and serve IMAP to Evolution. That’s still in the scribbling notes stage, though.
From what I can tell, Kmail screws up IMAP, too.