Migrate emails from GMail to another IMAP server with imapsync

It appears pretty easy to migrate an existing GMail account to another IMAP server, i.e. not GMail/Google server. There is an excellent synchronization tool – imapsync, which checks and downloads all the mails of an user account from one IMAP server to another IMAP server per user. The tool supports Google’s GMail accounts and their specific naming including the labels folders peculiarity (some folders in GMail may not have any physical emails, but just to show emails from another folders with specific labels). It’s worth mentioning that the imapsync works only only with GMail accounts, but it can be used to migrate from one IMAP server to another IMAP. The key here is the source and the destination server should support IMAP protocol.

Imapsync is an IMAP transfer tool. The purpose of imapsync is to migrate IMAP accounts or to backup IMAP accounts.

GMail will expose the labels as folders and in some early versions of the imapsync tool the emails with multiple labels may be shown in multiple folders and be duplicated. The version used here did not duplicate any email, even some emails were shown in multiple GMail folders.

There are two GMail settings to enable before proceeding with the migration:

  1. Enable “Less secure app access” or if 2-Step-Verification is enabled use App Passwords
  2. Enable IMAP, which is disabled by default.

SCREENSHOT 1) Manage the current Google account options by clicking on the top right corner as shown in the screenshot.

main menu
manage google account

SCREENSHOT 2) Scrow down to the “Less secure app access”, which is “Off” by default.

After clicking on it and setting it to “On” on the next page (the next screenshot), the imapsync will be able to login in the GMail account. Otherwise, the imapsync would throw an error with “Invalid credentials (Failure)“.

main menu
Security

SCREENSHOT 3) Set the “Less secure app access” setting to ON.

main menu
Less secure app access ON

SCREENSHOT 4) Click on “Settings” icon and then on the “See all settings” to enter the current GMail mail settings.

main menu
Settings See all settings

SCREENSHOT 5) Click on “Enable IMAP” and “Save Changes” on the bottom of the page to save the configuration.

main menu
Forwarding and POP IMAP

The migration command:

imapsync --gmail1 --host1 imap.googlemail.com --user1 "info@example.com" --password1 "11111111111" --host2 192.168.0.101 --user2 "info@example.com" --password2 "11111111111"

The command arguments are:

  • All options ending with “1” are meant for the source server, i.e. in this case, for the GMail account.
  • –host1, –user1 and –password are the GMail IMAP hostname, the email box and its password.
  • –gmail1 – enables specific options and features for GMail accounts. There is –gmail2 for the destination folder, too.
  • All options ending with “2” are meant for the destination server, i.e. in this case, for the GMail account.
  • –host2, –user2 and –password2 are the new IMAP server hostname, the email box and its password.
  • There is a dry run option, which don’t change anything – “–dry

Console output of the whole migration process.

Some of the sensitive information is replaced with generic one.
The GMail box has the following folders – INBOX, [Gmail]/Drafts, [Gmail]/Important, [Gmail]/Sent Mail, [Gmail]/Spam, [Gmail]/Starred, [Gmail]/Trash and they are going to be migrated to INBOX, Drafts, Important, Sent Mail, Spam, Starred, Trash. The imapsync tool automatically removes the prefix “[Gmail]/”.
At the end, there are information and statistics about what the imapsync have done. There is a progress for each folder and an avarage speed of messages import.

[myuser@srv ~]# imapsync --gmail1 --host1 imap.googlemail.com --user1 "info@exmaple.com" --password1 "111111111111111111" --host2 192.168.0.10 --user2 "info@example.com" --password2 "2222222222222222222"
Here is imapsync 1.882 on host srv, a linux system with 1.0/15.4 free GiB of RAM
with Perl 5.30.3 and Mail::IMAPClient 3.39
Transfer started at Fri Jun 10 09:42:06 2022
PID is 17245
Log file is LOG_imapsync/2022_06_10_09_42_06_559_info@exmaple.com_info@example.com.txt ( to change it, use --logfile path ; or use --nolog to turn off logging )
Load is 1.34 1.16 1.34 4/496 on 8 cores
Current directory is /root
Real user id is root (uid 0)
Effective user id is root (euid 0)
$RCSfile: imapsync,v $ $Revision: 1.882 $ $Date: 2018/05/05 21:10:43 $ 
Command line used:
/usr/bin/imapsync --gmail1 --host1 imap.googlemail.com --user1 info@exmaple.com --password1 MASKED --host2 192.168.0.10 --user2 info@example.com --password2 MASKED
Temp directory is /tmp ( to change it use --tmpdir dirpath )
kill -QUIT 17245 # special behavior
kill -TERM 17245 # special behavior
kill -INT 17245 # special behavior
kill -USR1 17245 # special behavior
PID file is /tmp/imapsync.pid ( to change it use --pidfile filepath ; to avoid it use --pidfile "" )
Writing my PID 17245 in /tmp/imapsync.pid
Modules version list:
Authen::NTLM         1.09
Compress::Zlib       2.084
Crypt::OpenSSL::RSA  0.31
Data::Uniqid         0.12
Digest::HMAC_MD5     1.01
Digest::HMAC_SHA1    1.03
Digest::MD5          2.55
File::Copy::Recursive 0.45
File::Spec           3.78
Getopt::Long         2.5
HTML::Entities       3.69
IO::Socket           1.40
IO::Socket::INET     1.40
IO::Socket::INET6    2.72
IO::Socket::SSL      2.066
IO::Tee              0.65
JSON                 2.94
JSON::WebToken       Not installed
LWP                  6.27
Mail::IMAPClient     3.39
Net::Ping            2.71
Net::SSLeay          1.88
Term::ReadKey        2.37
Test::MockObject     Not installed
Time::HiRes          1.976
URI::Escape          3.31
Unicode::String      2.10
( use --no-modulesversion to turn off printing this Perl modules list )
Info: will resync flags for already transferred messages. Use --noresyncflags to not resync flags.
Host2: probing ssl on port 993 ( use --nosslcheck to avoid this ssl probe ) 
Host2: sslcheck detected open ssl port 993 so turning ssl on (use --nossl2 --notls2 to turn off SSL and TLS wizardry)
SSL debug mode level is --debugssl 1 (can be set from 0 meaning no debug to 4 meaning max debug)
Host1: SSL default mode is like --sslargs1 "SSL_verify_mode=0", meaning for host1 SSL_VERIFY_NONE, ie, do not check the certificate server.
Host1: Use --sslargs1 SSL_verify_mode=1 to have SSL_VERIFY_PEER, ie, check the certificate server of host1
Host2: SSL default mode is like --sslargs2 "SSL_verify_mode=0", meaning for host2 SSL_VERIFY_NONE, ie, do not check the certificate server.
Host2: Use --sslargs2 SSL_verify_mode=1 to have SSL_VERIFY_PEER, ie, check the certificate server of host2
Info: turned ON syncinternaldates, will set the internal dates (arrival dates) on host2 same as host1.
Host1: will try to use LOGIN authentication on host1
Host2: will try to use LOGIN authentication on host2
Host1: imap connection timeout is 120 seconds
Host2: imap connection timeout is 120 seconds
Host1: IMAP server [imap.googlemail.com] port [993] user [info@exmaple.com]
Host2: IMAP server [192.168.0.10] port [993] user [info@example.com]
Host1: connecting and login on host1 [imap.googlemail.com] port [993] with user [info@exmaple.com]
Host1 IP address: 74.125.133.16
Host1 banner: * OK Gimap ready for requests from 77.88.55.66 1111111111111111
Host1 capability before authentication: IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH2 AUTH=PLAIN AUTH=PLAIN-CLIENTTOKEN AUTH=OAUTHBEARER AUTH=XOAUTH
Host1: success login on [imap.googlemail.com] with user [info@exmaple.com] auth [LOGIN]
Host2: connecting and login on host2 [192.168.0.10] port [993] with user [info@example.com]
Host2 IP address: 192.168.0.10
Host2 banner: * OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE AUTH=PLAIN ACL ACL2=UNION ENABLE UTF8=ACCEPT] Courier-IMAP ready. Copyright 1998-2019 Double Precision, Inc.  See COPYING for distribution information.
Host2 capability before authentication: IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE AUTH=PLAIN ACL ACL2=UNION ENABLE UTF8=ACCEPT
Host2: success login on [192.168.0.10] with user [info@example.com] auth [LOGIN]
Host1: state Authenticated
Host2: state Authenticated
Host1 capability once authenticated: IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE ENABLE MOVE CONDSTORE ESEARCH UTF8=ACCEPT LIST-EXTENDED LIST-STATUS LITERAL- SPECIAL-USE APPENDLIMIT=35651584
Host2 capability once authenticated: IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE AUTH=PLAIN ACL ACL2=UNION ENABLE UTF8=ACCEPT

