Imapsync script or How to move more email account easy.

Today I will post a script that show you how to move easy more email account from old mail server to new server.
The story: We have have many account and we now details about every account ( user and password ).

The script

# Example for imapsync massive migration on Unix systems.
# Data is supposed to be in file.txt in the following format
# user001_1;password001_1;user001_2;password001_2
# Do not forget to put absolute path
# Separator is character semi-colon ; it can be changed
# by any character changing IFS=';'
# Each data line contains 4 columns, columns are 
# parameters for --user1 --password1 --user2 --password2
# Replace "" and "" 
# with your own hostname values. 
# This loop will also create a log file called 
# LOG/log_${u2}_$NOW.txt for each account transfer
# where u2 is just a variable containing the user2 
# account name, and NOW is the current date_time

mkdir -p LOG
{ while IFS=';' read  u1 p1 u2 p2
         { echo "$u1" | egrep "^#" ; } > /dev/null && continue
         NOW=`date +%Y_%m_%d_%H_%M_%S` 
         echo syncing to user "$u2"
         imapsync --host1 -addheader  --user1 "$u1" --password1 "$p1" \
                  --host2 --user2 "$u2" --password2 "$p2" \
                  > LOG/log_${u2}_$NOW.txt 2>&1
} < /etc/rc.d/file.txt
### Do not forget to put absolute path to your file "file.txt" or what ever you name it.

Example for file.txt. ( I put diferent example of user and password )


Hope will help you this page!

How to move mails with imapsync from Linux Server to other server or Exchange Mail server.

We have an old Linux mail server and want to upgrade or move mails to other server or new server. How to move easy?  Answer: imapsync.

Example: Move mails from old Linux mail server to new Linux Server:

[root@Linux673]# imapsync –host1 –user1 cristian –password1 PASS07432 –host2 –user2 –password2 PASS-new87

Example: Move mails from old Linux mail server to new MS Exchange with TLS2

[root@Linux673]# imapsync –host1 –user1 –password1 PassWORD –tls2 –host2 –user2 new-user@domain.local –password2 PassWORD

Example: Move mails from old Linux mail server to new MS Exchange with  SSL2

[root@Linux673]# imapsync –host1 –user1 –password1 PassWORD –ssl2 –host2 –user2 new-user@domain.local –password2 PassWORD

You have to change, new-user@domain.local and PassWORD with your local setup.