Create a gist now

Instantly share code, notes, and snippets.

anonymous /imapsync.sh
Created Dec 26, 2012

What would you like to do?
Run like this: "sh ./imapsync.sh [source-server] [source-username] [source-password] [dest-server] [dest-username] [dest-password] Borrowed from here http://blog.otelconsulting.com/2010/01/imapsync-to-gmail-script/ If the destination server is not gmail, please review the parameters (security, ports, etc) to make sure your server is compatible.
#!/bin/sh
#Configure User
SERVER1=$1
UNAME1=$2
PWORD1=$3
SERVER2=$4
UNAME2=$5
PWORD2=$6
#Blank this out if you want to see folder sizes
HIDE="--nofoldersizes --skipsize"
imapsync --syncinternaldates --useheader 'Message-Id' \
--host1 ${SERVER1} --user1 ${UNAME1} \
--password1 ${PWORD1} --ssl1 \
--host2 ${SERVER2} \
--port2 993 --user2 ${UNAME2} \
--password2 ${PWORD2} --ssl2 \
--authmech1 LOGIN --authmech2 LOGIN --split1 200 --split2 200 ${HIDE} \
--exclude 'Drafts|Trash|Spam|Sent'
#TO Sync Special Folders to Gmail
imapsync --syncinternaldates --useheader 'Message-Id' \
--host1 ${SERVER1} --user1 ${UNAME1} \
--password1 ${PWORD1} --ssl1 \
--host2 imap.googlemail.com \
--port2 993 --user2 ${UNAME2} \
--password2 ${PWORD2} --ssl2 \
--ssl2 --noauthmd5 --split1 200 --split2 200 ${HIDE} \
--folder "Inbox/Sent" --prefix2 '[Gmail]/' --regextrans2 's/Inbox\/Sent/Sent Mail/' \
--folder "Inbox/Spam" --prefix2 '[Gmail]/' --regextrans2 's/Inbox\/Spam/Spam/' \
--folder "Inbox/Trash" --prefix2 '[Gmail]/' --regextrans2 's/Inbox\/Trash/Trash/' \
--folder "Inbox/Drafts" --prefix2 '[Gmail]/' --regextrans2 's/Inbox\/Drafts/Drafts/' \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment