Migrating mail from another service

Anybody had any luck with a particular email migration service or tool?
Or any thoughts on integrating such a tool into mail-in-a-box?

I’d really like to be able to be “all in” with my MIAB server, but transferring across my legacy mails are an important factor for me.

I use Thunderbird for this. Just add both e-mail account and copy all of the mails from one account to another.

Use Homebrew and install imapsync brew install imapsync

Syntax is something like this:

imapsync --host1 mail.oldserver.com --user1 user@old-email.com --password1 oldemailpassword --host2 mail.newserver.com --port2 993 --user2 user@new-email.com --password2 newemailpassword --ssl2

1 Like

imapsync is pretty good. i moved over 30 accounts with 3-5 gb per account to my server. Takes a while but it works.

Thanks for the suggestions guys.
I went with installing imapsync and used that.
Took a little while as I had to install a bunch of perl dependencies but once I’d done that it was pretty much smooth sailing.
Transferred about 10,000 emails over pretty quickly with no problems.

If anyone would like to know my process, from my terminal I did the following:

sudo apt-get install makepasswd rcs perl-doc libmail-imapclient-perl

then run the following which checks you have all the required dependencies

perl -c imapsync

If you get some sort of @INC error message then you are missing some things.
There’s some info here if you’d like to know how to check which dependencies are missing and how to install them.

Then once they;re sorted you can go ahead and install imapsync

git clone git://github.com/imapsync/imapsync.git

cd imapsync

mkdir dist

sudo make install

Once all that was done I was able to run something similar to the syntax used in pryley’s example above and the script did the rest.

2 Likes

Thanks for the notes, pryley and thingsofrandomness, I used them to transfer some large mailboxes from my old server to my MIAB before I switched DNS and things like that.

Below is the full list of stuff I typed to get it all working. I installed and ran imapsync on my MIAB host itself, so used ‘localhost’ as the destination hostname in the command. I set up the email account using the MIAB admin web interface.

Installing (on Mail-in-a-box host itself)

$ sudo apt-get install git libdigest-md5-file-perl libfile-copy-recursive-perl libio-tee-perl libmail-imapclient-perl libterm-readkey-perl libunicode-string-perl makepasswd perl-doc rcs
$ mkdir /home/ubuntu/src
$ cd /home/ubuntu/src
$ git clone git://github.com/imapsync/imapsync.git
$ perl -c imapsync

Running

# Put IMAP password here.
$ vi my_password.txt

# Loop until all mail has been sync-ed
$ while ! imapsync \
    --host1 mydomain.com \
    --user1 me@mydomain.com \
    --passfile1 my_password.txt \
    --host2 localhost \
    --user2 me@mydomain.com \
    --passfile2 my_password.txt \
    --port2 993 \
    --ssl2 \
    --useuid \
    --nofoldersizes
do
    echo "imapsync for me@mydomain.com bailed for some reason - restarting"
done

I ended up with some duplicate emails from running imap_sync as above. --useid caches message IDs in a temp file, and will skip them the next run. However, a box reboot seemed to remove the ID cache, so I ended up with a few thousand duplicates before I noticed.

I changed the imap_sync invocation to remove --useid, which may be slower, but avoids duplicates even after reboots.

I ended up running a bash one-liner to remove the duplicates. reformail uses the Message-ID header to find dups.

$ sudo su -

$ apt-get install courier-maildrop

$ cd /home/user-data/mail/mailboxes/mydomain.com/myuser/cur

$ > /tmp/mesg_dups ; for mesg in $(find . -type f); do reformail -D 10000000 /tmp/mesg_dups < "$mesg" && rm -v "$mesg"; done

$ apt-get remove courier-maildrop courier-authdaemon courier-authlib courier-authlib-userdb courier-base courier-maildrop expect gamin libgamin0 libtcl8.6

The apt-get removal list is taken from the list of extra dependencies installed along with courier-maildrop.

1 Like

are you actually using double dashes? or single dashes like in openssl command?