1

IMAP allows you to access the folder heirarchy and all emails on a given account.

There was a serverfault (pun intended) with our primary email servers and so we have to shift all email accounts to the new system. I'm using Shared hosting so not really possible to run command line.

Is it possible to connect to all accounts, get messages via IMAP in bulk, and then use IMAP with the new email server to upload all those messages back? Provided the email accounts are created..

2
  • You can get the emails via IMAP, but you can not upload the emails via IMAP. IMAP can be used only to retrieve the emails from the server not sending to a server.
    – Khaled
    Nov 11, 2010 at 17:07
  • 2
    @Khaled-you can put emails into the mail server with IMAP, since it's just shifting messages in a storage area on the server itself (unlike POP). If you create two IMAP accounts with something like Thunderbird, then drag messages from the inbox on server A to server B, voila'...you just moved them from one server to another over IMAP. It's not an MTA type of transfer, but IMAP can be used for moving messages between two servers. Nov 11, 2010 at 17:28

4 Answers 4

1

Larch is an alternative to imapsync that works just as swimmingly. With a working Ruby environment, installation is as simple as:

gem install larch

To migrate dozens of mailboxes from one server to another, you might create a script that looks something like:

#!/bin/bash

# pullmail.sh

function pullmail {
    larch \
        --all \
        --from imaps://source.example.com \
        --from-pass "$2" \
        --from-user "$1" \
        --max-retries 20 \
        --to imaps://dest.example.com \
        --to-pass "$2" \
        --to-user "$1"
}

PS4='\t+ '
set -x

pullmail alice password1
pullmail bob password2
[…and so on…]

Then you might run it with: ./pullmail.sh 2>&1 >> pullmail-$(date +%Y%m%d%H%M).log &. Once complete, you can review the log to address any email that might have had trouble syncing. With luck, all the mail in every folder and in every account will have been copied from the old server to the new.

Also, Larch is smart enough to keep track of what mail it has already synced, so it is safe to re-run the sync again and again until you are satisfied.

You’ll want to consult the documentation to fully understand what is going on. There is also a support forum in case you run into any issues.

1
  • Since 2013 Larch is unmaintained. Mar 31, 2017 at 11:53
6

There's a utility called imapsync which will do exactly what you've described.

1
  • Agreed - I've used imapsync many times and it works very well.
    – EEAA
    Nov 11, 2010 at 18:18
1

I found IMAP Migration Tool written in PHP is a better and easier to use alternative.

Whereas the ImapSync app has to be paid for, $15.

0

For simple use cases, imapsize can also be helpful for

  • making backup from a mail server over IMAP protocol in mbox format
  • restoring the backup to the same mail server or any other mail server
# after building the project
# and declaring source and destination mail server by updating
# ./build/resources/main/mbox.properties 
# in two separate steps

# to make a backup directory  
java -Xmx4096m -Xms512m -jar build/libs/imapsize-1.0-SNAPSHOT.jar -b

# to restore from a backup directory  
java -Xmx4096m -Xms512m -jar build/libs/imapsize-1.0-SNAPSHOT.jar -r

You must log in to answer this question.

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