FAQ.Flags.txt 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. #!/bin/cat
  2. $Id: FAQ.Flags.txt,v 1.28 2022/06/22 17:07:35 gilles Exp gilles $
  3. This documentation is also available online at
  4. https://imapsync.lamiral.info/FAQ.d/
  5. https://imapsync.lamiral.info/FAQ.d/FAQ.Flags.txt
  6. =======================================================================
  7. Imapsync tips about flags.
  8. =======================================================================
  9. Questions answered here are:
  10. Q. How to debug flag issues?
  11. Q. Is there a way to only sync messages with a specific flag set,
  12. for example, the \Seen flag?
  13. Q. How to convert flags?
  14. Q. Exchange sends an email to any sender whose email is deleted
  15. without reading. It's called "unread notifications".
  16. How to set the \Seen flag on host1 (source system) before syncing?
  17. Q. Every single mail synced to exchange online owns the
  18. category $MDNSent after migration. How can I avoid this?
  19. Q. Does imapsync retain the \Answered and $Forwarded flags?
  20. Q. How to fix this error: BAD Invalid system flag \FORWARDED
  21. Q. How to convert flags with $ to \ character?
  22. Q. imapsync fails with the following error:
  23. flags from : [\Seen NonJunk]
  24. Error trying to append string: 58 NO APPEND Invalid flag list
  25. Q. Flags are not well synchronized. Is it a bug?
  26. Q. Flags are resynced at each run for already synced/copied messages,
  27. how can I avoid this feature?
  28. Q. Is it possible to sync labels and stars made by Thunderbird to
  29. Exchange categories? Or a way in Outlook to show labels created by
  30. Thunderbird?
  31. Now the questions again with their answers.
  32. =======================================================================
  33. Q. How to debug flag issues?
  34. R. Use --debugflags
  35. imapsync ... --debugflags
  36. =======================================================================
  37. Q. Is there a way to only sync messages with a specific flag set,
  38. for example, the \Seen flag?
  39. R. use --search
  40. imapsync ... --search SEEN
  41. or
  42. imapsync ... --search UNSEEN
  43. or ...
  44. The complete list of search things related to flags are listed below
  45. http://www.faqs.org/rfcs/rfc3501.html
  46. 6.4.4. SEARCH Command
  47. ...
  48. ANSWERED
  49. Messages with the \Answered flag set.
  50. DELETED
  51. Messages with the \Deleted flag set.
  52. DRAFT
  53. Messages with the \Draft flag set.
  54. FLAGGED
  55. Messages with the \Flagged flag set.
  56. KEYWORD <flag>
  57. Messages with the specified keyword flag set.
  58. NEW
  59. Messages that have the \Recent flag set but not the \Seen flag.
  60. This is functionally equivalent to "(RECENT UNSEEN)".
  61. NOT <search-key>
  62. Messages that do not match the specified search key.
  63. OLD
  64. Messages that do not have the \Recent flag set. This is
  65. functionally equivalent to "NOT RECENT" (as opposed to "NOT
  66. NEW").
  67. OR <search-key1> <search-key2>
  68. Messages that match either search key.
  69. RECENT
  70. Messages that have the \Recent flag set.
  71. SEEN
  72. Messages that have the \Seen flag set.
  73. UNANSWERED
  74. Messages that do not have the \Answered flag set.
  75. UNDELETED
  76. Messages that do not have the \Deleted flag set.
  77. UNDRAFT
  78. Messages that do not have the \Draft flag set.
  79. UNFLAGGED
  80. Messages that do not have the \Flagged flag set.
  81. UNKEYWORD <flag>
  82. Messages that do not have the specified keyword flag set.
  83. UNSEEN
  84. Messages that do not have the \Seen flag set.
  85. =======================================================================
  86. Q. How to convert flags?
  87. R. use --regexflag
  88. For example to convert flag IMPORTANT to flag CANWAIT
  89. imapsync ... --regexflag "s/IMPORTANT/CANWAIT/g" --debugflags
  90. option --debugflags is usefull to see in details what imapsync
  91. does with flags.
  92. =======================================================================
  93. Q. Exchange sends an email to any sender whose email is deleted
  94. without reading. It's called "unread notifications".
  95. How to set the \Seen flag on host1 (source system) before syncing?
  96. R. You can add \Seen (if missing) to the host1 account by applying a
  97. first sync to the same account, same at source and destination,
  98. and the help of option --regexflag. It can also be done on the fly
  99. from account1 to account2 in case account1 has to stay as it is.
  100. Add the \Seen flag to all messages like this:
  101. On Winwows:
  102. imapsync.exe ... --regexflag "s,\\Seen,," --regexflag "s,,\\Seen ,"
  103. On Unix:
  104. imapsync ... --regexflag 's,\\Seen,,' --regexflag 's,,\\Seen ,'
  105. R2. You can also filter with --search1 UNSEEN and use only one
  106. of the regexes:
  107. On Unix:
  108. imapsync ... --search1 UNSEEN --regexflag 's,,\\Seen ,'
  109. On Winwows:
  110. imapsync.exe ... --search1 UNSEEN --regexflag "s,,\\Seen ,"
  111. R3. Fix it on the server Exchange:
  112. Google translate:
  113. https://translate.google.com/translate?sl=auto&tl=en&u=https%3A%2F%2Fwww.ci-solution.com%2Fblog%2Fartikel%2Fungelesen-geloescht-verhindern.html
  114. German original:
  115. https://www.ci-solution.com/blog/artikel/ungelesen-geloescht-verhindern.html
  116. (Link from Oliver B.)
  117. ======================================================================
  118. Q. Every single mail synced to exchange online owns the
  119. category $MDNSent after migration. How can I avoid this?
  120. R. To remove the flag $MDNSent from all messages, use:
  121. imapsync ... --regexflag "s/\$MDNSent//g"
  122. See also the document
  123. https://imapsync.lamiral.info/FAQ.d/FAQ.Flags.txt
  124. =======================================================================
  125. Q. Does imapsync retain the \Answered and $Forwarded flags?
  126. R. It depends on the destination server.
  127. a) If the destination server honours the "PERMANENTFLAGS \*"
  128. directive (meaning it accepts any flag) or no PERMANENTFLAGS at all
  129. then imapsync synchronizes all flags except the \Recent flag
  130. (RFC 3501 says about \Recent flag "This flag can not be
  131. altered by the client.").
  132. b) If the destination server honours the "PERMANENTFLAGS without the
  133. special "\*" then imapsync synchronizes only the flags listed
  134. in PERMANENTFLAGS.
  135. Some imap servers have problems with flags not beginning with
  136. the backslash character \
  137. (see next question to find a solution to this issue)
  138. =======================================================================
  139. Q. How to fix this error: BAD Invalid system flag \FORWARDED
  140. R. Filter flag \FORWARDED with --regexflag like this:
  141. On Windows:
  142. imapsync.exe ... --regexflag "s/\\FORWARDED//gi"
  143. On Unix:
  144. imapsync ... --regexflag 's/\\FORWARDED//gi'
  145. or (on Unix)
  146. imapsync ... --regexflag "s/\\\\FORWARDED//gi"
  147. Other related flags to remove are \Indexed and \ATTACHED
  148. Windows: imapsync.exe ... --regexflag "s/\\Indexed//gi"
  149. Unix: imapsync ... --regexflag 's/\\Indexed//gi'
  150. Windows: imapsync.exe ... --regexflag "s/\\ATTACHED//gi"
  151. Unix: imapsync ... --regexflag 's/\\ATTACHED//gi'
  152. Removing usually problematic flags in one line:
  153. Windows: imapsync.exe ... --regexflag "s/\\FORWARDED|\\Indexed|\\ATTACHED|\\RECEIPTCHECKED//gi"
  154. Unix: imapsync ... --regexflag 's/\\FORWARDED|\\Indexed|\\ATTACHED|\\RECEIPTCHECKED//gi'
  155. Removing all problematic flags I've seen so far in one line:
  156. Windows: imapsync.exe ... --regexflag "s/\\RECEIPTCHECKED|\\Indexed|\\X-EON-HAS-ATTACHMENT|\\UNSEEN|\\ATTACHED|\\X-HAS-ATTACH|\\FORWARDED|\\FORWARD|\\X-FORWARDED|\\\$FORWARDED|\\PRIORITY|\\READRCPT//g"
  157. Unix: imapsync ... --regexflag 's/\\RECEIPTCHECKED|\\Indexed|\\X-EON-HAS-ATTACHMENT|\\UNSEEN|\\ATTACHED|\\X-HAS-ATTACH|\\FORWARDED|\\FORWARD|\\X-FORWARDED|\\\$FORWARDED|\\PRIORITY|\\READRCPT//g'
  158. Removing all flags but the standard ones from the IMAP RFC:
  159. Windows: imapsync.exe ... --regexflag "s/.*?(?:(\\(?:Answered|Flagged|Deleted|Seen|Draft)\s?)|$)/defined($1)?$1:q()/eg"
  160. Unix: imapsync ... --regexflag 's/.*?(?:(\\(?:Answered|Flagged|Deleted|Seen|Draft)\s?)|$)/defined($1)?$1:q()/eg'
  161. =======================================================================
  162. Q. How to convert flags with $ to \ character?
  163. R. $ and \ are special characters we have to "escape" them.
  164. For example to convert flag $label1 to \label1
  165. imapsync ... --regexflag "s/\$label1/\\label1/g" --debugflags
  166. ======================================================================
  167. Q. imapsync fails with the following error:
  168. flags from : [\Seen NonJunk]
  169. Error trying to append string: 58 NO APPEND Invalid flag list
  170. R. For some servers, flags have to begin with a \ character.
  171. The flag "NonJunk" may be a invalid flag for your server
  172. so use for example:
  173. imapsync ... --regexflag "s/NonJunk//g"
  174. Remark (thanks to Arnt Gulbrandsen):
  175. IMAP system flags have to begin with \ character.
  176. Any other flag must begin with another character.
  177. System flags are just flags defined by an RFC instead of by users.
  178. Conclusion, some imap server coders don't read the RFCs (so do I).
  179. Recent imapsync deals with this issue by filter with PERMANENTFLAGS
  180. automatically.
  181. =======================================================================
  182. Q. Flags are not well synchronized. Is it a bug?
  183. R. It happens with some servers on the first sync.
  184. Also, it was a bug from revision 1.200 to revision 1.207
  185. Two solutions:
  186. * Run imapsync a second time. imapsync synchronizes flags on each run.
  187. * Use option --syncflagsaftercopy. With this option imapsync will
  188. also sync flags after each message transfer. Flags are already
  189. synced during the transfer with the imap APPEND command but
  190. option --syncflagsaftercopy does it again using the imap STORE
  191. command.
  192. =======================================================================
  193. Q. Flags are resynced at each run for already synced/copied messages,
  194. how can I avoid this feature?
  195. R. Use the option --noresyncflags
  196. =======================================================================
  197. Q. Is it possible to sync labels and stars made by Thunderbird to
  198. Exchange categories? Or a way in Outlook to show labels created by
  199. Thunderbird?
  200. R. Imapsync syncs all flags possible by default, so if it doesn't do
  201. that it might means there are not on the server but stay only on the
  202. client or that the host2 server claims to accept only a given set
  203. of flags.
  204. Check those claims by accessing the same mailbox on the same server
  205. from another thunderbird on another host, you should not retrieve
  206. those labels. If you do find them it then might mean that host2
  207. server don't want them, try --nofilterflags
  208. imapsync ... --nofilterflags
  209. You can try --nofilterflags straightaway without the
  210. "other thunderbird" proposal.
  211. There is also the possibility to map flags across servers
  212. with the option --regexflag. See some --regexflag examples
  213. above.
  214. =======================================================================
  215. =======================================================================