This commit is contained in:
Nick Bebout 2015-12-03 11:16:32 -06:00
parent f1987d5e52
commit b7c835d670
134 changed files with 44448 additions and 2810 deletions

View file

@ -1,39 +1,51 @@
#!/bin/cat
$Id: FAQ.Domino.txt,v 1.2 2015/03/26 04:24:17 gilles Exp gilles $
# $Id: FAQ.Domino.txt,v 1.4 2015/09/19 08:58:34 gilles Exp gilles $
======================================================================
Domino specific issues and solutions
Imapsync. Domino specific issues and solutions
======================================================================
======================================================================
Q. From Domino Notes to xxx
On Windows use:
imapsync.exe ... --sep2 "\\" --prefix2 ""
imapsync.exe ... --sep1 "\\" --prefix1 ""
On Unix use:
imapsync ... --sep2 '\\' --prefix2 ''
imapsync ... --sep1 '\' --prefix1 ''
======================================================================
Q. From xxx to Domino Notes
For Domino anywhere with imapsync.exe on Windows use:
Domino doesn't accept INBOX subfolders.
On Windows:
imapsync.exe ... ^
--sep2 "\\" --prefix2 "" ^
--regextrans2 "s,^INBOX\\(.*),$1,"
--regextrans2 "s,^Inbox\\(.*),$1,i"
Explanation: Domino doesn't accept INBOX subfolders.
On Unix:
imapsync ... \
--sep2 '\' --prefix2 '' \
--regextrans2 's,^Inbox\\(.*),$1,i'
If you want to sync the complete host1 mailbox in a subfolder called OLDBOX use:
On Windows:
imapsync.exe ... ^
--sep2 "\\" --prefix2 "" ^
--regextrans2 "s,(.*),OLDBOX\\$1," --justfolders --dry
--subfolder2 "OLDBOX" --justfolders --dry
On Unix:
imapsync ... \
--sep2 '\' --prefix2 '' \
--subfolder2 'OLDBOX' --justfolders --dry
If the output is correct for you then remove --dry and have a run.
Verify the folder hierarchy is good on host2 then remove --justfolders to
sync the messages.

View file

@ -1,8 +1,8 @@
#!/bin/cat
$Id: FAQ.Dovecot.txt,v 1.1 2015/03/23 00:16:43 gilles Exp gilles $
$Id: FAQ.Dovecot.txt,v 1.2 2015/07/18 22:35:27 gilles Exp gilles $
=======================================================================
Dovecot specific issues and solutions
Imapsync. Dovecot specific issues and solutions
=======================================================================

View file

@ -1,8 +1,8 @@
#!/bin/cat
$Id: FAQ.Duplicates.txt,v 1.3 2015/04/02 23:40:08 gilles Exp gilles $
$Id: FAQ.Duplicates.txt,v 1.5 2015/09/19 08:59:14 gilles Exp gilles $
======================================================================
Imapsync and message duplicates issues
Imapsync and duplicated messages issues.
======================================================================
=======================================================================
@ -62,6 +62,11 @@ and Received lines? Often standalone Message-Id works:
imapsync ... --useheader "Message-Id"
Once imapsync does not generate duplicates, the previous duplicates
can be deleted with option --delete2duplicates
imapsync ... --useheader "Message-Id" --delete2duplicates
Another good way toward a solution is to isolate two or three messages
in a BUG folder and send me the --debug output by email at
gilles.lamiral@laposte.net
@ -69,7 +74,7 @@ gilles.lamiral@laposte.net
imapsync ... --debug --folder BUG
I will take a close look at the log and modify imapsync to fix
this faulty duplicate behaviour.
this faulty duplicate behavior.
Remark. (Trick found by Tomasz Kaczmarski)

View file

