FAQ.Dates.txt 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #!/bin/cat
  2. $Id: FAQ.Dates.txt,v 1.11 2019/12/23 12:46:50 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.Dates.txt
  6. =======================================================================
  7. Imapsync tips about dates.
  8. =======================================================================
  9. Questions answered in this FAQ are:
  10. Q. We have found that the time and date displayed have been changed to
  11. the time at which the file was synchronized. What happened? Any fix?
  12. Q. Is there a way to set any message with
  13. "Date: (Invalid)" to a valid one like
  14. "Date: Thu, 1 Jun 2017 23:59:59 +0000"?
  15. =======================================================================
  16. Q. We have found that the time and date displayed have been changed to
  17. the time at which the file was synchronized. What happened? Any fix?
  18. R. This is the case by default with some email readers like:
  19. - Outlook 2003
  20. - Ipad
  21. - Iphone
  22. - spark https://sparkmailapp.com/ (iphone app)
  23. - Edison mail https://apps.apple.com/us/app/email-edison-mail/id922793622 (iphone app)
  24. - ...
  25. but not with:
  26. - Mutt
  27. - Thunderbird
  28. - Zimbra
  29. - Gmail
  30. First, a thing to keep in mind.
  31. Imapsync does not touch any byte of messages unless told to do so by
  32. special and rarely used options like --regexmess or --pipemess.
  33. Messages on both parts should be exactly identical because imapsync
  34. does a verbatim sync of all messages, by default.
  35. Now I explain the whole picture about dates of messages.
  36. There are several different dates attached to any message.
  37. First, there is the "Date:" header, which belongs to the message itself.
  38. You can see this "Date:" header line by asking "View->Message Source"
  39. in most email client software (Ctrl-u in Thunderbird).
  40. Most of the time, this "Date:" header date is set by the MUA,
  41. MUA stands for "Mail User Agent".
  42. MUA can be Outlook, Thunderbird, a webmail or Mutt etc.
  43. The "Date:" header is usually the date the message was written
  44. or sent the first time, at the writer side.
  45. This "Date:" header line is never changed by any transfer or copy.
  46. If an email reader uses the "Date:" header for displaying the date of
  47. a message then no problem should arise.
  48. Another date is the "internal date". In IMAP, the internal date is
  49. handled by the imap server and normally it corresponds to the arrival
  50. date in the mailbox. This date is not part of the email message
  51. itself, it is a metadata kept by the imap server.
  52. The IMAP protocol allows the internal date to be set by an email client
  53. when a message is delivered by the imap APPEND command.
  54. Imapsync synchronizes these internal dates, by default, so internal dates
  55. on host2 should then be the same as the internal dates on host1.
  56. If an email reader uses the internal date for displaying the date of a
  57. message then the sync date problem only occurs when the host2 imap
  58. server ignores the internal date given by imapsync during the APPEND
  59. imap command. It happens with some imap servers. Bad luck.
  60. There are also the "Received:" header lines. Each time a message
  61. travels a SMTP server, this one adds a "Received:" header
  62. line. Sometimes some email clients use the last "Received:" header
  63. date as the date of the message. And some IMAP servers software add a
  64. "Received:" line after and imap transfer. If those both conditions are
  65. met then the date displayed become the transfer date even if imapsync
  66. has done its best to keep all the dates synchronized. Bad luck.
  67. Solutions:
  68. a) Use another email client or configure it in order that it sorts messages
  69. by sent dates, the "Date:" header line.
  70. b) Use a imap server that respects the imap RFC and accepts
  71. the internal date set by imapsync.
  72. c) Try to understand why the email client software shows another date
  73. than the "Date:" header line.
  74. =======================================================================
  75. Q. Is there a way to set any message with
  76. "Date: (Invalid)" to a valid one like
  77. "Date: Thu, 1 Jun 2017 23:59:59 +0000"?
  78. R. Yes, there is a way with option --regexmess
  79. First, let's select only messages with a buggy Date header:
  80. --search "HEADER Date Invalid"
  81. Second, let's change this line by a valid one,
  82. on windows:
  83. --regexmess "s{\A(.*?(?! ^$))^Date:\ \(Invalid\)(.*?)$}{$1Date: Thu, 1 Jun 2017 23:59:59 +0000}xms"
  84. on Unix (replaced enclosing double-quotes " by single quotes ' ):
  85. --regexmess 's{\A(.*?(?! ^$))^Date:\ \(Invalid\)(.*?)$}{$1Date: Thu, 1 Jun 2017 23:59:59 +0000}xms'
  86. =======================================================================
  87. =======================================================================