Host1: found ID capability. Sending/receiving ID, presented in raw IMAP for now.
In order to avoid sending/receiving ID, use option --noid
Sending: 4 ID ("name" "imapsync" "version" "1.882" "os" "linux" "vendor" "Gilles LAMIRAL" "support-url" "https://imapsync.lamiral.info/" "date" "05-May-2018 21:10:43 +0000" "side" "host1")
Sent 181 bytes
Read:   * ID ("name" "GImap" "vendor" "Google, Inc." "support-url" "https://support.google.com/mail" "version" "gmail_imap_220603.07_p0" "remote-host" "77.88.55.66")
        4 OK Success

Host2: No ID capability

Host2: found quota, presented in raw IMAP
Sending: 4 GETQUOTAROOT INBOX
Sent 22 bytes
Read:   * QUOTAROOT "INBOX" "ROOT"
        * QUOTA "ROOT"
        4 OK GETQUOTAROOT Ok.

Host2: Quota current storage is 0 bytes. Limit is 0 bytes. So 0 % full
Host1: found 9 folders.
Host2: found 1 folders.
Including all folders found by default. Use --subscribed or --folder or --folderrec or --include to select specific folders. Use --exclude to unselect specific folders.
Host1: Checking wanted folders exist. Use --nocheckfoldersexist to avoid this check (shared of public namespace targeted).
Host1: Checking wanted folders are selectable. Use --nocheckselectable to avoid this check.
Host1: warning! ignoring folder [Gmail] because it is not selectable
Host1: guessing separator from folder listing: [/]
Host1: separator given by NAMESPACE: [/]
Host2: guessing separator from folder listing: [/]
Host2: separator given by NAMESPACE: [.]
Host1: guessing prefix from folder listing: []
Host1: prefix given by NAMESPACE: []
Host2: guessing prefix from folder listing: []
Host2: prefix given by NAMESPACE: [INBOX.]
Host1 separator and prefix: [/][]
Host2 separator and prefix: [.][INBOX.]
Turned on automapping folders ( use --noautomap to turn off automapping )
Host1: special [Gmail]/All Mail     = \All
Host1: special [Gmail]/Drafts       = \Drafts
Host1: special [Gmail]/Sent Mail    = \Sent
Host1: special [Gmail]/Spam         = \Junk
Host1: special [Gmail]/Starred      = \Flagged
Host1: special [Gmail]/Trash        = \Trash


++++ Listing folders
All foldernames are presented between brackets like [X] where X is the foldername.
When a foldername contains non-ASCII characters it is presented in the form
[X] = [Y] where
X is the imap foldername you have to use in command line options and
Y is the uft8 output just printed for convenience, to recognize it.

Host1 folders list (first the raw imap format then the [X] = [Y]):
* LIST (\HasNoChildren) "/" "INBOX"
* LIST (\HasChildren \Noselect) "/" "[Gmail]"
* LIST (\All \HasNoChildren) "/" "[Gmail]/All Mail"
* LIST (\Drafts \HasNoChildren) "/" "[Gmail]/Drafts"
* LIST (\HasNoChildren \Important) "/" "[Gmail]/Important"
* LIST (\HasNoChildren \Sent) "/" "[Gmail]/Sent Mail"
* LIST (\HasNoChildren \Junk) "/" "[Gmail]/Spam"
* LIST (\Flagged \HasNoChildren) "/" "[Gmail]/Starred"
* LIST (\HasNoChildren \Trash) "/" "[Gmail]/Trash"
19 OK Success

[INBOX]
[[Gmail]]
[[Gmail]/All Mail]
[[Gmail]/Drafts]
[[Gmail]/Important]
[[Gmail]/Sent Mail]
[[Gmail]/Spam]
[[Gmail]/Starred]
[[Gmail]/Trash]

Host2 folders list (first the raw imap format then the [X] = [Y]):
* LIST (\Marked \HasNoChildren) "." "INBOX"
10 OK LIST completed

[INBOX]