@ -1,13 +1,60 @@
#!/bin/cat
$Id: FAQ.Exchange.txt,v 1.4 2015/06/03 15:33:48 gilles Exp gilles $
$Id: FAQ.Exchange.txt,v 1.14 2015/11/30 16:12:18 gilles Exp gilles $
=======================================================================
Exchange 20xx and Office365 specific issues and solutions
Imapsync. Exchange 20xx and Office365 specific issues and solutions
=======================================================================
Questions anwswered in this FAQ are:
Q. Can I use imapsync to transfer from or to Exchange or Office365 accounts?
Q. How to sync from XXX to Exchange 2010/2013 or Office365
Q. For Office365 I have double and triple checked the username and
password spelling but I still get a "LOGIN failed". Any clue?
Q. Exchange fails with "User is authenticated but not connected".
Q. From XXX to Exchange 2013 or Office365, read receipts are all
resent again after a sync. Even for old messages. How can I fix that?
Q. From XXX to Exchange 2010/2013 or Office365 I get this error message
sometimes: "BAD Command Argument Error 11". What does it mean?
Q. From XXX to Exchange 2010 or 2013 or Office365 the flag Flagged does
not seem to be well synced. What can I do?
Q. Exchange and Office365 have throttle mechanisms to limit any huge
usage. Sometimes imapsync transfers are too stressful for servers.
How to deal with that?
Q. How to migrate from or to Exchange 2007/2010 with an
admin/authuser account?
Q. How to migrate from or to Office 365 with an admin/authuser account?
Q. How to migrate from or to Exchange 2003 with an admin/authuser
account?
Q. Couldn't create folder [trash] "Mailbox already exists".
Q. Migrating to Exchange 201O, messages get date of the transfer,
this is bad for sorting and listing. What can I do?
Q. How to sync from any to Exchange2007?
Q. How to sync from Microsoft Exchange 2000 IMAP4rev1 server?
=======================================================================
Q. From XXX to Exchange 2010/2013 or Office365
Q. Can I use imapsync to transfer from or to Exchange or Office365 accounts?
R. Yes. But IMAP access to a Exchange or Office365 account is not always
allowed by default so it has to be allowed in the server configuration
part:
=======================================================================
Q. How to sync from XXX to Exchange 2010/2013 or Office365
R. Here is a command line resume that solves most encountered issues when
migrating to Exchange or Office365. To understand or change the
@ -19,9 +66,13 @@ On Windows:
imapsync.exe ... ^
--maxsize 10000000 ^
--maxlinelength 9900 ^
--maxmessagespersecond 4 ^
--regexflag "s/\\Flagged//g" ^
--disarmreadreceipts ^
--maxlinelength 9000
--regexmess "s,(.{9900}),$1\r\n,g"
On Unix
imapsync ... --regexmess 's,(.{9900}),$1\r\n,g'
On Unix:
@ -29,18 +80,50 @@ On Unix:
imapsync ... \
--maxsize 10000000 \
--maxlinelength 9900 \
--regexflag "s/\\Flagged//g" \
--maxmessagespersecond 4 \
--regexflag 's/\\Flagged//g' \
--disarmreadreceipts \
--maxlinelengthcmd 'reformime -r7'
To get the "reformime" command on Linux install the "maildrop" package
No "reformime" on Windows so for now messages with too long line length
can't be synced to Exchange or Office365.
On Linux, to get the "reformime" command, install the "maildrop" package.
In case you don't have it you can use
--regexmess 's,(.{9900}),$1\r\n,g'
instead of --maxlinelengthcmd 'reformime -r7'
On Windows, no "reformime" is available so messages with too long line length
can be synced to Exchange or Office365 by inserting a CRLF every 9900
characters on long lines, using --regexmess "s,(.{9900}),$1\r\n,g"
=======================================================================
Q. From XXX to Exchange 2013 or Office365 read receipts are all
resent again after a sync. Even for old messages. How can I fix that?
Q. For Office365 I have double and triple checked the username and
password spelling but I still get a "LOGIN failed". Any clue?
R1. Triple check the hostname then. Try all of these:
* imap-mail.outlook.com
* imap.outlook.com
* outlook.office365.com
R2. Also triple check a license is assigned to that account
in Office365.
R3. Try with a classic email client like Thunderbird and the same
parameters.
=======================================================================
Q. Exchange fails with "User is authenticated but not connected".
R. "The message “User is authenticated but not connected” is due to a
bug in the Exchange server's IMAP implementation. If the client
presents a valid user name but an invalid password, the server
accepts the login, but subsequent commands fail with the
aforementioned error message." Source:
http://unix.stackexchange.com/questions/164823/user-is-authenticated-but-not-connected-after-changing-my-exchange-password
Thanks to James Abbottsmith for this link and explanation at
https://github.com/imapsync/imapsync/issues/32#issuecomment-153561647
=======================================================================
Q. From XXX to Exchange 2013 or Office365, read receipts are all
resent again after a sync. Even for old messages. How can I fix that?
R. imapsync can remove the header containing this read receipt request.
@ -74,7 +157,7 @@ Thanks to David Karnowski for pointing and solving this issue.
=======================================================================
Q. From XXX to Exchange 2010/2013 or Office365 I get this error message
sometimes: "BAD Command Argument Error 11"
sometimes: "BAD Command Argument Error 11". What does it mean?
R. This error message comes from Exchange IMAP server when it
encounters any problem. Most of the time it is one of the following:
@ -101,6 +184,15 @@ R. This error message comes from Exchange IMAP server when it
imapsync ... --maxlinelength 9900
In case you prefer fixing messages with long lines the hard way,
instead of skipping them with --maxlinelength 9900, just use:
On Windows
imapsync ... --regexmess "s,(.{9900}),$1\r\n,g"
On Unix
imapsync ... --regexmess 's,(.{9900}),$1\r\n,g'
Have also in mind that Exchange closes the connection after 10 errors
encountered so you might also see "BYE Connection closed" errors from
Exchange, which means Exchange leaves the session and say goodbye,
@ -108,7 +200,7 @@ come back later. Rerun a sync then.
=======================================================================
Q. From XXX to Exchange 2010 or 2013 or Office365 the flag Flagged does
not seem to be well synced.
not seem to be well synced. What can I do?
R. Use the following trick. Run imapsync twice, one with --regexflag
and one without, like this:
@ -128,7 +220,15 @@ With STORE it sets and gets the "\Flagged" flag everywhere.
Thanks to Dave Murray and Simon Savva for reporting and solving
this issue.
======================================================================
Q. Exchange and Office365 have throttle mechanisms to limit any huge
usage. Sometimes imapsync transfers are too stressful for servers.
How to deal with that?
R. It looks like limiting 4 messages per second is enough to never
reach any throttle limit.
imapsync ... --maxmessagespersecond 4
======================================================================
Q. How to migrate from or to Exchange 2007/2010 with an
@ -245,8 +345,7 @@ In case you are not aware:
=======================================================================
Q. Couldn't create folder [trash] from [INBOX.trash]:
588 NO Mailbox already exists.
Q. Couldn't create folder [trash] "Mailbox already exists".
R. Some servers take care about character case in folder names,
some servers do not, like Exchange. Since non-respecting case
@ -275,10 +374,13 @@ R. Some servers take care about character case in folder names,
mandatory, otherwise imapsync will sync messages from the
first Trash and then delete them when syncing trash.
In order to avoid merging folders that are considered different
on host1 but the same on destination host2 because of case
sensitivities and insensitivities, use --nomixfolders
======================================================================
Q. Migrating to Exchange 201O, messages get date of the transfer,
this is bad for sorting and listing.
this is bad for sorting and listing. What can I do?
R1. Be sure to have at least Exchange 2010 SP2 Rollup 5
http://www.tribalchicken.com.au/15-technical/29-imapsync-exchange2010
@ -291,7 +393,7 @@ It's often shorter to change one server than thousands clients
so R1 might be easier to do.
======================================================================
Q. From any to Exchange2007
Q. How to sync from any to Exchange2007?
Several problems:
- Big messages: increase the "send- and receive-connector"
@ -310,10 +412,9 @@ Two users succeeded by using "MS Transporter Suite" (which is closed
expensive non-free software).
======================================================================
Q. From Microsoft Exchange 2000 IMAP4rev1 server version 6.0.6487.0.
Q. How to sync from Microsoft Exchange 2000 IMAP4rev1 server?
R. imapsync ... \
--prefix1 INBOX.
R. imapsync ... --prefix1 "INBOX."
=======================================================================
=======================================================================

View file

@ -1,8 +1,8 @@
#!/bin/cat
$Id: FAQ.Flags.txt,v 1.3 2015/04/03 21:05:11 gilles Exp gilles $
$Id: FAQ.Flags.txt,v 1.4 2015/07/18 22:35:27 gilles Exp gilles $
======================================================================
Imapsync and flags
Imapsync and flags
======================================================================
Questions answered here are:

View file

@ -1,9 +1,9 @@
#!/bin/cat
$Id: FAQ.Folders_Mapping.txt,v 1.5 2015/05/11 10:36:33 gilles Exp gilles $
$Id: FAQ.Folders_Mapping.txt,v 1.8 2015/12/03 02:37:45 gilles Exp gilles $
===========================================
Imapsync changing folders names
===========================================
======================================================================
Imapsync. Changing folders names
======================================================================
Things to know and understand before playing with --regextrans2
@ -61,18 +61,23 @@ Q. Give examples about --regextrans2
Examples:
1) To remove INBOX. in the name of destination folders:
1) To remove INBOX. in the name of destination folders
--regextrans2 's/^INBOX\.(.+)/$1/'
imapsync ... --regextrans2 's/^INBOX\.(.+)/$1/'
2a) To sync all folders to INBOX:
2) To change only INBOX to Inbox_Migrated
imapsync ... --regextrans2 's{^INBOX$}{Inbox_Migrated}'
2a) To sync all folders to INBOX
imapsync ... --regextrans2 "s/.*/INBOX/"
2b) To sync a complete account in a subfolder called FOO:
2b) To sync a complete account in a subfolder called FOO
Since imapsync release 1.641 simply use:
Since imapsync release 1.641 simply use
imapsync ... --subfolder2 FOO
@ -130,6 +135,21 @@ On Windows:
--regextrans2 s,\^",_,g
3c) to substitute all characters *%. by underscores _
You can increase the *%. list by any unwanted character.
On Linux/Unix:
--regextrans2 'tr,*%.#,_,'
On Windows:
--regextrans2 "tr,*%.#,_,"
3d) It is a bad idea to substitute & characters since &
is a character to encode non-ascii characters in IMAP folder names.
4) to change folder names like this:
[mail/Sent Items] -> [Sent]

205
FAQ.d/FAQ.Gmail.txt Executable file → Normal file
View file

@ -1,13 +1,78 @@
#!/bin/cat
$Id: FAQ.Gmail.txt,v 1.2 2015/05/11 01:11:40 gilles Exp gilles $
$Id: FAQ.Gmail.txt,v 1.13 2015/11/05 21:01:12 gilles Exp gilles $
======================================================================
Imapsync with Gmail
Imapsync with Gmail
======================================================================
Questions anwswered in this FAQ are:
Q. Can I use imapsync to transfer from or to Gmail accounts?
Q. How to synchronize from Gmail to Gmail?
Q. How to synchronize from XXX to Gmail?
Q. How to synchronize from Gmail to XXX?
Q. How to avoid the [IMAP] prefix on Gmail side?
Q. I can't authenticate with Gmail via IMAP
and Gmail says "Please log in via your web browser"
Q. Can not open imap connection on [imap.gmail.com]
Q. Gmail does not really delete messages in folder [Gmail]/All Mail
Q. Does imapsync have the capability to do 2 stage authentication?
Q. How to use XOAUTH2 to globally authenticate gmail users?
Q. How to use XOAUTH to globally authenticate gmail users?
Q. How to use a Gmail account to backup several different imap accounts?
Q. How to migrate email from gmail to google apps?
=======================================================================
Q. Can I use imapsync to transfer from or to Gmail accounts?
R. Yes. But IMAP access to a Gmail account is not allowed by default so
it has to be allowed in the Gmail configuration part:
-> Settings
-> Forwarding and POP/IMAP
-> IMAP Access
-> Enable IMAP
=======================================================================
Q. How to synchronize from Gmail to Gmail?
R. Use the following example:
./imapsync \
--host1 imap.gmail.com \
--ssl1 \
--user1 account1@gmail.com \
--password1 gmailsecret1 \
--host2 imap.gmail.com \
--ssl2 \
--user2 account2@gmail.com \
--password2 gmailsecret2 \
--exitwhenover 500000000 \
--exclude "\[Gmail\]$"
Explanations:
--ssl1 --ssl2 are mandatory since Gmail only supports
imap ssl connections.
--exitwhenover 500000000 ( ~500 MB ) option is here to avoid
locking or errors when transfers exceed maximum limit.
See http://support.google.com/a/bin/answer.py?hl=en&answer=1071518
--exitwhenover is not mandatory in the sense you may be able to
use an upper value than 500 MB without disconnections; I don't
know the hard value, it seems to vary, so just have some tries
and report me what you discover in case you detect something
reliable.
--exclude "\[Gmail\]$" is just there to avoid a warning error
when selecting this not used folder.
=======================================================================
=======================================================================
Q. Synchronizing from XXX to Gmail
Q. How to synchronize from XXX to Gmail?
R. There are some details to get the special [Gmail] sub-folders
right. Here's an example of migrating an old "Sent" folder to
@ -102,31 +167,23 @@ unselect some "System labels", depending on your needs.
The "All Mail" archive pseudo-folder should be updated automatically.
=======================================================================
Q. Some of the folders are getting created with [IMAP] prefix on Google
side. How to stop creating folder with this prefix?
Any switch we can use? e.g. [IMAP]/Archive
Q. How to synchronize from Gmail to XXX?
R. No switch in imapsync since [IMAP]/ prefix is done by Gmail,
it might be configurable with Gmail parameters.
=======================================================================
Q. Synchronizing from Gmail to XXX
R. Gmail needs SSL
R. Use this example:
./imapsync \
--host1 imap.gmail.com \
--user1 gilles.lamiral@gmail.com \
--password1 gmailsecret \
--host2 localhost
--host2 localhost \
--user2 tata \
--password2 tatasecret \
--ssl1 \
--exitwhenover 2500000000 \
--useheader="X-Gmail-Received" \
--useheader "Message-Id" \
--regextrans2 "s,\[Gmail\].,," \
--skipcrossduplicates \
--folderfirst "Work" \
--folderfirst "Friends" \
@ -138,8 +195,9 @@ Explanations:
--ssl1 is mandatory since Gmail only supports imap ssl connections.
--exitwhenover 2500000000 option is here to avoid locking when
transfers exceed maximum limit.
--exitwhenover 2500000000 (2.5 GB) option is here to avoid
locking when transfers exceed maximum limit.
See http://support.google.com/a/bin/answer.py?hl=en&answer=1071518
--exitwhenover is not mandatory in the sense you may be able to
use an upper value than 2.5 GB without disconnections; I don't
@ -154,9 +212,9 @@ by imapsync can not fail using this header. "Message-Id" is there
for safety about this Gmail rule.
If your destination imap server doesn't like "[Gmail]" name, just add
option:
--regextrans2 's/\[Gmail\]/Gmail/'
--regextrans2 "s,\[Gmail\].,,"
If your destination imap server doesn't like "[Gmail]" name,
get rid of this "[Gmail]" part with that.
You can select folders exported to imap within the gmail preferences,
for example you may unselect all "System labels".
@ -186,9 +244,17 @@ label CanWait and only it.
--skipcrossduplicates, will only put in "[Gmail]/All Mail"
the messages that are not labeled at all.
=======================================================================
Q. How to avoid the [IMAP] prefix on Gmail side?
How to stop creating folder with this prefix?
Any switch we can use? e.g. [IMAP]/Archive
R. No switch in imapsync since [IMAP]/ prefix is done by Gmail,
it might be configurable within Gmail parameters configuration.
=======================================================================
Q. I can't authenticate with Gmail via IMAP
Gmail says "Please log in via your web browser"
and Gmail says "Please log in via your web browser"
R1. See Coert Grobbelaar solution:
https://security.stackexchange.com/questions/86404/how-do-i-interact-with-google-to-import-email-via-imapsync
@ -200,8 +266,40 @@ so I logged for this account via a web browser,
it asked me to receive a code via a mobile, I said yes,
I entered the code and everything went ok.
R3. Use https://www.google.com/settings/security/lesssecureapps
(thanks to Flavio Zarur)
See https://support.google.com/accounts/answer/6010255?hl=en
=======================================================================
Q. Gmail does not really delete messages in folder [Gmail]/All Mail
Q. Can not open imap connection on [imap.gmail.com]:
Unable to connect to imap.gmail.com
R0. It looks like this issue is related to ipv6. Both ipv4 and ipv6
protocols should work with gmail and imapsync, I test that regurlarly,
imapsync works fine for both ipv4 and ipv6.
If you disable ipv6 then disable also ipv6 resolution or at least
make ipv4 answers be taken before ipv6 since default resolution
order is to take ipv6 resolution if any.
R1. A first simple solution is to use directly gmail ipv4 ip address:
imapsync ... --host1 74.125.133.108
In case it changes, get with any command showing the imap.gmail.com resolution
nslookup imap.gmail.com
host imap.gmail.com
ping imap.gmail.com
Or go to http://ping.eu/nslookup/ to get the resolution.
R2. Fix imapsync with the line:
use IO::Socket::SSL 'inet4' ;
Thanks to Chris Nolan to report, understand and fix this issue!
=======================================================================
Q. Gmail does not really delete messages in folder [Gmail]/All Mail
What happens? What can I do?
R. It's true and explained in Gmail documentation at
@ -209,64 +307,45 @@ https://support.google.com/mail/answer/78755?hl=en
To really remove messages in folder "[Gmail]/All Mail", they have to
be moved to the "Trash" folder and be deleted from "Trash".
=======================================================================
Q. Does imapsync have the capability to do 2 stage authentication for google.
Q. Does imapsync have the capability to do 2 stage authentication?
R. No, imapsync doesn't support 2 stage authentication.
Reading https://support.google.com/mail/answer/1173270?hl=en
it looks like it can't because imapsync uses imap protocol.
So you have to follow the Google recommendation and generate an
application-specific password or normal authentication or XOAUTH.
application-specific password or normal authentication
or use XOAUTH or XOAUTH2.
=======================================================================
Q. Is XOAUTH2 authentication available with imapsync?
Q. How to use XOAUTH2 to globally authenticate gmail users?
R. Yes but only on Unix systems and not really well documented. See
* http://www.linux-france.org/prj/imapsync_list/msg02129.html
* https://github.com/imapsync/imapsync/pull/25/files
R. Yes, but really tested on Unix systems, not sure on Windows. See:
http://imapsync.lamiral.info/FAQ.d/FAQ.XOAUTH2.txt
=======================================================================
Q. How to use XOAUTH to globally authenticate gmail users?
The XOAUTH code and this FAQ item come from Eduardo Bortoluzzi
Thanks Eduardo!
R. The goal of OAUTH is to migrate all users from/to Google Apps
Premier Edition without knowing their passwords.
The global password is available at the Google Apps control panel,
at Advanced Tools -> Manage OAuth domain key.
./imapsync \
--host1 imap.gmail.com --ssl1 \
--user1 foo@lab3.dedal.br \
--password1 secret1 \
--authmech1 XOAUTH \
--host2 imap.gmail.com --ssl2 \
--user2 bar@lab3.dedal.br \
--password2 secret2 \
--authmech2 XOAUTH
Google Apps is a paid service, but you can try it for 30 days without any cost.
Some notes about configuring the Google Apps XOAUTH:
On "Advanced Tools > Manage OAuth domain key > Two-legged OAuth access control"
the "Allow access to all APIs" must be checked
(https://support.google.com/a/bin/answer.py?answer=162105)
OR
On "Advanced Tools > Manage third party OAuth client access",
the configured costumer key must have the scope
"https://mail.google.com/" configured
(https://support.google.com/a/bin/answer.py?answer=162106).
R0. XOAUTH is considered obsolete and superseded by XOAUTH2
See http://imapsync.lamiral.info/FAQ.d/FAQ.XOAUTH2.txt
=======================================================================
Q. migrate email from gmail to google apps
Q. How to use a Gmail account to backup several different imap accounts?
R. For each account named xxx use:
imapsync ... --subfolder2 xxx/xxx
It syncs the account xxx under a sub-subfolder xxx/xxx. This way there
is no supplementary label created on the multi-archive Gmail
destination account. No labels all over the place and all original
xxx sub-folders show up nested within xxx/xxx.
=======================================================================
Q. How to migrate email from gmail to google apps?
R. Take a look at:
http://www.linux-france.org/prj/imapsync_list/msg00639.html

72
FAQ.d/FAQ.ISP.txt Normal file
View file

@ -0,0 +1,72 @@
#!/bin/cat
$Id: FAQ.ISP.txt,v 1.2 2015/10/21 15:23:07 gilles Exp gilles $
=================================================
Imapsync. ISP specific issues and solutions
=================================================
* IMAP Sync - usage scenario with ISP - by Flávio Zarur Lucarelli.
I thought Id write a quick step by step on my attempts to learn the
imapsync features that matter the most, so it works as we expected in
the cenario in which we use it, which is to migrate customers from
their old ISP to our ISP/email hosting. Thanks to the master Gilles
Lamiral for all his help and hard work.
First of all, remember to use --dry to test things first always and
check the log file to see what would actually happen.
My first goal is to have an exact sync of an account from
current/source host to the new/destination host and be able to sync
several times. The --useuid parameter is very important for that
purpose. This is what I use:
imapsync --host1 imap.gmail.com --user1 user@domain.com --password1 pwd --ssl1 --host2 imap.myisp.com --user2 user@domain.com --password2 pwd --ssl2 --useuid --delete2 --delete2folders
This makes it so imap.myisp.com (destination) is an exact copy of the
account at imap.gmail.com (source). This is not a problem, since the
user is not using the new host yet. ]You can check Imapsync log files
and surely you will see the final difference should be 0. Check also
for any possible errors in the log (search for "error").
The second goal is to lower the TTL (ex: 5 min) for the host
associated with the MX record, in the domain's DNS server. Let's say
customer has a host mail which his MX points to, with a high TTL
(usually 1 hour). Lower it to 5 min so that, when you change the MX,
it propagates faster.
When comes time to switch over to the new host, do a final sync with
above syntax, before changing the MX. Then, change the MX and tell
your users to start using exclusively the new host.
A few hours after the MX change, we will run Imapsync again. We have
to start preserving emails users move or flag in the new host, which
they started using, so we can't do an exact sync anymore.
The best solution for me was to Sync any new emails (maxage:1) from
source (that could arrive in source even after MX change, due to
cache) and delete such emails from source server. This way, customer's
mailbox is still intact on the source server, except new emails, which
get synced to new server and deleted from source.
imapsync --host1 imap.gmail.com --user1 user@domain.com --password1 pwd --ssl2 --folder INBOX --useuid --noexpungeaftereach --skipemptyfolders --maxage 1 --delete1
I personally prefer to keep a copy of users box intact in source, but
if that's not an issue for you, you can remove --folder INBOX and even
--maxage, but then, all emails in source will be deleted. You can use
--maxage 1 with --delete1, however, for all folder (without specifying
--folder INBOX), so only any new email that arrives at source is
copied to destination and deleted from source.
My next goal was to automate the process, so I followed this advice:
http://imapsync.lamiral.info/examples/sync_loop_unix.sh
I also ended up requiring a regex to translate folder names. On the
old server (Gmail), Sent items were in a folder called [Gmail]/E-mails
enviados and on the new server, its simply called SENT. Same with
lixeira (trash) and rascunhos (drafts).
So this was added:
--regextrans2 "s,\[Gmail\].,," --regextrans2 "s,E-mails enviados,Sent," --regextrans2 "s,/Lixeira,Trash," --regextrans2 "s,/Rascunhos,Drafts,"

89
FAQ.d/FAQ.Massive.txt Executable file → Normal file
View file

@ -1,8 +1,8 @@
#!/bin/cat
$Id: FAQ.Massive.txt,v 1.1 2015/03/26 05:06:27 gilles Exp gilles $
$Id: FAQ.Massive.txt,v 1.5 2015/11/05 14:46:20 gilles Exp gilles $
======================================================================
Imapsync for massive migrations
Imapsync for massive migrations
======================================================================
Questions answered here are:
@ -10,49 +10,55 @@ Questions answered here are:
Q. I need to migrate hundred accounts, how can I do?
Q. I have to migrate 500k users using 400 TB of disk space.
How do I proceed?
Q. How to determine what is the bottleneck in my current imapsync process?
=======================================================================
Q. I need to migrate hundred accounts, how can I do?
R. If you have many mailboxes to migrate think about a little
shell program. Write a file called file.txt (for example)
containing users and passwords.
script program. Write a file called file.txt (for example)
containing hosts users and passwords on both sides.
The separator used in this example is ";"
The file.txt file contains:
The file.txt file contains for example:
user001_1;password001_1;user001_2;password001_2
user002_1;password002_1;user002_2;password002_2
user003_1;password003_1;user003_2;password003_2
user004_1;password004_1;user004_2;password004_2
user005_1;password005_1;user005_2;password005_2
...
host001_1;user001_1;password001_1;host001_2;user001_2;password001_2;
host002_1;user002_1;password002_1;host002_2;user002_2;password002_2;
host003_1;user003_1;password003_1;host003_2;user003_2;password003_2;
host004_1;user004_1;password004_1;host004_2;user004_2;password004_2;
etc.
On Unix the shell program can be:
On Unix the shell script can be:
{ while IFS=';' read u1 p1 u2 p2; do
imapsync --host1 imap.side1.org --user1 "$u1" --password1 "$p1" \
--host2 imap.side2.org --user2 "$u2" --password2 "$p2" ...
done ; } < file.txt
#!/bin/sh
{ while IFS=';' read h1 u1 p1 h2 u2 p2 fake
do
imapsync --host1 "$h1" --user1 "$u1" --password1 "$p1" \
--host2 "$h2" --user2 "$u2" --password2 "$p2"
done
} < file.txt
Here is a complete Unix example nearly ready to use:
Here is a complete Unix example ready to use:
http://imapsync.lamiral.info/examples/sync_loop_unix.sh
On Windows the batch program can be:
On Windows the batch script can be:
FOR /F "tokens=1,2,3,4 delims=; eol=#" %%G IN (file.txt) DO imapsync ^
--host1 imap.side1.org --user1 %%G --password1 %%H ^
--host2 imap.side2.org --user2 %%I --password2 %%J ...
CD /D %~dp0
SET csvfile=file.txt
FOR /F "tokens=1,2,3,4,5,6 delims=; eol=#" %%G IN (%csvfile%) DO (
imapsync ^
--host1 %%G --user1 %%H --password1 %%I ^
--host2 %%J --user2 %%K --password2 %%L ...
)
The ... can be replaced by nothing or any supplementary imapsync option.
The final ... can be replaced by nothing or any supplementary imapsync option.
Here is a complete Windows example nearly ready to use:
http://imapsync.lamiral.info/examples/sync_loop_windows.bat
=======================================================================
Q. I have to migrate 500k users using 400 TB of disk space.
How do I proceed?
@ -63,13 +69,15 @@ they can be processed independently.
500k on 400TB is 800 MB per account on average.
No one knows in advance what is the first bottleneck. The first
bottleneck has to be determined, by measurements, not by guesses.
Once this first bottleneck is known and overcome then the next
bottleneck has to be determined and overcome too, if needed. Repeat
the process of looking for the next bottleneck and its resolution
until you estimate the transfer rates, money costs and final dates are
good enough to proceed the whole 500k/400TB migration.
On any process involving several mechanisms there is always a
bottleneck among all elements taking part on the process. No one knows
in advance what is the first bottleneck. The first bottleneck has to
be determined, by measurements, not by guesses. Once this first
bottleneck is known and overcome then the next bottleneck has to be
determined and overcome too, if needed. Repeat the process of looking
for the next bottleneck and its resolution until you estimate the
transfer rates, money costs and final dates are good enough to proceed
the whole 500k/400TB migration.
Possible bottlenecks:
@ -96,3 +104,22 @@ Possible bottlenecks:
- Bad luck.
- ...
=======================================================================
Q. How to determine what is the bottleneck in my current imapsync process?
R. Divide and conquer.
In order to detect whether host1/link1 is the bottleneck or
host2/link2, we have several tests to explore:
1) run a sync from host1 to host1, with a host1 test account as destination.
This way, only host1+link1 are tested. host2 is not concerned.
If performances increase a lot then host2/link2 is the bottleneck.
2) run a sync from host2 to host2, with a host2 test account as destination.
This way, only host2+link2 are tested. host1 is not concerned.
If performances increase a lot then host1/link1 is the bottleneck.
If performances increase on both tests 1) and 2), I have no clue to explain that.
Same thing if they both decrease!

View file

@ -0,0 +1,93 @@
#!/bin/cat
$Id: FAQ.Messages_selection.txt,v 1.2 2015/10/21 15:39:57 gilles Exp gilles $
====================================
Imapsync. How to select messages
====================================
=======================================================================
Q. Is there a way we can specify a date range to sync emails?
If yes, can you please share an example?
R. Yes, with the --search option.
imapsync ... --search "SENTSINCE 1-Jan-2010 SENTBEFORE 31-Dec-2010"
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
=======================================================================
Q. Is there a way we can specify an age to sync emails?
If yes, can you please share some examples?
R. Yes, with the --maxage or the --minage option.
E.1 Sync only messages less than 2 days old:
imapsync ... --maxage 2
E.2 Sync only messages more than 2 days old:
imapsync ... --minage 2
E.3 Sync only messages more than 30 days old and less than 365 days old:
imapsync ... --minage 30 --maxage 365
E.4 Sync only messages less than 30 days old or more than 365 days old:
imapsync ... --maxage 30 --minage 365
Full explanation:
--maxage <int> : Skip messages older than <int> days.
final stats (skipped) don't count older messages
see also --minage
--minage <int> : Skip messages newer than <int> days.
final stats (skipped) don't count newer messages
You can do (+ are the messages selected):
past|----maxage+++++++++++++++>now
past|+++++++++++++++minage---->now
past|----maxage+++++minage---->now (intersection)
past|++++minage-----maxage++++>now (union)
=======================================================================
Q. I want to sync messages based on their UID.
R. First have in mind that UIDs are uniq only per folder, so work this
way only with one folder at a time, with --folder option.
To show UIDs, there is the --debugLIST parameter.
imapsync ... --debugLIST
To sync only a part of all messages, selected by UIDs
from 10000 to 11000:
imapsync ... --search1 "UID 10000:11000"
To sync from INBOX only 3 messages UIDs 20000 20002 20004:
imapsync ... --search1 'OR OR UID 20000 UID 20002 UID 20004' --folder INBOX
To sync all messages from INBOX except 3 messages
UIDs 20000 20002 20004:
imapsync ... --search1 'NOT OR OR UID 20000 UID 20002 UID 20004' --folder INBOX
If you search n UIDs then you have to put n-1 OR in the search line.
That's IMAP.

15
FAQ.d/FAQ.Oracle-UCS.txt Normal file
View file

@ -0,0 +1,15 @@
#!/bin/cat
$Id: FAQ.Oracle-UCS.txt,v 1.1 2015/07/20 04:34:32 gilles Exp gilles $
=======================================================================
Imapsync. Oracle-UCS specific issues and solutions
=======================================================================
Oracle-UCS was previously Sun JES, IPlanet, etc.
"NO Message contains NUL characters"
--skipmess 'm/(\x00)+\Z/'
"Message contains invalid header"
--skipmess 'm/[\x80-\xff]/'

21
FAQ.d/FAQ.Security.txt Normal file
View file

@ -0,0 +1,21 @@
#!/bin/cat
# $Id: FAQ.Security.txt,v 1.1 2015/10/21 14:18:27 gilles Exp gilles $
======================================================================
Imapsync. Security issues and solutions
======================================================================
======================================================================
Q. Imapsync used to use SSL_VERIFY_PEER now it uses SSL_VERIFY_NONE.
How can I change this back to the more secure SSL_VERIFY_PEER?
R1. In function "sub set_ssl", replace
IO::Socket::SSL::SSL_VERIFY_NONE()
by
IO::Socket::SSL::SSL_VERIFY_PEER()
C1. Don't do this in function "sub set_tls" since it won't work by principle,
tls is done AFTER the application level connexion is established

46
FAQ.d/FAQ.SmarterMail.txt Executable file
View file

@ -0,0 +1,46 @@
#!/bin/cat
$Id: FAQ.SmarterMail.txt,v 1.6 2015/11/30 02:58:25 gilles Exp gilles $
=======================================================================
Imapsync. SmarterMail specific issues and solutions
=======================================================================
=======================================================================
Q. Synchronizing from SmarterMail to XXX
On Unix:
imapsync --host1 imap.d1.org --user1 joe --password1 secret1 \
--host2 imap.d2.org --user2 joe --password2 secret2 \
--sep1 "/" --prefix1 "" --useheader Message-Id \
--regextrans2 "s,Deleted Items,Trash," \
--regextrans2 "s,Junk E-Mail,Junk," \
--regextrans2 "s,Sent Items,Sent,"
On Windows:
imapsync.exe --host1 imap.d1.org --user1 joe --password1 secret1 ^
--host2 imap.d2.org --user2 joe --password2 secret2 ^
--sep1 "/" --prefix1 "" --useheader Message-Id ^
--regextrans2 "s,Deleted Items,Trash," ^
--regextrans2 "s,Junk E-Mail,Junk," ^
--regextrans2 "s,Sent Items,Sent,"
Maybe add other --regextrans2 to change folder names, for this
see also http://imapsync.lamiral.info/FAQ.d/FAQ.Folders_Mapping.txt
=======================================================================
Q. Synchronizing from XXX to SmarterMail
On Unix:
imapsync --host1 imap.d1.org --user1 joe --password1 secret1 \
--host2 imap.d2.org --user2 joe --password2 secret2 \
--sep2 "/" --prefix2 "" --useheader Message-Id
On Windows:
imapsync.exe --host1 imap.d1.org --user1 joe --password1 secret1 ^
--host2 imap.d2.org --user2 joe --password2 secret2 ^
--sep2 "/" --prefix2 "" --useheader Message-Id
=======================================================================

