How to use imapsync

You will need IMAP access to both the source (SEAS) and the destination (,,, etc) email accounts. SEAS already provides imap access, but you may have to enable this on the destination. and have imap access turned off by default; to enable imap access login to your google account, click on the Gear (upper right), select Settings, select "Forwarding and POP/IMAP", set  IMAP Access = Enable IMAP, and click "Save Changes"

You will also need ssh access to EECS users can also use login.eecs. Instructions can be found here.

The most basic version of running imapsync is something like this (one long command):

imapsync --host1 --ssl1 --user1 jharvard --host2 --ssl2 --user2

host1 and user1 are for the source (SEAS) account. (For an EECS account, use for host1.) host2 and user2 are for the destination.

After prompting you for your passwords on both systems, this will copy all of your SEAS mail folders to the system.

Imapsync can be run multiple times (though not concurrently), with each run transferring messsages that arrived since the last run. This may be needed if you have tens of thousands of messages which may take days to transfer. If you plan on doing this, do not sort or delete the transferred messages on the destination ( or they may re-appear.

More advanced version are described below.

WARNING: while there are "--password1" and "--password2" options available, DO NOT USE THESE.

If you really want to  save your passwords, put your passwords into a file that only you can read, and use the "--passfile1" and "--passfile2" options, but if you do not know how to do this then please just enter your passwords every time you run the command.

imapsync only copies email messages. It does not copy calendars or contacts. If you use either of those, then you are probably using Microsft Outlook and can export those using that application.

Advanced imapsync options

Run a test:

  --dry --justfolders

The above will print a summary of the folders encountered and any renaming done using some of the below examples, e.g.:

++++ Looping on each folder
[Calendar]                          -> [seasmail/Calendar]
[INBOX]                             -> [seasmail/INBOX]
[Sent Items]                        -> [seasmail/Sent Mail]

Create a new "seasmail" folder in the destination and put all SEAS email folders into that:

  --regextrans2  's#(.*)#seasmail/$1#'

Ignore specific folders. Spaces and some other characters have to be treated specially:

  --exclude '^Junk\ E-Mail'
  --exclude '^Deleted\ Items'

If you have a lot of email and want to speed up incremental runs:

  --tmpdir ~ --useuid --nofoldersizes

Rename a single folder. You can use multiple --regextrans2 directives but their order does matter so this should go before the above seasmail global rename:

  --regextrans2 's#^Sent Items$#Sent Mail#'

Limit examined messages to those sent/received very recently. This speeds up subsequent runs if you want to catch any final emails you recently received:

  --search "SENTSINCE 1-Dec-2014"

Using some of the above options, what you run may end up looking like one very long command on a single line:

imapsync --host1 --ssl1 --user1 jharvard --host2 --ssl2 --user2 --regextrans2 's#^Sent Items$#Sent Mail#' --regextrans2 's#(.*)#seasmail/$1#' --exclude '^Junk\ E-Mail' --exclude '^Deleted\ Items' --tmpdir ~ --useuid --nofoldersizes


We've seen anything from about 2 messages to 16 messages processed per second. The message size is also important but the number of messages seems to be the most important factor for speed. If the sync job prematurely exits or if you decide to stop it, you can just re-run the same command. It will pick up where it left off. Do not modify the destination folders (renaming folders or re-sorting messages) as that may result in duplicates or missed messages; wait until all of you email is off of SEAS to do that. If you know what "screen" is, we suggest using that.

Other examples can be found at