Folders sizes before the synchronization.
You can remove foldersizes listings by using "--nofoldersizes" and  "--nofoldersizesatend"
but then you will also loose the ETA (Estimation Time of Arrival) given after each message copy.
++++ Calculating sizes of 8 folders on Host1
Host1 folder     1/8 [INBOX]                             Size: 128043765 Messages:   433 Biggest:  10727344
Host1 folder     2/8 [[Gmail]/Drafts]                    Size:         0 Messages:     0 Biggest:         0
Host1 folder     3/8 [[Gmail]/Important]                 Size:  68103771 Messages:   215 Biggest:  10727344
Host1 folder     4/8 [[Gmail]/Sent Mail]                 Size:     14382 Messages:     2 Biggest:      8999
Host1 folder     5/8 [[Gmail]/Spam]                      Size:   1326069 Messages:    24 Biggest:    991379
Host1 folder     6/8 [[Gmail]/Starred]                   Size:         0 Messages:     0 Biggest:         0
Host1 folder     7/8 [[Gmail]/Trash]                     Size:         0 Messages:     0 Biggest:         0
Host1 folder     8/8 [[Gmail]/All Mail]                  Size: 128058147 Messages:   435 Biggest:  10727344
Host1 Nb folders:                8 folders
Host1 Nb messages:            1109 messages
Host1 Total size:        325546134 bytes (310.465 MiB)
Host1 Biggest message:    10727344 bytes (10.230 MiB)
Host1 Time spent:              8.8 seconds
++++ Calculating sizes of 8 folders on Host2
Host2 folder     1/8 [INBOX]                             Size:     22482 Messages:     3 Biggest:     10438
Host2 folder     2/8 [INBOX.All Mail]                    does not exist yet
Host2 folder     3/8 [INBOX.Drafts]                      does not exist yet
Host2 folder     4/8 [INBOX.Important]                   does not exist yet
Host2 folder     5/8 [INBOX.Sent Mail]                   does not exist yet
Host2 folder     6/8 [INBOX.Spam]                        does not exist yet
Host2 folder     7/8 [INBOX.Starred]                     does not exist yet
Host2 folder     8/8 [INBOX.Trash]                       does not exist yet
Host2 Nb folders:                8 folders
Host2 Nb messages:               3 messages
Host2 Total size:            22482 bytes (21.955 KiB)
Host2 Biggest message:       10438 bytes (10.193 KiB)
Host2 Time spent:              0.0 seconds
++++ Looping on each one of 8 folders to sync
Folder     1/8 [INBOX]                             -> [INBOX]                            
Host1 folder [INBOX] has 433 messages in total (mentioned by SELECT)
Host2 folder [INBOX] has 3 messages in total (mentioned by SELECT)
Host2 folder [INBOX] permanentflags: 
Host2: Subscribing to folder INBOX
Host1 folder [INBOX] considering 433 messages
Host2 folder [INBOX] considering 3 messages
msg INBOX/4 {49361}           copied to INBOX/4          0.26 msgs/s  12.618 KiB/s 48.204 KiB copied  ETA: Fri Jun 10 10:52:52 2022  4233 s  1108/1109 msgs left
msg INBOX/5 {136660}          copied to INBOX/5          0.46 msgs/s  41.354 KiB/s 181.661 KiB copied  ETA: Fri Jun 10 10:22:51 2022  2431 s  1107/1109 msgs left
msg INBOX/6 {630173}          copied to INBOX/6          0.62 msgs/s  164.849 KiB/s 797.064 KiB copied  ETA: Fri Jun 10 10:12:02 2022  1783 s  1106/1109 msgs left
msg INBOX/7 {8889}            copied to INBOX/7          0.80 msgs/s  161.706 KiB/s 805.745 KiB copied  ETA: Fri Jun 10 10:05:16 2022  1376 s  1105/1109 msgs left
msg INBOX/8 {8451}            copied to INBOX/8          0.94 msgs/s  153.001 KiB/s 813.998 KiB copied  ETA: Fri Jun 10 10:01:55 2022  1175 s  1104/1109 msgs left
msg INBOX/9 {8612}            copied to INBOX/9          1.09 msgs/s  149.260 KiB/s 822.408 KiB copied  ETA: Fri Jun 10 09:59:13 2022  1013 s  1103/1109 msgs left
msg INBOX/10 {9576}           copied to INBOX/10         1.23 msgs/s  146.742 KiB/s 831.760 KiB copied  ETA: Fri Jun 10 09:57:13 2022  892 s  1102/1109 msgs left
msg INBOX/11 {5866}           copied to INBOX/11         1.38 msgs/s  144.005 KiB/s 837.488 KiB copied  ETA: Fri Jun 10 09:55:41 2022  800 s  1101/1109 msgs left
msg INBOX/12 {260371}         copied to INBOX/12         1.48 msgs/s  179.860 KiB/s 1.066 MiB copied  ETA: Fri Jun 10 09:54:43 2022  742 s  1100/1109 msgs left
msg INBOX/13 {1727}           copied to INBOX/13         1.61 msgs/s  175.860 KiB/s 1.068 MiB copied  ETA: Fri Jun 10 09:53:44 2022  683 s  1099/1109 msgs left
msg INBOX/14 {7673}           copied to INBOX/14         1.73 msgs/s  172.958 KiB/s 1.075 MiB copied  ETA: Fri Jun 10 09:52:57 2022  635 s  1098/1109 msgs left
msg INBOX/15 {3440841}        copied to INBOX/15         1.71 msgs/s  635.166 KiB/s 4.357 MiB copied  ETA: Fri Jun 10 09:53:04 2022  642 s  1097/1109 msgs left
msg INBOX/16 {2472}           copied to INBOX/16         1.81 msgs/s  621.503 KiB/s 4.359 MiB copied  ETA: Fri Jun 10 09:52:28 2022  605 s  1096/1109 msgs left
msg INBOX/17 {13132}          copied to INBOX/17         1.89 msgs/s  604.643 KiB/s 4.371 MiB copied  ETA: Fri Jun 10 09:52:01 2022  579 s  1095/1109 msgs left
msg INBOX/18 {8198}           copied to INBOX/18         1.97 msgs/s  589.852 KiB/s 4.379 MiB copied  ETA: Fri Jun 10 09:51:37 2022  554 s  1094/1109 msgs left
msg INBOX/19 {6860}           copied to INBOX/19         2.06 msgs/s  579.397 KiB/s 4.386 MiB copied  ETA: Fri Jun 10 09:51:12 2022  530 s  1093/1109 msgs left
msg INBOX/20 {1352534}        copied to INBOX/20         2.10 msgs/s  716.758 KiB/s 5.676 MiB copied  ETA: Fri Jun 10 09:51:04 2022  521 s  1092/1109 msgs left
msg INBOX/21 {11329}          copied to INBOX/21         2.18 msgs/s  704.252 KiB/s 5.686 MiB copied  ETA: Fri Jun 10 09:50:44 2022  501 s  1091/1109 msgs left
msg INBOX/22 {297251}         copied to INBOX/22         2.21 msgs/s  710.279 KiB/s 5.970 MiB copied  ETA: Fri Jun 10 09:50:37 2022  494 s  1090/1109 msgs left
msg INBOX/23 {5354}           copied to INBOX/23         2.28 msgs/s  698.076 KiB/s 5.975 MiB copied  ETA: Fri Jun 10 09:50:21 2022  477 s  1089/1109 msgs left
msg INBOX/24 {5975}           copied to INBOX/24         2.35 msgs/s  684.778 KiB/s 5.981 MiB copied  ETA: Fri Jun 10 09:50:07 2022  463 s  1088/1109 msgs left
msg INBOX/25 {8351}           copied to INBOX/25         2.37 msgs/s  661.979 KiB/s 5.989 MiB copied  ETA: Fri Jun 10 09:50:02 2022  458 s  1087/1109 msgs left
msg INBOX/26 {5106}           copied to INBOX/26         2.44 msgs/s  651.619 KiB/s 5.994 MiB copied  ETA: Fri Jun 10 09:49:49 2022  445 s  1086/1109 msgs left
msg INBOX/27 {6314}           copied to INBOX/27         2.49 msgs/s  637.277 KiB/s 6.000 MiB copied  ETA: Fri Jun 10 09:49:40 2022  436 s  1085/1109 msgs left
msg INBOX/28 {5626}           copied to INBOX/28         2.53 msgs/s  623.504 KiB/s 6.005 MiB copied  ETA: Fri Jun 10 09:49:32 2022  428 s  1084/1109 msgs left
.....
.....
msg INBOX/435 {6720}          copied to INBOX/434        3.39 msgs/s  983.196 KiB/s 122.090 MiB copied  ETA: Fri Jun 10 09:47:42 2022  200 s  678/1109 msgs left
msg INBOX/436 {11751}         copied to INBOX/435        3.39 msgs/s  981.738 KiB/s 122.101 MiB copied  ETA: Fri Jun 10 09:47:42 2022  200 s  677/1109 msgs left
msg INBOX/437 {11782}         copied to INBOX/436        3.39 msgs/s  980.123 KiB/s 122.112 MiB copied  ETA: Fri Jun 10 09:47:42 2022  199 s  676/1109 msgs left
Folder     2/8 [[Gmail]/Drafts]                    -> [INBOX.Drafts]                     
Host1 folder [[Gmail]/Drafts] has 0 messages in total (mentioned by SELECT)
Creating folder [INBOX.Drafts] on host2
Created folder [INBOX.Drafts] on host2
Host2 folder [INBOX.Drafts] has 0 messages in total (mentioned by SELECT)
Host2 folder [INBOX.Drafts] permanentflags: 
Host2: Subscribing to folder INBOX.Drafts
Host1 folder [[Gmail]/Drafts] considering 0 messages
Host2 folder [INBOX.Drafts] considering 0 messages
Folder     3/8 [[Gmail]/Important]                 -> [INBOX.Important]                  
Host1 folder [[Gmail]/Important] has 215 messages in total (mentioned by SELECT)
Creating folder [INBOX.Important] on host2
Created folder [INBOX.Important] on host2
Host2 folder [INBOX.Important] has 0 messages in total (mentioned by SELECT)
Host2 folder [INBOX.Important] permanentflags: 
Host2: Subscribing to folder INBOX.Important
Host1 folder [[Gmail]/Important] considering 215 messages
Host2 folder [INBOX.Important] considering 0 messages
Folder     4/8 [[Gmail]/Sent Mail]                 -> [INBOX.Sent Mail]                  
Host1 folder [[Gmail]/Sent Mail] has 2 messages in total (mentioned by SELECT)
Creating folder [INBOX.Sent Mail] on host2
Created folder [INBOX.Sent Mail] on host2
Host2 folder [INBOX.Sent Mail] has 0 messages in total (mentioned by SELECT)
Host2 folder [INBOX.Sent Mail] permanentflags: 
Host2: Subscribing to folder INBOX.Sent Mail
Host1 folder [[Gmail]/Sent Mail] considering 2 messages
Host2 folder [INBOX.Sent Mail] considering 0 messages
msg [Gmail]/Sent Mail/1 {8999}            copied to INBOX.Sent Mail/1          3.32 msgs/s  956.592 KiB/s 122.121 MiB copied  ETA: Fri Jun 10 09:46:44 2022  139 s  460/1109 msgs left
msg [Gmail]/Sent Mail/5 {5383}            copied to INBOX.Sent Mail/2          3.32 msgs/s  955.015 KiB/s 122.126 MiB copied  ETA: Fri Jun 10 09:46:44 2022  138 s  459/1109 msgs left
Folder     5/8 [[Gmail]/Spam]                      -> [INBOX.Spam]                       
Host1 folder [[Gmail]/Spam] has 24 messages in total (mentioned by SELECT)
Creating folder [INBOX.Spam] on host2
Created folder [INBOX.Spam] on host2
Host2 folder [INBOX.Spam] has 0 messages in total (mentioned by SELECT)
Host2 folder [INBOX.Spam] permanentflags: 
Host2: Subscribing to folder INBOX.Spam
Host1 folder [[Gmail]/Spam] considering 24 messages
Host2 folder [INBOX.Spam] considering 0 messages
msg [Gmail]/Spam/8539 {11363}        copied to INBOX.Spam/1          3.31 msgs/s  950.132 KiB/s 122.137 MiB copied  ETA: Fri Jun 10 09:46:45 2022  138 s  458/1109 msgs left
msg [Gmail]/Spam/8540 {9960}         copied to INBOX.Spam/2          3.32 msgs/s  948.838 KiB/s 122.146 MiB copied  ETA: Fri Jun 10 09:46:45 2022  138 s  457/1109 msgs left
msg [Gmail]/Spam/8541 {11326}        copied to INBOX.Spam/3          3.32 msgs/s  947.299 KiB/s 122.157 MiB copied  ETA: Fri Jun 10 09:46:44 2022  137 s  456/1109 msgs left
msg [Gmail]/Spam/8542 {11528}        copied to INBOX.Spam/4          3.32 msgs/s  946.168 KiB/s 122.168 MiB copied  ETA: Fri Jun 10 09:46:44 2022  137 s  455/1109 msgs left
msg [Gmail]/Spam/8543 {9871}         copied to INBOX.Spam/5          3.32 msgs/s  945.186 KiB/s 122.177 MiB copied  ETA: Fri Jun 10 09:46:44 2022  137 s  454/1109 msgs left
msg [Gmail]/Spam/8544 {24347}        copied to INBOX.Spam/6          3.33 msgs/s  943.860 KiB/s 122.201 MiB copied  ETA: Fri Jun 10 09:46:44 2022  136 s  453/1109 msgs left
msg [Gmail]/Spam/8545 {10097}        copied to INBOX.Spam/7          3.33 msgs/s  942.516 KiB/s 122.210 MiB copied  ETA: Fri Jun 10 09:46:43 2022  136 s  452/1109 msgs left
msg [Gmail]/Spam/8546 {9540}         copied to INBOX.Spam/8          3.33 msgs/s  940.788 KiB/s 122.219 MiB copied  ETA: Fri Jun 10 09:46:43 2022  135 s  451/1109 msgs left
msg [Gmail]/Spam/8547 {37916}        copied to INBOX.Spam/9          3.33 msgs/s  939.650 KiB/s 122.255 MiB copied  ETA: Fri Jun 10 09:46:43 2022  135 s  450/1109 msgs left
msg [Gmail]/Spam/8548 {10818}        copied to INBOX.Spam/10         3.33 msgs/s  938.244 KiB/s 122.266 MiB copied  ETA: Fri Jun 10 09:46:43 2022  135 s  449/1109 msgs left
msg [Gmail]/Spam/8549 {9686}         copied to INBOX.Spam/11         3.34 msgs/s  936.691 KiB/s 122.275 MiB copied  ETA: Fri Jun 10 09:46:43 2022  134 s  448/1109 msgs left
msg [Gmail]/Spam/8550 {11205}        copied to INBOX.Spam/12         3.34 msgs/s  934.843 KiB/s 122.286 MiB copied  ETA: Fri Jun 10 09:46:43 2022  134 s  447/1109 msgs left
msg [Gmail]/Spam/8551 {11276}        copied to INBOX.Spam/13         3.34 msgs/s  933.161 KiB/s 122.296 MiB copied  ETA: Fri Jun 10 09:46:43 2022  134 s  446/1109 msgs left
msg [Gmail]/Spam/8552 {9467}         copied to INBOX.Spam/14         3.34 msgs/s  931.911 KiB/s 122.305 MiB copied  ETA: Fri Jun 10 09:46:42 2022  133 s  445/1109 msgs left
msg [Gmail]/Spam/8553 {9536}         copied to INBOX.Spam/15         3.34 msgs/s  930.884 KiB/s 122.315 MiB copied  ETA: Fri Jun 10 09:46:42 2022  133 s  444/1109 msgs left
msg [Gmail]/Spam/8554 {12457}        copied to INBOX.Spam/16         3.34 msgs/s  928.064 KiB/s 122.326 MiB copied  ETA: Fri Jun 10 09:46:42 2022  133 s  443/1109 msgs left
msg [Gmail]/Spam/8555 {9490}         copied to INBOX.Spam/17         3.34 msgs/s  927.045 KiB/s 122.335 MiB copied  ETA: Fri Jun 10 09:46:42 2022  132 s  442/1109 msgs left
msg [Gmail]/Spam/8556 {16677}        copied to INBOX.Spam/18         3.35 msgs/s  925.578 KiB/s 122.351 MiB copied  ETA: Fri Jun 10 09:46:42 2022  132 s  441/1109 msgs left
msg [Gmail]/Spam/8557 {10216}        copied to INBOX.Spam/19         3.35 msgs/s  924.355 KiB/s 122.361 MiB copied  ETA: Fri Jun 10 09:46:42 2022  131 s  440/1109 msgs left
msg [Gmail]/Spam/8558 {9875}         copied to INBOX.Spam/20         3.35 msgs/s  923.348 KiB/s 122.371 MiB copied  ETA: Fri Jun 10 09:46:42 2022  131 s  439/1109 msgs left
msg [Gmail]/Spam/8559 {991379}       copied to INBOX.Spam/21         3.35 msgs/s  927.879 KiB/s 123.316 MiB copied  ETA: Fri Jun 10 09:46:42 2022  131 s  438/1109 msgs left
msg [Gmail]/Spam/8560 {8102}         copied to INBOX.Spam/22         3.35 msgs/s  926.716 KiB/s 123.324 MiB copied  ETA: Fri Jun 10 09:46:41 2022  130 s  437/1109 msgs left
msg [Gmail]/Spam/8561 {58122}        copied to INBOX.Spam/23         3.35 msgs/s  925.342 KiB/s 123.379 MiB copied  ETA: Fri Jun 10 09:46:41 2022  130 s  436/1109 msgs left
msg [Gmail]/Spam/8562 {11815}        copied to INBOX.Spam/24         3.35 msgs/s  923.358 KiB/s 123.390 MiB copied  ETA: Fri Jun 10 09:46:41 2022  130 s  435/1109 msgs left
Folder     6/8 [[Gmail]/Starred]                   -> [INBOX.Starred]                    
Host1 folder [[Gmail]/Starred] has 0 messages in total (mentioned by SELECT)
Creating folder [INBOX.Starred] on host2
Created folder [INBOX.Starred] on host2
Host2 folder [INBOX.Starred] has 0 messages in total (mentioned by SELECT)
Host2 folder [INBOX.Starred] permanentflags: 
Host2: Subscribing to folder INBOX.Starred
Host1 folder [[Gmail]/Starred] considering 0 messages
Host2 folder [INBOX.Starred] considering 0 messages
Folder     7/8 [[Gmail]/Trash]                     -> [INBOX.Trash]                      
Host1 folder [[Gmail]/Trash] has 0 messages in total (mentioned by SELECT)
Creating folder [INBOX.Trash] on host2
Created folder [INBOX.Trash] on host2
Host2 folder [INBOX.Trash] has 0 messages in total (mentioned by SELECT)
Host2 folder [INBOX.Trash] permanentflags: 
Host2: Subscribing to folder INBOX.Trash
Host1 folder [[Gmail]/Trash] considering 0 messages
Host2 folder [INBOX.Trash] considering 0 messages
Folder     8/8 [[Gmail]/All Mail]                  -> [INBOX.All Mail]                   
Host1 folder [[Gmail]/All Mail] has 435 messages in total (mentioned by SELECT)
Creating folder [INBOX.All Mail] on host2
Created folder [INBOX.All Mail] on host2
Host2 folder [INBOX.All Mail] has 0 messages in total (mentioned by SELECT)
Host2 folder [INBOX.All Mail] permanentflags: 
Host2: Subscribing to folder INBOX.All Mail
Host1 folder [[Gmail]/All Mail] considering 435 messages
Host2 folder [INBOX.All Mail] considering 0 messages
++++ End looping on each folder

