Browse Source

Fetch older emails first (to keep possibility for references header follow up detection).

Martin Edenhofer 8 years ago
parent
commit
52043bfdc5
1 changed files with 6 additions and 1 deletions
  1. 6 1
      app/models/channel/driver/imap.rb

+ 6 - 1
app/models/channel/driver/imap.rb

@@ -85,7 +85,12 @@ returns
       @imap.select(options[:folder])
     end
 
-    message_ids = @imap.search(['ALL'])
+    begin
+      message_ids = @imap.sort(['DATE'], ['ALL'], 'US-ASCII')
+    rescue => e
+      Rails.logger.error "Unable to use imap sort: #{e.inspect}, use imap search now"
+      message_ids = @imap.search(['ALL'])
+    end
 
     # check mode only
     if check_type == 'check'