0

I'm helping a friend migrate off of a Macbook. I've created an imap account on a server to hold the emails.

Is there a way to bulk-copy the contents of local folders ("On My Mac") to the imap server? My friend has folders within folders. Something like this:

  • House
    • message
    • message
    • message
    • Plumbing
      • message
      • message
      • Bills
        • message
      • message
    • Electrical
      • message
      • message
  • Vacation
    • message
    • message
    • Schedules
      • message
      • message
  • Jokes
    • message
    • message

and so forth. Probably around 50 top-level folders and I have no idea how many subfolders. 2G of email total.

I want to bulk-copy the entire lot to a server so he can access them from his iPad instead. Let's assume he won't be accessing the local folders on his Mac once we get this figured out.

Can this be done, or are we doomed to create the folders one by one and then copy the individual emails?


More information as I experimented:

The server is Dovecot

I was transferring folders to the server by simply dragging them within Mail.app. This worked fine in most cases.

Some piece of software in the chain doesn't like dots in folder names, so the folder "Dr.Who" got changed to "Dr" with the subfolder " Who" and then errors occurred. After I spent some time searching for folders with '.' in their names, and renaming them, things went better.

Sometimes when I dragged a folder that contained both messages and subfolders, it went smoothly. Sometimes the top-level folder would be empty and would not allow messages to be stored in it. When that happened, I could look around and find the folder named "folder (Messages)" which contained the missing messages. I would then be able to recombine the two folders and rename and I'd be good.

Mail.app really needs a "sort folders alphabetically" function. I found that I could do this manually by quitting Mail, deleting .mboxCache.plist, and restarting Mail.

The imap-upload tool would have been perfect for my needs if it had worked. I might look into debugging it.

I'll leave the question open for a while to see if anybody finds a real answer.


One more data point: as an experiment, I tried creating the subfolder "Dr. Who" from Thunderbird instead of Mail.app. It created the folder "Dr" with the subfolder " Who". I believe Mail.app uses dots as subfolder specifiers when talking to an IMAP server, but uses slashes for folders on the local system. Thus, a folder name with a dot in it is perfectly acceptable for a local folder, it causes issues when pushed to an IMAP server.

  • Didi you tried the export mailbox function? This creates a .mbox file which should contain all folders and subfolders. – Colin Jul 24 '17 at 6:01
  • maybe look at this question. It seems very similar to yours. apple.stackexchange.com/questions/286364/… – Colin Jul 24 '17 at 6:06
  • I did play around with export mailbox, but I couldn't figure out how to import the resulting files back to the server. – Edward Falk Jul 24 '17 at 15:20
  • What software does the server use? Do you run it by yourself or is it a public service? – Colin Jul 24 '17 at 15:40
  • 1
    no I found another software :) have a look here: wiki.dovecot.org/Migration/MailFormat – Colin Jul 25 '17 at 18:51
1

Informational post.

So … I've been reading up on the IMAP protocol. It seems to me that IMAP doesn't really have a formal concept of subfolders. If you want to name one mailbox "House" and another one "House.Plumbing", that's entirely up to you. It just happens that Mail.app, and probably many other email clients choose to present these folders to you in a hierarchical form.

That also explains why I encountered some higher-level folders that wouldn't accept any messages — if you were to create, e.g. "House.Plumbing" but not "House", Mail.app would show you the un-writable virtual folder "House" with the subfolder "Plumbing". But as far as the IMAP server is concerned, it's just a folder named "House.Plumbing".

(This isn't to say that the IMAP server itself won't store the folders in a hierarchical way, but the standard doesn't say either way, AFAIK.)

0

Well, for the record, I just gave up and wrote my own imap client in Python to do the job. It can download and upload any hierarchy of mailboxes from/to a Dovecot server. It should work with any server, but I haven't tested it on others. If it passes its final tests, and there's interest, I suppose I could upload it to github.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .