Always log if the date is going to be corrected
[imap-fix-internaldate] / fix_imap_internaldate.py
index d169f2b..06f39e0 100644 (file)
@@ -82,21 +82,21 @@ def main():
                     logging.error(ex)
                     continue
                 if(date_parser.compare_dates(received_date, internal_date, tolerance)):
-                    #print(received_date, internal_date)
+                    logging.warning("Date conflict found in message uid: %s - mailbox: %s - user: %s.\nInternal date %s is different from received date %s from RECEIVED header:\n%s.",
+                                    mid.decode('iso-8859-1'), box.name, box.owner,
+                                    internal_date.strftime("%d %b %Y %H:%M:%S"),
+                                    received_date.strftime("%d %b %Y %H:%M:%S"),
+                                    fetched_received_date.split("Received:")[1])
                     if(args.test_mode==0):
                         try:
                             session.update_message(mid, box.name, received_date)
                         except UserWarning as ex:
                             logging.error(ex)
                             continue
-                    else:
-                        logging.warning("Date conflict found in message uid: %s - mailbox: %s - user: %s.\nInternal date %s is different from received date %s from RECEIVED header:\n%s.",
-                                        mid.decode('iso-8859-1'), box.name, box.owner,
-                                        internal_date.strftime("%d %b %Y %H:%M:%S"),
-                                        received_date.strftime("%d %b %Y %H:%M:%S"),
-                                        fetched_received_date.split("Received:")[1])
+
                     # count total emails for every user and mailbox
                     box.date_conflicts += 1
+
             # if all messages were successfully fixed confirm caching
             if(not args.test_mode):
                 box.confirm_change()