View file

@ -0,0 +1,283 @@
#!/bin/cat
$Id: FAQ.Various_Server_Softwares.txt,v 1.2 2015/10/21 15:41:41 gilles Exp gilles $
=======================================================================
Imapsync. Server software specific issues and solutions
=======================================================================
=======================================================================
Q. From Zimbra to XXX
imapsync ... \
--exclude "Conversation Action Settings" \
--exclude "Quick Step Settings" \
--exclude "News Feed"
=======================================================================
Q. From or to HMailServer version 4.4.1.
R. You have to add prefix and separator manually because 4.4.1 doesn't
honor the NAMESPACE imap command.
Example for host1:
imapsync ... \
--prefix1 "" --sep1 .
No specific option for HMailServer 5.3.3 since NAMESPACE is supported.
Maybe --subscribe_all will help you to see all migrated folders.
=======================================================================
Q. Synchronizing from Kerio Connect to XXX
R. No special options required.
See also:
http://www.linux-france.org/prj/imapsync_list/msg01756.html
http://www.safetynet-it.com/it-support/mac-kerio-server-to-microsoft-exchange-2010-migration-1/
http://www.safetynet-it.com/it-support/mac-kerio-server-to-microsoft-exchange-2010-migration-2/
=======================================================================
Q. Synchronizing from Yahoo to XXX
R. Use --host1 imap.mail.yahoo.com --ssl1
./imapsync \
--host1 imap.mail.yahoo.com \
--user1 billy \
--password1 secret \
--ssl1 \
--host2 XXX \
--user2 billy \
--password2 secret
SSL is mandatory for yahoo since november 2011.
=======================================================================
Q. from Microsoft's Exchange 2007 to Google Apps for your Domain
(GAFYD)
R. Take a look at:
http://mark.ossdl.de/2009/02/migrating-from-exchange-2007-to-google-apps-mail/
=======================================================================
Q. Migrating from or to Parallels Plex Server
R. It depends on the OS
Parallells Plesk Panel for Windows requires --sep2 / --prefix2 ""
Parallells Plesk Panel for Linux works with default parameters.
=======================================================================
Q. I'm migrating from WU to Cyrus, and the mail folders are under
/home/user/mail but the tool copies everything in /home/user, how
can i avoid that?
Two solutions:
R. Use
imapsync ... --include '^mail'
R. or (better)
imapsync ... --subscribed --subscribe
=======================================================================
Q. I'm migrating from WU to Cyrus, and the mail folders are under
/home/user/mail directory. When imapsync creates the folders in
the new cyrus imap server, it makes a folder "mail" and below that
folder puts all the mail folders the user have in /home/user/mail,
i would like to have all those folders directly under INBOX.
R. Use
imapsync ... --regextrans2 's/^mail/INBOX/' --dry
look at the simulation and if all transformations seem
good then remove the --dry option.
=======================================================================
Q. Migrating from Groupwise to Cyrus
R. By Jamie Neil:
I eventually managed to get the mail to migrate without errors using the
following options:
--sep1 /
- doesn't report separator so has to be set explicitly.
--nosyncacls
- doesn't support ACLs.
--skipheader '^Content-Type'
- MIME separator IDs seem to change every time a mail is accessed so
this is required to stop duplicates.
--maxage 3650
- some messages just don't seem to want to transfer and produce the
perl errors I mentioned before. This prevents the errors, but the
bad messages don't transfer.
Even though the mail migrated OK, there are a couple of gotchas with
Groupwise IMAP:
1) Some of the GW folders are not real folders and are not available
to IMAP, the main problem one being "Sent Items". I could find no way
of coping the contents of these folders. The nearest I got was to
create a "real" folder and copy/move the sent items into it, but
imapsync still didn't see the messages (I think because there is
something funny about the reported dates/sizes).
It think this problem has been rectified in GW6.5.
2) The "skipheader '^Content-Type'" directive is required to stop
duplicate messages being created. GW seems to generate this field on
the fly for messages that have MIME separators and so it's different
every time.
3) Version 6.0.1 of the Groupwise Internet Connector sucks. I was
getting server aborts when I pushed it a bit hard! I eventually had to
upgrade to 6.0.4 which seems to be a lot more stable.
=======================================================================
Q. Migrating from iPlanet Messaging Server
5.2 Patch 2 (built Jul 14 2004)) to Groupwise 7.0
I encounter many errors like this:
"Error trying to append string: 17847 BAD APPEND"
R. GroupWise 7 seems buggy. Apply GroupWise 7 support pack 1
=======================================================================
Q. Migrating from David Tobit V10 (DvISE Mail Access Server MA-...)
R. Use the following options:
imapsync ... --prefix1 "" --sep1 / --idatefromheader ^
--nofoldersizes --useuid --nocheckmessageexists
=======================================================================
Q. Migrating from David Tobit V8
("* OK IMAP4rev1 DvISE Mail Access Server MA-8.10a (0126)")
First try above V10 solution since improvments have been made
to support Tobit.
R. Use the following options :
imapsync ... --prefix1 INBOX. --sep1 / --subscribe --subscribed
=======================================================================
Q. Migrating from Tobit David Server 6
("DvISE Mail Access Server MA-6.60a (0118)")
First try above V10 solution since improvments have been made
to support Tobit.
R. Look at the discussion:
http://www.linux-france.org/prj/imapsync_list/msg00582.html
http://www.linux-france.org/prj/imapsync_list/threads.html#00582
patch saved in ./patches/imapsync-1.337_tobit_V6.patch
=======================================================================
Q. I need to migrate 1250 mailboxes, passwords are in a MySQL Database.
Can you tell me if your script suits my needs?
R. Mailboxes must exist before running imapsync.
You have to extract users logins and passwords in a csv file.
See the "HUGE MIGRATION" section in the README file.
======================================================================
Q: From MailEnable 1.75
R: --sep1 "/" --prefix1 ""
Q: From MailEnable 2.2
R: --sep1 "." --prefix1 ""
Q: To MailEnable
R: --sep2 / --prefix2 "" --addheader --messageidnodomain --syncflagsaftercopy
======================================================================
Q. From GMX IMAP4 StreamProxy
R. Use:
--prefix1 INBOX and --sep1 .
======================================================================
Q. From Courier to Archiveopteryx
R. You can read http://www.archiveopteryx.org/migration/imapsync
Default values might be fine now with latest imapsync.
======================================================================
Q. To Sun Java(tm) System Messaging Server 6.2-7.05
Q. To Communigate Pro - Solaris version
R. See and run patches/imapsync_1.267_jari
======================================================================
Q. From Softalk Workgroup Mail 7.6.4
R. Old Softalk releases don't support the IMAP SEARCH command.
Here are the options to get it working.
imapsync ... --sep1 '.' --prefix1 '' \
--noabletosearch --nocheckmessageexists --addheader
(Thanks to Andrew Tucker)
======================================================================
Q. From or to QQMail IMAP4Server
R. imapsync ... --noabletosearch
======================================================================
Q. From FirstClass to XXX
http://www.firstclass.com/
R. Migrating from FirstClass is not easy because FirstClass, strangely,
does not show all messages via IMAP. To make it show all messages,
a trick, painful to follow by hand, is moving emails
out and back in, for each folder. May be it can be done by a script.
FirstClass releases prior to release 12 do not shows the "Sent"
folder in IMAP but FirstClass release 12 shows it.
I advice you to upgrade to FirstClass release 12 before leaving it
with imapsync or another imap tool.
Here is a command line used to migrate from FirtClass release 12:
imapsync ... \
--tmpdir /var/tmp --usecache \
--useheader Message-ID \
--idatefromheader \
--addheader \
--regextrans2 "s,(/|^) +,\$1,g" --regextrans2 "s, +(/|$),\$1,g" \
--regextrans2 "s/[\^]/_/g" \
--regextrans2 "s/['\"\\\\]/_/g" \
--regextrans2 "s,&AC8-,-,g" \
--regextrans2 "s,&APg-,oe,g"
On Windows, in the previous example containing \$1 you have to
replace the two \$1 by $1 (remove the \ before $).
Special thanks to Kristian Wind and Joey Alexander for helping me
writing this FAQ item.
See also this worth reading discussion in a Zimbra forum:
http://www.zimbra.com/forums/migration/20349-help-needed-migrating-firstclass.html
======================================================================
Q. From XXX to FTGate
R. Do NOT use --usecache since new UIDs are not given by FTGate and also
badly guessed by imapsync. UIDEXPUNGE does not work so use also
--expunge2 when using --delete2
imapsync ... \
--sep2 / --prefix2 "" \
--useheader Message-Id \

