README 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914
  1. NAME
  2. imapsync - Email IMAP tool for syncing, copying, migrating and archiving
  3. email mailboxes between two imap servers, one way, and without
  4. duplicates.
  5. VERSION
  6. This documentation refers to Imapsync $Revision: 2.229 $
  7. USAGE
  8. To synchronize the source imap account
  9. "test1" on server "test1.lamiral.info" with password "secret1"
  10. to the destination imap account
  11. "test2" on server "test2.lamiral.info" with password "secret2"
  12. do:
  13. imapsync \
  14. --host1 test1.lamiral.info --user1 test1 --password1 secret1 \
  15. --host2 test2.lamiral.info --user2 test2 --password2 secret2
  16. DESCRIPTION
  17. We sometimes need to transfer mailboxes from one imap server to one
  18. another.
  19. Imapsync command is a tool allowing incremental and recursive imap
  20. transfers from one mailbox to another. If you don't understand the
  21. previous sentence, it's normal, it's pedantic computer-oriented jargon.
  22. All folders are transferred, recursively, meaning the whole folder
  23. hierarchy is taken, all messages in them, and all message flags (\Seen
  24. \Answered \Flagged etc.) are synced too.
  25. Imapsync reduces the amount of data transferred by not transferring a
  26. given message if it already resides on the destination side. Messages
  27. that are on the destination side but not on the source side stay as they
  28. are. See the --delete2 option to have strict sync and delete them.
  29. How does imapsync know a message is already on both sides? Same specific
  30. headers and the transfer is done only once. By default, the
  31. identification headers are "Message-Id:" and "Received:" lines but this
  32. choice can be changed with the --useheader option, most often a
  33. duplicate problem is solved by using --useheader "Message-Id"
  34. All flags are preserved, unread messages will stay unread, read ones
  35. will stay read, deleted will stay deleted. In the IMAP protocol, a
  36. deleted message is not deleted, it is marked \Deleted and can be
  37. undeleted. Real destruction comes with the EXPUNGE or UIDEXPUNGE IMAP
  38. commands.
  39. You can abort the transfer at any time and restart it later, imapsync
  40. works well with bad connections and interruptions, by design. On a
  41. terminal hit Ctr-c twice within two seconds to abort the program. Hit
  42. Ctr-c just once makes imapsync reconnect to both imap servers.
  43. How do you know the sync is finished and well done? When imapsync ends
  44. by itself it mentions it with lines like those:
  45. Exiting with return value 0 (EX_OK: successful termination) 0/50 nb_errors/max_errors PID 301
  46. Removing pidfile /tmp/imapsync.pid
  47. Log file is LOG_imapsync/2020_11_17_15_59_22_761_test1_test2.txt ( to change it, use --logfile filepath ; or use --nolog to turn off logging )
  48. If you don't have those lines it means that either the sync process is
  49. still running (or eventually hanging indefinitely) or that it ended
  50. without a whisper, a strong kill -9 on Linux for example.
  51. If you have those final lines then it means the sync process is properly
  52. finished. It may have encountered problems though.
  53. A good synchronization is mentioned by some lines above the last ones,
  54. especially those three lines:
  55. The sync looks good, all 1745 identified messages in host1 are on host2.
  56. There is no unidentified message on host1.
  57. Detected 0 errors
  58. Imapsync mentions the total sizes of both accounts at the beginning of
  59. the sync and also at the end. Sometimes, even with a strict sync, those
  60. total sizes differ, and sometimes they differ a lot. The difference is
  61. not a good criterion to conclude the sync went wrong.
  62. Why? That's because message sizes given by the imap servers are not
  63. always accurate, they are not always the same as the actual message
  64. sizes of the messages transferred by imapsync. Imapsync use the sizes
  65. given by the imap servers to calculate the big total size. They can
  66. differ. In the early days, Imapsync used the sizes of the messages as
  67. one of the criteria to identify the messages, different sizes implied
  68. different messages; but it was a mistake, the same message had different
  69. sizes on both sides sometimes, depending on the imap servers.
  70. Another explanation for a big total size difference is that Gmail
  71. doesn't count the size of duplicate messages across folders twice, while
  72. imapsync does.
  73. A classical scenario is synchronizing a mailbox B from another mailbox A
  74. where you just want to keep a strict copy of A in B. Strict meaning all
  75. messages in A will be in B but no more.
  76. For a strict synchronization, use the option --delete2. The option
  77. --delete2 deletes the messages in the host2 folder B that are not in the
  78. host1 folder A. If you also need to destroy host2 folders that are not
  79. in host1 then use --delete2folders. See also --delete2foldersonly and
  80. --delete2foldersbutnot to set up exceptions on folders to destroy. INBOX
  81. will never be destroyed, it's a mandatory folder in IMAP so imapsync
  82. doesn't even try to remove it.
  83. A different scenario is to delete the messages from the source mailbox
  84. after a successful transfer, it can be a good feature when migrating
  85. mailboxes since messages will be only on one side. The source account
  86. will only have messages that are not on the destination yet, ie,
  87. messages that arrived after a sync or that failed to be transferred.
  88. In that case, use the --delete1 option. Option --delete1 implies also
  89. the option --expunge1 so all messages marked deleted on host1 will be
  90. deleted. In IMAP protocol deleting a message does not delete it, it
  91. marks it with the flag \Deleted, allowing an undelete. Expunging a
  92. folder removes, definitively, all the messages marked as \Deleted in
  93. this folder.
  94. You can also decide to remove empty folders once all of their messages
  95. have been transferred. Add --delete1emptyfolders to obtain this
  96. behavior.
  97. Imapsync is not adequate for maintaining two active imap accounts in
  98. synchronization when the user plays independently on both sides. Use
  99. offlineimap (written by John Goerzen) or mbsync (written by Michael R.
  100. Elkins) for a 2 ways synchronization.
  101. OPTIONS
  102. usage: imapsync [options]
  103. The standard options are the six values forming the credentials. Three
  104. values on each side are needed to login into the IMAP servers. These six
  105. values are a hostname, a username, and a password, two times.
  106. Here are the conventions used in the following descriptions of the
  107. options:
  108. str means a string
  109. int means an integer number
  110. flo means a float number
  111. reg means a regular expression
  112. cmd means a command
  113. --dry : Makes imapsync do nothing for real; it just prints what
  114. would be done without --dry.
  115. OPTIONS/credentials
  116. --host1 str : Source or "from" imap server.
  117. --port1 int : Port to connect on host1.
  118. Optional since default ports are the
  119. well known ports imap/143 or imaps/993.
  120. --user1 str : User to login on host1.
  121. --password1 str : Password of user1.
  122. --host2 str : "destination" imap server.
  123. --port2 int : Port to connect on host2. Optional
  124. --user2 str : User to login on host2.
  125. --password2 str : Password of user2.
  126. --showpasswords : Shows passwords on output instead of "MASKED".
  127. Useful to restart a complete run by just reading
  128. the command line used in the log,
  129. or to debug passwords.
  130. It's not a secure practice at all!
  131. --passfile1 str : Password file for the user1. It must contain the
  132. password on the first line. This option avoids showing
  133. the password on the command line like --password1 does.
  134. --passfile2 str : Password file for the user2.
  135. You can also pass the passwords in the environment variables
  136. IMAPSYNC_PASSWORD1 and IMAPSYNC_PASSWORD2. If you don't pass the user1
  137. password via --password1 nor --passfile1 nor $IMAPSYNC_PASSWORD1 then
  138. imapsync will prompt to enter the password on the terminal. Same thing
  139. for user2 password.
  140. OPTIONS/encryption
  141. --nossl1 : Do not use a SSL connection on host1.
  142. --ssl1 : Use a SSL connection on host1. On by default if possible.
  143. --nossl2 : Do not use a SSL connection on host2.
  144. --ssl2 : Use a SSL connection on host2. On by default if possible.
  145. --notls1 : Do not use a TLS connection on host1.
  146. --tls1 : Use a TLS connection on host1. On by default if possible.
  147. --notls2 : Do not use a TLS connection on host2.
  148. --tls2 : Use a TLS connection on host2. On by default if possible.
  149. --debugssl int : SSL debug mode from 0 to 4.
  150. --sslargs1 str : Pass any ssl parameter for host1 ssl or tls connection. Example:
  151. --sslargs1 SSL_verify_mode=1 --sslargs1 SSL_version=SSLv3
  152. See all possibilities in the new() method of IO::Socket::SSL
  153. http://search.cpan.org/perldoc?IO::Socket::SSL#Description_Of_Methods
  154. --sslargs2 str : Pass any ssl parameter for host2 ssl or tls connection.
  155. See --sslargs1
  156. OPTIONS/authentication
  157. --authmech1 str : Auth mechanism to use with host1:
  158. PLAIN, LOGIN, CRAM-MD5 etc. Use UPPERCASE.
  159. --authmech2 str : Auth mechanism to use with host2. See --authmech1
  160. --authuser1 str : User to auth with on host1 (admin user).
  161. Avoid using --authmech1 SOMETHING with --authuser1.
  162. --authuser2 str : User to auth with on host2 (admin user).
  163. --proxyauth1 : Use proxyauth on host1. Requires --authuser1.
  164. Required by Sun/iPlanet/Netscape IMAP servers to
  165. be able to use an administrative user.
  166. --proxyauth2 : Use proxyauth on host2. Requires --authuser2.
  167. --authmd51 : Use MD5 authentication for host1.
  168. --authmd52 : Use MD5 authentication for host2.
  169. --domain1 str : Domain on host1 (NTLM authentication).
  170. --domain2 str : Domain on host2 (NTLM authentication).
  171. --oauthaccesstoken1 str : The access token to authenticate with OAUTH2.
  172. It will be combined with the --user1 value to form the
  173. string to pass with XOAUTH2 authentication.
  174. The password given by --password1 or --passfile1
  175. is ignored but needed on the command line.
  176. Instead of the access token itself, the value can be a
  177. file containing the access token on the first line.
  178. If the value is a file, imapsync reads its first line
  179. and take this line as the access token. The advantage
  180. of the file is that if the access token changes then
  181. imapsync can read it again when it needs to reconnect
  182. during a run.
  183. --oauthaccesstoken2 str : same thing as --oauthaccesstoken1
  184. --oauthdirect1 str : The direct string to pass with XOAUTH2 authentication.
  185. The password given by --password1 or --passfile1 and
  186. the user given by --user1 are ignored but they are
  187. needed to be on the command line. Consider it a bug.
  188. --oauthdirect2 str : same thing as oauthdirect1
  189. OPTIONS/folders
  190. --folder str : Sync this folder.
  191. --folder str : and this one, etc.
  192. --folderrec str : Sync this folder recursively.
  193. --folderrec str : and this one, etc.
  194. --folderfirst str : Sync this folder first. Ex. --folderfirst "INBOX"
  195. --folderfirst str : then this one, etc.
  196. --folderlast str : Sync this folder last. --folderlast "[Gmail]/All Mail"
  197. --folderlast str : then this one, etc.
  198. --nomixfolders : Do not merge folders when host1 is case-sensitive
  199. while host2 is not (like Exchange). Only the first
  200. similar folder is synced. Example: with folders
  201. "Sent", "SENT" and "sent" on host1, only "Sent"
  202. will be synced to host2.
  203. --skipemptyfolders : Empty host1 folders are not created on host2.
  204. --include reg : Sync folders matching this regular expression
  205. --include reg : or this one, etc.
  206. If both --include --exclude options are used, then
  207. include is done before.
  208. --exclude reg : Skips folders matching this regular expression
  209. Several folders to avoid:
  210. --exclude 'fold1|fold2|f3' skips fold1, fold2 and f3.
  211. --exclude reg : or this one, etc.
  212. --automap : guesses folders mapping, for folders well known as
  213. "Sent", "Junk", "Drafts", "All", "Archive", "Flagged".
  214. --f1f2 str1=str2 : Force folder str1 to be synced to str2,
  215. --f1f2 overrides --automap and --regextrans2.
  216. Use several --f1f2 options to map several folders.
  217. Option --f1f2 is a one to one only folder mapping,
  218. str1 and str2 have to be full path folder names.
  219. --subfolder2 str : Syncs the whole host1 folders hierarchy under the
  220. host2 folder named str.
  221. It does it internally by adding three
  222. --regextrans2 options before all others.
  223. Add --debug to see what's really going on.
  224. --subfolder1 str : Syncs the host1 folders hierarchy which is under folder
  225. str to the root hierarchy of host2.
  226. It's the counterpart of a sync done by --subfolder2
  227. when doing it in the reverse order.
  228. Backup/Restore scenario:
  229. Use --subfolder2 str for a backup to the folder str
  230. on host2. Then use --subfolder1 str for restoring
  231. from the folder str, after inverting
  232. host1/host2 user1/user2 values.
  233. --subscribed : Transfers subscribed folders.
  234. --subscribe : Subscribe to the folders transferred on the
  235. host2 that are subscribed on host1. On by default.
  236. --subscribeall : Subscribe to the folders transferred on the
  237. host2 even if they are not subscribed on host1.
  238. --prefix1 str : Remove prefix str to all destination folders,
  239. usually "INBOX." or "INBOX/" or an empty string "".
  240. imapsync guesses the prefix if host1 imap server
  241. does not have NAMESPACE capability. So this option
  242. should not be used most of the time.
  243. --prefix2 str : Add prefix to all host2 folders. See --prefix1
  244. --sep1 str : Host1 separator. This option should not be used
  245. most of the time.
  246. Imapsync gets the separator from the server itself,
  247. by using NAMESPACE, or it tries to guess it
  248. from the folders listing (it counts
  249. characters / . \\ \ in folder names and choose the
  250. more frequent, or finally / if nothing is found.
  251. --sep2 str : Host2 separator. See --sep1
  252. --regextrans2 reg : Apply the whole regex to each destination folders.
  253. --regextrans2 reg : and this one. etc.
  254. When you play with the --regextrans2 option, first
  255. add also the safe options --dry --justfolders
  256. Then, when happy, remove --dry for a run, then
  257. remove --justfolders for the next ones.
  258. Have in mind that --regextrans2 is applied after
  259. the automatic prefix and separator inversion.
  260. For examples see:
  261. https://imapsync.lamiral.info/FAQ.d/FAQ.Folders_Mapping.txt
  262. OPTIONS/folders sizes
  263. --nofoldersizes : Do not calculate the size of each folder at the
  264. beginning of the sync. Default is to calculate them.
  265. --nofoldersizesatend: Do not calculate the size of each folder at the
  266. end of the sync. Default is to calculate them.
  267. --justfoldersizes : Exit after having printed the initial folder sizes.
  268. OPTIONS/tmp
  269. --tmpdir str : Where to store temporary files and subdirectories.
  270. Will be created if it doesn't exist.
  271. Default is system specific, Unix is /tmp but
  272. /tmp is often too small and deleted at reboot.
  273. --tmpdir /var/tmp should be better.
  274. --pidfile str : The file where imapsync pid is written,
  275. it can be dirname/filename complete path.
  276. The default name is imapsync.pid in tmpdir.
  277. --pidfilelocking : Abort if pidfile already exists. Useful to avoid
  278. concurrent transfers on the same mailbox.
  279. OPTIONS/log
  280. --nolog : Turn off logging on file
  281. --logfile str : Change the default log filename (can be dirname/filename).
  282. --logdir str : Change the default log directory. Default is LOG_imapsync/
  283. The default logfile name is for example
  284. LOG_imapsync/2019_12_22_23_57_59_532_user1_user2.txt
  285. where:
  286. 2019_12_22_23_57_59_532 is nearly the date of the start
  287. YYYY_MM_DD_HH_MM_SS_mmm
  288. year_month_day_hour_minute_second_millisecond
  289. and user1 user2 are the --user1 --user2 values.
  290. OPTIONS/messages
  291. --skipmess reg : Skips messages matching the regex.
  292. Example: 'm/[\x80-\xff]/' # to avoid 8bits messages.
  293. --skipmess is applied before --regexmess
  294. --skipmess reg : or this one, etc.
  295. --skipcrossduplicates : Avoid copying messages that are already copied
  296. in another folder, good from Gmail to XYZ when
  297. XYZ is not also Gmail.
  298. Activated with --gmail1 unless --noskipcrossduplicates
  299. --debugcrossduplicates : Prints which messages (UIDs) are skipped with
  300. --skipcrossduplicates and in what other folders
  301. they are.
  302. --pipemess cmd : Apply this cmd command to each message content
  303. before the copy.
  304. --pipemess cmd : and this one, etc.
  305. With several --pipemess, the output of each cmd
  306. command (STDOUT) is given to the input (STDIN)
  307. of the next command.
  308. For example,
  309. --pipemess cmd1 --pipemess cmd2 --pipemess cmd3
  310. is like a Unix pipe:
  311. "cat message | cmd1 | cmd2 | cmd3"
  312. --disarmreadreceipts : Disarms read receipts (host2 Exchange issue)
  313. --regexmess reg : Apply the whole regex to each message before transfer.
  314. Example: 's/\000/ /g' # to replace null characters
  315. by spaces.
  316. --regexmess reg : and this one, etc.
  317. --truncmess int : truncates messages when their size exceed the int
  318. value, specified in bytes. Good to sync too big
  319. messages or to "suppress" attachments.
  320. Have in mind that this way, messages become
  321. uncoherent somehow.
  322. OPTIONS/labels
  323. Gmail present labels as folders in imap. Imapsync can accelerate the
  324. sync by syncing X-GM-LABELS, it will avoid to transfer messages when
  325. they are already on host2 in another folder.
  326. --synclabels : Syncs also Gmail labels when a message is copied to host2.
  327. Activated by default with --gmail1 --gmail2 unless
  328. --nosynclabels is added.
  329. --resynclabels : Resyncs Gmail labels when a message is already on host2.
  330. Activated by default with --gmail1 --gmail2 unless
  331. --noresynclabels is added.
  332. For Gmail syncs, see also:
  333. https://imapsync.lamiral.info/FAQ.d/FAQ.Gmail.txt
  334. OPTIONS/flags
  335. If you encounter flag problems see also:
  336. https://imapsync.lamiral.info/FAQ.d/FAQ.Flags.txt
  337. --regexflag reg : Apply the whole regex to each flags list.
  338. Example: 's/"Junk"//g' # to remove "Junk" flag.
  339. --regexflag reg : then this one, etc.
  340. --resyncflags : Resync flags for already transferred messages.
  341. On by default.
  342. --noresyncflags : Do not resync flags for already transferred messages.
  343. May be useful when a user has already started to play
  344. with its host2 account.
  345. --filterbuggyflags : Filter flags known to be buggy and generators of errors
  346. "BAD Invalid system flag" or "NO APPEND Invalid flag list".
  347. OPTIONS/deletions
  348. --delete1 : Deletes messages on host1 server after a successful
  349. transfer. Option --delete1 has the following behavior:
  350. it marks messages as deleted with the IMAP flag
  351. \Deleted, then messages are really deleted with an
  352. EXPUNGE IMAP command. If expunging after each message
  353. slows down too much the sync then use
  354. --noexpungeaftereach to speed up, expunging will then be
  355. done only twice per folder, one at the beginning and
  356. one at the end of a folder sync.
  357. --expunge1 : Expunge messages on host1 just before syncing a folder.
  358. Expunge is done per folder.
  359. Expunge aims is to really delete messages marked deleted.
  360. An expunge is also done after each message copied
  361. if option --delete1 is set (unless --noexpungeaftereach).
  362. --noexpunge1 : Do not expunge messages on host1.
  363. --delete1emptyfolders : Deletes empty folders on host1, INBOX excepted.
  364. Useful with --delete1 since what remains on host1
  365. is only what failed to be synced.
  366. --delete2 : Delete messages in the host2 account that are not in
  367. the host1 account. Useful for backup or pre-sync.
  368. --delete2 implies --uidexpunge2
  369. --delete2duplicates : Deletes messages in host2 that are duplicates in host2.
  370. Works only without --useuid since duplicates are
  371. detected with an header part of each message.
  372. NB: --delete2duplicates is far less violent than --delete2
  373. since it removes only duplicates.
  374. --delete2folders : Delete folders in host2 that are not in host1.
  375. For safety, first try it like this, it is safe:
  376. --delete2folders --dry --justfolders --nofoldersizes
  377. and see what folders will be deleted.
  378. --delete2foldersonly reg : Delete only folders matching the regex reg.
  379. Example: --delete2foldersonly "/^Junk$|^INBOX.Junk$/"
  380. This option activates --delete2folders
  381. --delete2foldersbutnot reg : Do not delete folders matching the regex rex.
  382. Example: --delete2foldersbutnot "/Tasks$|Contacts$|Foo$/"
  383. This option activates --delete2folders
  384. --noexpunge2 : Do not expunge messages on host2.
  385. --nouidexpunge2 : Do not uidexpunge messages on the host2 account
  386. that are not on the host1 account.
  387. OPTIONS/dates
  388. If you encounter problems with dates, see also:
  389. https://imapsync.lamiral.info/FAQ.d/FAQ.Dates.txt
  390. --syncinternaldates : Sets the internal dates on host2 as the same as host1.
  391. Turned on by default. Internal date is the date
  392. a message arrived on a host (Unix mtime usually).
  393. --idatefromheader : Sets the internal dates on host2 as same as the
  394. ones in "Date:" headers.
  395. OPTIONS/message selection
  396. --maxsize int : Skip messages larger (or equal) than int bytes
  397. --minsize int : Skip messages smaller (or equal) than int bytes
  398. --maxage int : Skip messages older than int days.
  399. final stats (skipped) don't count older messages
  400. see also --minage
  401. --minage int : Skip messages newer than int days.
  402. final stats (skipped) don't count newer messages
  403. You can do (+ zone are the messages selected):
  404. past|----maxage+++++++++++++++>now
  405. past|+++++++++++++++minage---->now
  406. past|----maxage+++++minage---->now (intersection)
  407. past|++++minage-----maxage++++>now (union)
  408. --search str : Selects only messages returned by this IMAP SEARCH
  409. command. Applied on both sides.
  410. For a complete set of what can be search see
  411. https://imapsync.lamiral.info/FAQ.d/FAQ.Messages_Selection.txt
  412. --search1 str : Same as --search but for selecting host1 messages only.
  413. --search2 str : Same as --search but for selecting host2 messages only.
  414. So --search CRIT equals --search1 CRIT --search2 CRIT
  415. --noabletosearch : Makes --minage and --maxage options use the internal
  416. dates given by a FETCH imap command instead of the
  417. "Date:" header. Internal date is the arrival date
  418. in the mailbox.
  419. --noabletosearch equals --noabletosearch1 --noabletosearch2
  420. --noabletosearch1 : Like --noabletosearch but for host1 only.
  421. --noabletosearch2 : Like --noabletosearch but for host2 only.
  422. --maxlinelength int : skip messages with a line length longer than int bytes.
  423. RFC 2822 says it must be no more than 1000 bytes but
  424. real life servers and email clients do more.
  425. --useheader str : Use this header to compare messages on both sides.
  426. Example: "Message-Id" or "Received" or "Date".
  427. --useheader str and this one, etc.
  428. --syncduplicates : Sync also duplicates. Off by default.
  429. --usecache : Use cache to speed up next syncs. Off by default.
  430. --nousecache : Do not use cache. Caveat: --useuid --nousecache creates
  431. duplicates on multiple runs.
  432. --useuid : Use UIDs instead of headers as a criterion to recognize
  433. messages. Option --usecache is then implied unless
  434. --nousecache is used.
  435. OPTIONS/miscellaneous
  436. --syncacls : Synchronizes acls (Access Control Lists).
  437. Acls in IMAP are not standardized, be careful
  438. since one acl code on one side may signify something
  439. else on the other one.
  440. --nosyncacls : Does not synchronize acls. This is the default.
  441. --addheader : When a message has no headers to be identified,
  442. --addheader adds a "Message-Id" header,
  443. like "Message-Id: 12345@imapsync", where 12345
  444. is the imap UID of the message on the host1 folder.
  445. Useful to sync folders "Sent" or "Draft".
  446. OPTIONS/debugging
  447. --debug : Debug mode.
  448. --debugfolders : Debug mode for the folders part only.
  449. --debugcontent : Debug content of the messages transferred. Huge output.
  450. --debugflags : Debug mode for flags.
  451. --debugimap1 : IMAP debug mode for host1. Very verbose.
  452. --debugimap2 : IMAP debug mode for host2. Very verbose.
  453. --debugimap : IMAP debug mode for host1 and host2. Twice very verbose.
  454. --debugmemory : Debug mode showing memory consumption after each copy.
  455. --errorsmax int : Exit when int number of errors is reached. Default is 50.
  456. --tests : Run local non-regression tests. Exit code 0 means all ok.
  457. --testslive : Run a live test with test1.lamiral.info imap server.
  458. Useful to check the basics. Needs internet connection.
  459. --testslive6 : Run a live test with ks6ipv6.lamiral.info imap server.
  460. Useful to check the ipv6 connectivity. Needs internet.
  461. OPTIONS/specific
  462. --gmail1 : sets --host1 to Gmail and other options. See FAQ.Gmail.txt
  463. --gmail2 : sets --host2 to Gmail and other options. See FAQ.Gmail.txt
  464. --office1 : sets --host1 to Office365 and other options. See FAQ.Office365.txt
  465. --office2 : sets --host2 to Office365 and other options. See FAQ.Office365.txt
  466. --exchange1 : sets options for Exchange. See FAQ.Exchange.txt
  467. --exchange2 : sets options for Exchange. See FAQ.Exchange.txt
  468. --domino1 : sets options for Domino. See FAQ.Domino.txt
  469. --domino2 : sets options for Domino. See FAQ.Domino.txt
  470. OPTIONS/behavior
  471. --timeout1 flo : Connection timeout in seconds for host1.
  472. Default is 120 and 0 means no timeout at all.
  473. --timeout2 flo : Connection timeout in seconds for host2.
  474. Default is 120 and 0 means no timeout at all.
  475. Caveat, under CGI context, you may encounter a timeout
  476. from the webserver, killing imapsync and the imap connections.
  477. See the document INSTALL.OnlineUI.txt and search
  478. for "Timeout" for how to deal with this issue.
  479. --keepalive1 : https://metacpan.org/pod/Mail::IMAPClient#Keepalive
  480. Some firewalls and network gears like to timeout connections
  481. prematurely if the connection sits idle.
  482. This option enables SO_KEEPALIVE on the host1 socket.
  483. --keepalive1 is on by default since imapsync release 2.169
  484. Use --nokeepalive1 to disable it.
  485. --keepalive2 : Same as --keepalive2 but for host2.
  486. Use --nokeepalive2 to disable it.
  487. --maxmessagespersecond flo : limits the average number of messages
  488. transferred per second.
  489. --maxbytespersecond int : limits the average transfer rate per second.
  490. --maxbytesafter int : starts --maxbytespersecond limitation only after
  491. --maxbytesafter amount of data transferred.
  492. --maxsleep flo : do not sleep more than int seconds.
  493. On by default, 2 seconds max, like --maxsleep 2
  494. --abort : terminates a previous call still running.
  495. It uses the pidfile to know what process to abort.
  496. --exitwhenover int : Stop syncing and exits when int total bytes
  497. transferred is reached.
  498. --version : Print only the software version.
  499. --noreleasecheck : Do not check for any new imapsync release.
  500. --releasecheck : Check for new imapsync release.
  501. it's an http request to
  502. http://imapsync.lamiral.info/prj/imapsync/VERSION
  503. --emailreport1 : Put the email final report in host1 INBOX
  504. --emailreport2 : Put the email final report in host2 INBOX
  505. --noemailreport1 : Do not put the email final report in host1 INBOX
  506. --noemailreport2 : Do not put the email final report in host2 INBOX
  507. --noid : Do not send/receive IMAP "ID" command to imap servers.
  508. --justconnect : Just connect to both servers and print useful
  509. information. Need only --host1 and --host2 options.
  510. Obsolete since "imapsync --host1 imaphost" alone
  511. implies --justconnect
  512. --justlogin : Just login to both host1 and host2 with users
  513. credentials, then exit.
  514. --justfolders : Do only things about folders (ignore messages).
  515. --help : print this help.
  516. Example: to synchronize imap account "test1" on "test1.lamiral.info"
  517. to imap account "test2" on "test2.lamiral.info"
  518. with test1 password "secret1"
  519. and test2 password "secret2"
  520. imapsync \
  521. --host1 test1.lamiral.info --user1 test1 --password1 secret1 \
  522. --host2 test2.lamiral.info --user2 test2 --password2 secret2
  523. SECURITY
  524. You can use --passfile1 instead of --password1 to mention the password
  525. since it is safer. With --password1 option, on Linux, any user on your
  526. host can see the password by using the 'ps auxwwww' command. Using a
  527. variable (like IMAPSYNC_PASSWORD1) is also dangerous because of the 'ps
  528. auxwwwwe' command. So, saving the password in a well protected file (600
  529. or rw-------) is the best solution.
  530. Imapsync activates ssl or tls encryption by default, if possible.
  531. What detailed behavior is under this "if possible"?
  532. Imapsync activates ssl if the well known port imaps port (993) is open
  533. on the imap servers. If the imaps port is closed then it open a normal
  534. (clear) connection on port 143 but it looks for TLS support in the
  535. CAPABILITY list of the servers. If TLS is supported then imapsync goes
  536. to encryption with STARTTLS.
  537. If the automatic ssl and the tls detections fail then imapsync will not
  538. protect against sniffing activities on the network, especially for
  539. passwords.
  540. If you want to force ssl or tls just use --ssl1 --ssl2 or --tls1 --tls2
  541. See also the document FAQ.Security.txt in the FAQ.d/ directory or at
  542. https://imapsync.lamiral.info/FAQ.d/FAQ.Security.txt
  543. EXIT STATUS
  544. Imapsync will exit with a 0 status (return code) if everything went
  545. good. Otherwise, it exits with a non-zero status. That's classical Unix
  546. behavior. Here is the list of the exit code values (an integer between 0
  547. and 255). In Bourne Shells, this exit code value can be retrieved within
  548. the variable value "$?" if you read it just after the imapsync call.
  549. The names reflect their meaning:
  550. EX_OK => 0 ; #/* successful termination */
  551. EX_USAGE => 64 ; #/* command line usage error */
  552. EX_NOINPUT => 66 ; #/* cannot open input */
  553. EX_UNAVAILABLE => 69 ; #/* service unavailable */
  554. EX_SOFTWARE => 70 ; #/* internal software error */
  555. EXIT_CATCH_ALL => 1 ; # Any other error
  556. EXIT_BY_SIGNAL => 6 ; # Should be 128+n where n is the sig_num
  557. EXIT_BY_FILE => 7 ;
  558. EXIT_PID_FILE_ERROR => 8 ;
  559. EXIT_CONNECTION_FAILURE => 10 ;
  560. EXIT_TLS_FAILURE => 12 ;
  561. EXIT_AUTHENTICATION_FAILURE => 16 ;
  562. EXIT_SUBFOLDER1_NO_EXISTS => 21 ;
  563. EXIT_WITH_ERRORS => 111 ;
  564. EXIT_WITH_ERRORS_MAX => 112 ;
  565. EXIT_OVERQUOTA => 113 ;
  566. EXIT_ERR_APPEND => 114 ;
  567. EXIT_ERR_FETCH => 115 ;
  568. EXIT_ERR_CREATE => 116 ;
  569. EXIT_ERR_SELECT => 117 ;
  570. EXIT_TRANSFER_EXCEEDED => 118 ;
  571. EXIT_ERR_APPEND_VIRUS => 119 ;
  572. EXIT_TESTS_FAILED => 254 ; # Like Test::More API
  573. EXIT_CONNECTION_FAILURE_HOST1 => 101 ;
  574. EXIT_CONNECTION_FAILURE_HOST2 => 102 ;
  575. EXIT_AUTHENTICATION_FAILURE_USER1 => 161 ;
  576. EXIT_AUTHENTICATION_FAILURE_USER2 => 162 ;
  577. LICENSE AND COPYRIGHT
  578. Imapsync is free, open, public but not always gratis software cover by
  579. the NOLIMIT Public License, now called NLPL. See the LICENSE file
  580. included in the distribution or just read the following simple sentence
  581. as it IS the license text:
  582. "No limits to do anything with this work and this license."
  583. In case it is not long enough, I repeat:
  584. "No limits to do anything with this work and this license."
  585. Look at https://imapsync.lamiral.info/LICENSE
  586. AUTHOR
  587. Gilles LAMIRAL <gilles@lamiral.info>
  588. Good feedback is always welcome. Bad feedback is very often welcome.
  589. Gilles LAMIRAL earns his living by writing, installing, configuring and
  590. sometimes teaching free, open, and often gratis software. Imapsync used
  591. to be "always gratis" but now it is only "often gratis" because imapsync
  592. is sold by its author, your servitor, a good way to maintain and support
  593. free open public software tools over decades.
  594. BUGS AND LIMITATIONS
  595. See https://imapsync.lamiral.info/FAQ.d/FAQ.Reporting_Bugs.txt
  596. IMAP SERVERS supported
  597. See https://imapsync.lamiral.info/S/imapservers.shtml
  598. HUGE MIGRATION
  599. If you have many mailboxes to migrate think about a little shell
  600. program. Write a file called file.txt (for example) containing users and
  601. passwords. The separator used in this example is ';'
  602. The file.txt file contains:
  603. user001_1;password001_1;user001_2;password001_2
  604. user002_1;password002_1;user002_2;password002_2
  605. user003_1;password003_1;user003_2;password003_2
  606. user004_1;password004_1;user004_2;password004_2
  607. user005_1;password005_1;user005_2;password005_2 ...
  608. On Unix the shell program can be:
  609. { while IFS=';' read u1 p1 u2 p2; do
  610. imapsync --host1 imap.side1.org --user1 "$u1" --password1 "$p1" \
  611. --host2 imap.side2.org --user2 "$u2" --password2 "$p2" ...
  612. done ; } < file.txt
  613. On Windows the batch program can be:
  614. FOR /F "tokens=1,2,3,4 delims=; eol=#" %%G IN (file.txt) DO imapsync ^
  615. --host1 imap.side1.org --user1 %%G --password1 %%H ^
  616. --host2 imap.side2.org --user2 %%I --password2 %%J ...
  617. The ... have to be replaced by nothing or any imapsync option. Welcome
  618. in shell or batch programming !
  619. You will find already written scripts at
  620. https://imapsync.lamiral.info/examples/
  621. INSTALL
  622. Imapsync works under any Unix with Perl.
  623. Imapsync works under most Windows (2000, XP, Vista, Seven, Eight, Ten
  624. and all Server releases 2000, 2003, 2008 and R2, 2012 and R2, 2016)
  625. as a standalone binary software called imapsync.exe, usually launched
  626. from a batch file in order to avoid always typing the options. There
  627. is also a 32bit binary called imapsync_32bit.exe
  628. Imapsync works under OS X as a standalone binary software called
  629. imapsync_bin_Darwin
  630. Purchase latest imapsync at
  631. https://imapsync.lamiral.info/
  632. You'll receive a link to a compressed tarball called
  633. imapsync-x.xx.tgz where x.xx is the version number.
  634. Untar the tarball where you want (on Unix):
  635. tar xzvf imapsync-x.xx.tgz
  636. Go into the directory imapsync-x.xx and read the INSTALL file.
  637. As mentioned at https://imapsync.lamiral.info/#install
  638. the INSTALL file can also be found at
  639. https://imapsync.lamiral.info/INSTALL.d/INSTALL.ANY.txt
  640. It is now split in several files for each system
  641. https://imapsync.lamiral.info/INSTALL.d/
  642. CONFIGURATION
  643. There is no specific configuration file for imapsync, everything is
  644. specified by the command line parameters and the default behavior.
  645. HACKING
  646. Feel free to hack imapsync as the NOLIMIT license permits it.
  647. SIMILAR SOFTWARE
  648. See also https://imapsync.lamiral.info/S/external.shtml
  649. for a better up to date list.
  650. List verified on Friday July 1, 2021.
  651. imapsync: https://github.com/imapsync/imapsync (this is an imapsync copy, sometimes delayed, with --noreleasecheck by default since release 1.592, 2014/05/22)
  652. imap_tools: https://web.archive.org/web/20161228145952/http://www.athensfbc.com/imap_tools/. The imap_tools code is now at https://github.com/andrewnimmo/rick-sanders-imap-tools
  653. imaputils: https://github.com/mtsatsenko/imaputils (very old imap_tools fork)
  654. Doveadm-Sync: https://wiki2.dovecot.org/Tools/Doveadm/Sync ( Dovecot sync tool )
  655. davmail: http://davmail.sourceforge.net/
  656. offlineimap: http://offlineimap.org/
  657. fdm: https://github.com/nicm/fdm
  658. mbsync: http://isync.sourceforge.net/
  659. mailsync: http://mailsync.sourceforge.net/
  660. mailutil: https://www.washington.edu/imap/ part of the UW IMAP toolkit. (well, seems abandoned now)
  661. imaprepl: https://bl0rg.net/software/ http://freecode.com/projects/imap-repl/
  662. imapcopy (Pascal): http://www.ardiehl.de/imapcopy/
  663. imapcopy (Java): https://code.google.com/archive/p/imapcopy/
  664. imapsize: http://www.broobles.com/imapsize/
  665. migrationtool: http://sourceforge.net/projects/migrationtool/
  666. imapmigrate: http://sourceforge.net/projects/cyrus-utils/
  667. larch: https://github.com/rgrove/larch (derived from wonko_imapsync, good at Gmail)
  668. wonko_imapsync: http://wonko.com/article/554 (superseded by larch)
  669. pop2imap: http://www.linux-france.org/prj/pop2imap/ (I wrote that too)
  670. exchange-away: http://exchange-away.sourceforge.net/
  671. SyncBackPro: http://www.2brightsparks.com/syncback/sbpro.html
  672. ImapSyncClient: https://github.com/ridaamirini/ImapSyncClient
  673. MailStore: https://www.mailstore.com/en/products/mailstore-home/
  674. mnIMAPSync: https://github.com/manusa/mnIMAPSync
  675. imap-upload: http://imap-upload.sourceforge.net/ (A tool for uploading a local mbox file to IMAP4 server)
  676. imapbackup: https://github.com/rcarmo/imapbackup (A Python script for incremental backups of IMAP mailboxes)
  677. BitRecover email-backup 99 USD, 299 USD https://www.bitrecover.com/email-backup/.
  678. ImportExportTools: https://addons.thunderbird.net/en-us/thunderbird/addon/importexporttools/ ImportExportTools for Mozilla Thunderbird by Paolo Kaosmos. ImportExportTools does not do IMAP.
  679. rximapmail: https://sourceforge.net/projects/rximapmail/
  680. CodeTwo: https://www.codetwo.com/ but CodeTwo does imap source to Office365 only.
  681. HISTORY
  682. I initially wrote imapsync in July 2001 because an enterprise, called
  683. BaSystemes, paid me to install a new imap server without losing huge old
  684. mailboxes located in a far away remote imap server, accessible by an
  685. often broken low-bandwidth ISDN link.
  686. I had to verify every mailbox was well transferred, all folders, all
  687. messages, without wasting bandwidth or creating duplicates upon resyncs.
  688. The imapsync design was made with the beautiful rsync command in mind.
  689. Imapsync started its life as a patch of the copy_folder.pl script. The
  690. script copy_folder.pl comes from the Mail-IMAPClient-2.1.3 perl module
  691. tarball source (more precisely in the examples/ directory of the
  692. Mail-IMAPClient tarball).
  693. So many changes happened since then that I wonder if it remains any
  694. lines of the original copy_folder.pl in imapsync source code.