Folders sizes after the synchronization.
You can remove this foldersizes listing by using  "--nofoldersizesatend"
++++ Calculating sizes of 8 folders on Host1
Host1 folder     1/8 [INBOX]                             Size: 128043765 Messages:   433 Biggest:  10727344
Host1 folder     2/8 [[Gmail]/Drafts]                    Size:         0 Messages:     0 Biggest:         0
Host1 folder     3/8 [[Gmail]/Important]                 Size:  68103771 Messages:   215 Biggest:  10727344
Host1 folder     4/8 [[Gmail]/Sent Mail]                 Size:     14382 Messages:     2 Biggest:      8999
Host1 folder     5/8 [[Gmail]/Spam]                      Size:   1326069 Messages:    24 Biggest:    991379
Host1 folder     6/8 [[Gmail]/Starred]                   Size:         0 Messages:     0 Biggest:         0
Host1 folder     7/8 [[Gmail]/Trash]                     Size:         0 Messages:     0 Biggest:         0
Host1 folder     8/8 [[Gmail]/All Mail]                  Size: 128058147 Messages:   435 Biggest:  10727344
Host1 Nb folders:                8 folders
Host1 Nb messages:            1109 messages
Host1 Total size:        325546134 bytes (310.465 MiB)
Host1 Biggest message:    10727344 bytes (10.230 MiB)
Host1 Time spent:              5.8 seconds
++++ Calculating sizes of 8 folders on Host2
Host2 folder     1/8 [INBOX]                             Size: 128066247 Messages:   436 Biggest:  10727344
Host2 folder     2/8 [INBOX.All Mail]                    Size:         0 Messages:     0 Biggest:         0
Host2 folder     3/8 [INBOX.Drafts]                      Size:         0 Messages:     0 Biggest:         0
Host2 folder     4/8 [INBOX.Important]                   Size:         0 Messages:     0 Biggest:         0
Host2 folder     5/8 [INBOX.Sent Mail]                   Size:     14386 Messages:     2 Biggest:      9001
Host2 folder     6/8 [INBOX.Spam]                        Size:   1326069 Messages:    24 Biggest:    991379
Host2 folder     7/8 [INBOX.Starred]                     Size:         0 Messages:     0 Biggest:         0
Host2 folder     8/8 [INBOX.Trash]                       Size:         0 Messages:     0 Biggest:         0
Host2 Nb folders:                8 folders
Host2 Nb messages:             462 messages
Host2 Total size:        129406702 bytes (123.412 MiB)
Host2 Biggest message:    10727344 bytes (10.230 MiB)
Host2 Time spent:              0.4 seconds
++++ Statistics
Transfer started on               : Fri Jun 10 09:42:06 2022
Transfer ended on                 : Fri Jun 10 09:44:42 2022
Transfer time                     : 156.0 sec
Folders synced                    : 8/8 synced
Messages transferred              : 459 
Messages skipped                  : 650
Messages found duplicate on host1 : 0
Messages found duplicate on host2 : 0
Messages void (noheader) on host1 : 0
Messages void (noheader) on host2 : 0
Messages deleted on host1         : 0
Messages deleted on host2         : 0
Total bytes transferred           : 129384216 (123.390 MiB)
Total bytes duplicate host1       : 0 (0.000 KiB)
Total bytes duplicate host2       : 0 (0.000 KiB)
Total bytes skipped               : 196161918 (187.075 MiB)
Total bytes error                 : 0 (0.000 KiB)
Message rate                      : 2.9 messages/s
Average bandwidth rate            : 809.7 KiB/s
Reconnections to host1            : 0
Reconnections to host2            : 0
Memory consumption at the end     : 206.1 MiB (started with 153.6 MiB)
Biggest message                   : 10727344 bytes (10.230 MiB)
Memory/biggest message ratio      : 20.1
Start difference host2 - host1    : -1106 messages, -325523652 bytes (-310.444 MiB)
Final difference host2 - host1    : -647 messages, -196139432 bytes (-187.053 MiB)
Detected 0 errors

