Migrate mail from one server to another with imapsync

Rob —  October 11, 2013 — 2 Comments

Have you been in the situation where you needed to move everyone’s mail from one provider to another?  It’s a pain to do using the mail client one at a time, but with this guide, you’ll be able to create a csv with everyone’s info and run one command to fire it all off.  All you need is a Linux machine to do it.

First, you’ll need to install the epel repo (skip if you already have it):

CentOS 5 (as root):

CentOS 6 (as root):

Now, use yum to install imapsync. It will automagically install all of the deps.

Now that it’s installed, let’s print out the help file and take a look at all of the usefulness of imapsync:

Now let’s get to business and start a sync. Let’s just do one user first before we jump into doing multiple at once.

Our info for this task:
Old: server=old.mailserver.com, user=test@domain.com, pass=mypasswd
New: server=new.mailserver.com, user=test@domain.com, pass=mypasswd

Here’s the command:

Let’s migrate multiple people at once now!

Create a file full of info called ‘file.txt’. An example is here

Now, paste this into sync_loop_unix.sh

(Make sure to change the hosts in the sync_loop_unix.sh file)

Make it executable:

Now run it!

You can add as many accounts as you want in the csv file.

Read more about imapsync on their official page: http://imapsync.lamiral.info/

Related posts from Linux Brigade!

  • Migrating from Plesk to cPanel via commandlineMigrating from Plesk to cPanel via commandline If you’re anything like me, you prefer to do things via command line (CLI) rather than relying on a GUI to do most things in Linux. You also realize that while some of us don’t like to use […]
  • Block account from sending mail WHM/cPanelBlock account from sending mail WHM/cPanel There may come a time when you’d like to block an account / domain on your WHM/cPanel server from being able to send mail. Here’s how you’d get it done!

    We’re going to set up a […]

  • csf_largecPanel server – can’t send mail! If you are trying to send mail via webmail and it is not working out, you may have the answer right under your nose.  If you have CSF installed, it is likely blocking port 25.

    You may […]

  • Patch your WHM/cPanel machine for heartbleedPatch your WHM/cPanel machine for heartbleed You’ve certainly heard about Heartbleed by now. If not, you can read more about this vulnerability at Heartbleed.com. Continue reading this post to find out if you’re vulnerable, and how […]
  • Reduce TIME_WAIT socket connectionsReduce TIME_WAIT socket connections Some time in your life you’ll run across an Apache server that always has tons of TIME_WAIT connections just seeming to hang out. While these don’t take up as many resources as an […]

2 responses to Migrate mail from one server to another with imapsync

  1. thanks for you tutorial!

Leave a Reply


Text formatting is available via select HTML.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">