IMAP migration and changes to folder structure

384 views Asked by At

I am using imapcopy on a ubuntu 14.04 server and telnet to migrate and respectively edit heavy imap inboxes accounts. I would like to flatten the folder structure, meaning that I want to select and copy all emails from all children folders into one "Import" folder.

I cant seem to be able to do just that. Any suggestions to an alternative way to do this?

2

There are 2 answers

1
Rick Sanders On BEST ANSWER

Are you using this? https://launchpad.net/ubuntu/+source/imapcopy/1.04-1. If so, edit imaptools.pas and change the following line as shown to copy all messages to the IMPORT folder on the destination.

Original:

Result := Command ('APPEND '+Mailbox + Flags + ' {' + IntToStr (Length(Msg)) + '}',TRUE);

New:

Result := Command ('APPEND IMPORT' + Flags + ' {' + IntToStr (Length(Msg)) + '}',TRUE);

If the IMPORT folder does not already exist you'll need to create it.

Err := Dst.CreateMailbox ('IMPORT');

Then recompile it.

0
Lukas On

You can use https://github.com/Schluggi/pymap-copy as well. I think this is more handsome, because you don't have to compile anything.

If you would like it as described above (copy every mail of every subfolder to the import folder):

./pymap-copy.py \
--source-user=user1 \
--source-server=server1.example.org \
--source-pass=2345678 \
--destination-user=user2 \
--destination-server=server2.example.info \
--destination-pass=abcdef \
--redirect *:INBOX.import

And in the case you want to maintain your folder structure:

./pymap-copy.py \
--source-user=user1 \
--source-server=server1.example.org \
--source-pass=2345678 \
--destination-user=user2 \
--destination-server=server2.example.info \
--destination-pass=abcdef \
--destination-root INBOX.import