Check if a new imapsync release is available by adding --releasecheck
Homepage: https://imapsync.lamiral.info/
Exiting with return value 0
Log file is LOG_imapsync/2022_06_10_09_42_06_559_info@exmaple.com_info@example.com.txt ( to change it, use --logfile filepath ; or use --nolog to turn off logging )

The log file of the imapsync command is put in LOG_imapsync/2022_06_10_09_42_06_559_info@exmaple.com_info@example.com.txt.

Troubleshooting

Host1 banner: * OK Gimap ready for requests from 77.88.55.66 111111111111
Host1 capability before authentication: IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH2 AUTH=PLAIN AUTH=PLAIN-CLIENTTOKEN AUTH=OAUTHBEARER AUTH=XOAUTH
Host1: imap.googlemail.com says it has CAPABILITY for AUTHENTICATE XOAUTH
Host1 failure: Error login on [imap.googlemail.com] with user [info@example.com] auth [XOAUTH]: 2 NO [AUTHENTICATIONFAILED] Invalid credentials (Failure)

imapsync command options

This is the options of imapsync version 1.882:

[myuser@srv ~]# imapsync --help
Name:

 imapsync - Email IMAP tool for syncing, copying and migrating email
 mailboxes between two imap servers, one way, and without duplicates.

Version:

 This documentation refers to Imapsync $Revision: 1.882 $