110
FAQ.d/FAQ.XOAUTH2.txt Normal file
View file

@ -0,0 +1,110 @@
#!/bin/cat
$Id: FAQ.XOAUTH2.txt,v 1.6 2015/11/30 23:40:10 gilles Exp gilles $
=======================================================================
Imapsync. Using XOAUTH2 and XOAUTH authentication (Gmail)
=======================================================================
=======================================================================
Q. Is XOAUTH2 authentication available with imapsync?
R. Yes, but XOAUTH2 has been really tested on Unix systems,
less profund on Windows but it should work.
First, consider the XOAUTH2 feature at a prototype level.
Perl modules needed for xoauth2 are:
Crypt::OpenSSL::RSA
JSON
JSON::WebToken
LWP
HTML::Entities
A easy way to install or upgrade Perl modules is to use cpanm command,
also called cpanminus.
sudo cpanm JSON::WebToken JSON Crypt::OpenSSL::RSA LWP HTML::Entities
The code and first explanation comes from Joaquin Lopez at
https://github.com/imapsync/imapsync/pull/25
http://www.linux-france.org/prj/imapsync_list/msg02129.html
Also, the binary command "openssl" is needed since it is used to
convert the pk12 file.
On Windows I've tried xoauth2 with openssl from
https://slproweb.com/download/Win32OpenSSL-1_0_2d.exe at
https://slproweb.com/products/Win32OpenSSL.html
Here is a complete example for Gmail. It is a little stupid
since it is the same account as source and destination.
All xoauth2 is given via the --password1 parameter.
It has the form:
--password1 "A;B;C"
where A = 108687549524-gj68fg5ho5icoicv3v79dq2rcuf5c85e@developer.gserviceaccount.com
is the name of the Google Developer API service account.
where B = /g/var/pass/imapsync-xoauth2-15f8456ad5b7_notasecret.p12
is the location of the keyfile associated with it.
where C = notasecret
is the password to access the keyfile.
imapsync \
--host1 imap.gmail.com --ssl1 --user1 gilles.lamiral@gmail.com \
--password1 "108687549524-gj68fg5ho5icoicv3v79dq2rcuf5c85e@developer.gserviceaccount.com;/g/var/pass/imapsync-xoauth2-15f8456ad5b7_notasecret.p12;notasecret" \
--host2 imap.gmail.com --ssl2 --user2 gilles.lamiral@gmail.com \
--password2 "108687549524-gj68fg5ho5icoicv3v79dq2rcuf5c85e@developer.gserviceaccount.com;/g/var/pass/imapsync-xoauth2-15f8456ad5b7_notasecret.p12" \
--justfoldersizes --nofoldersizes \
--authmech1 XOAUTH2 --authmech2 XOAUTH2 --debug
Use your own xoauth2 values.
=======================================================================
Q. How to use XOAUTH to globally authenticate gmail users?
R0. XOAUTH is considered obsolete and superseded by XOAUTH2
Anyway the manage part might be the same (I don't know).
R1. The XOAUTH code and this FAQ item come from Eduardo Bortoluzzi
Thanks Eduardo!
R2. In case you still have to use XOAUTH, here is the method:
The goal of OAUTH is to migrate all users from/to Google Apps
Premier Edition without knowing their passwords.
The global password is available at the Google Apps control panel,
at Advanced Tools -> Manage OAuth domain key.
./imapsync \
--host1 imap.gmail.com --ssl1 \
--user1 foo@lab3.dedal.br \
--password1 secret1 \
--authmech1 XOAUTH \
--host2 imap.gmail.com --ssl2 \
--user2 bar@lab3.dedal.br \
--password2 secret2 \
--authmech2 XOAUTH
Google Apps is a paid service, but you can try it for 30 days without any cost.
Some notes about configuring the Google Apps XOAUTH:
On "Advanced Tools > Manage OAuth domain key > Two-legged OAuth access control"
the "Allow access to all APIs" must be checked
(https://support.google.com/a/bin/answer.py?answer=162105)
OR
On "Advanced Tools > Manage third party OAuth client access",
the configured costumer key must have the scope
"https://mail.google.com/" configured
(https://support.google.com/a/bin/answer.py?answer=162106).