Usage:

  To synchronize the source imap account
    "test1" on server "test1.lamiral.info" with password "secret1"
  to the destination imap account
    "test2" on server "test2.lamiral.info" with password "secret2"
  do:

   imapsync \
    --host1 test1.lamiral.info --user1 test1 --password1 secret1 \
    --host2 test2.lamiral.info --user2 test2 --password2 secret2

Options:

  usage: imapsync [options]

 Mandatory options are the six values, three on each sides, needed to log in
 into the IMAP servers, ie, a host, a username, and a password, two times.

 Conventions used:

  str means string
  int means integer
  reg means regular expression
  cmd means command

  --dry               : Makes imapsync doing nothing for real, just print what 
                        would be done without --dry.

Options/credentials:

  --host1        str  : Source or "from" imap server. Mandatory.
  --port1        int  : Port to connect on host1. 
                        Optional since default port is 143 or 993 if --ssl1
  --user1        str  : User to login on host1. Mandatory.
  --password1    str  : Password for the user1.

  --host2        str  : "destination" imap server. Mandatory.
  --port2        int  : Port to connect on host2. 
                        Optional since default port is 143 or 993 if --ssl2
  --user2        str  : User to login on host2. Mandatory.
  --password2    str  : Password for the user2.

  --showpasswords     : Shows passwords on output instead of "MASKED".
                        Useful to restart a complete run by just reading the log,
                        or to debug passwords. It's not a secure practice.

  --passfile1    str  : Password file for the user1. It must contain the
                        password on the first line. This option avoids to show
                        the password on the command line like --password1 does.
  --passfile2    str  : Password file for the user2. Contains the password.

Options/encryption:

  --nossl1            : Do not use a SSL connection on host1.
  --ssl1              : Use a SSL connection on host1. On by default if possible.

  --nossl2            : Do not use a SSL connection on host2.
  --ssl2              : Use a SSL connection on host2. On by default if possible.

  --notls1            : Do not use a TLS connection on host1.
  --tls1              : Use a TLS connection on host1. On by default if possible.

  --notls2            : Do not use a TLS connection on host2.
  --tls2              : Use a TLS connection on host2. On by default if possible.

  --debugssl     int  : SSL debug mode from 0 to 4.

  --sslargs1     str  : Pass any ssl parameter for host1 ssl or tls connection. Example:
                        --sslargs1 SSL_verify_mode=1 --sslargs1 SSL_version=SSLv3
                        See all possibilities in the new() method of IO::Socket::SSL
                        http://search.cpan.org/perldoc?IO::Socket::SSL#Description_Of_Methods
  --sslargs2     str  : Pass any ssl parameter for host2 ssl or tls connection.
                        See --sslargs1

  --timeout1     int  : Connection timeout in seconds for host1.
                        Default is 120 and 0 means no timeout at all.
  --timeout2     int  : Connection timeout in seconds for host2.
                        Default is 120 and 0 means no timeout at all.

Options/authentication:

  --authmech1    str  : Auth mechanism to use with host1:
                        PLAIN, LOGIN, CRAM-MD5 etc. Use UPPERCASE.
  --authmech2    str  : Auth mechanism to use with host2. See --authmech1

  --authuser1    str  : User to auth with on host1 (admin user).
                        Avoid using --authmech1 SOMETHING with --authuser1.
  --authuser2    str  : User to auth with on host2 (admin user).
  --proxyauth1        : Use proxyauth on host1. Requires --authuser1.
                        Required by Sun/iPlanet/Netscape IMAP servers to
                        be able to use an administrative user.
  --proxyauth2        : Use proxyauth on host2. Requires --authuser2.

  --authmd51          : Use MD5 authentication for host1.
  --authmd52          : Use MD5 authentication for host2.
  --domain1      str  : Domain on host1 (NTLM authentication).
  --domain2      str  : Domain on host2 (NTLM authentication).

Options/folders:

  --folder       str  : Sync this folder.
  --folder       str  : and this one, etc.
  --folderrec    str  : Sync this folder recursively.
  --folderrec    str  : and this one, etc.

  --folderfirst  str  : Sync this folder first. --folderfirst "Work"
  --folderfirst  str  : then this one, etc.
  --folderlast   str  : Sync this folder last. --folderlast "[Gmail]/All Mail"
  --folderlast   str  : then this one, etc.

  --nomixfolders      : Do not merge folders when host1 is case-sensitive
                        while host2 is not (like Exchange). Only the first
                        similar folder is synced (ex: with Sent SENT sent
                        on host1 only Sent will be synced to host2).

  --skipemptyfolders  : Empty host1 folders are not created on host2.

  --include      reg  : Sync folders matching this regular expression
  --include      reg  : or this one, etc.
                        If both --include --exclude options are used, then
                        include is done before.
  --exclude      reg  : Skips folders matching this regular expression
                        Several folders to avoid:
                         --exclude 'fold1|fold2|f3' skips fold1, fold2 and f3.
  --exclude      reg  : or this one, etc.

  --automap           : guesses folders mapping, for folders well known as
                        "Sent", "Junk", "Drafts", "All", "Archive", "Flagged".

  --f1f2    str1=str2 : Force folder str1 to be synced to str2,
                        --f1f2 overrides --automap and --regextrans2.

  --subfolder2   str  : Move whole host1 folders hierarchy under this
                        host2 folder  str    .
                        It does it by adding two --regextrans2 options before
                        all others. Add --debug to see what's really going on.

  --subscribed        : Transfers subscribed folders.
  --subscribe         : Subscribe to the folders transferred on the
                        host2 that are subscribed on host1. On by default.
  --subscribeall      : Subscribe to the folders transferred on the
                        host2 even if they are not subscribed on host1.

  --prefix1      str  : Remove prefix str to all destination folders,
                        usually INBOX. or INBOX/ or an empty string "".
                        imapsync guesses the prefix if host1 imap server
                        does not have NAMESPACE capability. This option
                        should not be used, most of the time.
  --prefix2      str  : Add prefix to all host2 folders. See --prefix1
  --sep1         str  : Host1 separator in case NAMESPACE is not supported.
  --sep2         str  : Host2 separator in case NAMESPACE is not supported.

  --regextrans2  reg  : Apply the whole regex to each destination folders.
  --regextrans2  reg  : and this one. etc.
                        When you play with the --regextrans2 option, first
                        add also the safe options --dry --justfolders
                        Then, when happy, remove --dry, remove --justfolders.
                        Have in mind that --regextrans2 is applied after prefix
                        and separator inversion. For examples see
                        https://imapsync.lamiral.info/FAQ.d/FAQ.Folders_Mapping.txt

Options/folders sizes:

  --nofoldersizes     : Do not calculate the size of each folder at the
                        beginning of the sync. Default is to calculate them.
  --nofoldersizesatend: Do not calculate the size of each folder at the 
                        end of the sync. Default is to calculate them.
  --justfoldersizes   : Exit after having printed the initial folder sizes.

Options/tmp:

  --tmpdir       str  : Where to store temporary files and subdirectories.
                        Will be created if it doesn't exist.
                        Default is system specific, Unix is /tmp but
                        /tmp is often too small and deleted at reboot.
                        --tmpdir /var/tmp should be better.
  --pidfile      str  : The file where imapsync pid is written,
                        it can be dirname/filename.
                        Default name is imapsync.pid in tmpdir.
  --pidfilelocking    : Abort if pidfile already exists. Useful to avoid
                        concurrent transfers on the same mailbox.

Options/log:

  --nolog             : Turn off logging on file
  --logfile      str  : Change the default log filename (can be dirname/filename).
  --logdir       str  : Change the default log directory. Default is LOG_imapsync/

Options/messages:

  --skipmess     reg  : Skips messages matching the regex.
                        Example: 'm/[\x80-ff]/' # to avoid 8bits messages.
                        --skipmess is applied before --regexmess
  --skipmess     reg  : or this one, etc.

  --pipemess     cmd  : Apply this cmd command to each message content
                        before the copy.
  --pipemess     cmd  : and this one, etc.

  --disarmreadreceipts : Disarms read receipts (host2 Exchange issue)

  --regexmess    reg  : Apply the whole regex to each message before transfer.
                        Example: 's/\000/ /g' # to replace null by space.
  --regexmess    reg  : and this one, etc.

Options/flags:

  --regexflag    reg  : Apply the whole regex to each flags list.
                        Example: 's/"Junk"//g' # to remove "Junk" flag.
  --regexflag    reg  : then this one, etc.

  --resyncflags       : Resync flags for already transferred messages.
                        On by default.
  --noresyncflags     : Do not resync flags for already transferred messages.
                        May be useful when a user has already started to play 
                        with its host2 account.

Options/deletions:

  --delete1           : Deletes messages on host1 server after a successful
                        transfer. Option --delete1 has the following behavior:
                        it marks messages as deleted with the IMAP flag
                        \Deleted, then messages are really deleted with an
                        EXPUNGE IMAP command. If expunging after each message
                        slows down too much the sync then use
                        --noexpungeaftereach to speed up.
  --expunge1          : Expunge messages on host1 just before syncing a folder.
                        Expunge is done per folder.
                        Expunge aims is to really delete messages marked deleted.
                        An expunge is also done after each message copied
                        if option --delete1 is set.
  --noexpunge1        : Do not expunge messages on host1.
  --delete1emptyfolders : Deletes empty folders on host1, INBOX excepted.
                          Useful with --delete1 since what remains on host1
                          is only what failed to be synced.

  --delete2           : Delete messages in host2 that are not in
                        host1 server. Useful for backup or pre-sync.
  --delete2duplicates : Delete messages in host2 that are duplicates.
                        Works only without --useuid since duplicates are
                        detected with an header part of each message.

  --delete2folders    : Delete folders in host2 that are not in host1 server.
                        For safety, first try it like this (it is safe):
                        --delete2folders --dry --justfolders --nofoldersizes
  --delete2foldersonly   reg : Deleted only folders matching regex.
                               Example: --delete2foldersonly "/^Junk$|^INBOX.Junk$/"
  --delete2foldersbutnot reg : Do not delete folders matching regex.
                               Example: --delete2foldersbutnot "/Tasks$|Contacts$|Foo$/"

  --expunge2          : Expunge messages on host2 after messages transfer.
  --uidexpunge2       : uidexpunge messages on the host2 account
                        that are not on the host1 account, requires --delete2

Options/dates:

  --syncinternaldates : Sets the internal dates on host2 same as host1.
                        Turned on by default. Internal date is the date
                        a message arrived on a host (mtime).
  --idatefromheader   : Sets the internal dates on host2 same as the
                        "Date:" headers.
                        If you encounter problems with dates see also
                        https://imapsync.lamiral.info/FAQ.d/FAQ.Dates.txt

Options/message selection:

  --maxsize      int  : Skip messages larger  (or equal) than  int  bytes
  --minsize      int  : Skip messages smaller (or equal) than  int  bytes
  --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)

  --search       str  : Selects only messages returned by this IMAP SEARCH
                        command. Applied on both sides.
                        For a complete of what can be search see
                        https://imapsync.lamiral.info/FAQ.d/FAQ.Messages_Selection.txt
                       
  --search1      str  : Same as --search but for selecting host1 messages only.
  --search2      str  : Same as --search but for selecting host2 messages only.
                        --search CRIT equals --search1 CRIT --search2 CRIT

  --maxlinelength int : skip messages with a line length longer than  int  bytes.
                        RFC 2822 says it must be no more than 1000 bytes.


  --useheader    str  : Use this header to compare messages on both sides.
                        Ex: Message-ID or Subject or Date.
  --useheader    str    and this one, etc.

  --usecache          : Use cache to speed up the sync.
  --nousecache        : Do not use cache. Caveat: --useuid --nousecache creates
                        duplicates on multiple runs.
  --useuid            : Use UIDs instead of headers as a criterium to recognize
                        messages. Option --usecache is then implied unless
                        --nousecache is used.

Options/miscellaneous:

  --syncacls          : Synchronizes acls (Access Control Lists).
  --nosyncacls        : Does not synchronize acls. This is the default.
                        Acls in IMAP are not standardized, be careful.

Options/debugging:

  --debug             : Debug mode.
  --debugfolders      : Debug mode for the folders part only.
  --debugcontent      : Debug content of the messages transferred. Huge output.
  --debugflags        : Debug mode for flags.
  --debugimap1        : IMAP debug mode for host1. Very verbose.
  --debugimap2        : IMAP debug mode for host2. Very verbose.
  --debugimap         : IMAP debug mode for host1 and host2. Twice very verbose.
  --debugmemory       : Debug mode showing memory consumption after each copy.

  --errorsmax     int : Exit when int number of errors is reached. Default is 50.

  --tests             : Run local non-regression tests. Exit code 0 means all ok.
  --testslive         : Run a live test with test1.lamiral.info imap server.
                        Useful to check the basics. Needs internet connection.
  --testslive6        : Run a live test with ks2ipv6.lamiral.info imap server.
                        Useful to check the ipv6 connectivity. Needs internet.

Options/specific:

   --gmail1           : sets --host1 to Gmail and options from FAQ.Gmail.txt
   --gmail2           : sets --host2 to Gmail and options from FAQ.Gmail.txt
  
   --office1          : sets --host1 to Office365 options from FAQ.Exchange.txt
   --office2          : sets --host2 to Office365 options from FAQ.Exchange.txt

   --exchange1        : sets options from FAQ.Exchange.txt, account1 part
   --exchange2        : sets options from FAQ.Exchange.txt, account2 part
  
   --domino1          : sets options from FAQ.Domino.txt, account1 part
   --domino2          : sets options from FAQ.Domino.txt, account2 part

Options/behavior:

  --maxmessagespersecond int : limits the number of messages transferred per second.
 
  --maxbytespersecond int : limits the average transfer rate per second.
  --maxbytesafter     int : starts --maxbytespersecond limitation only after 
                            --maxbytesafter amount of data transferred.
 
  --maxsleep      int : do not sleep more than int seconds.
                        On by default, 2 seconds max, like --maxsleep 2

  --abort             : terminates a previous call still running. 
                        It uses the pidfile to know what process to abort.

  --exitwhenover int  : Stop syncing when total bytes transferred reached.

  --version           : Print only software version.
  --noreleasecheck    : Do not check for new imapsync release (a http request).
  --releasecheck      : Check for new imapsync release (a http request).
  --noid              : Do not send/receive ID command to imap servers.
  --justconnect       : Just connect to both servers and print useful
                        information. Need only --host1 and --host2 options.
  --justlogin         : Just login to both host1 and host2 with users
                        credentials, then exit.
  --justfolders       : Do only things about folders (ignore messages).

  --help              : print this help.

  Example: to synchronize imap account "test1" on "test1.lamiral.info"
                      to  imap account "test2" on "test2.lamiral.info"
                      with test1 password "secret1"
                      and  test2 password "secret2"

  imapsync \
     --host1 test1.lamiral.info --user1 test1 --password1 secret1 \
     --host2 test2.lamiral.info --user2 test2 --password2 secret2

Here is imapsync 1.882 on host srv, a linux system with 0.5/15.4 free GiB of RAM
with Perl 5.30.3 and Mail::IMAPClient 3.39
$Id: imapsync,v 1.882 2018/05/05 21:10:43 gilles Exp gilles $
Check if a new imapsync release is available by adding --releasecheck
Homepage: https://imapsync.lamiral.info/

Leave a Reply

Your email address will not be published. Required fields are marked *